Skip to content
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

[#17] Support for Nested APIBlueprint enhancement #18

Closed
wants to merge 4 commits into from

Conversation

luolingchun
Copy link
Owner

Support for Nested APIBlueprint enhancement

@luolingchun luolingchun added the enhancement New feature or request label Apr 2, 2022
@luolingchun luolingchun added this to the 2.0.0 milestone Apr 2, 2022
@luolingchun

This comment was marked as resolved.

@dvaerum
Copy link
Contributor

dvaerum commented Apr 29, 2022

Hey @luolingchun, I have been working with your patch for the most of the week, and it seems to work, the only thing I have found is the order of when one does what is important, but if stuff is done in the right order, it works :D

Maybe it makes sense to have a way to do call-backs. E.g. if I add an endpoint endpoint_1 to an APIBlueprint name child and when register that APIBlueprint at one name parent I cannot afterwords add another endpoint (endpoint_2) to the child, but if child would have a reference to parent it could update parent if more endpoints was added to child

from flask_openapi3 import APIBlueprint

parent = APIBlueprint(name="parent", import_name=__name__, url_prefix="/parent")

child = APIBlueprint(name="child", import_name=__name__, url_prefix="/child")

@child.post(rule="endpoint_1", responses={"204": MsgResponse, "400": ErrorMsgResponse})
def endpoint_1(body: PostRequest):
    return {"msg": "test msg"}

parent.register_api(child)

@child.post(rule="endpoint_2", responses={"204": MsgResponse, "400": ErrorMsgResponse})
def endpoint_2(body: PostRequest):
    return {"msg": "test msg"}

@luolingchun
Copy link
Owner Author

@dvaerum There is the same problem in Flask, Therefore, I think we should solve this problem by ourselves when coding.

from flask import Flask, Blueprint


app = Flask(__name__)
bl = Blueprint('test', __name__)


@bl.route('/route1')
def route1():
    return 'Hello, World!'


app.register_blueprint(bl)


@bl.route('/route2')
def route2():
    return 'Hello, World!'


if __name__ == '__main__':
    print(app.url_map)
Map([<Rule '/route1' (GET, HEAD, OPTIONS) -> test.route1>,
 <Rule '/static/<filename>' (GET, HEAD, OPTIONS) -> static>])

@dvaerum
Copy link
Contributor

dvaerum commented May 2, 2022

Sounds completely fair 👍

@dvaerum
Copy link
Contributor

dvaerum commented May 14, 2022

@luolingchun I have been using this patch of yours for some time now and still have not found any problems with it 👍 Just want to give you an update 😃

@luolingchun luolingchun force-pushed the Support_for_Nested_APIBlueprint branch from 29feeba to 8890337 Compare May 15, 2022 01:42
@luolingchun luolingchun force-pushed the Support_for_Nested_APIBlueprint branch from 56f7e17 to 03c351a Compare May 15, 2022 01:53
@luolingchun
Copy link
Owner Author

@dvaerum I made a preview release v2.0.0rc1.

@luolingchun luolingchun deleted the Support_for_Nested_APIBlueprint branch May 15, 2022 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants