OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] Missing Api interface while using apisToGenerate Tag
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I have a very complex openApi file with 17 paths and only have to use a 3 of them. I would like only to generate these 3 endpoints in the Api Interface and related model/DTO classes. I found the xml<apisToGenerate> and xml<modelsToGenerate> Tags. But when I use these tags there is no interface class generated anymore.
I used the pets example in of the repository and modified it a little bit and get the same behavior as my 2000 loc openApi.yml file.
openapi-generator version
Version: 6.0.1 is in use, but I also tried Version 6.4.0
OpenAPI declaration file content or url
openapi: 3.0.0
info:
version: '1'
title: 'ServiceAPI'
paths:
/v1/dogs:
post:
summary: Create a dog
tags:
- pets
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/v1/cats:
post:
summary: Create a cat
tags:
- pets
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Dog:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Dogs:
type: array
items:
$ref: "#/components/schemas/Dog"
Cat:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Cats:
type: array
items:
$ref: "#/components/schemas/Cat"
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Generation Details
Pom.xml
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.4.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/../../documentation/contracts/openapi/dummy.openapi.yml</inputSpec>
<generatorName>jaxrs-spec</generatorName>
<output>${project.basedir}</output>
<apisToGenerate>v1dogs</apisToGenerate>
<modelsToGenerate>Dog,Dogs,Error</modelsToGenerate>
<configOptions>
<sourceFolder>src/main/java</sourceFolder>
<dateLibrary>java8</dateLibrary>
<useSwaggerAnnotations>false</useSwaggerAnnotations>
<supportAsync>true</supportAsync>
<!--ensure we only generate java interfaces and no implementation skeleton-->
<interfaceOnly>true</interfaceOnly>
<returnResponse>true</returnResponse>
<hideGenerationTimestam>true</hideGenerationTimestam>
<generateBuilders>true</generateBuilders>
<delegatePattern>true</delegatePattern>
</configOptions>
<apiPackage>de.dummy.generated.notifier.rest</apiPackage>
<modelPackage>de.dummy.generated.notifier.rest.domain</modelPackage>
<generateModelTests>true</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<generateSupportingFiles>false</generateSupportingFiles>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<auth>false</auth>
<library>quarkus</library>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
- added the openApi.yml
- configured the plugin in the pom.xml
- executed code generation
Without the configuration of
<apisToGenerate>v1dogs</apisToGenerate>
<modelsToGenerate>Dog,Dogs,Error</modelsToGenerate>
I get the expected result of

But with the configuration I get only the classes for models that I congfigured

the interface file i missing.
Related issues/PRs
Suggest a fix
Maybe it is just a misconfiguration, but I don't see it and i can't find any solution. Or it is a Bug in the Plugin.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the generation from the provided pom.xml and OpenAPI YAML, using the jaxrs-spec generator with apisToGenerate and modelsToGenerate. Trace how the Java generator handles the selected v1dogs operation and inspect the related generation logic. Done means the selected API interface is generated while the requested model filtering still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100