Skip to content
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

[REQ] Please add async support to native java client #6141

Closed
AceHack opened this issue May 3, 2020 · 4 comments
Closed

[REQ] Please add async support to native java client #6141

AceHack opened this issue May 3, 2020 · 4 comments

Comments

@AceHack
Copy link

AceHack commented May 3, 2020

Is your feature request related to a problem? Please describe.

Please add async support to native java client generation
https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/Java/libraries/native

Describe the solution you'd like

I would like to see async methods

@wing328
Copy link
Member

wing328 commented May 3, 2020

Closed via #4721

Please give it a try with the latest master or snapshot version.

@wing328 wing328 closed this as completed May 3, 2020
@AceHack
Copy link
Author

AceHack commented May 3, 2020

Do you have nightly releases for the grade plugin?

@AceHack
Copy link
Author

AceHack commented May 3, 2020

Okay, I finally was able to pull down a snapshot and it does not appear to be working with the Gradle plugin. I get the following error and this should be reopened.

Caused by: java.lang.RuntimeException: Unknown library: asyncNative
Available libraries:
  jersey1
  jersey2
  jersey2-experimental
  feign
  okhttp-gson
  retrofit
  retrofit2
  resttemplate
  webclient
  resteasy
  vertx
  google-api-client
  rest-assured
  native
  microprofile
        at org.openapitools.codegen.DefaultCodegen.setLibrary(DefaultCodegen.java:4725)
        at org.openapitools.codegen.languages.AbstractJavaCodegen.processOpts(AbstractJavaCodegen.java:378)
        at org.openapitools.codegen.languages.JavaClientCodegen.processOpts(JavaClientCodegen.java:211)
        at org.openapitools.codegen.DefaultGenerator.configureGeneratorProperties(DefaultGenerator.java:210)
        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:995)
        at org.openapitools.generator.gradle.plugin.tasks.GenerateTask.doWork(GenerateTask.kt:650)
        ... 95 more

Here is how I made snapshots work with the gradle plugin. I also built with --refresh-dependencies to ensure I was using the latest snapshot.

In build.gradle.kts

plugins {
    java
    id("org.openapi.generator") version "4.3.1-SNAPSHOT"
}

repositories {
    mavenCentral()
    maven("https://oss.sonatype.org/content/repositories/snapshots")
}

tasks.compileJava {
    dependsOn(tasks.openApiGenerate)
}

sourceSets.main {
    java.srcDir(openApiGeneratedDir)
}

openApiGenerate {
    inputSpec.set("https://xxx.yyy.zzz")
    validateSpec.set(true)
    generatorName.set("java")
    engine.set("mustache")
    skipOverwrite.set(false)
    outputDir.set(openApiGeneratedDir)
    apiPackage.set("datalake.subscription.api")
    invokerPackage.set("datalake.subscription.invoker")
    modelPackage.set("datalake.subscription.model")
    generateApiTests.set(false)
    generateApiDocumentation.set(false)
    generateModelTests.set(false)
    generateModelDocumentation.set(false)
    configOptions.set(mapOf(
            "java8" to "true",
            "dateLibrary" to "java8",
            "library" to "asyncNative",
            "serializationLibrary" to "jackson"
    ))
}

in setting.gradle.kts

pluginManagement {
    repositories {
        mavenCentral()
        gradlePluginPortal()
        maven("https://oss.sonatype.org/content/repositories/snapshots")
    }

    resolutionStrategy.eachPlugin {
        if(requested.id.id == "org.openapi.generator") {
            useModule("org.openapitools:openapi-generator-gradle-plugin:${requested.version}")
        }
    }
}

@AceHack
Copy link
Author

AceHack commented May 3, 2020

Scratch that, I changed my config options to the following and now it's working.

    configOptions.set(mapOf(
            "java8" to "true",
            "dateLibrary" to "java8",
            "library" to "native",
            "asyncNative" to "true",
            "serializationLibrary" to "jackson"
    ))

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

2 participants