forked from loafle/openapi-generator-original
Added missing copied properties from CodegenOperation in TypeScriptFetchClientCodegen and ErlangClientCodegen to resolve issue #15457 (#17627)
This commit is contained in:
parent
287e8fc69c
commit
a730fe5048
@ -347,7 +347,7 @@ public class CodegenOperation {
|
||||
sb.append(", isVoid=").append(isVoid);
|
||||
sb.append(", isResponseBinary=").append(isResponseBinary);
|
||||
sb.append(", isResponseFile=").append(isResponseFile);
|
||||
sb.append(", isResponseFile=").append(isResponseOptional);
|
||||
sb.append(", isResponseOptional=").append(isResponseOptional);
|
||||
sb.append(", hasReference=").append(hasReference);
|
||||
sb.append(", hasDefaultResponse=").append(hasDefaultResponse);
|
||||
sb.append(", hasErrorResponseObject=").append(hasErrorResponseObject);
|
||||
|
@ -419,6 +419,8 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
this.isArray = o.isArray;
|
||||
this.isMultipart = o.isMultipart;
|
||||
this.isResponseBinary = o.isResponseBinary;
|
||||
this.isResponseFile = o.isResponseFile;
|
||||
this.isResponseOptional = o.isResponseOptional;
|
||||
this.hasReference = o.hasReference;
|
||||
this.isRestfulIndex = o.isRestfulIndex;
|
||||
this.isRestfulShow = o.isRestfulShow;
|
||||
|
@ -1303,6 +1303,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.isMultipart = o.isMultipart;
|
||||
this.isResponseBinary = o.isResponseBinary;
|
||||
this.isResponseFile = o.isResponseFile;
|
||||
this.isResponseOptional = o.isResponseOptional;
|
||||
this.hasReference = o.hasReference;
|
||||
this.isRestfulIndex = o.isRestfulIndex;
|
||||
this.isRestfulShow = o.isRestfulShow;
|
||||
|
@ -74,6 +74,16 @@ public class DefaultCodegenTest {
|
||||
Assert.assertEquals(Sets.intersection(operation.imports, Sets.newHashSet("Person")).size(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionalResponseImports() {
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final OpenAPI openApi = TestUtils.parseFlattenSpec("src/test/resources/3_0/optionalResponse.yaml");
|
||||
codegen.setOpenAPI(openApi);
|
||||
PathItem path = openApi.getPaths().get("/api/Users/{userId}");
|
||||
CodegenOperation operation = codegen.fromOperation("/api/Users/{userId}", "get", path.getGet(), path.getServers());
|
||||
Assert.assertEquals(operation.isResponseOptional, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnumImports() {
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
|
@ -1,11 +1,13 @@
|
||||
package org.openapitools.codegen.typescript.fetch;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.PathItem;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.MapSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
import org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen;
|
||||
@ -43,6 +45,16 @@ public class TypeScriptFetchClientCodegenTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionalResponseImports() {
|
||||
TypeScriptFetchClientCodegen codegen = new TypeScriptFetchClientCodegen();
|
||||
final OpenAPI openApi = TestUtils.parseFlattenSpec("src/test/resources/3_0/optionalResponse.yaml");
|
||||
codegen.setOpenAPI(openApi);
|
||||
PathItem path = openApi.getPaths().get("/api/Users/{userId}");
|
||||
CodegenOperation operation = codegen.fromOperation("/api/Users/{userId}", "get", path.getGet(), path.getServers());
|
||||
Assert.assertEquals(operation.isResponseOptional, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithoutSnapshotVersion() {
|
||||
OpenAPI api = TestUtils.createOpenAPI();
|
||||
|
@ -0,0 +1,48 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: My Sample User API
|
||||
version: '1.0'
|
||||
paths:
|
||||
/api/Users/{userId}:
|
||||
get:
|
||||
tags:
|
||||
- Users
|
||||
summary: Get a specific user
|
||||
operationId: GetUserById
|
||||
parameters:
|
||||
- name: userId
|
||||
in: path
|
||||
description: ID of the user
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UserDto'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UserDto'
|
||||
text/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UserDto'
|
||||
'204':
|
||||
description: No Content
|
||||
components:
|
||||
schemas:
|
||||
UserDto:
|
||||
required:
|
||||
- id
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
name:
|
||||
type: string
|
||||
nullable: true
|
||||
additionalProperties: false
|
Loading…
x
Reference in New Issue
Block a user