Use Quality values in "Accept" request header
Created by: ackintosh
Description
Related issue: https://github.com/OpenAPITools/openapi-generator/issues/440
In the case below:
openapi: 3.0.0
servers:
- url: http://localhost/myapi
info:
version: "1.0"
title: My API
security:
- basicAuth: []
paths:
/download:
get:
operationId: download
responses:
200:
description: OK
content:
application/octet-stream:
schema:
type: string
format: binary
500:
description: Error
content:
application/json:
schema:
type: string
the generated api client (e.g. python client) selects application/json
as Accept header. but the API server accepts application/octet-stream
. (the API server returns application/json
only in case of 500 error.)
So the request from the API client is always result as 406 Not accepted
.
openapi-generator version
latest master
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/440
Suggest a fix/enhancement
Use Quality values in "Accept" request header instead of removing all media types except application/json
.
Accept: application/json,application/octet-stream;q=0.9
- list all media types defined in a spec
-
application/json
is set always default value (1
) - other media types is set
q=0.9
This suggestion keeps the priority that api client needs and avoid the error described above.