pmcelhaney / counterfact

OpenAPI / Swagger to TypeScript generator and mock server
MIT License
104 stars 13 forks source link

`path` property on HTTP_PUT type is `never` even though spec defines a path parameter #1105

Open jrunning opened 1 week ago

jrunning commented 1 week ago

Using the following OpenAPI spec:

openapi: 3.0.3
info:
  title: My API
  version: v2
paths:
  /api/{SomeId}:
    put:
      operationId: SomeOperation
      parameters:
        - $ref: '#/components/parameters/SomeId'
      responses:
        '200':
          description: Success
components:
  parameters:
    SomeId:
      name: SomeId
      in: path
      required: true
      schema:
        type: string
        format: uuid

Counterfact (invoked as npx counterfact test.yaml api) is generating the following type in api/types/paths/api/{SomeId}.types.ts:

export type HTTP_PUT = (
  $: OmitValueWhenNever<{
    query: never;
    path: never;
    // ...

As you can see the path property has type never even though the spec defines a path parameter (SomeId).

This might be a duplicate of #1089; if so please feel free to close it.

pmcelhaney commented 1 week ago

Thanks! Yeah looks related but I'll leave this open because it's extra motivation to finish the fix.