-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
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
API - How to have valid nullable fields in swagger ? #71
Comments
At first, your question is not library matter but just OpenAPI (swagger) matter. Answer is here: |
@fdescamps try using anyOf. Glad that you like the framework! |
Hi, Thanks for your answers. I tried anyOf like that : `
` But when the nodejs is starting, an exception is thrown : `express-openapi: Validating schema after populating paths express-openapi: validation errors [
"message": "is not exactly one from <#/definitions/response>,<#/definitions/jsonReference>", "schema": {
[...] "name": "oneOf",
` Do you know how to write a right anyOf ? Thanks. |
More Informations, oneOf is not valid, but allOf is valid |
@fdescamps take a look at the openapi schema. It should have the answer you're looking for. |
closing due to inactivity. let us know if you still have questions @fdescamps |
@fdescamps I recently adding schema extension support. Should address this. |
Is there a way to correctly validate requests/responses having nullable fields with OpenAPI v3? The OAI specifies that nullable fields should use the keyword "nullable", which doesn't seem to be implemented in any JS library for validation. I started working on trying to convert OAI's syntax to JSON-schema's (see #127). Does it make sense to work in that direction? |
The example in the test wouldn't pass validation until the quotes were removed from the $ref value:
Error with quotes around
|
@Frizzled which test are you referring to? |
Hi,
Thanks for express-openapi. I really appreciate to use it :)
But I have a problem, I need to expose fields which the type strings that could be nullable.
This following code works when i run the server based on express-api :
responses: { 200: { schema: { title: 'MyObject', properties: { myfield: { type: ['string', 'null'],
But it's not valid against Swagger (editor.swagger.io) :(
Do you have a valid way to use nullable fields with express-openapi ?
Thanks by advance !
And Thanks for this top library.
Regards,
F.
The text was updated successfully, but these errors were encountered: