En Intellij IDEA estoy probando este código. Cree un proyecto con Gradle, Java 1.8. Tengo el SDK correcto. Basicamente los imports de org.openapitools no funcionan, y ya no se que dependencias poner porque probe muchísimas cosas pero ninguna anda.
El código de a continuación es de un SDK de communications de AVALARA. Lo que quiero es probar esto, pero no puedo hacerlo andar.
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.auth.*;
import org.openapitools.client.models.*;
import org.openapitools.client.api.CustomizationApi;
public class Example {
public static void main(String() args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost");
CustomizationApi apiInstance = new CustomizationApi(defaultClient);
Integer requestedClientId = 56; // Integer | Client id associated with profile(s) to be fetched Null value will use client id submitting the request or default client id as applicable.
Integer requestedProfileId = 56; // Integer | Configuration profile id to be fetched Use 0 to indicate all profiles Null value will use profile id from request or 0 if not set.
TaxCalculationSettingTypes itemType = new TaxCalculationSettingTypes(); // TaxCalculationSettingTypes | Item Type Examples: Configuration, Bundle, Exclusion, Override, All
try {
TaxCalculationSettingsResponse result = apiInstance.apiV2ProfilesGetProfilesGet(requestedClientId, requestedProfileId, itemType);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CustomizationApi#apiV2ProfilesGetProfilesGet");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
Pero no me reconoce ningun import. En build.gradle
tengo esto:
buildscript {
repositories {
mavenLocal()
maven { url "https://repo1.maven.org/maven2" }
}
dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:3.3.4"
}
}
plugins {
id 'java'
id "org.openapi.generator" version "4.3.1"
}
apply plugin: 'org.openapi.generator'
También probe esto en build.gradle
y tampoco:
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
// https://mvnrepository.com/artifact/org.openapitools/openapi-generator
compile group: 'org.openapitools', name: 'openapi-generator', version: '4.3.1'
}
UPDATE: Recien viendo la configuración de Intellij, me aparece que el Gradle JVM
no reconoce al JAVA_HOME
. No se si tiene que ver o no, porque en realidad tenia la opción de Project SDK. La cambie por las otras, que es la 1.8, y tampoco nada.