-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Fix export types for typescript client (#6805) #19616
Fix export types for typescript client (#6805) #19616
Conversation
@macjohnny Looking at 598b509 I think this would actually make sense. It would help any post-processing of the TS when bundling, etc. - is there a reason we only do this for Deno? |
relates to #19484 |
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.
thanks for your contribution
@@ -34,7 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | |||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| | |||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| | |||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| | |||
|sourceFolder|source folder for generated code| |OpenAPI/src| | |||
|sourceFolder|source folder for generated code| |OpenAPI\src| |
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.
please manually revert to /
, as this is the standard for linux-based systems
IIRC this was because it was introduced with TypeScript 3.8 https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html, so to have a lower version requirement for non-deno code? |
That would make sense. What is the guidance for our support of TS versions? 3.8 was released on 20 February 2020. 4+ years is a long time ;) |
yeah, looking at openapi-generator/modules/openapi-generator/src/main/resources/typescript/package.mustache Line 78 in df22ca6
|
Blame says 3.x support was dropped about 2 years ago already in 8c57b66, so I think this pull request is a go? |
yes, after the paths are fixed we can merge |
@@ -5,6 +5,7 @@ | |||
.travis.yml | |||
DESCRIPTION | |||
NAMESPACE | |||
README.md |
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.
seems like the sort ordering is not kept stable across systems for this one
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.
yes, probably because the samples were generated on a windows machine
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.
Yes, the problem lies here:
Lines 1984 to 1999 in 849b3e8
filesToSort.sort(PathFileComparator.PATH_COMPARATOR); | |
filesToSort.forEach(f -> { | |
// some Java implementations don't honor .relativize documentation fully. | |
// When outDir is /a/b and the input is /a/b/c/d, the result should be c/d. | |
// Some implementations make the output ./c/d which seems to mix the logic | |
// as documented for symlinks. So we need to trim any / or ./ from the start, | |
// as nobody should be generating into system root and our expectation is no ./ | |
String relativePath = removeStart(removeStart(f.toString(), "." + File.separator), File.separator); | |
if (File.separator.equals("\\")) { | |
// ensure that windows outputs same FILES format | |
relativePath = relativePath.replace(File.separator, "/"); | |
} | |
if (!relativePath.equals(relativeMeta)) { | |
sb.append(relativePath).append(System.lineSeparator()); | |
} | |
}); |
There is some code to make the output platform-independent, however the sorting happens BEFORE, on the original paths with \
, which then affects the sorting. We can't just sort after, because sorting a list of relative paths is not straightforward, as the nesting information gets lost.
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.
can you fix it?
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.
trying already. Always tricky to do non-platform specific things with platform-specific objects :)
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.
#19725 has the changes and commits from here + latest master + regenerated samples. |
Your fix works and the slashes are correct now. But the line Endings will be converted on Windows: |
Thank you for checking @Drago92 - I didn't fix the first or last image, that is a separate codepath. I didn't touch the line-endings, they are FILES text eol=lf which should then keep them as |
Yeah it will help :) |
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming 7.6.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)