Skip to content

feat: add endpoint parameter contract snapshot tests for openapi.json#25

Draft
romitg2 wants to merge 1 commit intomainfrom
devin/1773226085-endpoint-parameter-contract-snapshots
Draft

feat: add endpoint parameter contract snapshot tests for openapi.json#25
romitg2 wants to merge 1 commit intomainfrom
devin/1773226085-endpoint-parameter-contract-snapshots

Conversation

@romitg2
Copy link
Copy Markdown
Member

@romitg2 romitg2 commented Mar 11, 2026

feat: add endpoint parameter contract snapshot tests for openapi.json

Summary

Adds vitest snapshot tests that parse docs/api-reference/v2/openapi.json directly and capture the full parameter contract for every endpoint. When the OpenAPI spec changes — parameters added/removed, required flags flipped, types changed, request body schemas altered — the relevant snapshots will fail and must be explicitly reviewed and updated via bun run test:update.

Changes:

  • Added vitest as a devDependency to packages/cli
  • Added test and test:update scripts to packages/cli/package.json
  • Created packages/cli/src/__tests__/endpoint-parameter-contracts.test.ts with 6 snapshot tests:
    1. Full endpoint contracts — params, request body schema, response codes per endpoint
    2. Parameter-only view — name, location, required flag, type, enums
    3. Request body schemas — resolved field names, types, required flags for endpoints with bodies
    4. Required parameters — isolated view of just required params per endpoint
    5. Component schemas — all schema definitions with their properties and required fields
    6. Tag-to-endpoint mappings — which endpoints belong to which tags (relevant for SDK generation filters)

Review & Testing Checklist for Human

  • Snapshot scope: The test currently snapshots all 272 endpoints from openapi.json, not just the 213 that the CLI imports. Confirm this is the desired scope — or whether it should be narrowed to CLI-imported endpoints only.
  • Snapshot file size (~757KB, ~33K lines): Verify this is acceptable for your team's PR review workflow. When openapi.json changes, snapshot diffs could be large.
  • Schema resolution depth: resolveSchemaContract resolves $ref one level deep. Verify this catches the contract changes you care about — deeply nested schema changes may not surface.
  • CI integration: These tests won't run in CI until the pipeline is updated to include bun run test (planned for PR 2). Confirm you're okay with this being test-only for now.

Suggested test plan

  1. cd packages/cli && bun run test — all 6 tests should pass
  2. Manually edit a parameter in openapi.json (e.g., flip a required: true to required: false) → re-run bun run test → verify the relevant snapshot(s) fail
  3. Run bun run test:update to accept the change, verify the snapshot diff is readable

Notes

Adds vitest snapshot tests that capture the full parameter contract for
every endpoint in the OpenAPI spec. When openapi.json changes, these
snapshots will fail and require explicit review/update.

Snapshots cover:
- Full endpoint contracts (params, request body, response codes)
- Parameter-only view (name, location, required, type, enums)
- Request body schemas (field names, types, required flags)
- Required parameters per endpoint
- Component schema definitions
- Tag-to-endpoint mappings

Co-Authored-By: romitgabani1 <romitgabani1.work@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant