Skip to content

Commit

Permalink
Merge pull request #232 from swagger-api/support-not
Browse files Browse the repository at this point in the history
Support of NOT - refs ticket #215
  • Loading branch information
gracekarina authored Jan 3, 2018
2 parents baefe48 + 5215b68 commit 3600d52
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public ResponseContext inlineRequiredBody(RequestContext request, com.fasterxml.
.entity("success!");
}

public ResponseContext updatePet(RequestContext request, com.fasterxml.jackson.databind.JsonNode petType) {
return new ResponseContext()
.status(200)
.entity("OK!");
}

public ResponseContext formTest(RequestContext request, String user) {
return new ResponseContext()
.status(Status.OK)
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/io/swagger/oas/test/integration/RequestTestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,30 @@ public void verifyModelMappingFromExtensions() throws Exception {
assertEquals(str, "{\"street\":\"3 street\"}");
}

@Test
public void verifyNotSupport() throws Exception {
Map<String,String> body = new HashMap<>();
body.put("pet_type","Cat");

String path = "/pets";
String str = client.invokeAPI(path, "POST", new HashMap<String, String>(), body, new HashMap<String, String>(), null, "application/json", null, new String[0]);
assertEquals(str, "OK!");
}

@Test
public void verifyNotSupportByFailling() throws Exception {
Map<String,Integer> body = new HashMap<>();
body.put("pet_type",31);

String path = "/pets";
try {
client.invokeAPI(path, "POST", new HashMap<String, String>(), body, new HashMap<String, String>(), null, "application/json", null, new String[0]);
Assert.fail("No exception was thrown");
} catch (ApiException e) {
Assert.assertEquals(e.getCode(), HttpURLConnection.HTTP_BAD_REQUEST);
}
}

@Test
public void verifyArrayModelMapping() throws Exception {
final Address first = new Address();
Expand Down
20 changes: 20 additions & 0 deletions src/test/swagger/oas3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ tags:
description: Find out more about our store
url: http://swagger.io
paths:
/pets:
post:
x-swagger-router-controller: TestController
operationId: updatePet
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PetByType'
responses:
'200':
description: Updated
/mockResponses/objectMultipleExamples:
get:
responses:
Expand Down Expand Up @@ -1052,6 +1064,14 @@ externalDocs:
url: http://swagger.io
components:
schemas:
PetByType:
type: object
properties:
pet_type:
not:
type: integer
required:
- pet_type
Water:
properties:
clear:
Expand Down

0 comments on commit 3600d52

Please sign in to comment.