-
Notifications
You must be signed in to change notification settings - Fork 488
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
Decorator APIProduces doesn't work #626
Comments
Please, provide a minimal repository which reproduces your issue. |
I created a repo: https://github.com/VaultDeveloper/SwaggerAPIProduces/tree/master
Impossible to check produced type. |
@VaultDeveloper https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md |
@kamilmysliwiec I am running into this issue as well. The I understand that the new OpenApi Spec does not include the key, but what should I be using to define the media type in the NestJS API? Specifically, I am using the Any guidance here would be appreciated. |
@kamilmysliwiec thanks for your reply. Is there a way to downgrade the version of OpenAPI we are using ? |
@zachgoll I found a way. @Get(':id')
@ApiProduces("application/json", "application/vnd.api+json")
@ApiCreatedResponse({
type: MyModel
})
public getModel(@Param('id') psModelId: string): MyModel {
return {
id: "123456789-12",
body: ""
};
} MyModel is a classic Typescript class containing attribute export class MyModel {
@ApiProperty()
id: string;
@ApiProperty()
body: string;
} Result. |
I made a tweak to make this work for Swagger 3 with the JS Codegen tool: @ApiProduces('image/png')
@ApiResponse({
status: 200,
schema: {
type: 'string',
format: 'binary',
},
}) The Swagger JSON produced looks like this: {
"responses":{"200":{"description":"","content":{"image/png":{"schema":{"type":"string","format":"binary"}}}}}
} Which matches the Swagger 3 Docs for Binary Files: https://swagger.io/docs/specification/basic-structure/ |
I'm submitting a Potential bug
Current behavior
I use
nestjs/swagger
withswagger-ui-express
.I set the decorator
@ApiProduces("text/csv")
but nothing is displayed in Swagger-ui.I check the produced specs using F12 on Swagger-UI and nothing, in the specs, involved "Produces".
Expected behavior
The user can choose the Content-Type of the Response in Swagger-UI. As shown on the image below. This image is generated with YAML.
The
GET
attribute has :Minimal reproduction of the problem with instructions
Insert this function in a controller.
Environment
Last version.
The text was updated successfully, but these errors were encountered: