Add fields doc
This commit is contained in:
parent
8d0ca77be1
commit
e6195206b9
1 changed files with 13 additions and 5 deletions
18
main.py
18
main.py
|
@ -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")
|
||||
|
||||
|
|
Reference in a new issue