When using json_or_form in location, the produced request spec is invalid and misses the requestBody.
e.g.:
@app.input(SomeRequest, location='json_or_form')
Produces this invalid spec:
{
"/some-request": {
"post": {
"parameters": [
{
"in": "json_or_form",
"name": "input",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"... redacted": ""
},
"summary": "Some Request"
}
}
}
Instead of requestBody it has parameters, with an invalid in parameter-locations.
Example of requestBody with multiple types:
{
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Order"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/Order"
}
},
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "#/components/schemas/Order"
}
}
}
}
}
See petstore3.swagger.io/api/v3/openapi.json for a full example.
While the OpenAPI file is unusable, the request parsing works in clients with a manual defined content-type header.
Environment:
- Python version: 3.10
- Flask version: 3.0.3
- APIFlask version: 2.2.0
When using
json_or_forminlocation, the produced request spec is invalid and misses therequestBody.e.g.:
@app.input(SomeRequest, location='json_or_form')Produces this invalid spec:
{ "/some-request": { "post": { "parameters": [ { "in": "json_or_form", "name": "input", "required": false, "schema": { "type": "string" } } ], "responses": { "... redacted": "" }, "summary": "Some Request" } } }Instead of
requestBodyit hasparameters, with an invalidinparameter-locations.Example of requestBody with multiple types:
{ "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Order" } }, "application/xml": { "schema": { "$ref": "#/components/schemas/Order" } }, "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/Order" } } } } }See petstore3.swagger.io/api/v3/openapi.json for a full example.
Environment: