Refine API documentation - #114
Open
juhoinkinen wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #114 +/- ##
=======================================
Coverage 98.50% 98.50%
=======================================
Files 13 13
Lines 536 536
=======================================
Hits 528 528
Misses 8 8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines the FastAPI/Swagger documentation for the BIBRA API by improving endpoint grouping and visibility, and by adding clearer endpoint descriptions/examples.
Changes:
- Tag all v0 API routes with
tags=["v0"]to avoid the default Swagger group. - Hide the HTML root endpoint (
/) from the OpenAPI schema. - Add OpenAPI summaries and a curl usage example for the extract endpoint.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bibra/main.py |
Hides the static HTML root route from Swagger via include_in_schema=False. |
bibra/api/v0/routes.py |
Adds v0 tagging, adds summaries, and adds a curl example to improve interactive docs. |
Suppressed comments (1)
bibra/api/v0/routes.py:47
response_model=dictfor/projectsmakes the OpenAPI contract too loose and hides the actual response structure ({"projects": [{"id","name","description"}, ...]}). This also weakens schema-based testing (e.g. Schemathesis) because almost any object would validate. Prefer an explicit response model that names theprojectsfield and its item shape.
@router.get("/projects", response_model=dict, summary="List projects")
async def list_projects(registry: Annotated[ProjectRegistry, Depends(get_registry)]):
"""Return a list of configured projects."""
try:
projects = registry.list_projects()
except ConfigError as e:
logger.exception("Configuration error")
raise HTTPException(status_code=500, detail=str(e))
return {"projects": projects}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+33
to
36
| @router.get("/", response_model=dict, summary="Get version information") | ||
| async def root(): | ||
| """Return the API version information.""" | ||
| """Return version information of BIBRA and the API.""" | ||
| return {"version": __version__, "message": "Welcome to BIBRA API v0"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reasons for creating this PR
The interactive Swagger API documentation (/docs endpoint) has some flaws and potential for improvement:
Link to relevant issue(s), if any
Description of the changes in this PR
include_in_schema=FalseInstructions how to test this PR
Run
and take a look.
Known problems or uncertainties in this PR
Should the static index.html page be included in the API endpoint list?
Checklist
Disclosure of AI Tool Usage
Please indicate AI use by choosing the most suitable TLP:AI category below and removing the irrelevant categories from the list. AI:ORANGE is the minimum level for merging.
Describe the AI tool(s) you used:
Describe the AI tool(s) you used: