-
Notifications
You must be signed in to change notification settings - Fork 2
Make API version number accessible via HTTP and display on swagger UI #64
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
eecavanna
merged 9 commits into
main
from
60-make-api-version-number-accessible-via-http-and-display-on-swagger-ui
Jul 18, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9b67dbc
Add `src/README.md` containing summaries of `src/` sub-items
eecavanna 62801fb
Define `HealthResponse` model and integrate with `/health` endpoint
eecavanna 5604856
Implement `/version` API endpoint that returns API and schema versions
eecavanna 11003c4
Reformat function invocation to resemble familiar JSON format
eecavanna 1cc0c8b
Derive version string from Git tag/commit and populate `pyproject.toml`
eecavanna e158680
Handle case where package is not installed
eecavanna d1fd7ab
Use non-string value to represent exception case
eecavanna d69f4d2
Sync version number in `uv.lock`
eecavanna cd49f72
Use `ruff` to format Python code
eecavanna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # src | ||
|
|
||
| ## Contents | ||
|
|
||
| <!-- TODO: Summarize the contents of the `bertron/` directory. --> | ||
|
|
||
| - `bertron/`: (Undocumented) | ||
| - `bertron_client.py`: A Python library client applications can use to access the BERtron API | ||
| - `lib/`: Library of helper functions, constants, etc. | ||
| - `README.md`: This document | ||
| - `server.py`: The BERtron API |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from importlib.metadata import PackageNotFoundError, version | ||
| from typing import Optional | ||
|
|
||
|
|
||
| def get_package_version(package_name: str) -> Optional[str]: | ||
| r""" | ||
| Returns the version identifier (e.g., "1.2.3") of the package having the specified name. | ||
|
|
||
| Args: | ||
| package_name: The name of the package | ||
|
|
||
| Returns: | ||
| The version identifier of the package, or `None` if package not found | ||
| """ | ||
| try: | ||
| return version(package_name) | ||
| except PackageNotFoundError: | ||
| return None |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| from pydantic import BaseModel, Field | ||
| from typing import Optional | ||
|
|
||
|
|
||
| class HealthResponse(BaseModel): | ||
| r"""A response containing system health information.""" | ||
|
|
||
| web_server: bool = Field( | ||
| ..., | ||
| title="Web server health", | ||
| description="Whether the web server is up and running", | ||
| ) | ||
| database: bool = Field( | ||
| ..., | ||
| title="Database health", | ||
| description="Whether the web server can access the database server", | ||
| ) | ||
|
|
||
|
|
||
| class VersionResponse(BaseModel): | ||
| r"""A response containing system version information.""" | ||
|
|
||
| api: Optional[str] = Field( | ||
| ..., | ||
| title="API version", | ||
| description="The version identifier of the API", | ||
| ) | ||
| bertron_schema: Optional[str] = Field( | ||
| ..., | ||
| title="BERtron schema version", | ||
| description="The version identifier of the BERtron schema", | ||
| ) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.