You need to add docs to the view-func. The first line is the summary, and the rest is the description. Like this:
1234567
@app.get('/book/<int:bid>',tags=[book_tag],responses={200:BookResponse},security=security)defget_book(path:BookPath,query:BookBody):"""Get book Get some book by id, like: http://localhost:5000/book/3 """return{"code":0,"message":"ok","data":{"bid":path.bid,"age":query.age,"author":query.author}}
New in v1.0.0
Now keyword parameters summary and description is supported, it will be take first.
1234567
@app.get('/book/<int:bid>',summary="new summary",description='new description')defget_book(path:BookPath,query:BookBody):"""Get book Get some book by id, like: http://localhost:5000/book/3 """return{"code":0,"message":"ok","data":{}}
fromflask_openapi3importOpenAPI,ExternalDocumentationapp=OpenAPI(__name__,info=info)@app.get('/book/<int:bid>',tags=[book_tag],summary='new summary',description='new description',external_docs=ExternalDocumentation(url="https://www.openapis.org/",description="Something great got better, get excited!"))defget_book(path:BookPath):...
You can set a custom callback to automatically set operation_id for an api (operation).
Just add a operation_id_callback param to the constructor of OpenAPI or APIBlueprint or APIView.
The example shows setting the default operation_id to be the function name, in this case create_book.
extra_form will be deprecated in v3.x, please use openapi_extra instead.
new in v2.1.0
Extra form information can be provided using extra_form as in the following sample:
1 2 3 4 5 6 7 8 9101112
fromflask_openapi3importExtraRequestBodyextra_form=ExtraRequestBody(description="This is form RequestBody",required=True,# replace style (default to form)encoding={"str_list":Encoding(style="simple")})@app.post('/book',extra_form=extra_form)defcreate_book(body:BookForm):...
fromflask_openapi3importExtraRequestBodyextra_body=ExtraRequestBody(description="This is post RequestBody",required=True,example="ttt",examples={"example1":Example(summary="example summary1",description="example description1",value={"age":24,"author":"author1"}),"example2":Example(summary="example summary2",description="example description2",value={"age":48,"author":"author2"})})@app.post('/book',extra_body=extra_body)defcreate_book(body:BookForm):...
An array of Server Objects, which provide connectivity information to a target server. If the server's property is not provided, or is an empty array, the default value would be a Server Object with an url value of /.
While the OpenAPI Specification tries to accommodate most use cases,
additional data can be added to extend the specification at certain points.
See Specification Extensions.