openapi-generator
openapi-generator copied to clipboard
Fix issue 18889,15274 - configOptions to not remove enum prefix and oneOf subtypes annotations example
- configOptions to not remove enum prefix: An option was implemented to not remove the common prefix between enums, but it was not available in the documentation and does not work by adding it to configOptions. I just added it to cliOptions so that it appears in the documentation and works through configOptions in the pom. merged: #5166 fix #18889
<configOptions>
<removeEnumValuePrefix>false</removeEnumValuePrefix>
</configOptions>
- oneOf subtypes annotations example: I created a test to show how using oneOf with mapping works without duplicating class mappings. fix #15274
example
@JsonIgnoreProperties(
value = "petType", // ignore manually set petType, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the petType to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "petType", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = Cat.class, name = "PET_CAT"),
@JsonSubTypes.Type(value = Dog.class, name = "PET_DOG"),
@JsonSubTypes.Type(value = Lizard.class, name = "PET_LIZARD")
})
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-06-22T15:24:51.304753300-03:00[America/Sao_Paulo]", comments = "Generator version: unset")
public interface Pet {
public PetType getPetType();
}
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:
(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./mvnw clean package ./bin/generate-samples.sh ./bin/configs/*.yaml ./bin/utils/export_docs_generators.sh./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) - [ ] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
@cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @wing328
@welshm
Looks good to me - although ideally we don't need to replicate each option in each sub-generator and can just refer to the global option
I agree. However, the project is very big and I'm still getting to know it. For now, I will continue as is being done as I believe it is safer. In the future maybe I will be a little more daring.
fix #18889 #15274