Search in sources :

Example 81 with Pet

use of io.swagger.v3.jaxrs2.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;
}
Also used : ArrayList(java.util.ArrayList) Tag(io.swagger.v3.plugins.gradle.resources.model.Tag) Pet(io.swagger.v3.plugins.gradle.resources.model.Pet)

Example 82 with Pet

use of io.swagger.v3.jaxrs2.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");
}
Also used : PathItem(io.swagger.v3.oas.models.PathItem) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) Schema(io.swagger.v3.oas.models.media.Schema) Paths(io.swagger.v3.oas.models.Paths) Operation(io.swagger.v3.oas.models.Operation) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Test(org.testng.annotations.Test)

Example 83 with Pet

use of io.swagger.v3.jaxrs2.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;
}
Also used : ArrayList(java.util.ArrayList) Pet(io.swagger.v3.jaxrs2.resources.model.Pet)

Example 84 with Pet

use of io.swagger.v3.jaxrs2.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;
}
Also used : ArrayList(java.util.ArrayList) Tag(io.swagger.v3.jaxrs2.resources.model.Tag) Pet(io.swagger.v3.jaxrs2.resources.model.Pet)

Example 85 with Pet

use of io.swagger.v3.jaxrs2.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;
}
Also used : ArrayList(java.util.ArrayList) Pet(io.swagger.v3.plugin.maven.resources.model.Pet)

Aggregations

Test (org.testng.annotations.Test)69 OpenAPI (io.swagger.v3.oas.models.OpenAPI)60 SwaggerParseResult (io.swagger.v3.parser.core.models.SwaggerParseResult)37 Schema (io.swagger.v3.oas.models.media.Schema)32 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)28 OpenAPIV3Parser (io.swagger.v3.parser.OpenAPIV3Parser)28 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)24 StringSchema (io.swagger.v3.oas.models.media.StringSchema)24 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)20 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)17 ParseOptions (io.swagger.v3.parser.core.models.ParseOptions)17 PathItem (io.swagger.v3.oas.models.PathItem)16 ByteArraySchema (io.swagger.v3.oas.models.media.ByteArraySchema)15 MapSchema (io.swagger.v3.oas.models.media.MapSchema)12 DateSchema (io.swagger.v3.oas.models.media.DateSchema)10 DateTimeSchema (io.swagger.v3.oas.models.media.DateTimeSchema)10 ArrayList (java.util.ArrayList)10 Operation (io.swagger.v3.oas.models.Operation)9 Paths (io.swagger.v3.oas.models.Paths)9 Parameter (io.swagger.v3.oas.models.parameters.Parameter)8