Search in sources :

Example 81 with Parameter

use of io.swagger.v3.oas.models.parameters.Parameter in project swagger-core by swagger-api.

the class ParameterSerializationTest method testAllowEmptyValueParameter.

@Test(description = "should mark a parameter as to allow empty value")
public void testAllowEmptyValueParameter() throws Exception {
    final Parameter qp = new QueryParameter().allowEmptyValue(true);
    final String json = "{\"in\":\"query\",\"allowEmptyValue\":true}";
    SerializationMatchers.assertEqualsToJson(qp, json);
}
Also used : QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) Parameter(io.swagger.v3.oas.models.parameters.Parameter) QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Example 82 with Parameter

use of io.swagger.v3.oas.models.parameters.Parameter in project swagger-core by swagger-api.

the class ParameterSerializationTest method serializeQueryParameter.

@Test(description = "it should serialize a QueryParameter")
public void serializeQueryParameter() {
    final Parameter p = new QueryParameter().schema(new StringSchema());
    final String json = "{\"in\":\"query\",\"schema\":{\"type\":\"string\"}}";
    SerializationMatchers.assertEqualsToJson(p, json);
}
Also used : QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) Parameter(io.swagger.v3.oas.models.parameters.Parameter) QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Test(org.testng.annotations.Test)

Example 83 with Parameter

use of io.swagger.v3.oas.models.parameters.Parameter in project swagger-core by swagger-api.

the class ParameterSerializationTest method serializeEnumPathParameter.

@Test(description = "it should serialize a path parameter with enum")
public void serializeEnumPathParameter() {
    List<String> values = new ArrayList<>();
    values.add("a");
    values.add("b");
    values.add("c");
    Parameter p = new PathParameter().schema(new StringSchema()._enum(values));
    final String json = "{" + "   \"in\":\"path\"," + "   \"required\":true," + "   \"schema\":{" + "      \"type\":\"string\"," + "       \"enum\":[\"a\",\"b\",\"c\"]" + "   }" + "}";
    SerializationMatchers.assertEqualsToJson(p, json);
}
Also used : ArrayList(java.util.ArrayList) Parameter(io.swagger.v3.oas.models.parameters.Parameter) QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) StringSchema(io.swagger.v3.oas.models.media.StringSchema) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Example 84 with Parameter

use of io.swagger.v3.oas.models.parameters.Parameter in project swagger-core by swagger-api.

the class ParameterSerializationTest method serializeArrayQueryParameter.

@Test(description = "it should serialize a QueryParameter with array")
public void serializeArrayQueryParameter() {
    final Parameter p = new QueryParameter().schema(new ArraySchema().items(new StringSchema()));
    final String json = "{" + "   \"in\":\"query\"," + "   \"schema\":{" + "     \"type\":\"array\"," + "     \"items\":{" + "       \"type\":\"string\"" + "   }}" + "}";
    SerializationMatchers.assertEqualsToJson(p, json);
}
Also used : QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) Parameter(io.swagger.v3.oas.models.parameters.Parameter) QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Test(org.testng.annotations.Test)

Example 85 with Parameter

use of io.swagger.v3.oas.models.parameters.Parameter in project swagger-core by swagger-api.

the class ParameterSerializationTest method serializeStringArrayPathParameter.

@Test(description = "it should serialize a PathParameter with string array")
public void serializeStringArrayPathParameter() {
    Parameter p = new PathParameter().schema(new ArraySchema().items(new StringSchema()));
    final String json = "{\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}}";
    SerializationMatchers.assertEqualsToJson(p, json);
    final String yaml = "---\n" + "in: \"path\"\n" + "required: true\n" + "schema:\n" + "  type: \"array\"\n" + "  items:\n" + "    type: \"string\"";
    SerializationMatchers.assertEqualsToYaml(p, yaml);
}
Also used : ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) Parameter(io.swagger.v3.oas.models.parameters.Parameter) QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) StringSchema(io.swagger.v3.oas.models.media.StringSchema) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Aggregations

Parameter (io.swagger.v3.oas.models.parameters.Parameter)48 Test (org.testng.annotations.Test)39 Operation (io.swagger.v3.oas.models.Operation)28 Operation (io.swagger.v3.oas.annotations.Operation)27 lombok.val (lombok.val)26 OpenAPI (io.swagger.v3.oas.models.OpenAPI)20 Map (java.util.Map)17 ArrayList (java.util.ArrayList)16 ReadOperation (org.springframework.boot.actuate.endpoint.annotation.ReadOperation)15 OpenAPI3RequestValidationHandlerImpl (io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl)14 Test (org.junit.Test)14 PathItem (io.swagger.v3.oas.models.PathItem)13 QueryParameter (io.swagger.v3.oas.models.parameters.QueryParameter)13 StringUtils (org.apache.commons.lang3.StringUtils)13 StringSchema (io.swagger.v3.oas.models.media.StringSchema)12 LinkedHashMap (java.util.LinkedHashMap)12 Parameter (io.swagger.v3.oas.annotations.Parameter)11 RequestParameters (io.vertx.ext.web.api.RequestParameters)11 HashMap (java.util.HashMap)11 Schema (io.swagger.v3.oas.models.media.Schema)10