-
-
Notifications
You must be signed in to change notification settings - Fork 777
Open
Description
I found a bug that causes the incorrect openAPI schema to be sent to swagger UI when params are present at both path and request level. I have attached a sample project. But, will include details inline as well.
The API schema is :
openapi: "3.0.0"
info:
title: Greeting application
version: 0.0.1
paths:
/greeting/{name}:
parameters:
- name: name
in: path
required: true
schema:
type: string
get:
operationId: run.post_greeting
parameters:
- name: last_name
in: query
required: true
schema:
type: string
responses:
'200':
description: "Greeting response"
content:
text/plain:
schema:
type: string
When connexion loads the schema is (which is correct):
{
"openapi": "3.0.0",
"info": {
"title": "Greeting application",
"version": "0.0.1"
},
"paths": {
"/greeting/{name}": {
"parameters": [
{
"name": "name",
"in": "path",
"required": True,
"schema": {
"type": "string"
}
}
],
"get": {
"operationId": "run.post_greeting",
"parameters": [
{
"name": "last_name",
"in": "query",
"required": True,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Greeting response",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
},
"components": {}
}
This is printed from Specification
__init__
method raw_spec
This is the schema that is passed to Specification
__init__
method raw_spec
when I load the swagger UI
{
"openapi": "3.0.0",
"info": {
"title": "Greeting application",
"version": "0.0.1"
},
"paths": {
"/greeting/{name}": {
"parameters": [
{
"name": "name",
"in": "path",
"required": True,
"schema": {
"type": "string"
}
}
],
"get": {
"operationId": "run.post_greeting",
"parameters": [
{
"name": "last_name",
"in": "query",
"required": True,
"schema": {
"type": "string"
}
},
{
"name": "name",
"in": "path",
"required": True,
"schema": {
"type": "string"
}
},
{
"name": "name",
"in": "path",
"required": True,
"schema": {
"type": "string"
}
},
{
"name": "name",
"in": "path",
"required": True,
"schema": {
"type": "string"
}
},
{
"name": "name",
"in": "path",
"required": True,
"schema": {
"type": "string"
}
},
{
"name": "name",
"in": "path",
"required": True,
"schema": {
"type": "string"
}
},
{
"name": "name",
"in": "path",
"required": True,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Greeting response",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
},
"components": {}
}
If I remove the path level parameters from the schema (see below) then this problem goes away.
openapi: "3.0.0"
info:
title: Greeting application
version: 0.0.1
paths:
/greeting/{name}:
get:
operationId: run.post_greeting
parameters:
- name: last_name
in: query
required: true
schema:
type: string
responses:
'200':
description: "Greeting response"
content:
text/plain:
schema:
type: string
Reproduce.
1. Unzip the files
2. poetry install
3. poetry run uvicorn run:app
4. visit http://127.0.0.1:8000/ui/
Metadata
Metadata
Assignees
Labels
No labels