Forum Discussion

chrispward's avatar
chrispward
Occasional Visitor
2 years ago

swagger How to pass servers into configuration

I'm using Python/Flask/Flask-restful/flask-swagger-ui.

I have swagger working just find using an openapi 3.0.1 definition.
That is fine when everything use the standard basepath of /

However, we need to be able to pass the basePath of /api.  
With openapi defintion, you have to pass the server ie

servers:
  - url: /api


In my flask app, to setup swagger, I use flask-swagger-ui.
I use a 'prefixmiddleware' to alter all my routes based on a urlprefix (ie '/api')

app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix='/api')


For my swagger blueprint I do...

swaggerui_blueprint = get_swaggerui_blueprint(base_url='/api/swagger', api_url='api/static/swagger.yaml', config={"validatorUrl": None, })
app.register_blueprint(blueprint=swaggerui_blueprint, url_prefix='swagger')


So the question is... Is there a way to pass in the 'server: -url :/api' in the 'config' variable.
Config relates to the following page and I doesnt indicate anything about server urls etc.
https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/


No RepliesBe the first to reply