-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
"Examples" incorrectly rendered for OpenAPI 3.x spec #535
Comments
Would you like to send a Pull Request to address this issue? Remember to add unit tests. |
Looking forward to have this fixed. |
Is
I'm not sure about the correct behavior we need to implement here and need some guidance in order to implement it |
Hey @mikicho
So, perhaps frustratingly, nested Onto the fix for the initial problem, is it enough to simply move the fastify.get('/description', {
schema: {
response: {
200: {
type: 'string',
examples: ['one', 'two'],
}
}
}
}, () => {}) gives something like "get": {
"responses": {
"200": {
"description": "Default Response",
"content": {
"application/json": {
"schema": {
"type": "string",
"examples": {
"one": {
"value": "one"
},
"two": {
"value": "two"
}
}
}
}
}
}
}
}, It gets a bit weird when using export const PrototypesSchema = Type.Object(
{
foo: Type.String(),
bar: Nullable(Type.String()),
}
); to generate the schema, then fastify.addSchema(PrototypesSchema)
// ...
fastify.get('/description', {
schema: {
200: {
...Type.Ref(PrototypesSchema),
examples: [
{
foo: 'example 1',
bar: null,
},
{
foo: 'example 2',
bar: 'some bar value',
},
],
},
}
}, () => {}) Would it be more correct if fastify-swagger used a As a side note, currently |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Prerequisites
Fastify version
3.27.0
Plugin version
4.13.0
Node.js version
16.13.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.2 (21D49)
Description
When adding an examples array to JSON Schema, when translating it to OpenAPI 3.x spec, the property seems to be misplaced: it is added under schemas but it should be next to it.
This causes a validation error in Swagger Editor, indicating the examples is not a valid property under schemas and it makes Swagger-UI not render the examples array.
Steps to Reproduce
Indeed, the examples object is placed below schemas, but it should be next to it
The text was updated successfully, but these errors were encountered: