Complete OpenAPI v3 Specification & Auto-Generated SDK Support (TypeScript & Python) - #134
Open
Just-Bamford wants to merge 1 commit into
Open
Conversation
…& Python) - Enhanced CI/CD pipeline to generate OpenAPI specification from NestJS Swagger decorators - Added TypeScript SDK auto-generation via OpenAPI Generator CLI - Added Python SDK auto-generation via OpenAPI Generator CLI - Added OpenAPI spec validation script - Created working examples for both TypeScript and Python - Artifacts published to GitHub Actions (90-day retention) - SDKs are auto-synced with API spec on every commit Addresses feature request for authoritative OpenAPI spec and SDK generation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Problem Solved
The alian-structure API previously lacked an authoritative, maintained OpenAPI specification and auto-generated SDKs. This made it harder for external integrators to:
Closes #129
Solution Implemented
We implemented a complete, CI-driven OpenAPI specification and SDK generation workflow that ensures:
1. Authoritative OpenAPI v3 Specification
scripts/export-openapi.ts(already existed, enhanced for CI/CD)2. Automated SDK Generation (TypeScript)
sdks/typescript/directory3. Automated SDK Generation (Python)
sdks/python/directory4. Example Client Implementations
TypeScript Example (
examples/typescript-client-example.ts): Complete, runnable example showing:Python Example (
examples/python-client-example.py): Complete, runnable example showing:5. Enhanced CI/CD Pipeline
.github/workflows/build-check.ymlmain/masterbranchesopenapi-spec: The OpenAPI JSON specificationtypescript-client: Complete TypeScript SDKpython-client: Complete Python SDKsdk-examples: Example implementations and documentation6. OpenAPI Validation Script
scripts/validate-openapi.tsnpm run openapi:validate7. Enhanced Package.json Scripts
New npm scripts for SDK management:
npm run openapi:export- Generate the OpenAPI spec (existing, enhanced)npm run openapi:validate- Validate the OpenAPI spec completenessnpm run openapi:client- Generate TypeScript SDKnpm run openapi:client:python- Generate Python SDKnpm run openapi:client:all- Generate both SDKsArchitecture & Workflow
CI/CD Execution Flow
Build Stage
OpenAPI Generation Stage (only on push to main/master)
Key Features
✅ Type Safety
✅ Comprehensive API Coverage
✅ Automatic Sync
✅ Multiple Authentication Methods
✅ Easy Integration
✅ Production Ready
Files Modified/Created
Modified Files
.github/workflows/build-check.yml- Enhanced with Python SDK generationpackage.json- Added SDK-related npm scriptsREADME.md- Added SDK section highlighting new capabilitiesNew Files
examples/typescript-client-example.ts- TypeScript SDK example (150+ lines)examples/python-client-example.py- Python SDK example (200+ lines)scripts/validate-openapi.ts- OpenAPI spec validation script (250+ lines)Generated Artifacts (from CI)
The GitHub Actions workflow now publishes 4 artifact bundles:
openapi-spec
docs/openapi.jsontypescript-client
python-client
sdk-examples
Accessing Generated SDKs
From GitHub Actions
From Local Development
Benefits to Integration & Adoption
✅ For External Developers
✅ For Grant Reviewers
✅ For Maintainers
✅ For Future Development
Technical Implementation Details
OpenAPI Generator Configuration
@openapitools/openapi-generator-cli@2.13.4typescript-fetchpythonAuthentication in SDKs
ConfigurationclassError Handling Patterns
What's Ready Now
✅ OpenAPI specification auto-generation in CI
✅ TypeScript SDK auto-generation in CI
✅ Python SDK auto-generation in CI
✅ Working examples for both languages
✅ OpenAPI spec validation
✅ Local SDK generation scripts
✅ All artifacts published to GitHub Actions
What Can Be Done Next
Success Criteria Met
✅ Complete OpenAPI v3 specification for REST surface
✅ CI-driven SDK generation for TypeScript clients
✅ CI-driven SDK generation for Python clients
✅ Example client usage implementations
✅ All artifacts accessible for end-to-end demos
✅ Automatic spec/SDK synchronization
✅ Grant reviewers can easily run demonstrations
Verification
The implementation has been tested to ensure: