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 openapi tags on endpoints #88

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_current_user(
# ------------------------------------------------------------------------------


@app.post("/api/v1/auth")
@app.post("/api/v1/auth", tags=["Auth"])
def authentication(
form_data: Annotated[OAuth2PasswordRequestForm, Depends()],
response: Response,
Expand Down Expand Up @@ -164,7 +164,7 @@ def authentication(
)


@app.get("/api/v1/prices", response_model=Page[schemas.PriceBase])
@app.get("/api/v1/prices", response_model=Page[schemas.PriceBase], tags=["Prices"])
def get_price(
filters: schemas.PriceFilter = FilterDepends(schemas.PriceFilter),
db: Session = Depends(get_db),
Expand All @@ -176,6 +176,7 @@ def get_price(
"/api/v1/prices",
response_model=schemas.PriceBase,
status_code=status.HTTP_201_CREATED,
tags=["Prices"],
)
def create_price(
price: schemas.PriceCreate,
Expand Down Expand Up @@ -237,6 +238,7 @@ def create_price(
"/api/v1/proofs/upload",
response_model=schemas.ProofBase,
status_code=status.HTTP_201_CREATED,
tags=["Proofs"],
)
def upload_proof(
file: UploadFile,
Expand All @@ -256,7 +258,7 @@ def upload_proof(
return db_proof


@app.get("/api/v1/proofs", response_model=list[schemas.ProofBase])
@app.get("/api/v1/proofs", response_model=list[schemas.ProofBase], tags=["Proofs"])
def get_user_proofs(
current_user: schemas.UserBase = Depends(get_current_user),
db: Session = Depends(get_db),
Expand All @@ -269,7 +271,11 @@ def get_user_proofs(
return crud.get_user_proofs(db, user=current_user)


@app.get("/api/v1/products/{product_id}", response_model=schemas.ProductBase)
@app.get(
"/api/v1/products/{product_id}",
response_model=schemas.ProductBase,
tags=["Products"],
)
def get_product(product_id: int, db: Session = Depends(get_db)):
db_product = crud.get_product_by_id(db, id=product_id)
if not db_product:
Expand All @@ -280,7 +286,11 @@ def get_product(product_id: int, db: Session = Depends(get_db)):
return db_product


@app.get("/api/v1/locations/{location_id}", response_model=schemas.LocationBase)
@app.get(
"/api/v1/locations/{location_id}",
response_model=schemas.LocationBase,
tags=["Locations"],
)
def get_location(location_id: int, db: Session = Depends(get_db)):
db_location = crud.get_location_by_id(db, id=location_id)
if not db_location:
Expand Down
Loading