forked from loafle/openapi-generator-original
[Kotlin][Retrofit2] fix missing import for file (#7121)
* fix missing import for file * test in shippable * test retrofit2 fx3 kotlin sample * add pom.xml
This commit is contained in:
parent
9f1d012d14
commit
aa698633b3
@ -627,6 +627,13 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// import okhttp3.MultipartBody if any parameter is a file
|
||||||
|
for (CodegenParameter param : operation.allParams) {
|
||||||
|
if (Boolean.TRUE.equals(param.isFile)) {
|
||||||
|
operations.put("x-kotlin-multipart-import", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {
|
if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {
|
||||||
operation.path = operation.path.substring(1);
|
operation.path = operation.path.substring(1);
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,12 @@ import io.reactivex.rxjava3.core.Completable;
|
|||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
|
{{#x-kotlin-multipart-import}}
|
||||||
|
{{^isMultipart}}
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
|
||||||
|
{{/isMultipart}}
|
||||||
|
{{/x-kotlin-multipart-import}}
|
||||||
interface {{classname}} {
|
interface {{classname}} {
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
/**
|
/**
|
||||||
@ -76,4 +82,4 @@ interface {{classname}} {
|
|||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
2
pom.xml
2
pom.xml
@ -1360,6 +1360,8 @@
|
|||||||
<module>samples/client/petstore/erlang-proper</module>
|
<module>samples/client/petstore/erlang-proper</module>
|
||||||
<module>samples/client/petstore/kotlin-multiplatform</module>
|
<module>samples/client/petstore/kotlin-multiplatform</module>
|
||||||
<!--<module>samples/client/petstore/kotlin/</module>-->
|
<!--<module>samples/client/petstore/kotlin/</module>-->
|
||||||
|
<module>samples/client/petstore/kotlin-retrofit2</module>
|
||||||
|
<module>samples/client/petstore/kotlin-retrofit2-rx3</module>
|
||||||
<module>samples/client/petstore/kotlin-jackson/</module>
|
<module>samples/client/petstore/kotlin-jackson/</module>
|
||||||
<module>samples/client/petstore/kotlin-gson/</module>
|
<module>samples/client/petstore/kotlin-gson/</module>
|
||||||
<module>samples/client/petstore/kotlin-nonpublic/</module>
|
<module>samples/client/petstore/kotlin-nonpublic/</module>
|
||||||
|
46
samples/client/petstore/kotlin-retrofit2-rx3/pom.xml
Normal file
46
samples/client/petstore/kotlin-retrofit2-rx3/pom.xml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>KotlinRetrofit2Rx3PetstoreClientTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>Kotlin Retrofit2 Rx3 Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>bundle-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>gradle</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -9,6 +9,8 @@ import io.reactivex.rxjava3.core.Completable;
|
|||||||
import org.openapitools.client.models.ApiResponse
|
import org.openapitools.client.models.ApiResponse
|
||||||
import org.openapitools.client.models.Pet
|
import org.openapitools.client.models.Pet
|
||||||
|
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
|
||||||
interface PetApi {
|
interface PetApi {
|
||||||
/**
|
/**
|
||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
|
46
samples/client/petstore/kotlin-retrofit2/pom.xml
Normal file
46
samples/client/petstore/kotlin-retrofit2/pom.xml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>KotlinRetrofit2PetstoreClientTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>Kotlin Retrofit2 Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>bundle-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>gradle</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -8,6 +8,8 @@ import okhttp3.RequestBody
|
|||||||
import org.openapitools.client.models.ApiResponse
|
import org.openapitools.client.models.ApiResponse
|
||||||
import org.openapitools.client.models.Pet
|
import org.openapitools.client.models.Pet
|
||||||
|
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
|
||||||
interface PetApi {
|
interface PetApi {
|
||||||
/**
|
/**
|
||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
|
Loading…
x
Reference in New Issue
Block a user