I am trying to work out if it is better to try implement JsonSchema or use #[openapi(skip)] and do a merge on a custom OpenApi struct with just this definition.
I was initially trying an OpenApi struct which is as follows.
pub fn process_data_openapi(schema_generator: &mut SchemaGenerator) -> OpenApi {
use indexmap::indexmap;
use rocket_okapi::okapi::openapi3::*;
OpenApi {
openapi: OpenApi::default_version(),
info: Default::default(),
servers: vec![],
paths: indexmap! {
"/process_data".to_owned() => PathItem {
post: Some(
Operation {
tags: vec!["Data".to_owned()],
summary: Some("Gets the data result from the given files.".to_owned()),
request_body: Some(RefOr::Object(
RequestBody {
description: Some("The data definition.".to_string()),
content: indexmap! {
"form-data".to_owned() => MediaType {
schema: Some(SchemaObject {
instance_type: Some(SingleOrVec::Vec(vec![
// TODO: Put definition here
])),
..Default::default()
}),
..Default::default()
}
},
..Default::default()
}
)),
responses: Responses {
responses: indexmap! {
"200".to_owned() => RefOr::Object(
Response {
description: "The response data".to_owned(),
content: indexmap! {
"application/json".to_owned() => MediaType {
schema: Some(ResponseData::json_schema(schema_generator).into()),
..Default::default()
}
},
..Default::default()
}
)
},
..Default::default()
},
..Default::default()
}
),
..Default::default()
},
},
..Default::default()
}
}
As you can see I'm not sure how to define the MediaTypeSchemaObject for the form-data
Are there any existing proc_macros that could help me or traits that I could implement?
The package versions I am using:
The form input structs and endpoint function I am using is as follows:
I am trying to work out if it is better to try implement
JsonSchema
or use#[openapi(skip)]
and do a merge on a customOpenApi
struct with just this definition.I was initially trying an
OpenApi
struct which is as follows.As you can see I'm not sure how to define the
MediaType
SchemaObject
for theform-data
Are there any existing proc_macros that could help me or traits that I could implement?
Any help would be greatly appreciated.