Add fields doc

This commit is contained in:
Gabriel Augendre 2021-11-09 12:50:21 +01:00
parent 8d0ca77be1
commit e6195206b9

18
main.py
View file

@ -1,9 +1,9 @@
import enum
from typing import List, Optional
from typing import Any, List, Optional
import httpx
from fastapi import FastAPI, HTTPException
from fastapi.params import Header
from fastapi.params import Header, Path
from pydantic import BaseModel
app = FastAPI()
@ -31,10 +31,18 @@ class Passages(BaseModel):
passages: List[Passage]
# Stop id can be optained using
# https://data.grandlyon.com/jeux-de-donnees/points-arret-reseau-transports-commun-lyonnais/donnees
@app.get("/stop/{stop_id}", response_model=Passages)
async def stop(stop_id: int, authorization: Optional[str] = Header(None)):
async def stop(
stop_id: int = Path(
None,
description="Stop id to monitor. Can be obtained using https://data.grandlyon.com/jeux-de-donnees/points-arret-reseau-transports-commun-lyonnais/donnees",
),
authorization: Optional[str] = Header(
None,
alias="Authorization",
description="Basic auth for remote API (data grand lyon)",
),
):
if authorization is None:
raise HTTPException(status_code=401, detail="Not authenticated")