1

I have started to use Swagger for API documentation. Please help me configure it. How to expand the schema in Swagger UI by default?

from flasgger import Swagger, swag_from
from flask import Flask

app = Flask(__name__)
swagger = Swagger(app)


@swag_from("example.yml", methods=["GET"])
@app.route("/")
def example():
    return "Hello World!"


if __name__ == "__main__":
    app.run()

example.yml

responses:
  '200':
    description: Successful response
    schema:
      type: object
      properties:
        data:
          type: object
          properties:
            messages:
              type: array
              items:
                type: object
                properties:
                  level:
                    type: string
                  title:
                    type: string
                  uid:
                    type: integer
                  value:
                    type: string

http://127.0.0.1:5000/apidocs

By default, this example displayed with collapsed Schema model data:

enter image description here

but I need to expand it by default, like:

enter image description here

Helen
  • 87,344
  • 17
  • 243
  • 314
pyjedy
  • 389
  • 2
  • 9
  • 1
    Try adding `'ui_params': {'defaultModelExpandDepth': 5}` to your `app.config['SWAGGER']`. [Example of using `ui_params`](https://github.com/flasgger/flasgger/blob/aa9bf3ee9315e3a60c4f9816920c7b12935d7f93/examples/changelog_090.py#L51) – Helen Mar 15 '23 at 13:53

0 Answers0