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

Generate and use enum types in parameters for typescript-axios #13438

Merged
merged 4 commits into from
Oct 6, 2022

Conversation

chaayac
Copy link
Contributor

@chaayac chaayac commented Sep 16, 2022

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

  • 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.
  • File the PR against the correct branch: master (6.1.0) (minor release - breaking changes with fallbacks), 7.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 (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)

@galihputera
Copy link

up

@amakhrov
Copy link
Contributor

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

@chaayac
Copy link
Contributor Author

chaayac commented Sep 20, 2022

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

@amakhrov
Copy link
Contributor

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

@chaayac chaayac changed the base branch from master to 7.0.x September 21, 2022 03:26
@chaayac chaayac changed the base branch from 7.0.x to master September 21, 2022 03:29
@chaayac chaayac changed the base branch from master to 7.0.x September 21, 2022 04:49
@chaayac
Copy link
Contributor Author

chaayac commented Sep 21, 2022

@amakhrov I switched to merge to 7.0.x.

@chaayac
Copy link
Contributor Author

chaayac commented Sep 23, 2022

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

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.

Looks good to me, thanks for your contribution!

@chaayac
Copy link
Contributor Author

chaayac commented Sep 30, 2022

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?

@amakhrov
Copy link
Contributor

One of the tests failed in CI.
Looks to be what has just been fixed in this PR: #13526 . Perhaps need to merge in latest changes from master here?

@chaayac
Copy link
Contributor Author

chaayac commented Sep 30, 2022

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

@chaayac
Copy link
Contributor Author

chaayac commented Oct 4, 2022

Bumping this for merging please @amakhrov.

@amakhrov
Copy link
Contributor

amakhrov commented Oct 4, 2022

@macjohnny

@macjohnny macjohnny merged commit 36fd9f1 into OpenAPITools:7.0.x Oct 6, 2022
@wing328
Copy link
Member

wing328 commented Oct 6, 2022

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 wing328 added this to the 6.2.1 milestone Oct 6, 2022
@Naktibalda
Copy link
Contributor

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

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.

[REQ] [typescript-axios] Use generated enums in operations
6 participants