Skip to content

Conversation

@pedro-avalos
Copy link
Collaborator

@pedro-avalos pedro-avalos commented Dec 17, 2025

Description

  • This PR simplifies the way we check and generate the OpenAPI schema by using the existing tox configuration
  • This PR is relevant because:
    • pre-commit is not designed for monorepo projects
    • Our guide on how to set up pre-commit was flimsy and confusing (needed to be run from a specific directory)
    • Our CI and scripts relied on deploying the server to check or update the schema (can be slow)
    • We already are using a tool for testing (tox) that contributors would be used to and are expected to run to prevent CI failures (i.e., format and lint the code)

Related Issue(s)

Untracked

Testing

  • Unit tests

  • Manual testing steps:

    1. cd server
    2. Modify the schema (format, indent, add entries, etc.)
    3. uvx tox run -e schema should generate the schema file back to what is in the repo
    4. Modify the schema again
    5. uvx tox run -e check-schema should generate a diff of the schema file and mark the test as failed

Checklist

  • I have followed the contribution guidelines.
  • I have signed the Canonical CLA.
  • I have added necessary tests.
  • I have added or updated any relevant documentation (if needed).
  • I have tested the changes.

Additional Notes

This is inspired by canonical/testflinger#852.

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.20%. Comparing base (6e2543d) to head (fceaa74).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #483      +/-   ##
==========================================
+ Coverage   89.11%   89.20%   +0.09%     
==========================================
  Files          28       28              
  Lines        1396     1390       -6     
  Branches        1        1              
==========================================
- Hits         1244     1240       -4     
+ Misses        152      150       -2     
Flag Coverage Δ *Carryforward flag
charm 100.00% <ø> (ø)
client 80.24% <ø> (ø) Carriedforward from 6e2543d
server 97.03% <100.00%> (+0.24%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
Server 97.03% <100.00%> (+0.24%) ⬆️
Client 80.24% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@tang-mm tang-mm left a comment

Choose a reason for hiding this comment

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

This is neat! Thanks!

The only change that might have an impact is the removal of the schema endpoint. IWe'd need to confirm that no service relies on it. All other changes look good

pre-commit doesn't really work in mono-repo setups anyways
the openapi schema endpoint should be /openapi.json by default
this script makes it easier to check for diffs or generate the schema using Python and fastapi built-in functions
@pedro-avalos pedro-avalos force-pushed the simplify-openapi-schema-generation branch from 80e09f4 to fceaa74 Compare December 18, 2025 20:10
@tang-mm tang-mm merged commit f655228 into main Dec 23, 2025
21 of 22 checks passed
@tang-mm tang-mm deleted the simplify-openapi-schema-generation branch December 23, 2025 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants