forked from loafle/openapi-generator-original
* [kotlin-spring] fix #9902 use flow for arrays in delegate * [kotlin-spring] fix #9902 only use flow for arrays in delegate for bodyParams
This commit is contained in:
parent
2ff8bd9f32
commit
8b74053c7c
@ -9,9 +9,6 @@ import org.springframework.web.context.request.NativeWebRequest
|
|||||||
import org.springframework.core.io.Resource
|
import org.springframework.core.io.Resource
|
||||||
{{#reactive}}
|
{{#reactive}}
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import org.springframework.web.server.ServerWebExchange
|
|
||||||
import reactor.core.publisher.Flux
|
|
||||||
import reactor.core.publisher.Mono
|
|
||||||
{{/reactive}}
|
{{/reactive}}
|
||||||
|
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
@ -33,7 +30,7 @@ interface {{classname}}Delegate {
|
|||||||
/**
|
/**
|
||||||
* @see {{classname}}#{{operationId}}
|
* @see {{classname}}#{{operationId}}
|
||||||
*/
|
*/
|
||||||
{{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{paramName}}: {{^isFile}}{{>optionalDataType}}{{/isFile}}{{#isFile}}Resource?{{/isFile}}{{^-last}},
|
{{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{paramName}}: {{^isFile}}{{^reactive}}{{>optionalDataType}}{{/reactive}}{{#reactive}}{{^isArray}}{{>optionalDataType}}{{/isArray}}{{#isArray}}{{#isBodyParam}}Flow<{{{baseType}}}>{{/isBodyParam}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{/isArray}}{{/reactive}}{{/isFile}}{{#isFile}}Resource?{{/isFile}}{{^-last}},
|
||||||
{{/-last}}{{/allParams}}): {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {
|
{{/-last}}{{/allParams}}): {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {
|
||||||
{{>methodBody}}
|
{{>methodBody}}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
package org.openapitools.codegen.kotlin.spring;
|
package org.openapitools.codegen.kotlin.spring;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
||||||
|
import static org.openapitools.codegen.TestUtils.assertFileNotContains;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.testing.Helpers;
|
import com.google.common.collect.testing.Helpers;
|
||||||
import io.swagger.parser.OpenAPIParser;
|
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
|
||||||
import io.swagger.v3.oas.models.info.Info;
|
|
||||||
import io.swagger.v3.oas.models.servers.Server;
|
|
||||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.openapitools.codegen.ClientOptInput;
|
import org.openapitools.codegen.ClientOptInput;
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
@ -17,15 +23,11 @@ import org.openapitools.codegen.languages.features.CXFServerFeatures;
|
|||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import io.swagger.parser.OpenAPIParser;
|
||||||
import java.io.IOException;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import java.nio.file.Files;
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
import java.nio.file.Paths;
|
import io.swagger.v3.oas.models.servers.Server;
|
||||||
import java.util.Collections;
|
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
|
||||||
import static org.openapitools.codegen.TestUtils.assertFileNotContains;
|
|
||||||
|
|
||||||
public class KotlinSpringServerCodegenTest {
|
public class KotlinSpringServerCodegenTest {
|
||||||
|
|
||||||
@ -236,7 +238,10 @@ public class KotlinSpringServerCodegenTest {
|
|||||||
new File(output, "src/main/kotlin/org/openapitools/api/TestV1ApiDelegate.kt"),
|
new File(output, "src/main/kotlin/org/openapitools/api/TestV1ApiDelegate.kt"),
|
||||||
new File(output, "src/main/kotlin/org/openapitools/api/TestV2Api.kt"),
|
new File(output, "src/main/kotlin/org/openapitools/api/TestV2Api.kt"),
|
||||||
new File(output, "src/main/kotlin/org/openapitools/api/TestV2ApiController.kt"),
|
new File(output, "src/main/kotlin/org/openapitools/api/TestV2ApiController.kt"),
|
||||||
new File(output, "src/main/kotlin/org/openapitools/api/TestV2ApiDelegate.kt")
|
new File(output, "src/main/kotlin/org/openapitools/api/TestV2ApiDelegate.kt"),
|
||||||
|
new File(output, "src/main/kotlin/org/openapitools/api/TestV3Api.kt"),
|
||||||
|
new File(output, "src/main/kotlin/org/openapitools/api/TestV3ApiController.kt"),
|
||||||
|
new File(output, "src/main/kotlin/org/openapitools/api/TestV3ApiDelegate.kt")
|
||||||
);
|
);
|
||||||
|
|
||||||
assertFileContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV1Api.kt"),
|
assertFileContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV1Api.kt"),
|
||||||
@ -253,9 +258,18 @@ public class KotlinSpringServerCodegenTest {
|
|||||||
assertFileNotContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV2Api.kt"),
|
assertFileNotContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV2Api.kt"),
|
||||||
"exchange");
|
"exchange");
|
||||||
assertFileContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV2ApiDelegate.kt"),
|
assertFileContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV2ApiDelegate.kt"),
|
||||||
"import kotlinx.coroutines.flow.Flow");
|
"import kotlinx.coroutines.flow.Flow", "ResponseEntity<Flow<kotlin.String>>");
|
||||||
assertFileNotContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV2ApiDelegate.kt"),
|
assertFileNotContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV2ApiDelegate.kt"),
|
||||||
"suspend fun", "ApiUtil");
|
"suspend fun", "ApiUtil");
|
||||||
|
|
||||||
|
assertFileContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV3Api.kt"),
|
||||||
|
"import kotlinx.coroutines.flow.Flow", "requestBody: Flow<kotlin.Long>");
|
||||||
|
assertFileNotContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV3Api.kt"),
|
||||||
|
"exchange");
|
||||||
|
assertFileContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV3ApiDelegate.kt"),
|
||||||
|
"import kotlinx.coroutines.flow.Flow", "suspend fun", "requestBody: Flow<kotlin.Long>");
|
||||||
|
assertFileNotContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV3ApiDelegate.kt"),
|
||||||
|
"ApiUtil");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -32,4 +32,18 @@ paths:
|
|||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
/api/v3/test:
|
||||||
|
post:
|
||||||
|
tags: [Test v3]
|
||||||
|
operationId: test3
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
responses:
|
||||||
|
202:
|
||||||
|
description: OK
|
||||||
|
Loading…
x
Reference in New Issue
Block a user