-
Notifications
You must be signed in to change notification settings - Fork 35
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
Different endpoints in swagger "Try it out" fire to the same endpoint when they have the same function name #127
Comments
Please make sure that before using the from flask_openapi3 import OpenAPI, APIBlueprint
app = OpenAPI(__name__)
parent1_bp = APIBlueprint('Parent 1', __name__, url_prefix='/parent1')
children_p1_bp = APIBlueprint('Child p1', __name__, url_prefix='/children')
parent2_bp = APIBlueprint('Parent 2', __name__, url_prefix='/parent2')
children_p2_bp = APIBlueprint('Child p2', __name__, url_prefix='/children')
root_parent_bp = APIBlueprint('Root Parent', __name__, url_prefix='/root')
@children_p1_bp.get('')
def get_children1():
return {"message": "children1"}
@children_p2_bp.get('')
def get_children2():
return {"message": "children2"}
parent1_bp.register_api(children_p1_bp)
parent2_bp.register_api(children_p2_bp)
root_parent_bp.register_api(parent1_bp)
root_parent_bp.register_api(parent2_bp)
app.register_api(root_parent_bp)
if __name__ == '__main__':
app.run(debug=True) |
Your code works fine for me. main.py from flask_openapi3 import APIBlueprint, OpenAPI
from app_1 import app_1_bp
from app_2 import app_2_bp
app = OpenAPI(__name__)
root_bp = APIBlueprint('App', __name__, url_prefix='/app')
root_bp.register_api(app_1_bp)
root_bp.register_api(app_2_bp)
app.register_api(root_bp)
if __name__ == '__main__':
app.run(debug=True) app_1.py from flask_openapi3 import Tag, APIBlueprint
app_1_tag = Tag(name='App 1')
app_1_bp = APIBlueprint('App 1', __name__, url_prefix='/app_1', abp_tags=[app_1_tag])
@app_1_bp.get('/hello')
def hello():
return 'Hello, World 1!' app_2.py from flask_openapi3 import APIBlueprint, Tag
app_2_tag = Tag(name='App 2')
app_2_bp = APIBlueprint('App 2', __name__, url_prefix='/app_2', abp_tags=[app_2_tag])
@app_2_bp.get('/hello')
def hello():
return 'Hello, World 2!' |
Thanks! this is a problem caused by the same "paths": {
"/app/app_1/hello": {
"get": {
"operationId": "hello_hello_get",
"responses": {},
"tags": [
"App 1"
]
}
},
"/app/app_2/hello": {
"get": {
"operationId": "hello_hello_get",
"responses": {},
"tags": [
"App 2"
]
}
}
}, |
Thanks :) |
Environment:
I will try to show that using a quick example:
Which gives 2 endpoints:
/root/parent1/children
/root/parent2/children
In swagger both endpoints are displayed separately, but both of them in the "Try it out" in swagger will fire to the first one.
When you make a request outside of the swagger everything works fine, but in swagger it doesn't.
Also, I didn't have this issue while using the flask-openapi3 version 2.5.4.
The text was updated successfully, but these errors were encountered: