Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,16 @@ void invalidQueryParamThrowsValidation() {

@Test
void integerQueryParamIsCoercedFromStringBeforeValidation() throws Exception {
var intSchema = new IntegerSchema(Set.of(TypeName.INTEGER), 1L, 100L, null, null, null, null);
var intSchema =
new IntegerSchema(Set.of(TypeName.INTEGER), 1L, 100L, null, null, null, null, Map.of());
var op =
new Operation(
"a",
HttpMethod.GET,
PathTemplate.compile("/x"),
Optional.empty(),
List.of(new Parameter("n", Parameter.Location.QUERY, true, intSchema)),
Map.of(),
Map.of());
Spec spec = specWith(op);
Filter f = newFilter(spec);
Expand All @@ -184,14 +186,16 @@ void integerQueryParamIsCoercedFromStringBeforeValidation() throws Exception {

@Test
void integerQueryParamRejectsNonNumericString() {
var intSchema = new IntegerSchema(Set.of(TypeName.INTEGER), null, null, null, null, null, null);
var intSchema =
new IntegerSchema(Set.of(TypeName.INTEGER), null, null, null, null, null, null, Map.of());
var op =
new Operation(
"a",
HttpMethod.GET,
PathTemplate.compile("/x"),
Optional.empty(),
List.of(new Parameter("n", Parameter.Location.QUERY, true, intSchema)),
Map.of(),
Map.of());
Spec spec = specWith(op);
Filter f = newFilter(spec);
Expand All @@ -205,14 +209,16 @@ void integerQueryParamRejectsNonNumericString() {

@Test
void numberQueryParamIsCoercedFromStringBeforeValidation() throws Exception {
var numSchema = new NumberSchema(Set.of(TypeName.NUMBER), null, null, null, null, null, null);
var numSchema =
new NumberSchema(Set.of(TypeName.NUMBER), null, null, null, null, null, null, Map.of());
var op =
new Operation(
"a",
HttpMethod.GET,
PathTemplate.compile("/x"),
Optional.empty(),
List.of(new Parameter("n", Parameter.Location.QUERY, true, numSchema)),
Map.of(),
Map.of());
Spec spec = specWith(op);
Filter f = newFilter(spec);
Expand All @@ -225,14 +231,16 @@ void numberQueryParamIsCoercedFromStringBeforeValidation() throws Exception {

@Test
void numberQueryParamRejectsNonNumericString() {
var numSchema = new NumberSchema(Set.of(TypeName.NUMBER), null, null, null, null, null, null);
var numSchema =
new NumberSchema(Set.of(TypeName.NUMBER), null, null, null, null, null, null, Map.of());
var op =
new Operation(
"a",
HttpMethod.GET,
PathTemplate.compile("/x"),
Optional.empty(),
List.of(new Parameter("n", Parameter.Location.QUERY, true, numSchema)),
Map.of(),
Map.of());
Spec spec = specWith(op);
Filter f = newFilter(spec);
Expand All @@ -246,14 +254,15 @@ void numberQueryParamRejectsNonNumericString() {

@Test
void booleanQueryParamCoercesTrueAndFalse() throws Exception {
var boolSchema = new BooleanSchema(Set.of(TypeName.BOOLEAN));
var boolSchema = new BooleanSchema(Set.of(TypeName.BOOLEAN), Map.of());
var op =
new Operation(
"a",
HttpMethod.GET,
PathTemplate.compile("/x"),
Optional.empty(),
List.of(new Parameter("b", Parameter.Location.QUERY, true, boolSchema)),
Map.of(),
Map.of());
Spec spec = specWith(op);
Filter f = newFilter(spec);
Expand All @@ -270,14 +279,15 @@ void booleanQueryParamCoercesTrueAndFalse() throws Exception {

@Test
void booleanQueryParamRejectsNonBooleanString() {
var boolSchema = new BooleanSchema(Set.of(TypeName.BOOLEAN));
var boolSchema = new BooleanSchema(Set.of(TypeName.BOOLEAN), Map.of());
var op =
new Operation(
"a",
HttpMethod.GET,
PathTemplate.compile("/x"),
Optional.empty(),
List.of(new Parameter("b", Parameter.Location.QUERY, true, boolSchema)),
Map.of(),
Map.of());
Spec spec = specWith(op);
Filter f = newFilter(spec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,16 @@ void numberFormatUnknownIsIgnored() {
@Test
void integerRejectsNumericLookingString() {
IntegerSchema s =
new IntegerSchema(Set.of(TypeName.INTEGER), null, null, null, null, null, null);
new IntegerSchema(Set.of(TypeName.INTEGER), null, null, null, null, null, null, Map.of());
assertThatThrownBy(() -> v.validate("42", s, "/v"))
.extracting(t -> ((ValidationException) t).error().keyword())
.isEqualTo("type");
}

@Test
void numberRejectsNumericLookingString() {
NumberSchema s = new NumberSchema(Set.of(TypeName.NUMBER), null, null, null, null, null, null);
NumberSchema s =
new NumberSchema(Set.of(TypeName.NUMBER), null, null, null, null, null, null, Map.of());
assertThatThrownBy(() -> v.validate("1234567890", s, "/v"))
.extracting(t -> ((ValidationException) t).error().keyword())
.isEqualTo("type");
Expand Down
Loading