okapi
okapi copied to clipboard
Using openapi3::OpenApi with schemars alpha version
Hello!
My goal is to produce an OpenApi spec using schemars.
I have a code:
let my_schemas: okapi::Map::<String, okapi::openapi3::SchemaObject> = ... // generated by schemars ^0.8
OpenApi {
openapi: "3.0.0".to_string(),
info: okapi::openapi3::Info {
title: "My API".to_string(),
version: "1.0.0".to_string(),
..Default::default()
},
components: Some(okapi::openapi3::Components {
schemas: my_schemas,
..Default::default()
}),
..Default::default()
}
Which works perfectly with schemars ^0.8.
However, I would like to use schemars 1.0.0-alpha.17 as it has better enum support and seems it has more useful features.
There is a problem. Now my_schemas type would be Schema(Value) from alpha version which is not compatible with OpenApi::components::schemas type Map<String, SchemaObject> as schemars ^0.8 generate except manually implementing that transformation which can be quirky. Another option I see is to generate pure json instead of using openapiv3::OpenApi
Could you please suggest a pretty solution for this issue?
cc @GREsau