-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
Null type in JSON schema ignore when generating swagger. #594
Comments
It is expected. There is no type call |
Type can be declared as Nullable as far as I know. |
You should use
|
I tried using the type |
OpenAPI v3.1 is compatible with JSON Schema, and introduced support for "null". See "Schema Object Changes " in https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0. As for OpenAPI 3.0, TypeBox has some documentation for supporting null types: https://github.com/sinclairzx81/typebox#OpenAPI. I haven't verified if this works well with |
Using the following versions:
Given a typebox definition like:
The following (invalid) open api 3.0 spec is generated:
Dropping the Union would remove the in 3.0 invalid |
Prerequisites
Fastify version
3.29.0
Plugin version
6.0.1
Node.js version
16.13.1
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.3.1
Description
I'm using Typebox to generate JSON schemas for an endpoint's response. In one endpoint some response properties may be
null
.In Typebox we defined it as follow
Which seems to generate the correct JSON schema
The generated swagger file does not indicate that field can be nullable (which cases some of our tests to fail).
Steps to Reproduce
Create a schema with a property with type
Generate swagger file.
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: