Closed parisni closed 2 years ago
Check this example: https://github.com/0b01001001/spectree/blob/36c4d18834eb2bbe19098d97e24036baca3943e2/examples/flask_demo.py#L55-L76
For the path variables, this library doesn't provide a strong validation with pydantic
. It will use the default path converter.
But of course you can still get the correct OpenAPI document for path variables.
But of course you can still get the correct OpenAPI document for path variables
Sorry I cannot find out in your example how to add a description to source
and target
path variable. I can see how to add constraints on them such as length but no description field that would appear in the openapi specs
Sorry I misunderstood your question before. Currently, this library doesn't support descriptions for the path variables. You can use function description for the path variables.
One possible way is to add another path model. But I'm not sure if we should validate the input again.
class PathVariables(pydantic.BaseModel):
source: str = pydantic.Field(..., description='source language')
target: str
@api.route('/api/<string:source>/<string:target>')
@spec.validate(path=PathVariables)
def index(source, target):
pass
Feel free to give more feedbacks about this.
So far, I can't find a way to add a description for
path
variables. On the flask side, It would be cool to have a parameter suchdoc
as flask-restfull provides :