-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Swagger plugin does not render example for response of array #72
Comments
Same issue here, it seems like the schema gets messed up. {
"/posts": {
"get": {
"responses": {
"200": {
"items": {
"type": "object",
"properties": {
"id": {
"format": "uuid",
"type": "string"
}
},
"required": ["id"]
},
"content": {
"application/json": {
"schema": {
"type": "array"
}
}
}
}
},
"operationId": "getPosts",
"description": "Get all posts"
}
}
} I think {
"/posts": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"format": "uuid",
"type": "string"
}
},
"required": ["id"]
}
}
}
}
}
},
"operationId": "getPosts",
"description": "Get all posts"
}
}
} |
You can add example of response like this: const app = new Elysia()
.use(swagger({}))
.get('/', () => [1, 2, 3], {
detail: {
responses: {
200: {
description: 'get numbers',
content: {
'application/json': {
example: [1, 2, 3],
},
},
},
},
},
}) |
Yeah, but the generated schema is still incorrect. Some clients depend on that schema for type generation or other stuff. *Edit: my bad, it works. But it requires some additional work which i´d rather not do myself |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this the intended behaviour? Arrays can be rendered as examples for the request body, however, for the response it always displays "no example available".
The example response of an object is rendered correctly:
The text was updated successfully, but these errors were encountered: