feat: add OpenAPI-based contract tests between FastAPI and Next.js#416
Open
Xenon010101 wants to merge 1 commit into
Open
feat: add OpenAPI-based contract tests between FastAPI and Next.js#416Xenon010101 wants to merge 1 commit into
Xenon010101 wants to merge 1 commit into
Conversation
- Python export script (scripts/export-openapi.py) generates FastAPI OpenAPI schema without DB, model downloads, or Groq - Golden spec (openapi.golden.json) as committed baseline - TypeScript contract tests (src/__tests__/contract.test.ts) validate: - All expected path/method combinations exist - Response schemas and status codes match golden spec - Auth headers (X-Internal-API-Key) are correctly applied - Error response schemas (HTTPValidationError, ValidationError) - Enum values match TypeScript expectations - Breaking path/field/nullability changes are detected - CI job exports spec from FastAPI and runs contract tests - One-command regeneration: pnpm contract:update-golden - Documentation in services/ai/README.md
|
@Xenon010101 is attempting to deploy a commit to the Adarsh's projects Team on Vercel. A member of the Team first needs to authorize it. |
MRIARC-08
requested changes
Jun 25, 2026
MRIARC-08
left a comment
Owner
There was a problem hiding this comment.
@Xenon010101 I like the direction, but this contract-test PR is not ready yet. It currently fails the local Node checks.
Local checks:
pnpm test src/__tests__/contract.test.tsfails becauseservices/ai/openapi.jsonis missing. The test should either generate it as part of the script, read the committed golden spec for local runs, or document/use a script that creates it before running the test.pnpm exec eslint src/__tests__/contract.test.tsfails on explicitanytypes and an unusedpathvariable.pnpm exec tsc --noEmitfails: missingbeforeAllimport,OpenApiSpec.securityis not typed,specis used outside its scope in the idempotency suite, andpathItemisunknown.
Please make pnpm test:contract work from a clean checkout and then rerun lint/typecheck.
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.
Closes #367
Summary
Adds OpenAPI-based contract tests between the Next.js TypeScript client and the FastAPI AI backend, enabling automated cross-service compatibility detection in CI.
What's included
Python: OpenAPI export script
services/ai/scripts/export-openapi.pypython scripts/export-openapi.pyGolden baseline
services/ai/openapi.golden.json— committed reference spec for breaking change detectionpnpm contract:update-goldenTypeScript: Contract tests
src/__tests__/contract.test.tsvalidates:CI workflow update
contract-testjob runs after theai-servicejobai-servicejobpnpm test:contractscript for local runsDocumentation
services/ai/README.md