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

Rust: Support Integer enums using Serde_repr #19199

Merged
merged 9 commits into from
Jul 24, 2024
Merged

Rust: Support Integer enums using Serde_repr #19199

merged 9 commits into from
Jul 24, 2024

Conversation

bertkdowns
Copy link
Contributor

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/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    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*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • [x ] File the PR against the correct branch: master (upcoming 7.6.0 minor release - breaking changes with fallbacks), 8.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. @jacob-pro @paladinzh

This #9976 solved this issue but was never merged. This PR incorporated the same changes, and updates it to work with the current version of the app.

closes #9967, closes #18840

An example from my app: The following couldn't be used, because it expected strings as explained in #18840

image

Now, it generates to integer enums as expected:
image

First time contributor - LMK if there's anything else I've missed or need to do :)

@bertkdowns
Copy link
Contributor Author

Agreed, that's much cleaner. Wasnt sure how to remove that, i've updated, synced with master, and re-gen the apis, so hopefully all the workflows should pass now too.

@@ -59,7 +59,7 @@ interface PetApi {
consumes = ["application/json", "application/xml"]
)
fun addPet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet,serverHttpRequest: ServerHttpRequest): ResponseEntity<Pet> {
return getDelegate().addPet(pet, serverHttpRequest)
return getDelegate().addPet(pet, )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... why there are changes to kotlin samples?

in the latest msater, the samples are up-to-date. can you please merge the latest master into your branch and regenerate the samples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's strange, I already did that and merging with master is what caused the kotlin examples to change for me. Perhaps it's an environment thing (I'm using the devcontainers environment and bin/generate-samples.sh) , or i'll try rollback to an earlier commit where the changes don't happen.

@wing328
Copy link
Member

wing328 commented Jul 23, 2024

can you please add a test spec for integer enum to modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml (and regenerate the samples) so that the CI can test it moving forward?

@bertkdowns
Copy link
Contributor Author

Ok, I think I've added those tests correctly - just involved updating the yaml file, so that the CI can check that it build correctly right? And dropped those changes to the kotlin files, must be an environment issue on my end

@wing328 wing328 added this to the 7.8.0 milestone Jul 24, 2024
@wing328 wing328 merged commit 9a673ea into OpenAPITools:master Jul 24, 2024
19 checks passed
@ogtn
Copy link

ogtn commented Aug 21, 2024

Thanks a lot for that PR !

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.

[BUG][RUST] json parser expects quotes with integer enum
4 participants