-
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
Consumes */* in OpenAPI breaks Swagger UI #6742
Comments
Workaround using injector:
|
It would be great if its possible to set the header to application/json if consumes is set to / only. As the workaround breaks other APIs that have proper consumes. |
Please post your OpenAPI YAML/JSON file. |
@hkosova I am using Kubernetes API: https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.20/api/openapi-spec/swagger.json Problem occurs with any API that has
Swagger UI curl requests automatically adds: |
I am using master swagger-ui from https://github.com/swagger-api/swagger-ui, cloned today. |
The problem is with Kubernetes OpenAPI definition. If their API only accepts request bodies with specific media types, such as
then "consumes": [
"application/json",
"application/yaml",
"application/vnd.kubernetes.protobuf",
], |
However consumes with wildcard is valid OpenAPI definition |
Yes - provided that the API server actually accepts |
But doesnt wildcard just represent anytype? for example if I send the application/json it works of course, so type wildcard works, the problem is that Swagger UI sent literally wildcard. Which I think is incorrect. In such situations at best I should be able to definy type myself as Server accepts wildcard. |
Consumes set to / in OpenAPI spec, breaks swagger ui request.
For example in Kubernetes:
curl -X DELETE "HOST/api/v1/namespaces/test-namespace/pods/test-pod?propagationPolicy=Background" -H "accept: application/json" -H "Content-Type: /" -d "{ "propagationPolicy": "Background"}"
breaks in app because it takes / literally, instead you should be able to choose from:
Such curl requests will results in:
"message": "the body of the request was in an unknown format - accepted media types include: application/json, application/yaml, application/vnd.kubernetes.protobuf",
"reason": "UnsupportedMediaType",
Is there a way to add custom content-types when / is matched?
The text was updated successfully, but these errors were encountered: