add a test for generateParameterId (#20256)

This commit is contained in:
William Cheng 2024-12-05 12:59:26 +08:00 committed by GitHub
parent b2507777e6
commit 6ba311e85c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 63 additions and 1 deletions

View File

@ -3210,4 +3210,28 @@ public class JavaClientCodegenTest {
);
}
}
@Test
public void testGenerateParameterId() {
final Path output = newTempFolder();
final CodegenConfigurator configurator = new CodegenConfigurator()
.setValidateSpec(false)
.setGeneratorName("java")
.setAdditionalProperties(Map.of(
CodegenConstants.API_PACKAGE, "xyz.abcdef.api"
))
.setInputSpec("src/test/resources/3_1/issue_20239.yaml")
.setOutputDir(output.toString().replace("\\", "/"));
new DefaultGenerator().opts(configurator.toClientOptInput()).generate();
TestUtils.assertFileContains(
output.resolve("src/main/java/xyz/abcdef/api/ATagApi.java"),
" getCall(String pathParameter, Integer queryParameter, final ApiCallback _callback)"
);
TestUtils.assertFileNotContains(
output.resolve("src/main/java/xyz/abcdef/api/ATagApi.java"),
" getCall(Integer queryParameter, final ApiCallback _callback)"
);
}
}

View File

@ -0,0 +1,38 @@
openapi: 3.1.0
info:
title: API Overview
version: "v1"
description: description
tags:
- name: aTag
paths:
"/path/{path_parameter}":
parameters:
- $ref: "#/components/parameters/path_parameter"
get:
tags:
- aTag
operationId: get
parameters:
- $ref: "#/components/parameters/query_parameter"
responses:
"200":
description: no body
components:
parameters:
path_parameter:
name: path_parameter
in: path
required: true
schema:
type: string
query_parameter:
name: query_parameter
in: query
schema:
type: integer
minimum: 0
default: 0