Skip to content

Commit 20a944a

Browse files
committed
chore: add CI check for openapi spec generation
1 parent f946d41 commit 20a944a

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

.github/workflows/python_lint.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,47 @@ jobs:
7676

7777
- name: Run mypy
7878
run: poetry run mypy --config-file mypy.ini airbyte_cdk
79+
80+
openapi-check:
81+
name: OpenAPI Spec Check
82+
runs-on: ubuntu-24.04
83+
steps:
84+
# Common steps:
85+
- name: Checkout code
86+
uses: actions/checkout@v4
87+
- name: Set up Poetry
88+
uses: snok/install-poetry@v1
89+
with:
90+
version: "2.0.1"
91+
- name: Set up Python
92+
uses: actions/setup-python@v5
93+
with:
94+
python-version: "3.10"
95+
cache: "poetry"
96+
- name: Install dependencies
97+
run: poetry install --all-extras
98+
99+
# Job-specific step(s):
100+
- name: Generate OpenAPI spec
101+
run: poetry run manifest-server generate-openapi
102+
103+
- name: Check for changes
104+
id: git-diff
105+
run: |
106+
git diff --quiet && echo "No changes to commit" || echo "changes=true" >> $GITHUB_OUTPUT
107+
shell: bash
108+
109+
- name: Fail if OpenAPI spec is outdated
110+
if: steps.git-diff.outputs.changes == 'true'
111+
run: |
112+
echo "❌ OpenAPI spec is out of date!"
113+
echo ""
114+
echo "The manifest-server API models have been modified, but the OpenAPI spec hasn't been updated."
115+
echo "The following files have changes:"
116+
git diff --name-only
117+
echo ""
118+
echo "Please run the following command and commit the changes:"
119+
echo ""
120+
echo " poetry run manifest-server generate-openapi"
121+
echo ""
122+
exit 1

airbyte_cdk/manifest_server/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ The generated OpenAPI specification is consumed by other applications and tools
125125
- Provide API documentation and validation
126126
- Enable integration with API development tools
127127

128+
### Automated OpenAPI Spec Validation
129+
130+
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.
131+
132+
If you modify any files in `airbyte_cdk/manifest_server/api_models/`, make sure to run:
133+
134+
```bash
135+
poetry run manifest-server generate-openapi
136+
```
137+
138+
The CI will fail if the committed OpenAPI spec doesn't match what would be generated from the current API models.
139+
128140
### Interactive API Documentation
129141

130142
When running, interactive API documentation is available at:

airbyte_cdk/manifest_server/openapi.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ components:
296296
$ref: '#/components/schemas/Manifest'
297297
config:
298298
$ref: '#/components/schemas/ConnectorConfig'
299+
context:
300+
anyOf:
301+
- $ref: '#/components/schemas/RequestContext'
302+
- type: 'null'
299303
type: object
300304
required:
301305
- manifest
@@ -330,6 +334,10 @@ components:
330334
$ref: '#/components/schemas/Manifest'
331335
config:
332336
$ref: '#/components/schemas/ConnectorConfig'
337+
context:
338+
anyOf:
339+
- $ref: '#/components/schemas/RequestContext'
340+
- type: 'null'
333341
type: object
334342
required:
335343
- manifest
@@ -357,6 +365,10 @@ components:
357365
minimum: 1.0
358366
title: Stream Limit
359367
default: 100
368+
context:
369+
anyOf:
370+
- $ref: '#/components/schemas/RequestContext'
371+
- type: 'null'
360372
type: object
361373
required:
362374
- manifest
@@ -457,10 +469,29 @@ components:
457469
- manifest
458470
title: ManifestResponse
459471
description: Response containing a manifest.
472+
RequestContext:
473+
properties:
474+
workspace_id:
475+
anyOf:
476+
- type: string
477+
- type: 'null'
478+
title: Workspace Id
479+
project_id:
480+
anyOf:
481+
- type: string
482+
- type: 'null'
483+
title: Project Id
484+
type: object
485+
title: RequestContext
486+
description: Optional context information for tracing and observability.
460487
ResolveRequest:
461488
properties:
462489
manifest:
463490
$ref: '#/components/schemas/Manifest'
491+
context:
492+
anyOf:
493+
- $ref: '#/components/schemas/RequestContext'
494+
- type: 'null'
464495
type: object
465496
required:
466497
- manifest
@@ -542,6 +573,7 @@ components:
542573
title: Pages
543574
slice_descriptor:
544575
anyOf:
576+
- type: object
545577
- type: string
546578
- type: 'null'
547579
title: Slice Descriptor
@@ -601,6 +633,10 @@ components:
601633
minimum: 1.0
602634
title: Slice Limit
603635
default: 5
636+
context:
637+
anyOf:
638+
- $ref: '#/components/schemas/RequestContext'
639+
- type: 'null'
604640
type: object
605641
required:
606642
- manifest

0 commit comments

Comments
 (0)