-
Notifications
You must be signed in to change notification settings - Fork 9k
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-ui does not use the right produces consumes application/json #2042
Comments
You may have hit a bug here. To help us test it more quickly, can you provide with a minimal spec that reproduces the behavior? |
I believe I have the same problem. I added the pem package and openssl to allow the server to work over https. The error I get from the console is: Curl starts out with: I put both the swagger file and the modified index.js file in a zip. Thanks |
I am having a similar issue. Any update? |
+1 When performing a With |
@benoitmasson, this is because the |
@danjor please try from the latest master--I cannot reproduce this issue. With this simplified spec: {
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "apiteam@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"basePath": "/v2/api",
"schemes": [
"http"
],
"produces": [
"application/xml"
],
"paths": {
"/pet/{petId}": {
"get": {
"tags": [
"pet"
],
"summary": "Find pet by ID",
"description": "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
"operationId": "getPetById",
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet that needs to be fetched",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"404": {
"description": "Pet not found"
},
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Pet"
}
},
"400": {
"description": "Invalid ID supplied"
}
},
"security": [
{
"api_key": []
},
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
}
},
"definitions": {
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Category"
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "http://petstore.swagger.io/v2/swagger.json#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"xml": {
"name": "photoUrl",
"wrapped": true
},
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"xml": {
"name": "tag",
"wrapped": true
},
"items": {
"$ref": "http://petstore.swagger.io/v2/swagger.json#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
},
"xml": {
"name": "Pet"
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Tag"
}
}
}
} I see the correct headers being sent to the server (intentionally set to Reopen if you still have this issue. |
I'm using the last version of swagger ui and I'm facing the following issue.
When no "host" attribute is defined in yaml, "produces" and "consumes" attributes are not used.
Indeed, with
When I try executing a request, I get
curl -X GET --header 'Accept: text/html' 'http://myapi/X'
instead of
curl -X GET --header 'Accept: application/json' --header 'Content-Type: application/json' 'http://myapi/X'
Then analysing with the Chrome dev tools, Swagger-ui effectively sends a request with the wrong header containing wrong Accept and Content-Type (text/html), and my generated SpringMVC backend responds with an error 415 : "server can't produce text/html"
Why this behavior is happening ?
The text was updated successfully, but these errors were encountered: