OpenAPITools / OpenAPITools/openapi-generator
[7.3.0] Generated code with dependency error in class JSON
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
If generating java code, the resulting JSON class has a dependency to the class com.fasterxml.jackson.databind.util.StdDateFormat even if not using jackson as a dependency
Code with error (JSON.java):
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
My gradle task:
tasks.create(name: "buildClientEcm_${swagFile}", type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
group = "swagger_generation"
**generatorName = "java"**
id = "ecm-client-generated"
inputSpec = "$projectDir/swagger_${swagFile}.json".toString()
outputDir = "$rootDir/ecm-client-generated-${swagFile}".toString()
apiPackage = "it.smi.ie.ecm.client${swagSpec}"
invokerPackage = "it.smi.ie.ecm.client${swagSpec}"
modelPackage = "it.smi.ie.ecm.client.model${swagSpec}"
**configOptions = [
openApiNullable: "false"
]**
}
The generated build gradle dependencies:
implementation 'io.swagger:swagger-annotations:1.6.8'
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'io.gsonfire:gson-fire:1.9.0'
implementation 'javax.ws.rs:jsr311-api:1.1.1'
implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testImplementation 'org.mockito:mockito-core:3.12.4'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
Bug present in 7.3.0 but not in 7.1.0
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
Reproduce the Java generator regression using the shown Gradle GenerateTask and inspect the generated JSON.java for the StdDateFormat reference. Compare output from generator versions 7.1.0 and 7.3.0, then verify that the generated client no longer requires an undeclared Jackson dependency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100