add test for body parameter example value (#363)

This commit is contained in:
William Cheng 2018-05-08 10:16:48 +08:00 committed by GitHub
parent 0dbb6dcaa6
commit 27b3302d8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -150,11 +150,22 @@ public class RubyClientCodegenTest {
final String path = "/fake"; final String path = "/fake";
final Operation p = openAPI.getPaths().get(path).getGet(); final Operation p = openAPI.getPaths().get(path).getGet();
final CodegenOperation op = codegen.fromOperation(path, "get", p, openAPI.getComponents().getSchemas()); final CodegenOperation op = codegen.fromOperation(path, "get", p, openAPI.getComponents().getSchemas());
Assert.assertEquals(op.formParams.size(), 2); Assert.assertEquals(op.formParams.size(), 2);
CodegenParameter fp = op.formParams.get(0); CodegenParameter fp = op.formParams.get(0);
Assert.assertEquals(fp.dataType, "Array<String>"); Assert.assertEquals(fp.dataType, "Array<String>");
} }
@Test(description = "test example value for body parameter")
public void bodyParameterTest() {
final OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml", null, new ParseOptions()).getOpenAPI();
final RubyClientCodegen codegen = new RubyClientCodegen();
codegen.setModuleName("OnlinePetstore");
final String path = "/pet";
final Operation p = openAPI.getPaths().get(path).getPost();
final CodegenOperation op = codegen.fromOperation(path, "post", p, openAPI.getComponents().getSchemas());
Assert.assertEquals(op.bodyParams.size(), 1);
CodegenParameter bp = op.bodyParams.get(0);
Assert.assertEquals(bp.example, "OnlinePetstore::Pet.new");
}
} }