Documenting path parameters in blueprint url_prefix
See original GitHub issueHow do I document path parameters that appear in url_prefix
in a Blueprint? Example:
blueprint = Blueprint(
'Media',
__name__,
url_prefix='/brands/<int:brand_id>/media',
)
@blueprint.route(...)
...
I’ve read through https://github.com/marshmallow-code/flask-smorest/issues/23 but it only seems to apply to @blueprint.route()
, not Blueprint()
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Blueprints and Views — Flask Documentation (2.2.x)
A Blueprint is a way to organize a group of related views and other code. ... The url_prefix will be prepended to all...
Read more >Blueprints — Sanic 22.9.1 documentation - Read the Docs
See user guide re: blueprints. Parameters. name (str) – unique name of the blueprint. url_prefix (Optional[str]) – URL to be prefixed before all...
Read more >Flask blueprint and registering path - Stack Overflow
Since you have url_prefix in your blueprint, it means the system is looking for all routes that start with that value i.e. /search...
Read more >APIBlueprint - flask-openapi3
Generate RESTful API and OpenAPI document for your Flask project. ... trail_slash = path_url.endswith("/") # merge url_prefix and new api blueprint path url ......
Read more >Blueprints — Explore Flask 1.0 documentation
route () . Using a dynamic URL prefix¶. Continuing with the Facebook example, notice how all of the profile routes start with the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just sent a PR for this. Sorry about the delay. It was less complicated than I expected.
url_prefix
can be specified both atBlueprint
init and when callingregister_blueprint
.I was not totally comfortable with overriding
Blueprint.__init__
and I figured it was enough to just addparameters
toregister_blueprint
. The downside I see is that it requires the user to pass that parameter on each call toregister_blueprint
, which could lead to code duplication in the unlikely case of aBlueprint
being registered several times with the sameurl_prefix
(I don’t think this could happen until perhaps we support nested blueprints). It probably also adds a bit of complexity for apps where all blueprints are registered in a loop, as they must manage this special case. I assume codes with such advanced patterns can easily handle the added complexity.I’m happy with this resolution and I shall merge #313 pretty soon.
how about