From 20a944abd30540e9182a4cdecc81475f93c54ba1 Mon Sep 17 00:00:00 2001 From: "Pedro S. Lopez" Date: Fri, 5 Sep 2025 16:15:18 -0400 Subject: [PATCH 1/2] chore: add CI check for openapi spec generation --- .github/workflows/python_lint.yml | 44 ++++++++++++++++++++++++ airbyte_cdk/manifest_server/README.md | 12 +++++++ airbyte_cdk/manifest_server/openapi.yaml | 36 +++++++++++++++++++ 3 files changed, 92 insertions(+) diff --git a/.github/workflows/python_lint.yml b/.github/workflows/python_lint.yml index 94e4e5e90..572b9edf7 100644 --- a/.github/workflows/python_lint.yml +++ b/.github/workflows/python_lint.yml @@ -76,3 +76,47 @@ jobs: - name: Run mypy run: poetry run mypy --config-file mypy.ini airbyte_cdk + + openapi-check: + name: OpenAPI Spec Check + runs-on: ubuntu-24.04 + steps: + # Common steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Poetry + uses: snok/install-poetry@v1 + with: + version: "2.0.1" + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: "poetry" + - name: Install dependencies + run: poetry install --all-extras + + # Job-specific step(s): + - name: Generate OpenAPI spec + run: poetry run manifest-server generate-openapi + + - name: Check for changes + id: git-diff + run: | + git diff --quiet && echo "No changes to commit" || echo "changes=true" >> $GITHUB_OUTPUT + shell: bash + + - name: Fail if OpenAPI spec is outdated + if: steps.git-diff.outputs.changes == 'true' + run: | + echo "❌ OpenAPI spec is out of date!" + echo "" + echo "The manifest-server API models have been modified, but the OpenAPI spec hasn't been updated." + echo "The following files have changes:" + git diff --name-only + echo "" + echo "Please run the following command and commit the changes:" + echo "" + echo " poetry run manifest-server generate-openapi" + echo "" + exit 1 diff --git a/airbyte_cdk/manifest_server/README.md b/airbyte_cdk/manifest_server/README.md index ee40ee55d..8dc9f4e7b 100644 --- a/airbyte_cdk/manifest_server/README.md +++ b/airbyte_cdk/manifest_server/README.md @@ -125,6 +125,18 @@ The generated OpenAPI specification is consumed by other applications and tools - Provide API documentation and validation - Enable integration with API development tools +### Automated OpenAPI Spec Validation + +The project includes a GitHub Actions check that automatically verifies the OpenAPI spec is up-to-date whenever API models are modified. This prevents developers from forgetting to regenerate the spec after making changes to request/response types. + +If you modify any files in `airbyte_cdk/manifest_server/api_models/`, make sure to run: + +```bash +poetry run manifest-server generate-openapi +``` + +The CI will fail if the committed OpenAPI spec doesn't match what would be generated from the current API models. + ### Interactive API Documentation When running, interactive API documentation is available at: diff --git a/airbyte_cdk/manifest_server/openapi.yaml b/airbyte_cdk/manifest_server/openapi.yaml index 8d8a68789..b807953e6 100644 --- a/airbyte_cdk/manifest_server/openapi.yaml +++ b/airbyte_cdk/manifest_server/openapi.yaml @@ -296,6 +296,10 @@ components: $ref: '#/components/schemas/Manifest' config: $ref: '#/components/schemas/ConnectorConfig' + context: + anyOf: + - $ref: '#/components/schemas/RequestContext' + - type: 'null' type: object required: - manifest @@ -330,6 +334,10 @@ components: $ref: '#/components/schemas/Manifest' config: $ref: '#/components/schemas/ConnectorConfig' + context: + anyOf: + - $ref: '#/components/schemas/RequestContext' + - type: 'null' type: object required: - manifest @@ -357,6 +365,10 @@ components: minimum: 1.0 title: Stream Limit default: 100 + context: + anyOf: + - $ref: '#/components/schemas/RequestContext' + - type: 'null' type: object required: - manifest @@ -457,10 +469,29 @@ components: - manifest title: ManifestResponse description: Response containing a manifest. + RequestContext: + properties: + workspace_id: + anyOf: + - type: string + - type: 'null' + title: Workspace Id + project_id: + anyOf: + - type: string + - type: 'null' + title: Project Id + type: object + title: RequestContext + description: Optional context information for tracing and observability. ResolveRequest: properties: manifest: $ref: '#/components/schemas/Manifest' + context: + anyOf: + - $ref: '#/components/schemas/RequestContext' + - type: 'null' type: object required: - manifest @@ -542,6 +573,7 @@ components: title: Pages slice_descriptor: anyOf: + - type: object - type: string - type: 'null' title: Slice Descriptor @@ -601,6 +633,10 @@ components: minimum: 1.0 title: Slice Limit default: 5 + context: + anyOf: + - $ref: '#/components/schemas/RequestContext' + - type: 'null' type: object required: - manifest From f66e05bd567f3500e2a0ef234e8c52c0d9a68ba8 Mon Sep 17 00:00:00 2001 From: "Pedro S. Lopez" Date: Fri, 5 Sep 2025 13:16:58 -0700 Subject: [PATCH 2/2] Potential fix for code scanning alert no. 42: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/python_lint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python_lint.yml b/.github/workflows/python_lint.yml index 572b9edf7..be04ef205 100644 --- a/.github/workflows/python_lint.yml +++ b/.github/workflows/python_lint.yml @@ -1,4 +1,6 @@ name: Linters +permissions: + contents: read on: push: