Skip to content

Commit

Permalink
updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
fehguy committed Feb 22, 2017
2 parents 6f70fa8 + 8c466c2 commit b87723f
Showing 1 changed file with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public void testCodegenPetstore() {
assertNotNull(orderIdPathParam.getMinimum());

BigDecimal minimum = orderIdPathParam.getMinimum();
assertEquals(minimum.toString(), "1.0");
assertEquals(minimum.toString(), "1");

FormParameter formParam = (FormParameter)swagger.getPath("/fake").getPost().getParameters().get(3);

Expand All @@ -689,4 +689,76 @@ public void testIssue339() throws Exception {
assertTrue(pp.getMinimum().toString().equals("1"));
assertTrue(pp.getMaximum().toString().equals("5"));
}

@Test
public void testCodegenIssue4555() throws Exception {
SwaggerParser parser = new SwaggerParser();
String yaml = "swagger: '2.0'\n" +
"\n" +
"info:\n" +
" title: test\n" +
" version: \"0.0.1\"\n" +
"\n" +
"schemes:\n" +
" - http\n" +
"produces:\n" +
" - application/json\n" +
"\n" +
"paths:\n" +
" /contents/{id}:\n" +
" parameters:\n" +
" - name: id\n" +
" in: path\n" +
" description: test\n" +
" required: true\n" +
" type: integer\n" +
"\n" +
" get:\n" +
" description: test\n" +
" responses:\n" +
" 200:\n" +
" description: OK\n" +
" schema:\n" +
" $ref: '#/definitions/Content'\n" +
"\n" +
"definitions:\n" +
" Content:\n" +
" type: object\n" +
" title: \t\ttest";
final SwaggerDeserializationResult result = parser.readWithInfo(yaml);

// can't parse with tabs!
assertNull(result.getSwagger());
}

@Test
public void testIssue393() {
SwaggerParser parser = new SwaggerParser();

String yaml =
"swagger: '2.0'\n" +
"info:\n" +
" title: x\n" +
" version: 1.0.0\n" +
"paths:\n" +
" /test:\n" +
" get:\n" +
" parameters: []\n" +
" responses:\n" +
" '400':\n" +
" description: |\n" +
" The account could not be created because a credential didn't meet the complexity requirements.\n" +
" x-error-refs:\n" +
" - '$ref': '#/x-error-defs/credentialTooShort'\n" +
" - '$ref': '#/x-error-defs/credentialTooLong'\n" +
"x-error-defs:\n" +
" credentialTooShort:\n" +
" errorID: credentialTooShort";
final SwaggerDeserializationResult result = parser.readWithInfo(yaml);

assertNotNull(result.getSwagger());
Swagger swagger = result.getSwagger();

assertNotNull(swagger.getVendorExtensions().get("x-error-defs"));
}
}

0 comments on commit b87723f

Please sign in to comment.