Skip to content

Common parameters declared on a path object are not included in generated operation handlers #3

@henhal

Description

@henhal

If a path has common parameters declared outside of the operations, those parameters are not included in the generated operation requests / operation handler types.

paths:
  /foo/{id}:
    parameters:
      - in: path
        name: id
        schema:
          type: string
        required: true
      - in: query
        name: x
        schema:
          type: string
        required: false
    get:
      operationId: getFoo
      ...
    put:
      operationId: putFoo
      parameters:
        - in: query
          name: y
          schema:
            type: number
          required: false
      ...

This results in these handlers, as expected:

export interface OperationHandlers<T> extends Record<string, OperationHandler<T, any>> {
  getFoo: OperationHandler<T, operations['getFoo']>;
  putFoo: OperationHandler<T, operations['putFoo']>;
}

However, when implementing the operations getFoo and putFoo, the req.params and req.query types will not include the id and x parameters that were declared on the path level. Instead, putFoo will only have a req.query type of {y?: number}.

Expected:
getFoo should have req.params typed as {id: string} and req.query typed as {x?: string}
putFoo should have req.params typed as {id: string} and req.query typed as {x?: string, y?: number}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions