Skip to content

Error generating code when shared path is used for multiple endpointsΒ #1879

@seriouslag

Description

@seriouslag

Description

Error when generating from an OpenAPI spec with two endpoints containing a shared referenced component for a path variable.

There is no error if the same referenced component is not used for two endpoints.
See the success in the readme.

We should be able to use shared components for multiple endpoints

# error
Reference not found: #/paths/~1test1~1%7BpathId%7D/get/parameters/0
Error: Reference not found: #/paths/~1test1~1%7BpathId%7D/get/parameters/0
    at Kn (/Users/seriouslag/openapi-ts-error/node_modules/@hey-api/openapi-ts/dist/index.cjs:12:1919)
    at Dr.resolveRef (/Users/seriouslag/openapi-ts-error/node_modules/@hey-api/openapi-ts/dist/index.cjs:14:410)
    at ve (/Users/seriouslag/openapi-ts-error/node_modules/@hey-api/openapi-ts/dist/index.cjs:14:26247)
    at Qn (/Users/seriouslag/openapi-ts-error/node_modules/@hey-api/openapi-ts/dist/index.cjs:14:29550)
    at oa (/Users/seriouslag/openapi-ts-error/node_modules/@hey-api/openapi-ts/dist/index.cjs:14:85572)
    at uo (/Users/seriouslag/openapi-ts-error/node_modules/@hey-api/openapi-ts/dist/index.cjs:14:90818)
    at async Promise.all (index 0)
    at async pj (/Users/seriouslag/openapi-ts-error/node_modules/@hey-api/openapi-ts/dist/index.cjs:1311:4503)
    at async start (/Users/seriouslag/openapi-ts-error/node_modules/@hey-api/openapi-ts/bin/index.cjs:124:21)

Reproducible example or configuration

https://github.com/seriouslag/openapi-ts-error

OpenAPI specification (optional)

# error.yaml
openapi: 3.0.0
info:
  version: 1.0.0
  title: TEST
servers:
  - url: http://localhost:3000
paths:
  /test1/{pathId}:
    get:
      summary: This endpoint uses the same pathId as the other endpoint
      parameters:
        - $ref: path.yaml#/pathId
      responses:
        '200':
          description: Test 1 response
  /test2/{pathId}:
    get:
      summary: This endpoint uses the same pathId as the other endpoint
      parameters:
        - $ref: path.yaml#/pathId
      responses:
        '200':
          description: Test 2 response
# path.yaml
pathId:
  name: pathId
  in: path
  required: true
  schema:
    type: string
    format: uuid

System information (optional)

mac os, node 22.x, npm 10.x, latest @hey-api/openapi-ts

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions