Description
When two or more reusable response components in components/responses reference the same schema via $ref, the code generator crashes with:
Symbol finalName has not been resolved yet for [Symbol {"category":"type","resource":"definition","resourceId":"#/components/responses/ErrorMessageResponse"}#53]
Version
@hey-api/openapi-ts v0.94.4
Minimal Reproduction
This spec works (single response component):
openapi: 3.0.0
info:
title: Test
version: 0.0.1
paths:
/test:
get:
operationId: getTest
responses:
'200':
description: OK
'500':
$ref: '#/components/responses/ErrorMessageResponse'
components:
responses:
ErrorMessageResponse:
description: Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
schemas:
Error:
type: object
properties:
message:
type: string
This spec crashes (two response components sharing the same schema $ref):
openapi: 3.0.0
info:
title: Test
version: 0.0.1
paths:
/test:
get:
operationId: getTest
responses:
'200':
description: OK
'400':
$ref: '#/components/responses/BadRequestError'
'500':
$ref: '#/components/responses/ErrorMessageResponse'
/test2:
get:
operationId: getTest2
responses:
'200':
description: OK
'400':
$ref: '#/components/responses/BadRequestError'
'424':
$ref: '#/components/responses/ErrorMessageResponse'
'500':
$ref: '#/components/responses/ErrorMessageResponse'
components:
responses:
BadRequestError:
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
ErrorMessageResponse:
description: Error message
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
schemas:
Error:
type: object
properties:
message:
type: string
Error
Symbol finalName has not been resolved yet for [Symbol {"category":"type","resource":"definition","resourceId":"#/components/responses/ErrorMessageResponse"}#N]
at get finalName [as finalName] (@hey-api/codegen-core/dist/index.mjs)
at Planner.updateScope
at Planner.assignSymbolName
at Planner.assignLocalName
Expected Behavior
Both specs should generate successfully. Multiple response components referencing the same schema is valid OpenAPI 3.0.
Workaround
Inlining the response component at each usage site (removing it from components/responses) avoids the crash.
Description
When two or more reusable response components in
components/responsesreference the same schema via$ref, the code generator crashes with:Version
@hey-api/openapi-tsv0.94.4Minimal Reproduction
This spec works (single response component):
This spec crashes (two response components sharing the same schema
$ref):Error
Expected Behavior
Both specs should generate successfully. Multiple response components referencing the same schema is valid OpenAPI 3.0.
Workaround
Inlining the response component at each usage site (removing it from
components/responses) avoids the crash.