-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: add GH workflow to generate openapi schema #39025
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
Open
Faraz32123
wants to merge
1
commit into
master
Choose a base branch
from
feat/add_workflow_to_automatically_generate_openapi_schema
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+103
−0
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # generate_openapi_schemas.yml | ||
| # | ||
| # Purpose: Generate OpenAPI schemas for the LMS and CMS using drf-spectacular, | ||
| # then open a pull request if either schema changed. The generated schema files | ||
| # are consumed by the openedx-platform-sdk repo's regen_sdk.sh script to keep | ||
| # the SDK in sync with the platform's tagged API views. | ||
| # | ||
| # Tuning notes: | ||
| # - The settings modules below (lms.envs.production / cms.envs.production) | ||
| # must have SPECTACULAR_SETTINGS configured. Adjust if your environment | ||
| # uses a different settings module (e.g. lms.envs.devstack). | ||
| # - The requirements path (requirements/edx/base.txt) may need adjustment | ||
| # depending on your local layout or if drf-spectacular lives in a different | ||
| # requirements file. | ||
|
|
||
| name: Generate OpenAPI Schemas | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| push: | ||
| branches: | ||
| - master | ||
| paths: | ||
| # Triggers whenever a view file tagged with the openedx-platform-sdk | ||
| # @extend_schema tag changes — add new tagged view paths here as more | ||
| # APIs are onboarded to the SDK. | ||
| # | ||
| # LMS — Enrollment v2 | ||
| - 'openedx/core/djangoapps/enrollments/**' | ||
| # CMS — XBlock v1, Home v3/v4, Course Details v3, Authoring Grading v3 | ||
| - 'cms/djangoapps/contentstore/rest_api/v1/views/xblock.py' | ||
| - 'cms/djangoapps/contentstore/rest_api/v3/views/home.py' | ||
| - 'cms/djangoapps/contentstore/rest_api/v3/views/course_details.py' | ||
| - 'cms/djangoapps/contentstore/rest_api/v3/views/authoring_grading.py' | ||
| - 'cms/djangoapps/contentstore/rest_api/v4/views/home.py' | ||
| # drf-spectacular config changes in either service | ||
| - 'lms/lib/spectacular.py' | ||
| - 'cms/lib/spectacular.py' | ||
| - 'lms/envs/common.py' | ||
| - 'cms/envs/common.py' | ||
|
|
||
| jobs: | ||
| generate-schemas: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python 3.12 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| pip install --upgrade pip | ||
| # Note: adjust this path if drf-spectacular is in a different requirements file | ||
| pip install -r requirements/edx/base.txt | ||
|
|
||
| - name: Generate LMS OpenAPI schema | ||
| run: | | ||
| # SPECTACULAR_SETTINGS must be present in the settings module used here. | ||
| # Switch to a lighter settings module if production settings require | ||
| # environment variables or external services that are unavailable in CI. | ||
| python manage.py spectacular \ | ||
| --settings=lms.envs.production \ | ||
| --file lms_schema.yml | ||
|
|
||
| - name: Generate CMS OpenAPI schema | ||
| run: | | ||
| # Same note as above — SPECTACULAR_SETTINGS must be available. | ||
| python manage.py spectacular \ | ||
| --settings=cms.envs.production \ | ||
| --file cms_schema.yml | ||
|
|
||
| - name: Open pull request if schemas changed | ||
| uses: peter-evans/create-pull-request@v6 | ||
| with: | ||
| branch: chore/update-openapi-schemas | ||
| commit-message: 'chore: regenerate OpenAPI schemas' | ||
| title: 'chore: update OpenAPI schemas for SDK generation' | ||
| body: | | ||
| ## Auto-generated OpenAPI schema update | ||
|
|
||
| This PR was opened automatically by the **Generate OpenAPI Schemas** workflow. | ||
| It contains regenerated `lms_schema.yml` and/or `cms_schema.yml` files | ||
| reflecting the latest state of the platform's tagged API views. | ||
|
|
||
| These schema files are used by the | ||
| [openedx-platform-sdk](https://github.com/your-org/openedx-platform-sdk) | ||
| repository's `regen_sdk.sh` script to keep the SDK client in sync with | ||
| the platform. Update the link above once the SDK repo URL is finalised. | ||
|
|
||
| **Do not edit these files by hand** — they will be overwritten on the next run. | ||
| add-paths: | | ||
| lms_schema.yml | ||
| cms_schema.yml | ||
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.