1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-04-19 22:44:38 +00:00
deprecated-gotham-restful/gotham_restful/src/openapi/router.rs

595 lines
17 KiB
Rust
Raw Normal View History

2019-09-29 21:15:22 +02:00
use crate::{
resource::*,
result::*,
2019-10-01 00:23:34 +02:00
routing::*,
2019-10-01 16:13:13 +02:00
OpenapiSchema,
2019-10-01 00:49:13 +02:00
OpenapiType,
2019-10-20 14:49:53 +00:00
RequestBody,
2019-10-01 00:49:13 +02:00
ResourceType
2019-09-29 21:15:22 +02:00
};
2019-09-30 17:34:48 +02:00
use futures::future::ok;
2019-09-29 21:15:22 +02:00
use gotham::{
2019-10-13 17:43:42 +02:00
extractor::QueryStringExtractor,
2019-09-30 17:34:48 +02:00
handler::{Handler, HandlerFuture, NewHandler},
2019-09-29 21:15:22 +02:00
helpers::http::response::create_response,
pipeline::chain::PipelineHandleChain,
router::builder::*,
state::State
};
2019-10-13 17:43:42 +02:00
use hyper::Body;
2019-09-29 21:15:22 +02:00
use indexmap::IndexMap;
2019-09-30 17:34:48 +02:00
use log::error;
2019-10-20 14:49:53 +00:00
use mime::{Mime, APPLICATION_JSON, TEXT_PLAIN};
2019-09-30 20:58:15 +02:00
use openapiv3::{
APIKeyLocation, Components, MediaType, OpenAPI, Operation, Parameter, ParameterData, ParameterSchemaOrContent, PathItem,
2019-10-20 14:49:53 +00:00
Paths, ReferenceOr, ReferenceOr::Item, ReferenceOr::Reference, RequestBody as OARequestBody, Response, Responses, Schema,
SchemaKind, SecurityRequirement, SecurityScheme, Server, StatusCode, Type
2019-09-30 20:58:15 +02:00
};
2019-09-29 21:15:22 +02:00
use serde::de::DeserializeOwned;
use std::panic::RefUnwindSafe;
2019-10-14 00:59:02 +02:00
/**
This type is required to build routes while adding them to the generated OpenAPI Spec at the
same time. There is no need to use this type directly. See [`WithOpenapi`] on how to do this.
[`WithOpenapi`]: trait.WithOpenapi.html
*/
2019-09-30 18:18:10 +02:00
pub struct OpenapiRouter(OpenAPI);
2019-09-29 21:15:22 +02:00
2019-09-30 18:18:10 +02:00
impl OpenapiRouter
2019-09-29 21:15:22 +02:00
{
2019-09-30 18:41:18 +02:00
pub fn new<Title : ToString, Version : ToString, Url : ToString>(title : Title, version : Version, server_url : Url) -> Self
2019-09-29 21:15:22 +02:00
{
2019-09-30 18:18:10 +02:00
Self(OpenAPI {
openapi: "3.0.2".to_string(),
info: openapiv3::Info {
title: title.to_string(),
description: None,
terms_of_service: None,
contact: None,
license: None,
version: version.to_string()
},
2019-09-30 18:41:18 +02:00
servers: vec![Server {
url: server_url.to_string(),
description: None,
variables: None
}],
2019-09-30 18:18:10 +02:00
paths: Paths::new(),
components: None,
security: Vec::new(),
tags: Vec::new(),
external_docs: None
})
2019-09-29 21:15:22 +02:00
}
/// Remove path from the OpenAPI spec, or return an empty one if not included. This is handy if you need to
/// modify the path and add it back after the modification
fn remove_path(&mut self, path : &str) -> PathItem
{
2019-10-13 23:36:10 +02:00
match self.0.paths.swap_remove(path) {
Some(Item(item)) => item,
_ => PathItem::default()
2019-09-29 21:15:22 +02:00
}
}
fn add_path<Path : ToString>(&mut self, path : Path, item : PathItem)
{
2019-09-30 18:18:10 +02:00
self.0.paths.insert(path.to_string(), Item(item));
2019-09-29 21:15:22 +02:00
}
2019-09-30 23:53:55 +02:00
2019-10-01 16:13:13 +02:00
fn add_schema_impl(&mut self, name : String, mut schema : OpenapiSchema)
2019-09-30 23:53:55 +02:00
{
2019-10-01 16:13:13 +02:00
self.add_schema_dependencies(&mut schema.dependencies);
2019-09-30 23:53:55 +02:00
match &mut self.0.components {
Some(comp) => {
2019-10-13 23:36:10 +02:00
comp.schemas.insert(name, Item(schema.into_schema()));
2019-09-30 23:53:55 +02:00
},
None => {
let mut comp = Components::default();
2019-10-13 23:36:10 +02:00
comp.schemas.insert(name, Item(schema.into_schema()));
2019-09-30 23:53:55 +02:00
self.0.components = Some(comp);
}
};
2019-10-01 16:13:13 +02:00
}
fn add_schema_dependencies(&mut self, dependencies : &mut IndexMap<String, OpenapiSchema>)
{
let keys : Vec<String> = dependencies.keys().map(|k| k.to_string()).collect();
for dep in keys
{
let dep_schema = dependencies.swap_remove(&dep);
if let Some(dep_schema) = dep_schema
{
self.add_schema_impl(dep, dep_schema);
}
}
}
fn add_schema<T : OpenapiType>(&mut self) -> ReferenceOr<Schema>
{
2019-10-13 23:36:10 +02:00
let mut schema = T::schema();
match schema.name.clone() {
Some(name) => {
let reference = Reference { reference: format!("#/components/schemas/{}", name) };
self.add_schema_impl(name, schema);
reference
},
None => {
self.add_schema_dependencies(&mut schema.dependencies);
Item(schema.into_schema())
}
2019-10-01 16:13:13 +02:00
}
2019-09-30 23:53:55 +02:00
}
2019-09-29 21:15:22 +02:00
}
2019-09-30 17:34:48 +02:00
#[derive(Clone)]
struct OpenapiHandler(OpenAPI);
2019-09-30 17:34:48 +02:00
impl OpenapiHandler
{
2019-09-30 18:18:10 +02:00
fn new(openapi : &OpenapiRouter) -> Self
2019-09-30 17:34:48 +02:00
{
Self(openapi.0.clone())
2019-09-30 17:34:48 +02:00
}
}
impl NewHandler for OpenapiHandler
2019-09-29 21:15:22 +02:00
{
2019-09-30 17:34:48 +02:00
type Instance = Self;
fn new_handler(&self) -> gotham::error::Result<Self::Instance>
{
Ok(self.clone())
}
}
#[cfg(feature = "auth")]
const SECURITY_NAME : &'static str = "authToken";
#[cfg(feature = "auth")]
fn get_security(state : &mut State) -> (Vec<SecurityRequirement>, IndexMap<String, ReferenceOr<SecurityScheme>>)
{
use crate::AuthSource;
use gotham::state::FromState;
let source = match AuthSource::try_borrow_from(state) {
Some(source) => source,
None => return Default::default()
};
let mut security : IndexMap<String, Vec<String>> = Default::default();
security.insert(SECURITY_NAME.to_owned(), Vec::new());
let security = vec![security];
let security_scheme = match source {
AuthSource::Cookie(name) => SecurityScheme::APIKey {
location: APIKeyLocation::Cookie,
name: name.to_string()
},
AuthSource::Header(name) => SecurityScheme::APIKey {
location: APIKeyLocation::Header,
name: name.to_string()
},
AuthSource::AuthorizationHeader => SecurityScheme::HTTP {
scheme: "bearer".to_owned(),
bearer_format: Some("JWT".to_owned())
}
};
let mut security_schemes : IndexMap<String, ReferenceOr<SecurityScheme>> = Default::default();
security_schemes.insert(SECURITY_NAME.to_owned(), ReferenceOr::Item(security_scheme));
(security, security_schemes)
}
#[cfg(not(feature = "auth"))]
fn get_security(state : &mut State) -> (Vec<SecurityRequirement>, IndexMap<String, ReferenceOr<SecurityScheme>>)
{
Default::default()
}
2019-09-30 17:34:48 +02:00
impl Handler for OpenapiHandler
{
fn handle(self, mut state : State) -> Box<HandlerFuture>
2019-09-30 17:34:48 +02:00
{
let mut openapi = self.0;
let (security, security_schemes) = get_security(&mut state);
openapi.security = security;
let mut components = openapi.components.unwrap_or_default();
components.security_schemes = security_schemes;
openapi.components = Some(components);
match serde_json::to_string(&openapi) {
2019-09-30 17:34:48 +02:00
Ok(body) => {
let res = create_response(&state, hyper::StatusCode::OK, APPLICATION_JSON, body);
Box::new(ok((state, res)))
},
Err(e) => {
error!("Unable to handle OpenAPI request due to error: {}", e);
let res = create_response(&state, hyper::StatusCode::INTERNAL_SERVER_ERROR, TEXT_PLAIN, "");
Box::new(ok((state, res)))
}
}
2019-09-29 21:15:22 +02:00
}
}
2019-10-14 00:59:02 +02:00
/// This trait adds the `get_openapi` method to an OpenAPI-aware router.
2019-09-30 18:18:10 +02:00
pub trait GetOpenapi
{
fn get_openapi(&mut self, path : &str);
}
2019-10-20 14:49:53 +00:00
fn schema_to_content(types : Vec<Mime>, schema : ReferenceOr<Schema>) -> IndexMap<String, MediaType>
2019-10-01 00:23:34 +02:00
{
let mut content : IndexMap<String, MediaType> = IndexMap::new();
2019-10-20 14:49:53 +00:00
for ty in types
{
content.insert(ty.to_string(), MediaType {
schema: Some(schema.clone()),
example: None,
examples: IndexMap::new(),
encoding: IndexMap::new()
});
}
content
}
2019-10-13 23:12:12 +02:00
#[derive(Default)]
struct OperationParams<'a>
{
path_params : Vec<&'a str>,
query_params : Option<OpenapiSchema>
}
impl<'a> OperationParams<'a>
{
fn new(path_params : Vec<&'a str>, query_params : Option<OpenapiSchema>) -> Self
{
Self { path_params, query_params }
}
fn from_path_params(path_params : Vec<&'a str>) -> Self
{
Self::new(path_params, None)
}
fn from_query_params(query_params : OpenapiSchema) -> Self
{
Self::new(Vec::new(), Some(query_params))
}
fn add_path_params(&self, params : &mut Vec<ReferenceOr<Parameter>>)
{
2019-10-13 23:17:49 +02:00
for param in &self.path_params
2019-10-13 23:12:12 +02:00
{
params.push(Item(Parameter::Path {
parameter_data: ParameterData {
name: param.to_string(),
description: None,
required: true,
deprecated: None,
2019-10-13 23:36:10 +02:00
format: ParameterSchemaOrContent::Schema(Item(String::schema().into_schema())),
2019-10-13 23:12:12 +02:00
example: None,
examples: IndexMap::new()
},
style: Default::default(),
2019-10-13 23:12:12 +02:00
}));
}
}
fn add_query_params(self, params : &mut Vec<ReferenceOr<Parameter>>)
2019-10-13 23:12:12 +02:00
{
let query_params = match self.query_params {
Some(qp) => qp.schema,
2019-10-13 23:12:12 +02:00
None => return
};
let query_params = match query_params {
SchemaKind::Type(Type::Object(ty)) => ty,
_ => panic!("Query Parameters needs to be a plain struct")
};
for (name, schema) in query_params.properties
{
let required = query_params.required.contains(&name);
params.push(Item(Parameter::Query {
parameter_data: ParameterData {
name,
description: None,
required,
deprecated: None,
format: ParameterSchemaOrContent::Schema(schema.unbox()),
example: None,
examples: IndexMap::new()
},
allow_reserved: false,
style: Default::default(),
allow_empty_value: None
}))
}
2019-10-13 23:12:12 +02:00
}
fn into_params(self) -> Vec<ReferenceOr<Parameter>>
2019-10-13 23:12:12 +02:00
{
let mut params : Vec<ReferenceOr<Parameter>> = Vec::new();
self.add_path_params(&mut params);
self.add_query_params(&mut params);
2019-10-13 23:12:12 +02:00
params
}
}
2019-10-20 14:49:53 +00:00
fn new_operation(default_status : hyper::StatusCode, accepted_types : Option<Vec<Mime>>, schema : ReferenceOr<Schema>, params : OperationParams, body_schema : Option<ReferenceOr<Schema>>, supported_types : Option<Vec<Mime>>) -> Operation
{
2019-10-20 14:49:53 +00:00
let content = schema_to_content(accepted_types.unwrap_or_default(), schema);
2019-10-05 14:50:05 +02:00
2019-10-01 00:23:34 +02:00
let mut responses : IndexMap<StatusCode, ReferenceOr<Response>> = IndexMap::new();
2019-10-05 14:50:05 +02:00
responses.insert(StatusCode::Code(default_status.as_u16()), Item(Response {
description: default_status.canonical_reason().map(|d| d.to_string()).unwrap_or_default(),
2019-10-01 00:23:34 +02:00
headers: IndexMap::new(),
2019-10-05 14:50:05 +02:00
content,
2019-10-01 00:23:34 +02:00
links: IndexMap::new()
}));
2019-10-20 14:49:53 +00:00
let request_body = body_schema.map(|schema| Item(OARequestBody {
description: None,
2019-10-20 14:49:53 +00:00
content: schema_to_content(supported_types.unwrap_or_default(), schema),
required: true
}));
2019-10-01 00:23:34 +02:00
Operation {
tags: Vec::new(),
summary: None,
description: None,
external_documentation: None,
operation_id: None, // TODO
parameters: params.into_params(),
request_body,
2019-10-01 00:23:34 +02:00
responses: Responses {
default: None,
responses
},
deprecated: false,
security: Vec::new(),
servers: Vec::new()
}
}
2019-09-29 21:15:22 +02:00
macro_rules! implOpenapiRouter {
($implType:ident) => {
2019-09-30 18:18:10 +02:00
impl<'a, C, P> GetOpenapi for (&mut $implType<'a, C, P>, &mut OpenapiRouter)
2019-09-29 21:15:22 +02:00
where
C : PipelineHandleChain<P> + Copy + Send + Sync + 'static,
P : RefUnwindSafe + Send + Sync + 'static
{
2019-09-30 18:18:10 +02:00
fn get_openapi(&mut self, path : &str)
2019-09-29 21:15:22 +02:00
{
2019-09-30 18:18:10 +02:00
self.0.get(path).to_new_handler(OpenapiHandler::new(&self.1));
2019-09-29 21:15:22 +02:00
}
}
2019-09-30 18:18:10 +02:00
impl<'a, C, P> DrawResources for (&mut $implType<'a, C, P>, &mut OpenapiRouter)
2019-09-29 21:15:22 +02:00
where
C : PipelineHandleChain<P> + Copy + Send + Sync + 'static,
P : RefUnwindSafe + Send + Sync + 'static
{
fn resource<R : Resource, T : ToString>(&mut self, path : T)
{
R::setup((self, path.to_string()));
}
}
2019-09-30 18:18:10 +02:00
impl<'a, C, P> DrawResourceRoutes for (&mut (&mut $implType<'a, C, P>, &mut OpenapiRouter), String)
2019-09-29 21:15:22 +02:00
where
C : PipelineHandleChain<P> + Copy + Send + Sync + 'static,
P : RefUnwindSafe + Send + Sync + 'static
{
fn read_all<Handler, Res>(&mut self)
where
Res : ResourceResult,
Handler : ResourceReadAll<Res>
{
2019-10-01 16:13:13 +02:00
let schema = (self.0).1.add_schema::<Res>();
2019-09-30 23:53:55 +02:00
let path = format!("/{}", &self.1);
let mut item = (self.0).1.remove_path(&path);
2019-10-20 14:49:53 +00:00
item.get = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::default(), None, None));
2019-09-30 18:18:10 +02:00
(self.0).1.add_path(path, item);
2019-09-29 21:15:22 +02:00
2019-09-30 18:18:10 +02:00
(&mut *(self.0).0, self.1.to_string()).read_all::<Handler, Res>()
2019-09-29 21:15:22 +02:00
}
fn read<Handler, ID, Res>(&mut self)
where
ID : DeserializeOwned + Clone + RefUnwindSafe + Send + Sync + 'static,
Res : ResourceResult,
Handler : ResourceRead<ID, Res>
{
2019-10-01 16:13:13 +02:00
let schema = (self.0).1.add_schema::<Res>();
2019-10-01 00:23:34 +02:00
let path = format!("/{}/{{id}}", &self.1);
let mut item = (self.0).1.remove_path(&path);
2019-10-20 14:49:53 +00:00
item.get = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::from_path_params(vec!["id"]), None, None));
2019-10-01 00:23:34 +02:00
(self.0).1.add_path(path, item);
2019-09-30 18:18:10 +02:00
(&mut *(self.0).0, self.1.to_string()).read::<Handler, ID, Res>()
2019-09-29 21:15:22 +02:00
}
2019-10-13 17:43:42 +02:00
fn search<Handler, Query, Res>(&mut self)
where
2019-10-20 14:49:53 +00:00
Query : ResourceType + DeserializeOwned + QueryStringExtractor<Body> + Send + Sync + 'static,
2019-10-13 17:43:42 +02:00
Res : ResourceResult,
Handler : ResourceSearch<Query, Res>
{
let schema = (self.0).1.add_schema::<Res>();
let path = format!("/{}/search", &self.1);
let mut item = (self.0).1.remove_path(&self.1);
2019-10-20 14:49:53 +00:00
item.get = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::from_query_params(Query::schema()), None, None));
2019-10-13 17:43:42 +02:00
(self.0).1.add_path(path, item);
(&mut *(self.0).0, self.1.to_string()).search::<Handler, Query, Res>()
}
2019-09-29 21:15:22 +02:00
fn create<Handler, Body, Res>(&mut self)
where
2019-10-20 14:49:53 +00:00
Body : RequestBody,
2019-09-29 21:15:22 +02:00
Res : ResourceResult,
Handler : ResourceCreate<Body, Res>
{
2019-10-01 16:13:13 +02:00
let schema = (self.0).1.add_schema::<Res>();
let body_schema = (self.0).1.add_schema::<Body>();
let path = format!("/{}", &self.1);
let mut item = (self.0).1.remove_path(&path);
2019-10-20 14:49:53 +00:00
item.post = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::default(), Some(body_schema), Body::supported_types()));
(self.0).1.add_path(path, item);
2019-09-30 18:18:10 +02:00
(&mut *(self.0).0, self.1.to_string()).create::<Handler, Body, Res>()
2019-09-29 21:15:22 +02:00
}
fn update_all<Handler, Body, Res>(&mut self)
where
2019-10-20 14:49:53 +00:00
Body : RequestBody,
2019-09-29 21:15:22 +02:00
Res : ResourceResult,
Handler : ResourceUpdateAll<Body, Res>
{
2019-10-01 16:13:13 +02:00
let schema = (self.0).1.add_schema::<Res>();
let body_schema = (self.0).1.add_schema::<Body>();
let path = format!("/{}", &self.1);
let mut item = (self.0).1.remove_path(&path);
2019-10-20 14:49:53 +00:00
item.put = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::default(), Some(body_schema), Body::supported_types()));
(self.0).1.add_path(path, item);
2019-09-30 18:18:10 +02:00
(&mut *(self.0).0, self.1.to_string()).update_all::<Handler, Body, Res>()
2019-09-29 21:15:22 +02:00
}
fn update<Handler, ID, Body, Res>(&mut self)
where
ID : DeserializeOwned + Clone + RefUnwindSafe + Send + Sync + 'static,
2019-10-20 14:49:53 +00:00
Body : RequestBody,
2019-09-29 21:15:22 +02:00
Res : ResourceResult,
Handler : ResourceUpdate<ID, Body, Res>
{
2019-10-01 16:13:13 +02:00
let schema = (self.0).1.add_schema::<Res>();
let body_schema = (self.0).1.add_schema::<Body>();
let path = format!("/{}/{{id}}", &self.1);
let mut item = (self.0).1.remove_path(&path);
2019-10-20 14:49:53 +00:00
item.put = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::from_path_params(vec!["id"]), Some(body_schema), Body::supported_types()));
(self.0).1.add_path(path, item);
2019-09-30 18:18:10 +02:00
(&mut *(self.0).0, self.1.to_string()).update::<Handler, ID, Body, Res>()
2019-09-29 21:15:22 +02:00
}
fn delete_all<Handler, Res>(&mut self)
where
Res : ResourceResult,
Handler : ResourceDeleteAll<Res>
{
2019-10-01 16:13:13 +02:00
let schema = (self.0).1.add_schema::<Res>();
let path = format!("/{}", &self.1);
let mut item = (self.0).1.remove_path(&path);
2019-10-20 14:49:53 +00:00
item.delete = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::default(), None, None));
(self.0).1.add_path(path, item);
2019-09-30 18:18:10 +02:00
(&mut *(self.0).0, self.1.to_string()).delete_all::<Handler, Res>()
2019-09-29 21:15:22 +02:00
}
fn delete<Handler, ID, Res>(&mut self)
where
ID : DeserializeOwned + Clone + RefUnwindSafe + Send + Sync + 'static,
Res : ResourceResult,
Handler : ResourceDelete<ID, Res>
{
2019-10-01 16:13:13 +02:00
let schema = (self.0).1.add_schema::<Res>();
let path = format!("/{}/{{id}}", &self.1);
let mut item = (self.0).1.remove_path(&path);
2019-10-20 14:49:53 +00:00
item.delete = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::from_path_params(vec!["id"]), None, None));
(self.0).1.add_path(path, item);
2019-09-30 18:18:10 +02:00
(&mut *(self.0).0, self.1.to_string()).delete::<Handler, ID, Res>()
2019-09-29 21:15:22 +02:00
}
}
}
}
implOpenapiRouter!(RouterBuilder);
implOpenapiRouter!(ScopeBuilder);
#[cfg(test)]
mod test
{
2019-10-20 14:49:53 +00:00
use crate::ResourceResult;
use super::*;
#[derive(OpenapiType)]
#[allow(dead_code)]
struct QueryParams
{
2019-10-20 19:39:00 +02:00
id : isize
}
#[test]
fn params_empty()
{
let op_params = OperationParams::default();
let params = op_params.into_params();
assert!(params.is_empty());
}
#[test]
fn params_from_path_params()
{
let name = "id";
let op_params = OperationParams::from_path_params(vec![name]);
let params = op_params.into_params();
let json = serde_json::to_string(&params).unwrap();
assert_eq!(json, format!(r#"[{{"in":"path","name":"{}","required":true,"schema":{{"type":"string"}},"style":"simple"}}]"#, name));
}
#[test]
fn params_from_query_params()
{
let op_params = OperationParams::from_query_params(QueryParams::schema());
let params = op_params.into_params();
let json = serde_json::to_string(&params).unwrap();
assert_eq!(json, r#"[{"in":"query","name":"id","required":true,"schema":{"type":"integer"},"style":"form"}]"#);
}
#[test]
fn params_both()
{
let name = "id";
let op_params = OperationParams::new(vec![name], Some(QueryParams::schema()));
let params = op_params.into_params();
let json = serde_json::to_string(&params).unwrap();
assert_eq!(json, format!(r#"[{{"in":"path","name":"{}","required":true,"schema":{{"type":"string"}},"style":"simple"}},{{"in":"query","name":"id","required":true,"schema":{{"type":"integer"}},"style":"form"}}]"#, name));
}
2019-10-20 14:49:53 +00:00
#[test]
fn no_content_schema_to_content()
{
let types = NoContent::accepted_types();
let schema = <NoContent as OpenapiType>::schema();
let content = schema_to_content(types.unwrap_or_default(), Item(schema.into_schema()));
assert!(content.is_empty());
}
#[test]
fn raw_schema_to_content()
{
let types = Raw::<&str>::accepted_types();
let schema = <Raw<&str> as OpenapiType>::schema();
let content = schema_to_content(types.unwrap_or_default(), Item(schema.into_schema()));
assert_eq!(content.len(), 1);
let json = serde_json::to_string(&content.values().nth(0).unwrap()).unwrap();
assert_eq!(json, r#"{"schema":{"type":"string","format":"binary"}}"#);
}
}