From 7223b3fc18d61955d2dcbd7e988f76db608c6652 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Tue, 25 Aug 2026 18:09:00 +0500 Subject: [PATCH 1/7] feat: add GH workflow to generate openapi schema Add GH workflow to automatically generate openapi schema whenever view file tagged with the "openedx-platform-sdk" @extend_schema tag changes --- .../workflows/generate_openapi_schemas.yml | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 .github/workflows/generate_openapi_schemas.yml diff --git a/.github/workflows/generate_openapi_schemas.yml b/.github/workflows/generate_openapi_schemas.yml new file mode 100644 index 000000000000..26f9555c081a --- /dev/null +++ b/.github/workflows/generate_openapi_schemas.yml @@ -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 From 331c78932ebb8120df5e8b7f1f1c12927bea382b Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Wed, 9 Sep 2026 16:03:51 +0500 Subject: [PATCH 2/7] feat: address comments --- .../workflows/generate_openapi_schemas.yml | 43 ++++++------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/.github/workflows/generate_openapi_schemas.yml b/.github/workflows/generate_openapi_schemas.yml index 26f9555c081a..d5ac4838f38f 100644 --- a/.github/workflows/generate_openapi_schemas.yml +++ b/.github/workflows/generate_openapi_schemas.yml @@ -4,14 +4,6 @@ # 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 @@ -50,37 +42,24 @@ jobs: steps: - name: Check out repository - uses: actions/checkout@v4 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - - name: Set up Python 3.12 - uses: actions/setup-python@v5 + - name: Install uv + uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 with: - python-version: '3.12' + enable-cache: true - 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 + run: uv sync --frozen - 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 + run: uv run python manage.py lms spectacular --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 + run: uv run python manage.py cms spectacular --file cms_schema.yml - name: Open pull request if schemas changed - uses: peter-evans/create-pull-request@v6 + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8 with: branch: chore/update-openapi-schemas commit-message: 'chore: regenerate OpenAPI schemas' @@ -93,11 +72,13 @@ jobs: 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) + [openedx-platform-sdk](https://github.com/edly-io/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. + the platform. **Do not edit these files by hand** — they will be overwritten on the next run. + + @openedx/wg-maintenance-openedx-platform-oncall heads up on this automated PR. add-paths: | lms_schema.yml cms_schema.yml From 39c55c5a8002755c5aa0ff1c40b2700fc1ddb902 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Thu, 10 Sep 2026 18:09:54 +0500 Subject: [PATCH 3/7] fix: address comments on generate schemas workflow address comments on generate_openapi_schemas workflow - weekly schedule - use team-reviewers param --- .../workflows/generate_openapi_schemas.yml | 27 +++---------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/workflows/generate_openapi_schemas.yml b/.github/workflows/generate_openapi_schemas.yml index d5ac4838f38f..a2334315bab7 100644 --- a/.github/workflows/generate_openapi_schemas.yml +++ b/.github/workflows/generate_openapi_schemas.yml @@ -14,27 +14,9 @@ permissions: 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' + schedule: + # Regenerate and commit the full OpenAPI schemas every Monday at 09:00 UTC. + - cron: "0 9 * * 1" jobs: generate-schemas: @@ -64,6 +46,7 @@ jobs: branch: chore/update-openapi-schemas commit-message: 'chore: regenerate OpenAPI schemas' title: 'chore: update OpenAPI schemas for SDK generation' + team-reviewers: wg-maintenance-openedx-platform-oncall body: | ## Auto-generated OpenAPI schema update @@ -77,8 +60,6 @@ jobs: the platform. **Do not edit these files by hand** — they will be overwritten on the next run. - - @openedx/wg-maintenance-openedx-platform-oncall heads up on this automated PR. add-paths: | lms_schema.yml cms_schema.yml From b2c447e28bee10a41dbe388eabdecab901baf9bc Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Thu, 17 Sep 2026 21:23:07 +0500 Subject: [PATCH 4/7] fix: write the generated schemas to docs/ - write to docs/lms-openapi.yaml and docs/cms-openapi.yaml instead of creating new schema files at the repo root - generate the LMS schema under docs.docs_settings so the workflow writes the same full API surface `make swagger` does, rather than overwriting the docs schema with the narrow SDK-facing one --- .../workflows/generate_openapi_schemas.yml | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/generate_openapi_schemas.yml b/.github/workflows/generate_openapi_schemas.yml index a2334315bab7..a7c07f7ec1fd 100644 --- a/.github/workflows/generate_openapi_schemas.yml +++ b/.github/workflows/generate_openapi_schemas.yml @@ -34,11 +34,18 @@ jobs: - name: Install dependencies run: uv sync --frozen + # `docs.docs_settings` is what `make swagger` uses: it applies the + # unfiltered /api-docs configuration instead of the narrow, SDK-facing + # schema that SPECTACULAR_SETTINGS carries by default. Without it this + # workflow would overwrite docs/lms-openapi.yaml with the enrollment-only + # subset. There is no CMS equivalent, so Studio gets its tagged schema. - name: Generate LMS OpenAPI schema - run: uv run python manage.py lms spectacular --file lms_schema.yml + run: | + DJANGO_SETTINGS_MODULE=docs.docs_settings \ + uv run python manage.py lms spectacular --file docs/lms-openapi.yaml - name: Generate CMS OpenAPI schema - run: uv run python manage.py cms spectacular --file cms_schema.yml + run: uv run python manage.py cms spectacular --file docs/cms-openapi.yaml - name: Open pull request if schemas changed uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8 @@ -51,15 +58,19 @@ jobs: ## 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. + It contains regenerated `docs/lms-openapi.yaml` and/or `docs/cms-openapi.yaml` + files reflecting the latest state of the platform's API views. - These schema files are used by the + `docs/lms-openapi.yaml` is the full LMS API surface — the same schema + `make swagger` produces, which the docs build publishes. + `docs/cms-openapi.yaml` is Studio's tagged schema. + + Both are consumed by the [openedx-platform-sdk](https://github.com/edly-io/openedx-platform-sdk) - repository's `regen_sdk.sh` script to keep the SDK client in sync with - the platform. + repository's `regen_sdk.sh`, which filters them down to the tagged + operations it generates a client for. **Do not edit these files by hand** — they will be overwritten on the next run. add-paths: | - lms_schema.yml - cms_schema.yml + docs/lms-openapi.yaml + docs/cms-openapi.yaml From 9532c3c82bed8016e00fc9ac3b6a3655155db9a3 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Tue, 22 Sep 2026 21:54:22 +0500 Subject: [PATCH 5/7] fix: address comments on the schema generation workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit uv sync installed no groups, so ora2 was missing and both schema steps died with ModuleNotFoundError. Use the docs group, which pulls in bundled, the same set .readthedocs.yaml installs. manage.py cms defaults to cms.envs.devstack, which needs a CMS_CFG file CI does not have. Run it under cms.envs.development, and give cms/envs/common.py the schema title and version — the Authoring API's SPECTACULAR_SETTINGS lives in devstack and production, so development would otherwise emit an untitled 0.0.0 document. Also align the setup-uv pin with the other workflows, and add branch-suffix and workflow_ref provenance to match the other PR-opening ones. --- .../workflows/generate_openapi_schemas.yml | 39 +++++++++++++++---- cms/envs/common.py | 14 +++++++ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/.github/workflows/generate_openapi_schemas.yml b/.github/workflows/generate_openapi_schemas.yml index a7c07f7ec1fd..d9da194859a2 100644 --- a/.github/workflows/generate_openapi_schemas.yml +++ b/.github/workflows/generate_openapi_schemas.yml @@ -27,37 +27,62 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - name: Install uv - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 + uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 with: enable-cache: true + # `default-groups = []` in pyproject.toml means a bare `uv sync` installs + # no groups at all, which leaves out ora2 and makes both schema steps fail + # with ModuleNotFoundError. `docs` includes `bundled`, which carries the + # bundled XBlocks — the same set .readthedocs.yaml and the other workflows + # install. - name: Install dependencies - run: uv sync --frozen + run: uv sync --no-default-groups --group docs --frozen # `docs.docs_settings` is what `make swagger` uses: it applies the # unfiltered /api-docs configuration instead of the narrow, SDK-facing # schema that SPECTACULAR_SETTINGS carries by default. Without it this - # workflow would overwrite docs/lms-openapi.yaml with the enrollment-only - # subset. There is no CMS equivalent, so Studio gets its tagged schema. + # step would overwrite the published LMS reference with the + # enrollment-only subset. + # + # NOTE: docs_settings only carries that unfiltered configuration as of + # https://github.com/openedx/openedx-platform/pull/39108, which must merge + # before this workflow runs. - name: Generate LMS OpenAPI schema run: | DJANGO_SETTINGS_MODULE=docs.docs_settings \ uv run python manage.py lms spectacular --file docs/lms-openapi.yaml + # Studio has no docs_settings equivalent. `manage.py cms` defaults to + # cms.envs.devstack, which imports production.py and so requires a + # CMS_CFG file that does not exist in CI — settings raise + # ImproperlyConfigured before the command is even registered. + # cms.envs.development needs no such file. Its schema is the Authoring + # API's contentstore-scoped surface, the same one Studio publishes at + # /authoring-api/schema/. - name: Generate CMS OpenAPI schema - run: uv run python manage.py cms spectacular --file docs/cms-openapi.yaml + run: | + DJANGO_SETTINGS_MODULE=cms.envs.development \ + uv run python manage.py cms spectacular --file docs/cms-openapi.yaml - name: Open pull request if schemas changed uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8 with: branch: chore/update-openapi-schemas - commit-message: 'chore: regenerate OpenAPI schemas' + # Without a suffix, a run that happens while the previous PR is + # still open pushes onto that same branch. Matches + # compile-python-requirements.yml and upgrade-one-python-dependency.yml. + branch-suffix: short-commit-hash + commit-message: | + chore: regenerate OpenAPI schemas + + Commit generated by workflow `${{ github.workflow_ref }}` title: 'chore: update OpenAPI schemas for SDK generation' team-reviewers: wg-maintenance-openedx-platform-oncall body: | ## Auto-generated OpenAPI schema update - This PR was opened automatically by the **Generate OpenAPI Schemas** workflow. + PR generated by workflow `${{ github.workflow_ref }}`. It contains regenerated `docs/lms-openapi.yaml` and/or `docs/cms-openapi.yaml` files reflecting the latest state of the platform's API views. diff --git a/cms/envs/common.py b/cms/envs/common.py index e2f324cdc2e7..9a0b0a342d20 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -1314,6 +1314,20 @@ def _should_send_xblock_events(settings): # This affects the Authoring API swagger docs but not the legacy swagger docs under /api-docs/. REST_FRAMEWORK['DEFAULT_SCHEMA_CLASS'] = 'drf_spectacular.openapi.AutoSchema' # noqa: F405 +# Identity of the generated Authoring API schema. The full configuration — +# endpoint filtering, path prefixes and SERVERS — lives in devstack.py and +# production.py, because SERVERS depends on CMS_BASE and AUTHORING_API_URL, +# which are only populated there. These three fields do not, so they are +# defined here to give any settings module that does not define its own +# SPECTACULAR_SETTINGS (notably cms.envs.development, used to generate the +# committed schema in CI) a titled, versioned document rather than +# drf-spectacular's empty-title, 0.0.0 default. +SPECTACULAR_SETTINGS = { + 'TITLE': 'Authoring API', + 'DESCRIPTION': 'Experimental API to edit xblocks and course content.', + 'VERSION': '0.1.0', +} + ################### Studio Search (beta), using Meilisearch ################### # Enable Studio search features (powered by Meilisearch) (beta, off by default) From 04b12be45ea2c56324022a4c50f010a1c2a9de50 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Tue, 29 Sep 2026 13:14:11 +0500 Subject: [PATCH 6/7] fix: give the schema job a database and the CMS schema its filtering Generation needs migrated tables, not just a server: drf-spectacular evaluates a queryset while building a warning for edxval's VideoList. Add the mysql service and a migrate step the way migrations-check.yml does. cms.envs.development inherited the Authoring API's title and version but none of its filtering, so docs/cms-openapi.yaml came out at 235 paths with the rest of the service in it. Only SERVERS and the long DESCRIPTION depend on CMS_BASE and AUTHORING_API_URL, so the hooks and the path prefix move down to cms/envs/common.py as well. 57 paths. --- .../workflows/generate_openapi_schemas.yml | 38 ++++++++++++++++++- cms/envs/common.py | 25 ++++++++---- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/.github/workflows/generate_openapi_schemas.yml b/.github/workflows/generate_openapi_schemas.yml index d9da194859a2..967f7b968e61 100644 --- a/.github/workflows/generate_openapi_schemas.yml +++ b/.github/workflows/generate_openapi_schemas.yml @@ -22,10 +22,38 @@ jobs: generate-schemas: runs-on: ubuntu-latest + # Schema generation needs a migrated database: drf-spectacular evaluates a + # queryset while building a warning for edxval's VideoList, so the tables + # have to exist, not just the server. Credentials match the defaults in + # openedx/envs/common.py. Mongo is not needed. + services: + mysql: + image: mysql:8 + ports: + - 3306:3306 + env: + MYSQL_DATABASE: "edxapp" + MYSQL_USER: "edxapp001" + MYSQL_PASSWORD: "password" + MYSQL_RANDOM_ROOT_PASSWORD: true + options: >- + --health-cmd "mysqladmin ping" + --health-interval 10s + --health-timeout 5s + --health-retries 3 + steps: - name: Check out repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + # mysqlclient ships no wheels, so pip builds it from source and needs the + # MySQL and xmlsec headers. migrations-check.yml and unit-tests.yml do the + # same before installing Python dependencies. + - name: Install system packages + run: | + sudo apt-get update + make ubuntu-requirements + - name: Install uv uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 with: @@ -39,6 +67,11 @@ jobs: - name: Install dependencies run: uv sync --no-default-groups --group docs --frozen + - name: Run migrations + run: | + uv run ./manage.py lms migrate + uv run ./manage.py cms migrate + # `docs.docs_settings` is what `make swagger` uses: it applies the # unfiltered /api-docs configuration instead of the narrow, SDK-facing # schema that SPECTACULAR_SETTINGS carries by default. Without it this @@ -57,8 +90,9 @@ jobs: # cms.envs.devstack, which imports production.py and so requires a # CMS_CFG file that does not exist in CI — settings raise # ImproperlyConfigured before the command is even registered. - # cms.envs.development needs no such file. Its schema is the Authoring - # API's contentstore-scoped surface, the same one Studio publishes at + # cms.envs.development needs no such file, and inherits the Authoring + # API's SPECTACULAR_SETTINGS from cms/envs/common.py, so this emits the + # same contentstore-scoped surface Studio publishes at # /authoring-api/schema/. - name: Generate CMS OpenAPI schema run: | diff --git a/cms/envs/common.py b/cms/envs/common.py index 9a0b0a342d20..1bdd12e3ff4e 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -1314,18 +1314,27 @@ def _should_send_xblock_events(settings): # This affects the Authoring API swagger docs but not the legacy swagger docs under /api-docs/. REST_FRAMEWORK['DEFAULT_SCHEMA_CLASS'] = 'drf_spectacular.openapi.AutoSchema' # noqa: F405 -# Identity of the generated Authoring API schema. The full configuration — -# endpoint filtering, path prefixes and SERVERS — lives in devstack.py and -# production.py, because SERVERS depends on CMS_BASE and AUTHORING_API_URL, -# which are only populated there. These three fields do not, so they are -# defined here to give any settings module that does not define its own -# SPECTACULAR_SETTINGS (notably cms.envs.development, used to generate the -# committed schema in CI) a titled, versioned document rather than -# drf-spectacular's empty-title, 0.0.0 default. +# The Authoring API schema, for any settings module that does not define its +# own SPECTACULAR_SETTINGS -- notably cms.envs.development, which generates the +# committed docs/cms-openapi.yaml in CI. Without these the document has no +# title, version 0.0.0, and every endpoint in the service rather than the +# Authoring API's own surface. +# +# devstack.py and production.py replace this wholesale, adding SERVERS and a +# longer DESCRIPTION. Those are the only parts that depend on CMS_BASE and +# AUTHORING_API_URL, which are empty here; the filtering and the path prefix do +# not, so they belong at this level. SPECTACULAR_SETTINGS = { 'TITLE': 'Authoring API', 'DESCRIPTION': 'Experimental API to edit xblocks and course content.', 'VERSION': '0.1.0', + 'SERVE_INCLUDE_SCHEMA': False, + # Restrict the schema to the Authoring API's endpoints (cms/lib/spectacular.py). + 'PREPROCESSING_HOOKS': ['cms.lib.spectacular.cms_api_filter'], + # Trim the shared prefix from the published paths; consumers supply it + # through their base URL. + 'SCHEMA_PATH_PREFIX': '/api/contentstore', + 'SCHEMA_PATH_PREFIX_TRIM': '/api/contentstore', } ################### Studio Search (beta), using Meilisearch ################### From fefa708c946bd984165d5d2284c02f0cf1af3ae6 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Wed, 30 Sep 2026 15:30:04 +0500 Subject: [PATCH 7/7] fix: give the migrate steps mongo and their settings split_modulestore_django's 0002_data_migration reads the modulestore, so migrating from empty needs Mongo even though generation doesn't. Add the service and the user setup step from migrations-check.yml. manage.py falls back to devstack without DJANGO_SETTINGS_MODULE, and devstack's DATABASES is empty without an LMS_CFG, so both migrate steps failed before reaching the service. Run each under the same settings as its generate step. --- .../workflows/generate_openapi_schemas.yml | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/generate_openapi_schemas.yml b/.github/workflows/generate_openapi_schemas.yml index 967f7b968e61..682496b6a7a4 100644 --- a/.github/workflows/generate_openapi_schemas.yml +++ b/.github/workflows/generate_openapi_schemas.yml @@ -24,9 +24,22 @@ jobs: # Schema generation needs a migrated database: drf-spectacular evaluates a # queryset while building a warning for edxval's VideoList, so the tables - # have to exist, not just the server. Credentials match the defaults in - # openedx/envs/common.py. Mongo is not needed. + # have to exist, not just the server. Mongo is needed for the migration + # itself rather than for generation -- split_modulestore_django's + # 0002_data_migration reads the modulestore. Credentials match the defaults + # in openedx/envs/common.py. services: + mongo: + image: mongo:7 + ports: + - 27017:27017 + # Note: Calling mongo here only works with mongo 4, in newer versions of mongo + # we'll have to use `mongosh`, hence the 'which mongosh mongo'. + options: >- + --health-cmd "$(which mongosh mongo) --quiet --eval 'db.runCommand(\"ping\")'" + --health-interval 10s + --health-timeout 5s + --health-retries 3 mysql: image: mysql:8 ports: @@ -43,6 +56,20 @@ jobs: --health-retries 3 steps: + - name: Setup mongodb user + run: | + docker exec ${{ job.services.mongo.id }} mongosh edxapp --eval ' + db.createUser( + { + user: "edxapp", + pwd: "password", + roles: [ + { role: "readWrite", db: "edxapp" }, + ] + } + ); + ' + - name: Check out repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 @@ -67,10 +94,15 @@ jobs: - name: Install dependencies run: uv sync --no-default-groups --group docs --frozen + # Each migrate runs under the same settings as the generate step below + # it, so the tables land in the database that step reads. Without the + # settings module manage.py falls back to devstack, whose DATABASES is + # empty without an LMS_CFG, and the step fails before reaching the + # service. - name: Run migrations run: | - uv run ./manage.py lms migrate - uv run ./manage.py cms migrate + DJANGO_SETTINGS_MODULE=docs.docs_settings uv run ./manage.py lms migrate + DJANGO_SETTINGS_MODULE=cms.envs.development uv run ./manage.py cms migrate # `docs.docs_settings` is what `make swagger` uses: it applies the # unfiltered /api-docs configuration instead of the narrow, SDK-facing