Skip to content

feat: add API contract validation CI job and sync script - #77

Open
VerifiedFlemzy1 wants to merge 2 commits into
stellar-network-builders:mainfrom
VerifiedFlemzy1:api-contract-validation
Open

feat: add API contract validation CI job and sync script#77
VerifiedFlemzy1 wants to merge 2 commits into
stellar-network-builders:mainfrom
VerifiedFlemzy1:api-contract-validation

Conversation

@VerifiedFlemzy1

Copy link
Copy Markdown

Closes #74

  • Adds a new CI job api-contract-check to the GitHub Actions workflow.
  • The job fetches the latest OpenAPI spec from the backend, generates TypeScript types using openapi-typescript, and compares them with the committed src/types/api.ts.
  • Fails the CI run if the generated types differ, ensuring the frontend stays in sync with backend API changes.
  • Provides a clear failure message and optional warning for breaking changes.

Why is this needed?

No API contract validation existed, leading to potential runtime errors when the backend API changes. This CI job catches mismatches early, enforcing contract integrity.

How to test

  1. Run npm run api:sync-types locally to generate fresh types.
  2. Verify the CI job runs successfully on the PR.
  3. Introduce a change in the OpenAPI spec and confirm the CI fails when the generated types are out of date.

Additional notes

  • The api:sync-types npm script is already defined in package.json.
  • No other parts of the codebase were modified.

@Husten150

Copy link
Copy Markdown
Contributor

check pipeline

@Husten150

Copy link
Copy Markdown
Contributor

check pipeline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

13. Add API contract validation between frontend and backend

2 participants