-
Notifications
You must be signed in to change notification settings - Fork 679
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
Define 'File' Schema Type without filter #1144
Comments
Hi, I have the very same project. Working with ASP.NET Core and Swashbuckle.AspNetCore 1.2.0, the following code does not generate the appropriate "produces", and the "Response Content Type" always shows "application/json" instead of the configured values. Example of the code:
I had to create an IOperationFilter to add it. Thank you. |
ExpectationsMy expectations would be something like this: ...
[ProducesResponseType(typeof(FileResult), 200)]
[ProducesResponseType(typeof(ErrorModel), 403, MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(ErrorModel), 404, MediaTypeNames.Application.Json)]
... The status' code 200 response type would be declared either way: [Produces(MediaTypeNames.Application.Pdf)] // could act as default, and already does, nice
// or
[ProducesResponseType(typeof(FileResult), 200, MediaTypeNames.Application.Pdf)] and would produce: ...
"responses": {
"200": {
"description": "Success",
"content": {
"application/pdf": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorModel"
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorModel"
}
}
}
}
}
... What changes or should change, imhoIn this example, status code 200 stays the same, if you use it with: [Produces(MediaTypeNames.Application.Pdf)] But currently if you use: [ProducesResponseType(typeof(ErrorModel), statusCode, MediaTypeNames.Application.Json)] or anything defined with content type in "{statusCode}": {
"description": "{statusCodeDescription}"
} and the only change would be to add: "content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorModel"
}
}
} if content type is defined. @rliberoff could you post your IOperationFilter, or what did you try to do with it? |
Okay, I found a PR on the Swashbuckle.AspNetCore repo which actually implemented this in the However, it is not perfect because But anyway, could be another issue in the other repo because it is out of scope. I hope, I didn't disturb you all to much, have a nice day. |
Hi,
Is it possible to achieve below without the filter i.e. using an attribute or any other way?
![image](https://user-images.githubusercontent.com/17155996/28608698-b8c4e216-7224-11e7-83f7-c7dd78f1886b.png)
The text was updated successfully, but these errors were encountered: