-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Bugfix/fix for correctly generating additional properties, added types for typescript #18491
Open
mvarchdev
wants to merge
11
commits into
OpenAPITools:master
Choose a base branch
from
mvarchdev:bugfix/typescript-fix-for-correctly-set-parent-when-additional-properties-exist
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
193c9cf
fix: when instantiation type is not defined for language, return type…
mvarchdev 250548f
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
mvarchdev cc3c46f
fix: fixed additional properties generator, fixed typescript types
mvarchdev 278d357
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
mvarchdev db2a03f
fix: pulled from master and updated branch
mvarchdev a49be1a
feat: reverted object serializer as it did not make sense to keep unk…
mvarchdev e684184
fix: removed "any" from AnyType check in typescript-axios
mvarchdev 4631191
fix: changed object type to object in TS in codegen
mvarchdev 16da601
feat: generalised detecting any object type in additional properties
mvarchdev b60f23e
fix: corrected additionalProperties type generator
mvarchdev cfce5bf
Update DefaultCodegen.java
mvarchdev File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...generator/src/main/resources/typescript-angular/modelGenericAdditionalProperties.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{{#additionalPropertiesType}} | ||
|
||
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}}; | ||
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | unknown{{/hasVars}}; | ||
|
||
{{/additionalPropertiesType}} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if its a good idea to use
unknown
instead ofany
, since this probably breaks a lot of client code that accesses these valuesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the typescript perspective (ECMA standarts etc) it is better to use unknown, as it is exactly describe its state/type, which is unknown and you must check/know the type of it. IMO it make the code more error-free/robust in runtime as you will be forced to check the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can put it back to any but my linter and strict tsconfig settings do not like it, which is sign of not best typing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe, make use of config switch
supportsES6
that when it would be true, it would useunknown
instead ofany
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would suggest to switch it back to
any
, in order not to break existing use cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for late reply, had a lot in work... I do not agree with that completely, preserving backwards compatibility si for sure important, but in our codebase,
any
type will fail in every project as we use strict typing config from official ts configs package. I suggest to add config switch to generator that we will be able to set ifany
ofunknown
, as default there would beany
so preserving backwards compatibility, what do you think? @macjohnny @andreseloysvThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applying linting/strict typing rules etc. to generated code is a hard one anyway. you can always just have a custom script to post-process the output and replace
any
withunknown
a config switch sounds a bit like an overkill here, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@macjohnny We use that, because we have strict typing rule in our org :/ and tbh imo, having script to post-process the output and replace any with unknown is overkill as you would change already generated code, instead, with switch, you would just already set what will be generated in the end. In @sunray-eu We would really love to have this switch available. Let me know your final decision if it would be to big change in code with this switch adding, and then, we can finally merge it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*shrug* ok lets have the switch. an alternative though would be to generate the code into a separate npm package, and import that package in your project. this way, you dont need to apply your projects build rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have alternative package, of course, but 1. there is also build, 2. when we use it in other package, the return data type is sometimes any, which in lot of cases disable type check