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

Add support additional properties for openapi-generator #1427

Conversation

altro3
Copy link
Collaborator

@altro3 altro3 commented Feb 9, 2024

Set stability level to STABLE for generators.
Add support additional properties for openapi-generator:

schemaMapping
importMapping
nameMapping
typeMapping
enumNameMapping
modelNameMapping
inlineSchemaNameMapping
inlineSchemaOption
openapiNormalizer
apiNamePrefix
apiNameSuffix
modelNamePrefix
modelNameSuffix

Fixed #1421

@altro3 altro3 force-pushed the add-support-mapping-options-to-generator branch 2 times, most recently from 0593509 to c091b64 Compare February 11, 2024 06:24
@altro3 altro3 requested a review from sdelamo February 11, 2024 06:56
@altro3 altro3 force-pushed the add-support-mapping-options-to-generator branch from c091b64 to afadb42 Compare February 11, 2024 09:42
@altro3 altro3 changed the title Add support openapi-generator mapping configuration properties: Add support additional properties for openapi-generator Feb 11, 2024
@altro3 altro3 force-pushed the add-support-mapping-options-to-generator branch from afadb42 to 4e33463 Compare February 11, 2024 10:02
Copy link
Contributor

@sdelamo sdelamo left a comment

Choose a reason for hiding this comment

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

can you include tests?

@altro3
Copy link
Collaborator Author

altro3 commented Feb 15, 2024

@sdelamo Well, what can I say, if I write a regular unit test, then it will not be testing our generator, but the openapi-generator library, because it performs all these functions. I'm not sure it's worth spending time on this.

I just added the ability to set these parameters through the configuration so that the user can set them through the plugin.

So, in order to fully test this mapping, you need to put all these properties in the gradle, but because of this, the generated code will completely change - all class names, mapping to other schemes, etc. If you add these settings to existing test suites, you will have to completely recycle them, because absolutely all names will change and the main the problem is, the generated code will simply be difficult to match with the source file.

I checked all this locally, everything worked out correctly, added only one property to the test -

nameMapping = [test: "changedTest"]

because it affects only one class. Prefixes and suffixes affect absolutely all generated code

@altro3 altro3 force-pushed the add-support-mapping-options-to-generator branch 3 times, most recently from f251bb7 to 9781d81 Compare February 15, 2024 09:29
Add support additional properties for openapi-generator:

schemaMapping
importMapping
nameMapping
typeMapping
enumNameMapping
modelNameMapping
inlineSchemaNameMapping
inlineSchemaOption
openapiNormalizer
apiNamePrefix
apiNameSuffix
modelNamePrefix
modelNameSuffix

Fixed micronaut-projects#1421
@altro3 altro3 force-pushed the add-support-mapping-options-to-generator branch from 9781d81 to f72b657 Compare February 16, 2024 13:45
if (options.openapiNormalizer != null) {
javaCodeGen.addOpenapiNormalizer(options.openapiNormalizer);
}
if (options.apiNamePrefix != null && !options.apiNamePrefix.isBlank()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a utils class StringUtils::isNotBlank

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I know, but this module does not depend on the libraries of the micronaut. It depends only on the openapi-generator

@sdelamo sdelamo merged commit 6d77a49 into micronaut-projects:master Feb 16, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAPI Generator: Expose configuration for import mapping / schema mapping
2 participants