use of io.swagger.v3.plugin.maven.resources.model.Pet in project swagger-core by swagger-api.
the class ModelSerializerTest method convertModel.
@Test(description = "it should convert a model")
public void convertModel() throws JsonProcessingException {
final Schema pet = new Schema();
final Map<String, Schema> props = new LinkedHashMap<String, Schema>();
props.put("intValue", new IntegerSchema());
props.put("longValue", new IntegerSchema().format("int64"));
props.put("dateValue", new DateSchema());
props.put("dateTimeValue", new DateTimeSchema());
pet.setProperties(props);
pet.setRequired(Arrays.asList("intValue", "name"));
final String json = "{\n" + " \"required\":[\n" + " \"intValue\"\n" + " ],\n" + " \"properties\":{\n" + " \"intValue\":{\n" + " \"type\":\"integer\",\n" + " \"format\":\"int32\"\n" + " },\n" + " \"longValue\":{\n" + " \"type\":\"integer\",\n" + " \"format\":\"int64\"\n" + " },\n" + " \"dateValue\":{\n" + " \"type\":\"string\",\n" + " \"format\":\"date\"\n" + " },\n" + " \"dateTimeValue\":{\n" + " \"type\":\"string\",\n" + " \"format\":\"date-time\"\n" + " }\n" + " }\n" + "}";
SerializationMatchers.assertEqualsToJson(pet, json);
}
use of io.swagger.v3.plugin.maven.resources.model.Pet in project swagger-core by swagger-api.
the class PetData method findPetByTags.
public List<Pet> findPetByTags(String tags) {
String[] tagList = tags.split(",");
List<Pet> result = new ArrayList<Pet>();
for (Pet pet : pets) {
if (null != pet.getTags()) {
for (Tag tag : pet.getTags()) {
for (String tagListString : tagList) {
if (tagListString.equals(tag.getName())) {
result.add(pet);
}
}
}
}
}
return result;
}
use of io.swagger.v3.plugin.maven.resources.model.Pet in project swagger-core by swagger-api.
the class ReaderTest method testResourceWithSubresources.
@Test(description = "test resource with subresources")
public void testResourceWithSubresources() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(ResourceWithSubResource.class);
Paths paths = openAPI.getPaths();
assertEquals(paths.size(), 3);
PathItem pathItem = paths.get("/employees/{id}");
assertNotNull(pathItem);
Operation operation = pathItem.getGet();
assertNotNull(operation);
ArraySchema arraySchema = (ArraySchema) operation.getResponses().get("200").getContent().values().iterator().next().getSchema();
assertNotNull(arraySchema);
assertEquals(arraySchema.getItems().get$ref(), "#/components/schemas/Pet");
pathItem = paths.get("/employees/{id}/{id}");
assertNotNull(pathItem);
operation = pathItem.getGet();
assertNotNull(operation);
Schema schema = operation.getResponses().get("200").getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.get$ref(), "#/components/schemas/Pet");
pathItem = paths.get("/employees/noPath");
assertNotNull(pathItem);
operation = pathItem.getGet();
assertNotNull(operation);
schema = operation.getResponses().getDefault().getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.getType(), "string");
}
use of io.swagger.v3.plugin.maven.resources.model.Pet in project swagger-core by swagger-api.
the class PetData method findPetByStatus.
public List<Pet> findPetByStatus(String status) {
String[] statues = status.split(",");
List<Pet> result = new ArrayList<Pet>();
for (Pet pet : pets) {
for (String s : statues) {
if (s.equals(pet.getStatus())) {
result.add(pet);
}
}
}
return result;
}
use of io.swagger.v3.plugin.maven.resources.model.Pet in project swagger-core by swagger-api.
the class PetData method findPetByTags.
public List<Pet> findPetByTags(String tags) {
String[] tagList = tags.split(",");
List<Pet> result = new ArrayList<Pet>();
for (Pet pet : pets) {
if (null != pet.getTags()) {
for (Tag tag : pet.getTags()) {
for (String tagListString : tagList) {
if (tagListString.equals(tag.getName())) {
result.add(pet);
}
}
}
}
}
return result;
}
Aggregations