-
Notifications
You must be signed in to change notification settings - Fork 4
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
[feature] Switch API server to huma
for OpenAPI docs auto generation/documentation
#311
Merged
els0r
merged 16 commits into
main
from
309-openapi-switch-api-server-to-huma-for-docs-auto-generation
May 15, 2024
Merged
[feature] Switch API server to huma
for OpenAPI docs auto generation/documentation
#311
els0r
merged 16 commits into
main
from
309-openapi-switch-api-server-to-huma-for-docs-auto-generation
May 15, 2024
Conversation
This file contains 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
fako1024
approved these changes
May 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noice - Thanks for going through all the painful effort of documenting the stuff in code! There's a few minor points of feedback (and the usual nitpicks), but apart from that LGTM!
els0r
deleted the
309-openapi-switch-api-server-to-huma-for-docs-auto-generation
branch
May 15, 2024 08:28
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.
Simplifies the API documentation massively, as it is now embedded in the struct tags. Closes #309 .
API
Under the hood, the huma framework is used:
gin
frameworkNot only does this simplify the hooks into the API, it also doesn't touch the remaining server setup fundamentally. The router in front of
huma
is stillgin
.The API documentation is reachable under the
/docs
endpoint.Error Handling
This addresses parts of #277. The detail errors for parsing args now relies on the
huma.ErrorModel
, which returns an RFC-compliant list of errors.The benefit is that every field in the query args is validated and the whole list of offending fields is returned in the error. Both the API and
goQuery
use this to provide details to the caller.For
goQuery
, the output looks as followsFlags / OpenAPI Generation
The OpenAPI spec can now be generated by the tool itself. This is necessary in order to guarantee up-to-date generation during the release step.
To this end, the
--openapi
flag was added to bothgoProbe
andglobal-query
. It causes the tools to start and generate the API spec as soon as possible.Since neither tools start without config, the
.buildconfig
directory contains a minimal, stripped-down config, which can be relied on for OpenAPI spec generation.