mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 02:55:19 +00:00
Consider cases where complexType is null (#680)
This commit is contained in:
parent
3c3ac0a071
commit
14ab3d763e
@ -4423,7 +4423,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(bodyParameterName)) {
|
||||
codegenParameter.baseName = mostInnerItem.complexType;
|
||||
if(StringUtils.isEmpty(mostInnerItem.complexType)) {
|
||||
codegenParameter.baseName = "request_body";
|
||||
} else {
|
||||
codegenParameter.baseName = mostInnerItem.complexType;
|
||||
}
|
||||
} else {
|
||||
codegenParameter.baseName = bodyParameterName;
|
||||
}
|
||||
|
@ -17,11 +17,17 @@
|
||||
|
||||
package org.openapitools.codegen.perl;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.languages.PerlClientCodegen;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class PerlClientCodegenTest {
|
||||
|
||||
@ -54,4 +60,14 @@ public class PerlClientCodegenTest {
|
||||
Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIssue677() {
|
||||
final OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/3_0/issue677.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
final PerlClientCodegen codegen = new PerlClientCodegen();
|
||||
|
||||
Operation operation = openAPI.getPaths().get("/issue677").getPost();
|
||||
CodegenOperation co = codegen.fromOperation("/issue677", "POST", operation, ModelUtils.getSchemas(openAPI), openAPI);
|
||||
Assert.assertNotNull(co);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: My title
|
||||
description: API under test
|
||||
version: 1.0.7
|
||||
servers:
|
||||
- url: https://localhost:9999/root
|
||||
paths:
|
||||
/issue677:
|
||||
post:
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
responses:
|
||||
201:
|
||||
description: OK
|
||||
components: {}
|
Loading…
Reference in New Issue
Block a user