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

Fix(docat): Trailing Slash resulting in 404 status code #269

Merged
merged 1 commit into from
Sep 19, 2022
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
15 changes: 15 additions & 0 deletions docat/docat/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ def get_projects():
status_code=status.HTTP_200_OK,
responses={status.HTTP_404_NOT_FOUND: {"model": ApiResponse}},
)
@app.get(
"/api/projects/{project}/",
response_model=ProjectDetailResponse,
status_code=status.HTTP_200_OK,
responses={status.HTTP_404_NOT_FOUND: {"model": ApiResponse}},
)
def get_project(project):
docs_folder = DOCAT_UPLOAD_FOLDER / project
if not docs_folder.exists():
Expand All @@ -108,6 +114,7 @@ def get_project(project):


@app.post("/api/{project}/{version}", response_model=ApiResponse, status_code=status.HTTP_201_CREATED)
@app.post("/api/{project}/{version}/", response_model=ApiResponse, status_code=status.HTTP_201_CREATED)
def upload(
project: str,
version: str,
Expand Down Expand Up @@ -141,6 +148,7 @@ def upload(


@app.put("/api/{project}/{version}/tags/{new_tag}", response_model=ApiResponse, status_code=status.HTTP_201_CREATED)
@app.put("/api/{project}/{version}/tags/{new_tag}/", response_model=ApiResponse, status_code=status.HTTP_201_CREATED)
def tag(project: str, version: str, new_tag: str, response: Response):
destination = DOCAT_UPLOAD_FOLDER / project / new_tag

Expand All @@ -157,6 +165,12 @@ def tag(project: str, version: str, new_tag: str, response: Response):
status_code=status.HTTP_201_CREATED,
responses={status.HTTP_409_CONFLICT: {"model": ApiResponse}},
)
@app.get(
"/api/{project}/claim/",
response_model=ClaimResponse,
status_code=status.HTTP_201_CREATED,
responses={status.HTTP_409_CONFLICT: {"model": ApiResponse}},
)
def claim(project: str, db: TinyDB = Depends(get_db)):
Project = Query()
table = db.table("claims")
Expand All @@ -173,6 +187,7 @@ def claim(project: str, db: TinyDB = Depends(get_db)):


@app.delete("/api/{project}/{version}", response_model=ApiResponse, status_code=status.HTTP_200_OK)
@app.delete("/api/{project}/{version}/", response_model=ApiResponse, status_code=status.HTTP_200_OK)
def delete(project: str, version: str, response: Response, docat_api_key: str = Header(None), db: TinyDB = Depends(get_db)):
token_status = check_token_for_project(db, docat_api_key, project)
if token_status.valid:
Expand Down