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
Support alternate media types #61
Comments
Hello I have had this request in the past, usually for XML support. I've never heard of hal+json. I don't really know what support Swashbuckle has for other content types. The swagger examples page here doesn't have an example of an XML example in a swagger.json file. That's a mouthful. This spec here is more useful:
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#exampleObject My best guess for the XML content type, is that it should look something like this: "responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/Blah"
},
"examples": {
"application/json": {
"id": "38",
"title": "T-Shirt"
},
"text/xml": {
"example": "<id>38</id><title>T-Shirt</title>"
}
}
}, That's a complete guess though! Again, I have no idea how Swashbuckle handles different content types, I've never had to do that. The key point from the quote above is that the content type needs to be one of the "produces" values. My thoughts on how to implement this. I don't think the I would certainly welcome a PR that added support for other media types, starting with XML. You could include your hal+json support as part of that. But if you just want hal+json, well I'm not seeing a lot of demand for that from the community. It might be easiest if you take a copy of ExamplesOperationFilter and customize it for your hal+json needs for now? |
+1 for hal+json support! |
I still haven't really gotten my head around hal+json as I've never used it on a project, so I am not going to implement support for it. FWIW I've added XML support in my
Closing this issue, since I'm not going to implement it. But a PR is welcome. |
Currently a response example always uses the media type application/json. It would be useful to be able to specify alternate media types such as application/hal+json. The SwaggerResponseExampleAttribute could accept a content type parameter.
Happy to create a PR.
The text was updated successfully, but these errors were encountered: