Skip to content

docs: added documentation to all API endpoint routes so far #75

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

Merged
merged 15 commits into from
Mar 10, 2025

Conversation

adithyasunil04
Copy link

No description provided.

Copy link
Contributor

@KreativeThinker KreativeThinker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add response documentation in the following manner:

@router.get(
    "/list",
    summary="Get all teams",
    response_model=list[Team_Pydantic],
    response_description="""Returns a complete list of registered teams.
    
    Example response:
    ```json
    [
        {
            "id": 1,
            "name": "Team Alpha",
            "coins": 100,
            "points": 250
        }
    ]
    ```
    """,
)

Ensure the response_model field has data and move technical description to response_description or remove altogether.

In docs you should be able to see something like this:
image

adithyasunil04 and others added 3 commits February 25, 2025 22:03
created new file `response_models.py` in `src/pwncore/routes/ctf` used for API endpoint documentation for functions that start/stop/stopall docker containers in `start.py` file
merge lugvitc master branch to my branch for documentation
@adithyasunil04
Copy link
Author

@ThEditor @KreativeThinker how can i fix this tox build check failing??

@KreativeThinker
Copy link
Contributor

@ThEditor @KreativeThinker how can i fix this tox build check failing??

Don't worry about that

Copy link
Contributor

@KreativeThinker KreativeThinker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

summary should be removed
response_description should only contain specifics like message codes. No need to put it in markdown/json format

@adithyasunil04
Copy link
Author

I reckon we shud keep response_description for all in very short concise format, instead of removing it

i think its best not to remove response_description, u can understand what the endpoint does just from reading the source code
also removed summary as requested
@KreativeThinker
Copy link
Contributor

Merge with lugvitc:docs for now as more changes are incoming. We will update there.

Copy link
Contributor

@KreativeThinker KreativeThinker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response_description field should only contain specific edge cases or error codes. No need to have other text.

Once changes are made, create a new PR to lugvitc/pwncore:docs

@KreativeThinker
Copy link
Contributor

KreativeThinker commented Mar 8, 2025

Add response documentation in the following manner:

@router.get(
    "/list",
    summary="Get all teams",
    response_model=list[Team_Pydantic],
    response_description="""Returns a complete list of registered teams.
    
    Example response:
    ```json
    [
        {
            "id": 1,
            "name": "Team Alpha",
            "coins": 100,
            "points": 250
        }
    ]
    ```
    """,
)

Ensure the response_model field has data and move technical description to response_description or remove altogether.

In docs you should be able to see something like this: image

Use this instead:

@router.get(
    "/list",
    response_model=list[Team_Pydantic],
    response_description="""
        specifics like msg_codes or error messages.
    """,
)

@KreativeThinker KreativeThinker linked an issue Mar 8, 2025 that may be closed by this pull request
@KreativeThinker KreativeThinker linked an issue Mar 8, 2025 that may be closed by this pull request
@adithyasunil04 adithyasunil04 changed the base branch from master to docs March 8, 2025 13:31
Copy link
Author

@adithyasunil04 adithyasunil04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all Pydantic response models that use the BaseModel pydantic model are moved to one common folder

Copy link
Contributor

@KreativeThinker KreativeThinker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just delete wherever mentioned and make PR to pwncore:docs

@KreativeThinker KreativeThinker merged commit 43bb662 into lugvitc:docs Mar 10, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: add documentation for returns
3 participants