openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

Generate and use enum types in parameters for typescript-axios

Open chaayac opened this issue 2 years ago • 5 comments

Resolves #13439

Changes enum implementation for operators in the typescript-axios generator to more closely follow the fetch generator - generating actual types for enums defined in operators rather than using union (|) syntax.

This should be a non-breaking change since the effective types are the same, but please correct me if i'm wrong.

PR checklist

  • [x] Read the contribution guidelines.
  • [x] 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.
  • [x] 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 (6.1.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • [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. @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04)

chaayac avatar Sep 16 '22 00:09 chaayac

up

galihputera avatar Sep 19 '22 13:09 galihputera

This should be a non-breaking change since the effective types are the same

If real enums are used (via the stringEnums option), it will be a breaking change, since strings are not assignable to enums Screen Shot 2022-09-19 at 10 24 16 AM

amakhrov avatar Sep 19 '22 17:09 amakhrov

@amakhrov I see, any suggestions to fix that, or should I just merge to 7.0.x?

chaayac avatar Sep 20 '22 23:09 chaayac

I think targeting this for the 7.x branch is reasonable

amakhrov avatar Sep 21 '22 00:09 amakhrov

@amakhrov I switched to merge to 7.0.x.

chaayac avatar Sep 21 '22 05:09 chaayac

@amakhrov can I get your review/approval?

I'm not sure what the failing bitrise test is, could use some help with that too please.

chaayac avatar Sep 23 '22 08:09 chaayac

Thanks for the review. Is there anything else I need to do to get this merged? Need someone with write access to do it please.

@amakhrov or @jimschubert?

chaayac avatar Sep 30 '22 00:09 chaayac

One of the tests failed in CI. Looks to be what has just been fixed in this PR: https://github.com/OpenAPITools/openapi-generator/pull/13526 . Perhaps need to merge in latest changes from master here?

amakhrov avatar Sep 30 '22 01:09 amakhrov

I updated the PR with the fix. Can't directly merge because the fix isn't on the 7.0.x branch.

chaayac avatar Sep 30 '22 06:09 chaayac

Bumping this for merging please @amakhrov.

chaayac avatar Oct 04 '22 01:10 chaayac

@macjohnny

amakhrov avatar Oct 04 '22 16:10 amakhrov

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

wing328 avatar Oct 06 '22 16:10 wing328

Is there a reason why isNullable is missing on isEnum side?

{{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}},

We have a nullable enum field in our API

field:
    type: string
    nullable: true
    enum: &a5
    - foo
    - bar
    - baz

but generator generates code with non-nullable type :field: fieldEnum

Naktibalda avatar Nov 30 '23 11:11 Naktibalda