[Java][jaxrs-spec] add fromString() method to generated enums as required by JAX RS spec - #7494
Conversation
|
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. |
|
@upachler the current master is for the upcoming v5.0.0 release. |
6aa402f to
ee4cf62
Compare
|
Hi @wing328, |
|
Is there any hope that you guys will proceed with such solution for this long-standing issue anytime soon? |
|
@hermes85pl sorry that this PR has not been reviewed yet.... May I know if you've tested the change? Does it work for you? If yes, we can definitely include it in the upcoming v6.0.0 release due in a month or 2. |
|
Tested locally with updated samples and the result is ok: Thanks for the fix and sorry for the delay in merging the PR. |
I'd like to fix issue #3995 with this PR (see my comments there).
The fix creates an additional static method
fromString()as required by the JAX RS spec, so that compliant implementations can correctly parse enum arguments whoose wire string representation differs from the Java enum field name (e.g. MyEnum.FOO vs. "foo"). As it stands right now, a JAX RS implementation would expect "FOO" as a value passed as parameter, so parsing "foo" will fail.I've coded this fix against v4.3.1, as I ran into other issues with 5.0.0 in my project and did use 4.3.1 there; however I assume this can be merged into both the 4.3.x and 5.0.x lines. I couldn't find a release branch for 4.3.x, so this PR is made against
masterin the hope that it will also be patched into the 4.3.x line if accepted.PR checklist
./bin/generate-samples.shto update all Petstore samples related to your fix. 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.master