-
Notifications
You must be signed in to change notification settings - Fork 468
feat(api-docs): Improve SDK API documentation #6626
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Docker builds report
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6626 +/- ##
=======================================
Coverage 98.18% 98.18%
=======================================
Files 1295 1294 -1
Lines 46920 46994 +74
=======================================
+ Hits 46067 46141 +74
Misses 853 853 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
emyller
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.
Looks solid! Non-blocking comments.
emyller
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.
LGTM!
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Contributes to #6341.
In this PR, we improve the SDK API documentation, decoupling it from the flagsmith-engine's legacy code.
flagsmith_schemasintegration for OpenAPI generationTypedDictin schema generationsecuritySchemescorrectlyHow did you test this code?
CI,
make -C docs serve.How to review this PR
This PR contains three distinct types of changes:
1. Python code architecture changes
The backend moves from Django REST serializers and legacy engine's Pydantic models to using
flagsmith_schemasas the single source of truth for API contracts.Key files to examine:
api/api/openapi.py: existing tooling for Pydantic models repurposed forTypedDicts. Added generation code for authentication classes used in our viewsapi/environments/identities/serializers.py&views.py: Modified to align with schema definitionsapi/tests/integration/sdk/test_sdk_api_schemas.py: New integration tests that validate actual API responses againstflagsmith_schemas.apitypes using Pydantic'sTypeAdapterWhat got deleted and why:
api/environments/sdk/schemas.py: Redundant, replaced byflagsmith_schemasapi/util/pydantic.py: Custom Pydantic utilities no longer needed2. OpenAPI spec generation tooling
New infrastructure for generating SDK API documentation from the backend code.
Core components:
sdk/openapi.yaml: The generated OpenAPI spec describing SDK endpoints. Can be ignored unless you're really interested in how generation works.api/openapi-filter-flagsmith-sdk.yml: Filter configuration that extracts only SDK endpoints from the full API specapi/Makefile&docs/Makefile: Newgenerate-sdk-api-docstarget that runs the generation pipelineGeneration flow to verify:
sdktag get removed)sdk/openapi.yamlmake -C docs build)3. Documentation migration
Complete replacement of Edge API docs with SDK API docs, plus fixing all internal references. This part is responsible for a significant chunk of the diff as the generated docs are replaced and shuffled around.
Documentation structure change:
/docs/edge-api/*(6 files deleted)/docs/sdk-api/*(6 files created) — suggest to ignore these and check the deployed, or locally served, docs instead.sdk/openapi.yamlrather than hand-written schemaLink updates across the docs:
docs/vercel.json: Redirects from/edge-api/*to/sdk-api/*paths.mdfiles: Updated references from "Edge API" to "SDK API"docusaurus.config.ts: Plugin configuration for the new SDK API documentationFollow-up issues
/api/v1/bulk-identitiesin Core API #6628 — eliminate discrepancy between Core and Edge APIs. More context here.Tokenauthentication in Core API #6629 — surfaced after adding autogeneration for OpenAPI security schemes.