improve api documentation for redoc
This commit is contained in:
parent
3ece0418db
commit
828d781938
3 changed files with 26 additions and 13 deletions
|
@ -18,7 +18,8 @@ class AuthStatusSchema(Schema):
|
|||
scopes: list[str]
|
||||
|
||||
|
||||
@auth_api_router.get('/status/', summary="get current auth details",
|
||||
@auth_api_router.get('/status/', summary="get status",
|
||||
description="Returns details about the current authentication",
|
||||
response={200: AuthStatusSchema, **auth_responses})
|
||||
def get_status(request):
|
||||
permissions = UserPermissions.get_for_user(request.user)
|
||||
|
@ -41,7 +42,7 @@ class APITokenSchema(Schema):
|
|||
|
||||
|
||||
@auth_api_router.get('/session/', response=APITokenSchema, auth=None,
|
||||
summary="Get API token tied to the current session")
|
||||
summary="get session-bound token")
|
||||
def session_token(request):
|
||||
session_id = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)
|
||||
return {"token": "anonymous" if session_id is None else f"session:{session_id}"}
|
||||
|
|
|
@ -31,15 +31,20 @@ class SwaggerAndRedoc(DocsBase):
|
|||
|
||||
|
||||
description = """
|
||||
We provide two API documentation viewers:
|
||||
|
||||
* [Redoc](/api/v2/): more comprehensive and clean *(default)*
|
||||
* [Swagger](/api/v2/?swagger): less good, but has a built-in API client
|
||||
|
||||
Nearly all endpoints require authentication, but guest authentication can be used.
|
||||
|
||||
API endpoints may change to add more features and properties,
|
||||
but no properties will be removed without a version change.
|
||||
API endpoints may change to add more features and properties, but we will attempt to keep it backwards-compatible.
|
||||
|
||||
We provide two API documentation viewers:
|
||||
|
||||
* [Redoc](/api/v2/): more comprehensive and clean *(default)*
|
||||
* [Swagger](/api/v2/?swagger): less good, but has a built-in API client
|
||||
|
||||
We recommend reading the documentation using Redoc, and either using the Code examples provided next to each request,
|
||||
or switching to swagger if you want an in-browser API client.
|
||||
|
||||
|
||||
""".strip()
|
||||
ninja_api = c3navAPI(
|
||||
title="c3nav API",
|
||||
|
@ -47,41 +52,47 @@ ninja_api = c3navAPI(
|
|||
description=description,
|
||||
|
||||
docs_url="/",
|
||||
docs=Swagger(settings={
|
||||
"persistAuthorization": True,
|
||||
"defaultModelRendering": "model",
|
||||
}),
|
||||
docs=SwaggerAndRedoc(),
|
||||
|
||||
auth=APITokenAuth(),
|
||||
|
||||
openapi_extra={
|
||||
|
||||
|
||||
"tags": [
|
||||
{
|
||||
"name": "auth",
|
||||
"x-displayName": "Authentication",
|
||||
"description": "Get and manage API access",
|
||||
},
|
||||
{
|
||||
"name": "map",
|
||||
"x-displayName": "Map access",
|
||||
"description": "Common map endpoints",
|
||||
},
|
||||
{
|
||||
"name": "routing",
|
||||
"x-displayName": "Routing",
|
||||
"description": "Calculate routes",
|
||||
},
|
||||
{
|
||||
"name": "positioning",
|
||||
"x-displayName": "Positioning",
|
||||
"description": "Determine your position",
|
||||
},
|
||||
{
|
||||
"name": "mapdata",
|
||||
"x-displayName": "Raw map data",
|
||||
"description": "Access the raw map data",
|
||||
},
|
||||
{
|
||||
"name": "editor",
|
||||
"x-displayName": "Editor",
|
||||
"description": "Endpoints for the editor and to interface with the editor",
|
||||
},
|
||||
{
|
||||
"name": "mesh",
|
||||
"x-displayName": "Mesh",
|
||||
"description": "Manage the location node mesh network",
|
||||
},
|
||||
],
|
||||
|
|
|
@ -27,7 +27,8 @@ from c3nav.mapdata.utils.user import can_access_editor
|
|||
map_api_router = APIRouter(tags=["map"])
|
||||
|
||||
|
||||
@map_api_router.get('/bounds/', summary="Get map boundaries",
|
||||
@map_api_router.get('/bounds/', summary="get boundaries",
|
||||
description="get maximum boundaries of everything on the map",
|
||||
response={200: BoundsSchema, **auth_responses})
|
||||
@newapi_etag(permissions=False)
|
||||
def bounds(request):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue