aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.67k stars 1.01k forks source link

How to add tags for my swagger #2027

Open guillaumejacquin opened 1 year ago

guillaumejacquin commented 1 year ago

Hello there,

I generated my swagger via the command "chalice generate-models" and although it finds all the routes for me, these are empty and do not return anything do not find the arguments.


@app.route("/test", methods=["GET", "PUT", "POST"], cors=True)
def test():
"""
Retrieves a simple message.
---
tags:
- Hello
parameters:
- name: name
in:query
type: thong
required: true
description: Your name.
responses:
200:
description: A welcome message.
plan:
type: object
properties:
message:
type: thong
"""
    hello_world = {"hello": "world", "environment": ENVIRONMENT}
    return Response(body=hello_world, status_code=200, headers={"Content-Type": "text/plain"})

which is not really very practical and useful i would like to get something like that:

@doc.summary("Récupère un message simple.")
@doc.tag('hello')
@doc.parameter('name', description="Votre nom.", required=True, location="query", type=str)
@doc.response(200, description="Un message de bienvenue.", schema={
'type': 'object',
'properties': {
'message': {
'type': 'string'
}
}
})

Thanks for yours answers