openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[REQ] Selective Operation/Tag Generation with automatic schema inference

Open asafbennatan opened this issue 2 years ago • 3 comments

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

i have a large spec file with alot of apis (jira spec) , i would like to generate only one (or few) specific operations/tags and their relevant schemas

for example lets say i want to generate only searchProjects operation so it will generate the searchProjects api with #/components/schemas/PageBeanProject schema and all dependent schema (used properties schemas , inheritance etc)

i believe this is quite common use case , specs are usually sent as one single file which can be quite huge

Describe the solution you'd like

i want to input operation ids or tags and generate only these apis and their schemas

Describe alternatives you've considered

i read that i can use FILTER=operationId:searchProjects but this still generates unrelated schema

i assume i could select the apis and the related nested schemas required for these apis but this is very tedious to do for nested models

Additional context

currently using:

    <plugin>
              <groupId>org.openapitools</groupId>
              <artifactId>openapi-generator-maven-plugin</artifactId>
              <!-- RELEASE_VERSION -->
              <version>7.10.0</version>
              <!-- /RELEASE_VERSION -->
              <executions>
                  <execution>
                      <goals>
                          <goal>generate</goal>
                      </goals>
                      <configuration>
                          <inputSpec>${project.basedir}/api.yaml</inputSpec>
                          <generatorName>java</generatorName>
                          <modelNameSuffix>Dto</modelNameSuffix>
                          <openapiNormalizer>FILTER=operationId:searchProjects</openapiNormalizer>
                          <configOptions>
                              <sourceFolder>src/gen/java/main</sourceFolder>
                              <dateLibrary>java8</dateLibrary>
                              <library>resttemplate</library>
                              <useSpringBoot>true</useSpringBoot>
                              <useJakartaEe>true</useJakartaEe>
                              <useOptional>false</useOptional>
                              <openApiNullable>false</openApiNullable>
                          </configOptions>
                      </configuration>
                  </execution>
              </executions>
          </plugin>

i couldn't find any configuration that does that but perheps I'm wrong

asafbennatan avatar Nov 25 '24 22:11 asafbennatan

I am also working on a gigantic API spec right now which I want a couple of operations from, and I find myself on a trial-and-error strategy of figuring out all the recursive tree of models I need to add to modelsToGenerate so I can have the operations I need covered.

This feature would be extremely useful.

bcmedeiros avatar Jun 16 '25 14:06 bcmedeiros

This feature would be an awesome one - exactly what I want to be able to use the generator for. A transitive generation based on operationIds!

JohannesProbst avatar Sep 23 '25 10:09 JohannesProbst

I'm currently using https://github.com/line/tsr as an workaround.

e.g to remove all unused APIs and models except FooApi:

// index.ts

export { FooApi } from "./__http__"

scarf005 avatar Sep 24 '25 00:09 scarf005