Search code examples
pythonrestflaskswaggerflask-restplus

How to edit Flask-plus default swagger-UI text


I am developing a simple rest api that only has two Get methods so far. It's working fine etc, and looks pretty great when I navigate to the url thanks to the built in swagger documentation.

However I do not actually see a yaml or json file anywhere. How do I change the title and default values as shown in the screenshot? Hopefully it's possible without making a whole separate yaml or json doc?

I don't actually want to change the design at all. I only want to edit the text a little.

enter image description here


Solution

  • You set the title when creating the API:

    api = Api(app, version='1.0', title='Your API Name', 
              description='A more complete description')
    

    You set the namespace to something other than default by creating a namespace:

    ns = api.namespace('not-default', 
                       description='Whatever your namespace is')
    

    Then you create your routes in the appropriate namespace:

    @ns.route(...)
    

    This is a handy way to group your APIs. See the Full Example for help if needed.