OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][FEIGN] Code generation outputs non-compilable code.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When building with Feign, the generated code can not be compiled because of the missing OAuth.class on the classpath.
When in the JavaClientCodegen.java the classes OauthPasswordGrant.java and OauthClientCredentialsGrant.java get added we need also the OAuth-class to be added because the 2 mentioned classes extend this abstract-class.
This can be seen in the mustache files OauthPasswordGrant.mustache and OauthClientCredentialsGrant.mustache
openapi-generator version
the version I tested is 5.1.1
Generation Details
This codegeneration is run with following gradle-task:
openApiGenerate {
generatorName = "java"
inputSpec = "$buildDir/openapi.json"
outputDir = "$buildDir/generated-client"
apiPackage = "our.package.api"
invokerPackage = "our.package.invoker"
modelPackage = "our.package.model"
configOptions = [
dateLibrary : "java8",
interfaceOnly : "true",
debugModels : "true",
java8 : "true",
ensureUniqueParams: "false",
library : "feign"
]
globalProperties = [
modelDocs: "false"
]
skipValidateSpec = true
logToStderr = true
generateAliasAsModel = false
enablePostProcessFile = false
}
execution of a build with the generated gradle.build results in a compilation error that OAuth.class is not found.
Suggest a fix
add following line in the javaClientCodegen in the if-clause of Feign (if (FEIGN.equals(getLibrary()))):
supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java"));
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 in JavaClientCodegen.java and inspect the Feign branch where supporting files are registered. Compare OauthPasswordGrant.mustache and OauthClientCredentialsGrant.mustache with the available auth templates, then generate a Feign client using the reported Gradle configuration. Done means the generated OAuth.java is present and the generated project compiles without the missing OAuth.class error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100