Repository navigation
Add modelNamePrefix/modelNameSuffix settings for generated beans - #519
Open
matheusandre1 wants to merge 1 commit into
Open
matheusandre1 wants to merge 1 commit into
matheusandre1 wants to merge 1 commit into
Conversation
Contributor
Author
|
cc: @mathecruz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #518
Problem
classNamePrefixandclassNameSuffixare applied inCodegenUtil.toClassName(...), which is usedfor both beans and JAX-RS interfaces. Setting
classNameSuffix=DtogivesBeerDto, but alsoBeersResourceDto. There is no way to rename only the models.The use case comes from quarkiverse/quarkus-openapi-generator#1724: generated models are DTOs that
live next to hand-written domain classes with the same simple names.
Change
modelNamePrefixandmodelNameSuffixinJaxRsProjectSettings(default"").CodegenUtil.toBeanClassName(...), used wherever a bean class name is resolved:OpenApi2JaxRs#generateJavaBean(bean name and the$reflookup) andCodegenUtil#schemaRefToFQCN.toClassName(...)is unchanged and is now used only for interfaces.For beans the settings are combined:
classNamePrefix+modelNamePrefix+ name +modelNameSuffix+classNameSuffix.Result
With
modelNamePrefix=MyandmodelNameSuffix=Dtoonbeer-api.json:beans/Beerbeans/MyBeerDtobeans/Brewerybeans/MyBreweryDtoBeersResourceBeersResourceBreweriesResourceBreweriesResourceInterfaces reference the renamed beans, e.g.
MyBeerDto getBeer(...).Compatibility
Both settings default to empty, so existing output is unchanged. The existing prefixed/suffixed
tests pass without changes to their expected files.
Tests and docs
OpenApi2JaxRsTest#testGenerateFullModelSuffixedwith expected files in_expected-full-model-suffixed/.configuration-reference.mdandmaven-plugin.mddocument the new settings.Open question
I chose to combine the model prefix/suffix with the class-level ones rather than replace them for
beans. Happy to switch if replacing is preferred.