I have an API with multiple versions and it would be nice to provide different URLs for different versions to have things more cleanly (I don't want to distract users with deprecated APIs but still provide docs for users stuck with the deprecated API).
I tried this trick to build multiple apispecs at different URLs:
for bp in blueprints:
app.config.update({
'APISPEC_SPEC': APISpec(
title='Accounts Service',
version=bp.name,
openapi_version='2.0',
plugins=[MarshmallowPlugin()],
),
'APISPEC_SWAGGER_URL': f'/swagger/{bp.name}',
'APISPEC_SWAGGER_UI_URL': '/swagger/{bp.name}/ui',
})
spec = FlaskApiSpec(app)
for name, endpoint in spec.app.view_functions.items():
if not isinstance(endpoint, types.FunctionType):
continue
if '.' in name:
spec.register(endpoint, blueprint=name[:name.index('.')])
else:
spec.register(endpoint)
But flask would complain about Both share the same name "flask-apispec". Blueprints that are created on the fly need unique names. because this blueprint name is hardcoded and can't be changed:
|
blueprint = flask.Blueprint( |
|
'flask-apispec', |
|
__name__, |
|
static_folder='./static', |
|
template_folder='./templates', |
|
static_url_path='/flask-apispec/static', |
|
) |
It would be nice to provide a way to override the blueprint name.
I have an API with multiple versions and it would be nice to provide different URLs for different versions to have things more cleanly (I don't want to distract users with deprecated APIs but still provide docs for users stuck with the deprecated API).
I tried this trick to build multiple apispecs at different URLs:
But flask would complain about
Both share the same name "flask-apispec". Blueprints that are created on the fly need unique names.because this blueprint name is hardcoded and can't be changed:flask-apispec/flask_apispec/extension.py
Lines 75 to 81 in de6f5ad
It would be nice to provide a way to override the blueprint name.