Skip to content

[typescript] fix issue with special characters#9940

Closed
mayrmax wants to merge 1 commit intoOpenAPITools:masterfrom
tributech-solutions:fix-typecript-special-chars
Closed

[typescript] fix issue with special characters#9940
mayrmax wants to merge 1 commit intoOpenAPITools:masterfrom
tributech-solutions:fix-typecript-special-chars

Conversation

@mayrmax
Copy link

@mayrmax mayrmax commented Jul 13, 2021

Fix issue where special characters such as @ get stripped in the abstract typescript options. This changes affects all typescript generators.

Fixes:

@TiFu @taxpon @petejohansonxo @amakhrov

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/utils/export_docs_generators.sh
    
    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*.
    For Windows users, please run the script in Git BASH.
  • [X File the PR against the correct branch: master, 5.3.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@mayrmax mayrmax force-pushed the fix-typecript-special-chars branch from 80d50f6 to 2665f4f Compare July 13, 2021 14:43
@mayrmax
Copy link
Author

mayrmax commented Jul 13, 2021

Seems like this leaves the breaking @ in, maybe ^[^\w_$@]*|[^\w$] would work.

Fix issue where special characters such as @ get stripped.
@mayrmax mayrmax force-pushed the fix-typecript-special-chars branch from 2665f4f to 7b4083c Compare July 13, 2021 15:14
@mayrmax
Copy link
Author

mayrmax commented Jul 15, 2021

Copy link
Contributor

@amakhrov amakhrov 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!

A few thoughts:

  • Could you please provide examples of the code generated before and after this change?
  • Let's add some tests verifying the changed behavior
  • I'm slightly concerned that with this change TS generators will generally produce uncompilable code, since models are generated without quoting. We probably need to update all templates to account for unsafe identifiers:
// before 
interface SomeModel {
  @unsafeName: string;
}

// after
interface SomeModel {
  '@unsafeName': string;
}

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