openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

Required in path converts to required in query too

Open jensjakob opened this issue 10 months ago • 4 comments

openapi-typescript version

7.4.4

Node.js version

22.6.0

OS + version

macOS 15.1.1

Description

It seems like openapi-typescript converts an OpenAPI Schema where the required is part of the in: path to be required for both path and query for typescript.

Example:

- in: path
  name: site_id
  schema:
    type: string
    format: uuid
  required: true

gets converted to:

params: {
  path: {
    site_id: string;
  };
  query: {
    site_id: string;
  };
}

even if it's not a required part of the query, only required in path

Can someone confirm and fix this?

Reproduction

sorry, I am not yet allowed to share the full schema, is there any small template schema I can adjust and share? The Redocly gives me unrelated errors

Expected result

params: {
  path: {
    site_id: string;
  };
}

Required

  • [X] My OpenAPI schema is valid and passes the Redocly validator (npx @redocly/cli@latest lint)

Extra

jensjakob avatar Jan 07 '25 12:01 jensjakob