Skip to content

[7.3.0] Generated code with dependency error in class JSON #17929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alecar-smi opened this issue Feb 22, 2024 · 2 comments
Open

[7.3.0] Generated code with dependency error in class JSON #17929

alecar-smi opened this issue Feb 22, 2024 · 2 comments

Comments

@alecar-smi
Copy link

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

@guitaoliu
Copy link

Introduced in #17052

@Philzen
Copy link
Contributor

Philzen commented Jun 2, 2024

@alecar-smi This should be fixed now via #18811

Kindly retest on master-branch (there are also pregenerated samples, you'd be looking for samples/client/petstore/java/okhttp-* which you can easily try out without needing to build the project) or when v7.7.0 comes out and close this issue if you're happy with the result 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants