Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add markdown doc based on app's openapi specification #43

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Iito
Copy link

@Iito Iito commented Jul 10, 2024

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: integer
title: Item Id
N/A N/A
q query False type: N/A
title: 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
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant