Skip to content
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

Conversation

Drago92
Copy link

@Drago92 Drago92 commented Sep 18, 2024

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    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.
  • File the PR against the correct branch: master (upcoming 7.6.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@joscha
Copy link
Contributor

joscha commented Sep 30, 2024

@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?

@joscha
Copy link
Contributor

joscha commented Sep 30, 2024

relates to #19484

Copy link
Member

@macjohnny macjohnny left a 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|
Copy link
Member

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

@macjohnny
Copy link
Member

@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?

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?

@joscha
Copy link
Contributor

joscha commented Sep 30, 2024

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 ;)

@macjohnny
Copy link
Member

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

, it seems we now require at least typescript 4.0

@joscha
Copy link
Contributor

joscha commented Sep 30, 2024

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

, it seems we now require at least typescript 4.0

Blame says 3.x support was dropped about 2 years ago already in 8c57b66, so I think this pull request is a go?

@macjohnny
Copy link
Member

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
Copy link
Contributor

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

Copy link
Member

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

Copy link
Contributor

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:

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you fix it?

Copy link
Contributor

@joscha joscha Sep 30, 2024

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 :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joscha
Copy link
Contributor

joscha commented Sep 30, 2024

#19725 has the changes and commits from here + latest master + regenerated samples.

@Drago92 Drago92 deleted the Fix-export-types-for-TypescriptClient-(#6805) branch October 1, 2024 07:01
@joscha
Copy link
Contributor

joscha commented Oct 1, 2024

@Drago92 if you have a second, it would be amazing if you could regenerate in #19726 on your system via:

gh pr checkout 19726

and then

./mvnw clean package 
./bin/generate-samples.sh ./bin/configs/*.yaml
./bin/utils/export_docs_generators.sh

to see if the fix works as expected.

@Drago92
Copy link
Author

Drago92 commented Oct 1, 2024

@Drago92 if you have a second, it would be amazing if you could regenerate in #19726 on your system via:

gh pr checkout 19726

and then

./mvnw clean package 
./bin/generate-samples.sh ./bin/configs/*.yaml
./bin/utils/export_docs_generators.sh

to see if the fix works as expected.

Your fix works and the slashes are correct now. But the line Endings will be converted on Windows:
image
image

and in .dist-Files a "\" will be added after src:
image

@joscha
Copy link
Contributor

joscha commented Oct 1, 2024

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 \n currently, probably if you saved the file they will become \r\n. We could possibly add a .gitattributes file with:

FILES text eol=lf

which should then keep them as \n. You could try that if you wanted?

@Drago92
Copy link
Author

Drago92 commented Oct 2, 2024

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 \n currently, probably if you saved the file they will become \r\n. We could possibly add a .gitattributes file with:

FILES text eol=lf

which should then keep them as \n. You could try that if you wanted?

Yeah it will help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants