Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
seriouslag opened this issue Mar 27, 2025 · 2 comments
Open
Labels
bug 🔥 Something isn't working

Comments

@seriouslag
Copy link

seriouslag commented Mar 27, 2025

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

@seriouslag seriouslag added the bug 🔥 Something isn't working label Mar 27, 2025
@mrlubos
Copy link
Member

mrlubos commented Mar 27, 2025

Quite positive this is a duplicate of #668

@seriouslag
Copy link
Author

This workaround keeps things moving:

#1135 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants