Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

modelNameSuffix #65

Closed
aegliv opened this issue May 5, 2021 · 9 comments
Closed

modelNameSuffix #65

aegliv opened this issue May 5, 2021 · 9 comments
Labels
enhancement New feature or request
Milestone

Comments

@aegliv
Copy link

aegliv commented May 5, 2021

Hi,

awesome project, thanks for putting in the hours!

The openapi-generator-maven-plugin has a configuration property called modelNameSuffix which, as the name suggest, allows the user to append a suffix to the generated model classes.

Do you thing such a feature would be valuable in your project as well?

Example

Swagger:

components:
  schemas:
    FooObject:
      type: object
      properties:
        bar:
          type: boolean

Mapping:

openapi-processor-mapping: v2

options:
   package-name: example.gen

   modelNameSuffix: Dto

Would result in the generation of example.gen.model.FooObjectDto.java

@hauner
Copy link
Member

hauner commented May 5, 2021

Funny, haven't thought of that. :-)

Yes, I guess this would be useful. That way we can avoid the postfix "noise" in the openapi description, which is our current strategy at work.. ;-)

@hauner hauner added the enhancement New feature or request label May 5, 2021
@hauner hauner added this to the 2021.4 milestone May 5, 2021
hauner added a commit that referenced this issue May 9, 2021
hauner added a commit that referenced this issue May 9, 2021
hauner added a commit that referenced this issue May 9, 2021
hauner added a commit that referenced this issue May 9, 2021
hauner added a commit that referenced this issue May 9, 2021
hauner added a commit that referenced this issue May 9, 2021
hauner added a commit that referenced this issue May 9, 2021
hauner added a commit that referenced this issue May 10, 2021
@aegliv
Copy link
Author

aegliv commented May 11, 2021

Wow, seems that you went along and implemented it already?

If I can give you a hand or test your solution just give me a mention!

@hauner
Copy link
Member

hauner commented May 11, 2021

Started it :-) It does not work yet. I still have a few failing tests.

Giving it a test run would be nice, I'll notify you when it is ready to try.

hauner added a commit that referenced this issue May 13, 2021
hauner added a commit that referenced this issue May 13, 2021
hauner added a commit that referenced this issue May 13, 2021
hauner added a commit that referenced this issue May 13, 2021
hauner added a commit that referenced this issue May 13, 2021
hauner added a commit that referenced this issue May 13, 2021
hauner added a commit that referenced this issue May 15, 2021
hauner added a commit that referenced this issue May 15, 2021
hauner added a commit that referenced this issue May 16, 2021
hauner added a commit that referenced this issue May 16, 2021
hauner added a commit that referenced this issue May 16, 2021
hauner added a commit that referenced this issue May 16, 2021
hauner added a commit that referenced this issue May 16, 2021
hauner added a commit that referenced this issue May 16, 2021
hauner added a commit that referenced this issue May 16, 2021
hauner added a commit to openapi-processor/openapi-processor-spring that referenced this issue May 17, 2021
@hauner
Copy link
Member

hauner commented May 18, 2021

@aegliv I think it should work now. Tests pass but I haven't tried it on a real project yet.

You can try the latest openapi-processor-spring snapshot (2021.4-SNAPSHOT) (or openapi-processor-micronaut 2021.2-SNAPSHOT). Just update the version.

The mapping looks like this:

openapi-processor-mapping: v2

options:
  package-name: generated
  model-name-suffix: Resource

It will ignore the suffix if the schema already ends with the suffix to ease migration.

@aegliv
Copy link
Author

aegliv commented May 24, 2021

Thanks for the quick implementation! But where did you release your snapshot version? Can't find it on mvn central...

@hauner
Copy link
Member

hauner commented May 24, 2021

Hi @aegliv,

it is on maven central (https://oss.sonatype.org/#nexus-search;quick~openapiprocessor), the central snapshots repository is: https://oss.sonatype.org/content/repositories/snapshots

if you are using the gradle plugin (2021.3) it should automatically find it (the plugin adds the snapshots repository), if you are using the maven plugin (2021.1) you probably need to add the repository.

    <pluginRepositories>

        <pluginRepository>
            <id>openapi-processor-snapshots</id>
            <name>openapi-processor-snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </pluginRepository>

    </pluginRepositories>

@hauner
Copy link
Member

hauner commented Jun 6, 2021

released with 2021.4

@hauner hauner closed this as completed Jun 6, 2021
@aegliv
Copy link
Author

aegliv commented Jun 14, 2021

Thanks, works like a charm!

Sry I could not test it earlier but my company's firewall did not let me download your SNAPSHOT version

@hauner
Copy link
Member

hauner commented Jun 15, 2021

Thanks, nice to hear that it works for you :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants