Reputation: 21
I have a Swagger file and the Maven plugin generates a big API class for me. How would I have to set the plugin to create one endpoint per API class?
The current config of the plugin is:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.2.0</version>
<executions>
<execution>
<id>swagger-codegen-fbs4me</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/openapi/CarAPI_v0.2.yaml</inputSpec>
<generatorName>spring</generatorName>
<library>spring-boot</library>
<skipValidateSpec>true</skipValidateSpec>
<configHelp>false</configHelp>
<templateDirectory>${project.basedir}/src/main/resources/templates</templateDirectory>
<configOptions>
<delegatePattern>false</delegatePattern>
<apiPackage>com.ger.car.somewhere.clients</apiPackage>
<modelPackage>com.ger.car.somewhere.model</modelPackage>
<dateLibrary>java8</dateLibrary>
<java8>true</java8>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 1
Views: 5306
Reputation: 41
To make openAPI generator generate one client class per endpoint you could try having separate tags for the endpoints in your openapi spec, this method can create separate API client classes. I.E:
/myEndpoint/{myParam}/:
parameters:
- name: myParam
in: path
required: true
schema:
type: string
get:
tags:
- {unique tag for this endpoint}
Upvotes: 3