-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Typescript generator. Using allOf in an external reference produces RangeError: Maximum call stack size exceeded. #1479
Comments
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request. |
This also re-produces it: asyncapi: '2.6.0'
info:
title: 'Persistent Storage'
version: '2.0.0'
channels:
this/is/a/topic:
publish:
operationId: opId
message:
$ref: '#/components/messages/problemResponse'
components:
messages:
problemResponse:
title: Problem Response
contentType: application/problem+json
payload:
$ref: '#/components/schemas/parentProblems'
schemas:
parentProblems:
oneOf:
- $ref: '#/components/schemas/problem'
- $ref: '#/components/schemas/parentProblems'
problem:
x-parser-schema-id: problem
type: object
properties:
type:
type: string
format: URI |
@AlbinAndersson96 what is the expected output for this small example? |
@jonaslagoni Probably something similar to this when generating with defaults. Can't remember if named exports is the default but if it isn't just replace my export with the default. import Problem from './Problem';
type ParentProblem = Problem | ParentProblem; // Very unsure about this. A type referencing itself?
export { ParentProblem }; class Problem {
private _type?: string;
constructor(input: {
type?: string,
}) {
this._type = input.type;
}
get type(): string | undefined { return this._type; }
set type(_type: string | undefined) { this._type= _type; }
}
export { Problem }; |
EDIT: The original example in this comment did in fact NOT trigger the issue. The edited one does however That said. The self-reference of ParentProblem is tripping me up a bit with how to actually generate it. This example also triggers the issue, without the self-reference. asyncapi.yaml asyncapi: '2.6.0'
info:
title: 'Persistent Storage'
version: '2.0.0'
channels:
this/is/a/topic:
publish:
operationId: opId
message:
$ref: '#/components/messages/problemResponse'
components:
messages:
problemResponse:
title: Problem Response
contentType: application/problem+json
payload:
$ref: '#/components/schemas/problem'
schemas:
problem:
$ref: './problem.yaml#/parentProblems' problem.yaml parentProblems:
oneOf:
- $ref: '#/problem'
- $ref: '#/validationProblem'
problem:
x-parser-schema-id: problem
type: object
properties:
type:
type: string
format: uri
discriminator: '__extensionObjectType__'
validationProblem:
allOf:
- $ref: '#/problem'
- type: object
properties:
errors:
type: object
additionalProperties: true |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Just encountered this problem, working on the fix "again" 🙃 |
Should be fixed as of v3 ✌️ |
Describe the bug
When using allOf in an external schema and referencing said schema from the root, it potentially throws the below error when generating with the default Typescript generator.
How to Reproduce
Generate models from the following spec files:
asyncapi.yaml
problem.yaml
Expected behavior
We expect the data models to generate, or alternatively throw an informative error if the use case isn't supported.
The text was updated successfully, but these errors were encountered: