Skip to content

Commit

Permalink
add tests for 18772 (OpenAPITools#18828)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored Jun 2, 2024
1 parent c08afa3 commit 713aa92
Show file tree
Hide file tree
Showing 68 changed files with 25 additions and 5,160 deletions.
14 changes: 0 additions & 14 deletions bin/configs/csharp-generichost-net8-oneOf-3.1.0.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,29 @@ public void testHandleConstantParams() throws IOException {
assertFileContains(apiFile.toPath(),
"localVarRequestOptions.HeaderParameters.Add(\"X-CUSTOM_CONSTANT_HEADER\", Org.OpenAPITools.Client.ClientUtils.ParameterToString(\"CONSTANT_VALUE\"));");
}

@Test
public void test31specAdditionalPropertiesOfOneOf() throws IOException {
// for https://github.com/OpenAPITools/openapi-generator/pull/18772
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
output.deleteOnExit();
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_1/csharp/additional_properties_oneof.yaml");
final DefaultGenerator defaultGenerator = new DefaultGenerator();
final ClientOptInput clientOptInput = new ClientOptInput();
clientOptInput.openAPI(openAPI);
CSharpClientCodegen cSharpClientCodegen = new CSharpClientCodegen();
cSharpClientCodegen.setOutputDir(output.getAbsolutePath());
cSharpClientCodegen.setAutosetConstants(true);
clientOptInput.config(cSharpClientCodegen);
defaultGenerator.opts(clientOptInput);

Map<String, File> files = defaultGenerator.generate().stream()
.collect(Collectors.toMap(File::getPath, Function.identity()));

File modelFile = files
.get(Paths.get(output.getAbsolutePath(), "src", "Org.OpenAPITools", "Model", "Response.cs").toString());
assertNotNull(modelFile);
assertFileContains(modelFile.toPath(),
" Dictionary<string, ResponseResultsValue> results = default(Dictionary<string, ResponseResultsValue>");
}
}
Loading

0 comments on commit 713aa92

Please sign in to comment.