Skip to content

Commit 713aa92

Browse files
authored
add tests for 18772 (#18828)
1 parent c08afa3 commit 713aa92

File tree

68 files changed

+25
-5160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+25
-5160
lines changed

bin/configs/csharp-generichost-net8-oneOf-3.1.0.yaml

-14
This file was deleted.

modules/openapi-generator/src/test/java/org/openapitools/codegen/csharpnetcore/CSharpClientCodegenTest.java

+25
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,29 @@ public void testHandleConstantParams() throws IOException {
116116
assertFileContains(apiFile.toPath(),
117117
"localVarRequestOptions.HeaderParameters.Add(\"X-CUSTOM_CONSTANT_HEADER\", Org.OpenAPITools.Client.ClientUtils.ParameterToString(\"CONSTANT_VALUE\"));");
118118
}
119+
120+
@Test
121+
public void test31specAdditionalPropertiesOfOneOf() throws IOException {
122+
// for https://github.com/OpenAPITools/openapi-generator/pull/18772
123+
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
124+
output.deleteOnExit();
125+
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_1/csharp/additional_properties_oneof.yaml");
126+
final DefaultGenerator defaultGenerator = new DefaultGenerator();
127+
final ClientOptInput clientOptInput = new ClientOptInput();
128+
clientOptInput.openAPI(openAPI);
129+
CSharpClientCodegen cSharpClientCodegen = new CSharpClientCodegen();
130+
cSharpClientCodegen.setOutputDir(output.getAbsolutePath());
131+
cSharpClientCodegen.setAutosetConstants(true);
132+
clientOptInput.config(cSharpClientCodegen);
133+
defaultGenerator.opts(clientOptInput);
134+
135+
Map<String, File> files = defaultGenerator.generate().stream()
136+
.collect(Collectors.toMap(File::getPath, Function.identity()));
137+
138+
File modelFile = files
139+
.get(Paths.get(output.getAbsolutePath(), "src", "Org.OpenAPITools", "Model", "Response.cs").toString());
140+
assertNotNull(modelFile);
141+
assertFileContains(modelFile.toPath(),
142+
" Dictionary<string, ResponseResultsValue> results = default(Dictionary<string, ResponseResultsValue>");
143+
}
119144
}

0 commit comments

Comments
 (0)