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

[typescript-fetch] Fix for nullable enums + separate treatment of null and undefined #4315

Merged
merged 1 commit into from
Nov 8, 2019

Conversation

jtbeach
Copy link
Contributor

@jtbeach jtbeach commented Oct 30, 2019

The typescript-fetch generator can still generate code with type failures in the case of nullable enum values. This addresses this by applying a similar fix that was made to modelGenericMustache to modelEnumMustache.

In addition, tweak the previous fix to modelGenericMustache so that it handles null and undefined separately rather than using == to map them both to undefined. There is a difference between a key existing vs. a key existing with a null value.

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@jtbeach jtbeach changed the title Fix for nullable enums + separate treatment of null and undefined [typescript-fetch] Fix for nullable enums + separate treatment of null and undefined Oct 30, 2019
@jtbeach
Copy link
Contributor Author

jtbeach commented Oct 30, 2019

/cc @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) @akehir (2019/07)

@jtbeach jtbeach force-pushed the task/null-fixes branch 4 times, most recently from 9648f38 to d7dc740 Compare October 30, 2019 02:43
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.

LGTM

@macjohnny
Copy link
Member

@jtbeach please run

mvn clean package
bin/typescript-fetch-petstore-all.sh

and commit all changed samples in /samples

@jtbeach
Copy link
Contributor Author

jtbeach commented Oct 30, 2019

@macjohnny Done now

@macjohnny macjohnny added this to the 4.2.1 milestone Nov 1, 2019
@macjohnny macjohnny merged commit 79d7e61 into OpenAPITools:master Nov 8, 2019
jimschubert added a commit to jimschubert/openapi-generator that referenced this pull request Nov 10, 2019
* master: (28 commits)
  [meta] Support Kotlin meta generator (OpenAPITools#4156)
  [Go][Server] minor enhancement to the template (OpenAPITools#4417)
  Replace the old ResourceSupport (OpenAPITools#4426)
  [Core, Rust Server, ASP.NET Core] Fix Codegen Operation Scope Consistency (OpenAPITools#3495)
  Add Go Server featureCORS option (OpenAPITools#4400)
  Fix treatment of nullable types in a few more places (OpenAPITools#4315)
  prefix local variable with localVar (OpenAPITools#4402)
  [kotlin][client] gson complete integration (OpenAPITools#4332)
  [kotlin] [bugfix] [maven-plugin]: prevent ClassCastException with boolean config options (OpenAPITools#4361)
  add sbt, bazel to integration (OpenAPITools#4416)
  Add a blog post tutorial about generating Java clients using OpenAPI v3 (OpenAPITools#4405)
  add freshcells to company list (OpenAPITools#4414)
  Update isSet when the object is received from callback. (OpenAPITools#4385)
  Ruby client nullable (OpenAPITools#4391)
  Fixes Kotlin client property names that include a dollar sign for template override (OpenAPITools#4351)
  [Python] [Performance] Avoid unnessacary checks inside the loop (OpenAPITools#4305)
  Add QEDIT as a company that's using OpenAPI Generator (OpenAPITools#4392)
  update cpp flag for pistache (OpenAPITools#4386)
  Feature optional emit default values (OpenAPITools#4347)
  skip the test as async call may have finished (OpenAPITools#4377)
  ...
@wing328
Copy link
Member

wing328 commented Nov 15, 2019

@jtbeach thanks for the PR, which has been included in the v4.2.1 release: https://twitter.com/oas_generator/status/1195339336922759168

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

Successfully merging this pull request may close these issues.

3 participants