-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[BUG] [TYPESCRIPT] Array model of alias to array model is missing inner type argument #4968
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
The code generation seems to also work properly with the java I have traced the source of the wrong type declaration to the codegen's Lines 316 to 319 in 4627c7d
Lines 713 to 715 in 4627c7d
The differences are the calls to I think I should be able to cook up a pull request. Guess for #802 a separate one needs to be created as it only exist in its own branch. |
@bodograumann this looks related to #4563 . Is it so, or is it a separate issue that only manifests itself in Typescript generators? |
@amakhrov You are correct, that this seems to be the same issue. Not sure which other languages are affected though. php maybe, but there the types are only annotations in comments. |
Bug Report Checklist
Description
When defining a data scheme, which has a property that contains an array of another data scheme, which is an alias of an array, the resulting property definition is
Array<Array>
, i.e. the inner generic has no type parameter.openapi-generator version
I have tested this with master.
OpenAPI declaration file content or url
Example declaration gist: https://gist.github.com/bodograumann/0ec60e9b2b6d8824fba49fa74c2f88a9
Command line used for generation
java -jar ~/Programme/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i array-of-array-alias.openapi.yaml -g typescript-node -o src
Steps to reproduce
Generate the code with the
typescript-node
,typescript-inversify
ortypescript-axios
template.Then run
tsc --noEmit
to typecheck the generated code. The following error will be produced:Instead of
Array<Array>
, the type should beArray<Array<string>>
. Indeed, if instead of the reference toEnclosure
, the inner array is included directly in the outer array's items-definition, the correct type is generated. The linked gist contains a second api definition, which demonstrates that fact.It also does not work with the new typescript template from #802
Related issues/PRs
I have not found any related issues.
In #4569 there was some talk about removing
isAlias
. If that would be done, I guess that would probably impact this issue as well.Suggest a fix
Seems like the whole alias handling seems to be volatile and complicated. Maybe defaulting to using the literal name and then optionally inlining would improve the situation? Not sure what the plans for aliases are.
The text was updated successfully, but these errors were encountered: