Open caleb-cushing0-kr opened 9 months ago
You can achieve this with Configuration.generateApis=false Configuration.generateSupportingFiles=false And configOptions.library=resttemplate
for some reason I get okhttp and gson errors
/Users/ccushing/IdeaProjects/cg-customer-platform-clients/groups-client/build/generated/sources/openapi/src/main/java/com/myorg/cg/clients/groups/MetadataDetail.java:38: error: package com.google.gson.stream does not exist
import com.google.gson.stream.JsonReader;
symbol: class JsonElement
location: class MemberDetail
/Users/ccushing/IdeaProjects/cg-customer-platform-clients/groups-client/build/generated/sources/openapi/src/main/java/com/myorg/cg/clients/ApiClient.java:17: error: package okhttp3.internal.http does not exist
import okhttp3.internal.http.HttpMethod;
openApiGenerate {
generatorName = "java"
library = "resttemplate"
inputSpec = "$projectDir/src/main/resources/openapi.json".toString()
outputDir = layout.buildDirectory.dir("generated/sources/openapi").get().toString()
configOptions.putAll([
openApiNullable : "false",
generateApis : "false",
generateSupportingFiles: "false",
serializationLibrary : "jackson",
])
ignoreFileOverride = "$projectDir/.openapi-generator-ignore"
generateSupportingFiles is a configuration property, not a configOptions.
this works for me using the maven plugin
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.6.0</version>
<executions>
<execution>
<id>generate-api-spring</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>${openapi.file}</inputSpec>
<generatorName>java</generatorName>
<modelPackage>be.jpfinne.model</modelPackage>
<generateSupportingFiles>true</generateSupportingFiles>
<modelNameSuffix/>
<generateApis>false</generateApis>
<generateModelDocumentation>false</generateModelDocumentation>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<library>resttemplate</library>
<useJakartaEe>true</useJakartaEe>
<dateLibrary>java8</dateLibrary>
</configOptions>
</configuration>
</execution>
</executions>
<dependencies/>
</plugin>
> Could not set unknown property 'generateSupportingFiles' for extension 'openApiGenerate' of type org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGenerateExtension.
not documented https://openapi-generator.tech/docs/generators/java/
I see it in the maven plugin: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.md
Maybe this works:
supportingFilesConstrainedTo = emptyList()
But the result seems to be the same in my project
This seems to fulfil your requirements:
modelFilesConstrainedTo = listOf("")
apiFilesConstrainedTo = listOf("")
but for my case I just wanted all sources and none of the build files, so I need to include some supporting files as well:
supportingFilesConstrainedTo =
listOf(
// base package
"ApiClient",
"JavaTimeFormatter",
"RFC3339DateFormat",
"ServerConfiguration",
"ServerVariable",
"StringUtil",
// auth
"ApiKeyAuth",
"Authentication",
"HttpBasicAuth",
"HttpBearerAuth",
)
.map { "$it.java" }
modelFilesConstrainedTo = listOf("")
apiFilesConstrainedTo = listOf("")
Is your feature request related to a problem? Please describe.
I don't like the way client code is generated. I want to implement my own and let openapi-generator take care of simply generating the DTO classes. E.g. I want to just generate classes with Jackson annotations
Describe the solution you'd like
support a library
none
and generate code using theserializationLibrary
only.