fastapi-cli
fastapi-cli copied to clipboard
feat: Add markdown doc based on app's openapi specification
This feat adds the possibility to generate the documentation of an app in Markdown (git style).
Beautifully named fastapi doc
It uses from fastapi.openapi.utils.get_openapi to generate the openapi specs then turn those specs into markdown.
Here is an example of generated doc based on FastAPI's example
from typing import Union
from fastapi import FastAPI
app = FastAPI(title="MyFirstAPI")
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
Generated doc:
MyFirstAPI
Version: 0.1.0
Paths
/
GET
Summary: Read Root
Operation ID: read_root__get
Responses:
| Status Code | Description | Content |
|---|---|---|
| 200 | Successful Response | application/json: schema: [A](#a) |
/items/{item_id}
GET
Summary: Read Item
Operation ID: read_item_items__item_id__get
Parameters:
| Name | In | Required | Schema | Description | Example |
|---|---|---|---|---|---|
| item_id | path | True | type: integertitle: Item Id |
N/A | N/A |
| q | query | False | type: N/Atitle: Q |
N/A | N/A |
| Responses: |
| Status Code | Description | Content |
|---|---|---|
| 200 | Successful Response | application/json: schema: [A](#a) |
| 422 | Validation Error | application/json: schema: [HTTPValidationError](#httpvalidationerror) |
Components
Schemas
HTTPValidationError
- Type: object
- Title: HTTPValidationError
- Properties:
- detail:
- Type: array
- Title: Detail
- Description: N/A
- detail:
ValidationError
- Type: object
- Required: loc, msg, type
- Title: ValidationError
- Properties:
- loc:
- Type: array
- Title: Location
- Description: N/A
- msg:
- Type: string
- Title: Message
- Description: N/A
- type:
- Type: string
- Title: Error Type
- Description: N/A
- loc:
This pull request has a merge conflict that needs to be resolved.