Skip to content

feat: typed enums#241

Merged
deepmap-marcinr merged 2 commits intooapi-codegen:masterfrom
bonitoo-io:feat/enum
Apr 14, 2021
Merged

feat: typed enums#241
deepmap-marcinr merged 2 commits intooapi-codegen:masterfrom
bonitoo-io:feat/enum

Conversation

@vlastahajek
Copy link
Copy Markdown
Contributor

@vlastahajek vlastahajek commented Oct 21, 2020

This PR adds support for generating typed enum constants for enums in all places. It replaces #181 and properly fixes #54.

There is also a small fix for propagating the servers property declared locally on the operation.

@vlastahajek vlastahajek marked this pull request as draft October 21, 2020 11:34
@vlastahajek vlastahajek force-pushed the feat/enum branch 2 times, most recently from dd6ffb6 to 099671f Compare October 21, 2020 13:10
@vlastahajek vlastahajek marked this pull request as ready for review October 21, 2020 13:11
@vlastahajek vlastahajek force-pushed the feat/enum branch 2 times, most recently from 50c2c06 to 96a920e Compare October 23, 2020 12:26
@deepmap-marcinr deepmap-marcinr added the ☢️ breaking change This change would break existing users' code label Apr 2, 2021
@vlastahajek vlastahajek force-pushed the feat/enum branch 2 times, most recently from f5acdf5 to 35a0253 Compare April 13, 2021 15:25
@vlastahajek
Copy link
Copy Markdown
Contributor Author

@deepmap-marcinr, could you, please, share what do you plan with this PR?

This generator is used in the InfluxDB Client Go to generate client stubs from the InfluxDB server very complex swagger. As there are many enums, these changes are necessary. This generator even fails on this swagger due to changes in #181 without this PR.

It is becoming harder and harder to maintain this PR due to its complex changes to schema processing.

Maybe, in order to don't break generated interfaces and make this PR better to merge, this could be done by a cmd option?
However, in order to make this optional, it would require complex changes, which I don't know now.

@deepmap-marcinr
Copy link
Copy Markdown
Contributor

I'd like to merge this, but I'm going to break people, that's the part that is difficult to deal with right now.

My plan is to make a V2 version of this library which pulls in a number of breaking changes, but more importantly, we're going to version the templates separately from the tool itself, to make future changes easier. However, it's going to take me a while to get there.

I'm leaning towards merging this end explaining what happened in release notes.

@deepmap-marcinr deepmap-marcinr merged commit 44a9a08 into oapi-codegen:master Apr 14, 2021
@vlastahajek
Copy link
Copy Markdown
Contributor Author

Thanks for merging this, @deepmap-marcinr

@ada-henchmans
Copy link
Copy Markdown

ada-henchmans commented Dec 7, 2022

This may be a weird question on a long closed issue but I don't believe this actually type checks the enums, since GeneratedEnumType("ANYSTRING") will return a valid GeneratedEnumType, and when this is unmarshalled any string would also be a valid GeneratedEnumType.

adrianpk pushed a commit to foorester/oapi-codegen that referenced this pull request Jan 16, 2024
* fix(model): Copying servers from path definition to operation definition

* feat(enums): Adding support for enums in all positions
adrianpk added a commit to foorester/oapi-codegen that referenced this pull request May 31, 2024
* fix(model): Copying servers from path definition to operation definition

* feat(enums): Adding support for enums in all positions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ breaking change This change would break existing users' code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing Enum Values and validation code

3 participants