Skip to content

fix: always treat path parameters as required per OpenAPI 3.x spec#149

Merged
Himenon merged 3 commits into
mainfrom
fix/issue-148
May 26, 2026
Merged

fix: always treat path parameters as required per OpenAPI 3.x spec#149
Himenon merged 3 commits into
mainfrom
fix/issue-148

Conversation

@Himenon
Copy link
Copy Markdown
Owner

@Himenon Himenon commented May 26, 2026

Summary

  • Per OpenAPI 3.x spec §3.3.2, path parameters (in: path) are always required — the required field is REQUIRED and its value MUST be true.
  • Added normalizePathParameters in generateValidRootSchema.ts to unconditionally set required: true on all path parameters, covering three locations: components.parameters, PathItem-level parameters, and operation-level parameters.
  • Without this fix, path parameters that omit required: true in the spec would appear as required: undefined in pickedParameters and operationParams.parameters, violating the OpenAPI contract.

Test plan

  • Added unit tests for generateValidRootSchema covering: operation-level path params, PathItem-level path params, components.parameters path params, query params (unchanged), and already-explicit required: true (unchanged).
  • Added OpenAPI fixture test/path-parameter/index.yml with path parameters that omit required: true.
  • Added snapshot tests (class + functional) verifying the generated Parameter interface has non-optional properties for path parameters (id: string, not id?: string), and pickedParameters carries required: true.
  • All existing tests pass (pnpm test:vitest 40/40, pnpm test:snapshot 53/53).

Closes #148

🤖 Generated with Claude Code

Himenon and others added 3 commits May 26, 2026 22:59
)

Per OpenAPI 3.x specification §3.3.2, path parameters are always
required regardless of whether the `required` field is explicitly set.
Normalize `required: true` for all path parameters in
`generateValidRootSchema` so that `pickedParameters` and
`operationParams.parameters` are consistent with the spec.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…xtures

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…hema tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Himenon Himenon merged commit 106fddd into main May 26, 2026
2 checks passed
@Himenon Himenon deleted the fix/issue-148 branch May 26, 2026 22:38
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.

Path parameters should always be treated as required per OpenAPI 3.x spec

1 participant