OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.24k stars 6.43k forks source link

[REQ] Conveniently only generate client classes #5800

Open philipp-paland opened 4 years ago

philipp-paland commented 4 years ago

I often generate client code from a spec file with the maven plugin, like this:

        <configuration>
          <inputSpec>src/main/oas/oas.yaml</inputSpec>

          <generatorName>java</generatorName>
          <library>native</library>

          <configOptions>
            <dateLibrary>java8</dateLibrary>
          </configOptions>

          <apiPackage>${project.groupId}.client</apiPackage>
          <modelPackage>${project.groupId}.client</modelPackage>
          <invokerPackage>${project.groupId}.client</invokerPackage>

          <generateApiTests>false</generateApiTests>
          <generateModelTests>false</generateModelTests>
          <generateModelDocumentation>false</generateModelDocumentation>
          <generateApiDocumentation>false</generateApiDocumentation>
          <supportingFilesToGenerate>
            ApiException.java,Pair.java,ApiClient.java
          </supportingFilesToGenerate>
        </configuration>

It would be nice to have a single config property that disables the generation of tests, documentation and also all the supporting files that are not needed for compilation.

It would also be nice to be able to specify the package name only once if you want everything in the same package. packageName does not do this.

dragetd commented 4 years ago

This seemes to be an ongoing wish back from the swagger times: https://github.com/swagger-api/swagger-codegen/issues/1737

The clunky defaults and lack of proper documentation on how to bend those into shape is frustrating when working with it. Your example actually helped me a lot right now. :S

Woodham commented 3 years ago

Honestly personally I'd go so far as to say this should really be the default for how the maven plugin is configured. It's certainly unexpected that a maven codegen plugin by default generates a whole separate maven project.

mikesaurus commented 3 years ago

+1 on this request.

We generate the client code as part of a larger parent project and have no use for anything but the Java class files, as the module that generates the client also compiles and builds the client jar. I would assume that setting generateSupportingFiles=true would have done the trick, but OAG "supporting" files are differ from my expectations since non-Java files are still generated while some of the Java files required to compile the client are not.

I agree with @Woodham that it seems like generating all-and-only source files should be the default behavior with an option to generate "supporting" files. But I would definitely settle for it being optional behavior with a param allowing me to toggle it on.

Hope that this is considered for an upcoming release. 🤞

philipp-paland commented 2 years ago

So is there any chance this would ever get picked up?

ppa-fyayc commented 5 months ago

To my knowledge, nothing has changed in this area. Right?

wing328 commented 5 months ago

I don't think anyone has started working on this yet. I've some ideas.

Would you like to contribute a PR or sponsor the work?

PM me via Slack if you want to discuss further

https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g