Skip to content

Conversation

@manuel-covas
Copy link
Contributor

@manuel-covas manuel-covas commented Apr 17, 2024

The instanceOf{{classname}} function introduced in 93b76dd makes use of the Object.values function introduced in ECMAScript 2017, thus breaking compatibility with prior versions such as ES2016 and ES2015.

This PR suggests an alternate implementation for the instanceOf{{classname}} function in the modelEnum.mustache template that restores backward-compatibility.

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.1.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.

@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka

manuel-covas and others added 3 commits April 17, 2024 16:21
…late

Restore pre-es2017 compatibility in modelEnum template by not using Object.values in instanceOf{{classname}} function

export function instanceOf{{classname}}(value: any): boolean {
return Object.values({{classname}}).includes(value);
for (const key in {{classname}})
Copy link
Member

Choose a reason for hiding this comment

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

please use { and } in the if/for

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

please update the generated samples

@manuel-covas manuel-covas force-pushed the typescript-fetch-pre-es2017-compatibility branch from bf8759c to 78a74a0 Compare May 2, 2024 17:52
@manuel-covas
Copy link
Contributor Author

@macjohnny
Added curly brackets and regenerated

@manuel-covas manuel-covas force-pushed the typescript-fetch-pre-es2017-compatibility branch from 05eb53a to f9ab9ea Compare May 4, 2024 17:37
@macjohnny macjohnny merged commit 296a6ac into OpenAPITools:master May 5, 2024
@wing328 wing328 added this to the 7.6.0 milestone May 20, 2024
macjohnny pushed a commit that referenced this pull request May 28, 2024
* Fix bug referenced in #18746 , introduced in #18418

* Generate examples
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