Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjusted Min/Max datatype for draft07 compliance #100

Merged
merged 1 commit into from
Feb 15, 2023
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 @@ -8,6 +8,7 @@
import lombok.NoArgsConstructor;

import javax.annotation.CheckForNull;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -261,31 +262,31 @@ Validation Keywords for Numeric Instances (number and integer)
* If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to "maximum".
*/
@CheckForNull
public Integer maximum;
public BigDecimal maximum;

/**
* The value of "exclusiveMaximum" MUST be number, representing an exclusive upper limit for a numeric instance.
* <br>
* If the instance is a number, then the instance is valid only if it has a value strictly less than (not equal to) "exclusiveMaximum".
*/
@CheckForNull
public Integer exclusiveMaximum;
public BigDecimal exclusiveMaximum;

/**
* The value of "minimum" MUST be a number, representing an inclusive lower limit for a numeric instance.
* <br>
* If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to "minimum".
*/
@CheckForNull
public Integer minimum;
public BigDecimal minimum;

/**
* The value of "exclusiveMinimum" MUST be number, representing an exclusive lower limit for a numeric instance.
* <br>
* If the instance is a number, then the instance is valid only if it has a value strictly greater than (not equal to) "exclusiveMinimum".
*/
@CheckForNull
public Integer exclusiveMinimum;
public BigDecimal exclusiveMinimum;

/*
Validation Keywords for Strings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import java.math.BigDecimal

/**
* @author Pavel Bodiachevskii
Expand Down Expand Up @@ -98,8 +99,8 @@ class ComponentsTest {
.type(Type.OBJECT)
.properties(mapOf(Pair("my-app-header", Schema.builder()
.type(Type.INTEGER)
.minimum(0)
.maximum(100)
.minimum(BigDecimal.ZERO)
.maximum(BigDecimal.valueOf(100))
.build()))
)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -160,14 +161,14 @@ private Map<String, Object> getSchemas() {
Map<String, Schema> lampInfoPayloadProperties = new HashMap<>();
lampInfoPayloadProperties.put("lumens", Schema.builder()
.type(Type.INTEGER)
.minimum(0)
.minimum(BigDecimal.ZERO)
.description("Lamp intensity measured in lumens.")
.build()
);
lampInfoPayloadProperties.put("watts", Schema.builder()
.type(Type.INTEGER)
.minimum(0)
.maximum(100)
.minimum( BigDecimal.ZERO )
.maximum( BigDecimal.valueOf( 100 ) )
.description("Lamp watt consumption.")
.build()
);
Expand Down Expand Up @@ -214,8 +215,8 @@ private Map<String, MessageTrait> getMessageTraits() {
Map<String, Schema> commonHeadersProperties = new HashMap<>();
commonHeadersProperties.put("my-app-header", Schema.builder()
.type(Type.INTEGER)
.minimum(0)
.maximum(100)
.minimum(BigDecimal.ONE)
.maximum(BigDecimal.valueOf( 100 ))
.build()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -210,7 +211,7 @@ private Map<String, Object> getSchemas() {
Map<String, Schema> lightMeasuredPayloadProperties = new HashMap<>();
lightMeasuredPayloadProperties.put("lumens", Schema.builder()
.type(Type.INTEGER)
.minimum(0)
.minimum(BigDecimal.ZERO)
.description("Light intensity measured in lumens.")
.build()
);
Expand Down Expand Up @@ -248,8 +249,8 @@ private Map<String, Object> getSchemas() {
Map<String, Schema> dimLightPayloadProperties = new HashMap<>();
dimLightPayloadProperties.put("command", Schema.builder()
.type(Type.INTEGER)
.minimum(0)
.maximum(100)
.minimum( BigDecimal.ONE )
.maximum(BigDecimal.valueOf( 100 ))
.build()
);
dimLightPayloadProperties.put("sentAt", Schema.builder()
Expand Down Expand Up @@ -360,8 +361,8 @@ private Map<String, MessageTrait> getMessageTraits() {
Map<String, Schema> commonHeadersProperties = new HashMap<>();
commonHeadersProperties.put("my-app-header", Schema.builder()
.type(Type.INTEGER)
.minimum(0)
.maximum(100)
.minimum(BigDecimal.ZERO)
.maximum(BigDecimal.valueOf( 100 ))
.build()
);

Expand Down