We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It would be nice if a type being wrapped in Option<> would be shown as nullable in the OpenAPI document. See https://stackoverflow.com/questions/48111459/how-to-define-a-property-that-can-be-string-or-null-in-openapi-swagger
Option<>
#[oai(path = "/hello", method = "get")] async fn hello(&self) -> Json<Option<String>> { Json(None) }
would generate
paths: /hello: get: responses: '200': description: '' content: application/json; charset=utf-8: schema: type: string nullable: true
Additionally,
#[derive(Object)] struct Foo { x: Option<i32>, } #[OpenApi] impl Api { #[oai(path = "/hello", method = "post")] async fn hello(&self, _p: Json<Foo>) {} }
paths: /hello: post: requestBody: content: application/json; charset=utf-8: schema: $ref: '#/components/schemas/Foo' required: true responses: '200': description: '' components: schemas: Foo: type: object properties: x: type: integer format: int32 nullable: true
Thanks for the amazing work!
The text was updated successfully, but these errors were encountered:
By default, serde serializes Option::None as null. It does not skip the field altogether.
serde
Option::None
null
This means that objects serialized by serde actually do not adhere to the schema generated by poem-openapi in case there are Option::None values.
poem-openapi
Sorry, something went wrong.
Isn't this what is happening in the example and PR? A nullable field, albeit manually specified in the PR, would make None become null
None
No branches or pull requests
Description of the feature
It would be nice if a type being wrapped in
Option<>
would be shown as nullable in the OpenAPI document. See https://stackoverflow.com/questions/48111459/how-to-define-a-property-that-can-be-string-or-null-in-openapi-swaggerCode example
would generate
Additionally,
would generate
Thanks for the amazing work!
The text was updated successfully, but these errors were encountered: