Search in sources :

Example 86 with Pet

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

Example 87 with Pet

use of io.swagger.v3.plugin.maven.resources.model.Pet in project swagger-core by swagger-api.

the class PetData method createPet.

static Pet createPet(long id, Category cat, String name, String[] urls, String[] tags, String status) {
    Pet pet = new Pet();
    pet.setId(id);
    pet.setCategory(cat);
    pet.setName(name);
    if (null != urls) {
        List<String> urlObjs = new ArrayList<String>();
        for (String urlString : urls) {
            urlObjs.add(urlString);
        }
        pet.setPhotoUrls(urlObjs);
    }
    List<Tag> tagObjs = new ArrayList<Tag>();
    int i = 0;
    if (null != tags) {
        for (String tagString : tags) {
            i = i + 1;
            Tag tag = new Tag();
            tag.setId(i);
            tag.setName(tagString);
            tagObjs.add(tag);
        }
    }
    pet.setTags(tagObjs);
    pet.setStatus(status);
    return pet;
}
Also used : ArrayList(java.util.ArrayList) Tag(io.swagger.v3.jaxrs2.resources.model.Tag) Pet(io.swagger.v3.jaxrs2.resources.model.Pet)

Example 88 with Pet

use of io.swagger.v3.plugin.maven.resources.model.Pet in project vertx-web by vert-x3.

the class OpenAPI3MultipleFilesValidationTest method testAdditionalPropertiesJson.

@Test
public void testAdditionalPropertiesJson() throws Exception {
    Operation op = testSpec.getPaths().get("/additionalProperties").getPost();
    OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec, refsCache);
    loadHandlers("/additionalProperties", HttpMethod.POST, true, validationHandler, (routingContext) -> {
        RequestParameters params = routingContext.get("parsedParameters");
        routingContext.response().setStatusCode(200).setStatusMessage("OK").putHeader(HttpHeaders.CONTENT_TYPE, "application/json").end(params.body().getJsonObject().encode());
    });
    JsonObject pet = new JsonObject();
    pet.put("id", 14612);
    pet.put("name", "Willy");
    pet.put("lazyness", "Highest");
    testRequestWithJSON(HttpMethod.POST, "/additionalProperties", pet.toBuffer(), 400, errorMessage(ValidationException.ErrorType.JSON_INVALID));
}
Also used : OpenAPI3RequestValidationHandlerImpl(io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl) JsonObject(io.vertx.core.json.JsonObject) Operation(io.swagger.v3.oas.models.Operation) RequestParameters(io.vertx.ext.web.api.RequestParameters) Test(org.junit.Test)

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 Operation (io.swagger.v3.oas.models.Operation)12 MapSchema (io.swagger.v3.oas.models.media.MapSchema)12 ArrayList (java.util.ArrayList)11 DateSchema (io.swagger.v3.oas.models.media.DateSchema)10 DateTimeSchema (io.swagger.v3.oas.models.media.DateTimeSchema)10 Paths (io.swagger.v3.oas.models.Paths)9 Test (org.junit.Test)9