flasgger
flasgger copied to clipboard
apidocs endpoint
Hi, I would like to change the apidocs url endpoint to some other endpoint such as api-docs. Is there any way to do this through some configuration?
Thank you Moshe
You can config the Flasgger though Flask's config, eg:
SWAGGER = {
"specs": [
{
"endpoint": "apispec_1",
"route": "/project/apispec_1.json",
"rule_filter": lambda rule: True, # all in
"model_filter": lambda tag: True, # all in
}
],
"static_url_path": "/project/flasgger_static",
"swagger_ui": True,
"specs_route": "/project/apidocs"
}
@moshere You should close this issue if the given response was correct.
I tried this:
template = {
"info": {
"title": "My API"
},
"specs_route": "/api/"
}
swagger = Swagger(app, template=template)
But the route is still /apidocs
Hi, pls see source code: default config: https://github.com/flasgger/flasgger/blob/7f8bb663b177d936a1a7921db0acfeecd75edce5/flasgger/base.py#L162
https://github.com/flasgger/flasgger/blob/7f8bb663b177d936a1a7921db0acfeecd75edce5/flasgger/base.py#L178
and set specs_route https://github.com/flasgger/flasgger/blob/7f8bb663b177d936a1a7921db0acfeecd75edce5/flasgger/base.py#L565
Try this:
config = {
"specs_route": "/api/"
}
swagger = Swagger(app, config=config)
swagger = Swagger(app, config=config, merge=True)