-
Notifications
You must be signed in to change notification settings - Fork 37
docs(server): add OpenAPI spec generation and validation workflow #852
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
base: main
Are you sure you want to change the base?
Conversation
7f0c1ac to
0a506ca
Compare
0a506ca to
8be0e10
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #852 +/- ##
=======================================
Coverage 71.31% 71.31%
=======================================
Files 108 108
Lines 9651 9651
Branches 858 858
=======================================
Hits 6883 6883
Misses 2595 2595
Partials 173 173
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
rene-oromtz
left a comment
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.
This looks really great, thanks for taking care of this!
I just added couple comments that I think will make more "simple" running the flask spec but let me know what you think.
Also, do you think we should also remove the awful to maintain API.md in this PR? The whole purpose of that file was not rely in a testflinger connection to review the /docs but this PR already solves that so I think it can go...
|
I agree with @rene-oromtz I think the I think this PR can move along and merge without removing the |
|
Ah I was about to open a Jira issue to track this when I realized @tang-mm already created one! (CERTTF-780). Please ignore my comment then related to |
|
@tang-mm you inspired me with this PR to look at how we check and generate it in hardware-api, and I think I found a simpler solution. See: canonical/hardware-api#483. Also, I'd like to standardize the Hardware API uses FastAPI rather that APIFlask, so there are some differences. However, I think you can use what I wrote and change the |
Co-authored-by: rene-oromtz <157750458+rene-oromtz@users.noreply.github.com>
change to use the APIFlask.spec attribute to get the schema object in dict form, instead of using the string-based CLI output.
|
@pedro-avalos @rene-oromtz I updated the implementation - instead of using Flask CLI to get the string output, it now calls the With regards to naming, I agree with the verb-first format. I'm open to validating all schemas (if we have new ones other than the API) in the same tox env. So I updated the name to |
pedro-avalos
left a comment
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.
One minor change, otherwise looks good to me
| parser.add_argument( | ||
| "--output", | ||
| type=Path, | ||
| default=Path("./openapi.json"), |
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.
The docstring for this script says that running without arguments will print to stdout. This should therefore be default=None
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.
Fix added in 3023c18
Description
This pull request introduces the functionality to:
/docsURL)TESTINGmode, so that Flask CLI can be used for spec generation without MongoDBserver/openapi.jsonopenapi-checktox environment that compares the spec file in the working directory against a newly generated versionserver-tox.ymlworkflowResolved issues
Resolves CERTTF-243
Documentation
docs/reference/openapi.rstwith Swagger UI integration. The JSON file is copied from theserver/directory todocs/during doc build, and the copy only exists in the build output. (Same changes as in docs: Add Swagger UI for OpenAPI reference documentation hardware-api#456)Preview: https://canonical-testflinger--852.com.readthedocs.build/852/reference/openapi/#/
Web service API changes
(No API changes introduced. This PR adds infrastructure to document the existing API.)
Tests