Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One of property creation missed #590

Merged
merged 11 commits into from
Jan 29, 2020
Prev Previous commit
Next Next commit
added tests for csharp generator
  • Loading branch information
HugoMario committed Jan 29, 2020
commit 2dac5d15bc0d8f1eb43fbc4b0a92b58f42f46d0f
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.swagger.codegen.v3.generators.dotnet;

import io.swagger.codegen.v3.CodegenConfig;
import io.swagger.codegen.v3.CodegenModel;
import io.swagger.codegen.v3.ISchemaHandler;
import io.swagger.codegen.v3.generators.AbstractCodegenTest;
import io.swagger.codegen.v3.generators.CodegenWrapper;
import io.swagger.v3.oas.models.OpenAPI;
import org.testng.Assert;
import org.testng.annotations.Test;

public class CSharpClientCodegenTest extends AbstractCodegenTest {

@Test
public void checkOneOfModelCreation() {
final OpenAPI openAPI = getOpenAPI("3_0_0/composed_schemas.yaml");
final CodegenConfig config = new CSharpClientCodegen();
final CodegenWrapper codegenWrapper = processSchemas(config, openAPI);

CodegenModel codegenModel = codegenWrapper.getAllModels().get("PartMaster");

boolean hasOneOfProperty = codegenModel.getVars()
.stream()
.anyMatch(codegenProperty -> codegenProperty.datatype.equals("OneOfPartMasterDestination"));

Assert.assertTrue(hasOneOfProperty);

hasOneOfProperty = codegenModel.getVars()
.stream()
.anyMatch(codegenProperty -> codegenProperty.datatype.equals("OneOfPartMasterOrigin"));

Assert.assertTrue(hasOneOfProperty);

final ISchemaHandler schemaHandler = codegenWrapper.getSchemaHandler();

boolean hasComposedModel = schemaHandler.getModels()
.stream()
.anyMatch(model -> model.name.equals("OneOfPartMasterDestination"));

Assert.assertTrue(hasComposedModel);

hasComposedModel = schemaHandler.getModels()
.stream()
.anyMatch(model -> model.name.equals("OneOfPartMasterOrigin"));

Assert.assertTrue(hasComposedModel);
}
}