I already posted this to StackOverflow, but this seems like a more likely
forum.
I am using `Swashbuckle 5.6.0` and `Swashbuckle.Examples.3.5.1` to document
a WebApi2 project. I have an action which consumes an XML body and returns
a text response. I want the documentation to include an example of the XML
input - e.g. `<SampleXml><!-- example XML --></SampleXml>`.
My swagger output is below, except that for the purposes of this question I
have added the content-type `application/json` to the `comsumes`
property. In reality, I only want to allow `application/xml` and
`text/xml`.
When I view this with Swagger, I see:
- When parameter content type `application/xml` is selected, I get a
generated XML example with my model name, i.e. `<XmlModel></XmlModel>`.
- When parameter content type `application/json` is selected, I get my
desired example input `<SampleXml><!-- example XML --></SampleXml>`.
How can I get the example input while parameter content type
`application/xml` is selected?
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "Sample"
},
"host": "localhost:63434",
"schemes": [
"http"
],
"paths": {
"/sampleXml/": {
"post": {
"tags": [
"xmlSample"
],
"summary": "XML sample.",
"description": "Post XML sample",
"operationId": "Xml_Post",
"consumes": [
"application/xml",
"application/json",
"text/xml",
],
"produces": [
"text/plain"
],
"parameters": [
{
"name": "xmlContent",
"in": "body",
"description": "The content of the XML document.",
"required": true,
"schema": {
"$ref": "#/definitions/XmlModel"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
}
}
}
},
"definitions": {
"XmlModel": {
"type": "object",
"properties": {},
"example": "<SampleXml><!-- example XML --></SampleXml>"
}
}
}
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.