Skip to content

feat(mock-server-core): add parseOpenApiRequestBodies export#31

Merged
apicircle-dev merged 1 commit into
mainfrom
feat/openapi-request-bodies
Jul 19, 2026
Merged

feat(mock-server-core): add parseOpenApiRequestBodies export#31
apicircle-dev merged 1 commit into
mainfrom
feat/openapi-request-bodies

Conversation

@apicircle-dev

Copy link
Copy Markdown
Contributor

Additive parser export returning each operation's request-body schema — the one part of an operation's contract the mock pipeline deliberately drops (MockEndpoint carries no request body, since the mock server never validates request payloads). It walks the same dereferenced operations as parseOpenApiToEndpoints and emits { method, path, contentType, schema, required } per operation: OpenAPI 3.x requestBody content (a JSON media type preferred) and Swagger 2.0 in:'body' parameters both reduce to the same shape.

Exposed browser-safe from the /parsing subpath and swagger-parser-backed from the Node root, mirroring parseOpenApiToEndpoints, so a consumer — the Lens code-vs-spec contract-drift check — can read a request body's declared shape and join it to the endpoint table by (method, path). Zero change to MockEndpoint or the mock runtime.

  • openapi.ts: OpenApiRequestBody interface + requestBody?/consumes? on OpenApiOperation; parseOpenApiRequestBodies + pickRequestBody helper
  • openapiNode.ts: parseOpenApiRequestBodiesNode (swagger-parser deref)
  • parsing.ts / index.ts: re-exports (+ OpenApiRequestBodySpec / ParseOpenApiRequestBodiesResult result types)
  • tests: 100% patch coverage (openapi.test.ts, openapiNode.test.ts)
  • docs: CHANGELOG (Unreleased), mock-server-core README, docs/mock-server.md

Additive parser export returning each operation's request-body schema —
the one part of an operation's contract the mock pipeline deliberately
drops (MockEndpoint carries no request body, since the mock server never
validates request payloads). It walks the same dereferenced operations as
parseOpenApiToEndpoints and emits { method, path, contentType, schema,
required } per operation: OpenAPI 3.x requestBody content (a JSON media
type preferred) and Swagger 2.0 in:'body' parameters both reduce to the
same shape.

Exposed browser-safe from the /parsing subpath and swagger-parser-backed
from the Node root, mirroring parseOpenApiToEndpoints, so a consumer — the
Lens code-vs-spec contract-drift check — can read a request body's declared
shape and join it to the endpoint table by (method, path). Zero change to
MockEndpoint or the mock runtime.

- openapi.ts: OpenApiRequestBody interface + requestBody?/consumes? on
  OpenApiOperation; parseOpenApiRequestBodies + pickRequestBody helper
- openapiNode.ts: parseOpenApiRequestBodiesNode (swagger-parser deref)
- parsing.ts / index.ts: re-exports (+ OpenApiRequestBodySpec /
  ParseOpenApiRequestBodiesResult result types)
- tests: 100% patch coverage (openapi.test.ts, openapiNode.test.ts)
- docs: CHANGELOG (Unreleased), mock-server-core README, docs/mock-server.md
@apicircle-dev
apicircle-dev merged commit c34ce60 into main Jul 19, 2026
15 checks passed
@github-actions

Copy link
Copy Markdown

E2E coverage (strict mode)

Metric This PR main Δ
Live coverage 78.24% (2949/3769) 78.24% (2949/3769) ±0.00pp (+0)
Scaffold-only 93
Manual-residue 727
Passing TC-IDs this run 0

Live coverage unchanged.
Definitions: live = inline tc() / tcRange() in non-fixme test() calls. Scaffold-only = test.fixme() placeholders. Manual-residue = explicitly excluded from automation (see e2e/web/manual-residue.ts).
Full report in the e2e-coverage-${{ run_id }} artifact.

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