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
20.56k stars 6.28k forks source link

[REQ] Add ability to skip some of the web services in an openapi contract #18897

Open nddipiazza-ebay opened 3 weeks ago

nddipiazza-ebay commented 3 weeks ago

Is your feature request related to a problem? Please describe.

Sometimes the openapi is huge and you only want a small number of web services to be included in the generator output.

Describe the solution you'd like

Configuration options:

Example:

<includedResources>
  <includedResource>/hello-world</includedResource>
  <includedResource>/hello-world2</includedResource>
</includedResources>
<excludedResources>
  <excludedResources>/hello-world</excludedResource>
  <excludedResources>/hello-world2</excludedResource>
</excludedResources>

Describe alternatives you've considered

None of the other work arounds are as simple. Editing the openapi yaml is not attractive option. etc. The other exclusion options are not very declarative and seem to be bugged.

wing328 commented 3 weeks ago

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#openapi-normalizer

there's a FILTER rule in the openapi normalizer. would that meet your requirement?

nddipiazza-ebay commented 3 weeks ago

i tried. does not work. am i missing something?

            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>6.3.0</version>
                <executions>
                    <execution>
                        <id>exampleClientGenerate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generatorName>java</generatorName>
                            <output>${project.build.directory}/generated-sources</output>
                            <skipValidateSpec>true</skipValidateSpec>
                            <library>jersey2</library>
                            <apiPackage>com.example.api</apiPackage>
                            <modelPackage>com.example.model</modelPackage>
                            <invokerPackage>com.example.invoker</invokerPackage>
                            <inputSpec>${basedir}/src/main/resources/openapi-contracts/example.yaml</inputSpec>
                            <generateApiTests>false</generateApiTests>
                            <generateModelTests>false</generateModelTests>
                            <openapiNormalizer>FILTER=operationId:helloworld</openapiNormalizer>
                            <configOptions>
                                <dateLibrary>java8-localdatetime</dateLibrary>
                                <useTags>true</useTags>
                                <openapiNormalizer>FILTER=operationId:helloworld</openapiNormalizer>
                            </configOptions>
                            <apiNameSuffix>example</apiNameSuffix>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
wing328 commented 3 weeks ago
          <version>6.3.0</version>

can you try the latest stable release 7.6.0 instead?

nddipiazza-ebay commented 3 weeks ago

no change. same thing. seems to ignore it.

wing328 commented 3 weeks ago

can you try the CLI instead? the doc has an example

nddipiazza-ebay commented 3 weeks ago

unfortunately, i don't have the ability to use CLI in my workspace. maven plugin is all i have