Skip to content

Commit ea10134

Browse files
committed
fix: add support for decimal min and max #326
Signed-off-by: anessi <16045045+anessi@users.noreply.github.com>
1 parent 4e2766b commit ea10134

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

template/src/main/java/com/asyncapi/model/$$objectSchema$$.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,13 @@ public class {{allName}} {
147147
{%- if prop.deprecated() %}@Deprecated{% endif %}
148148
{%- if prop.minLength() or prop.maxLength() or prop.maxItems() or prop.minItems() %}@Size({% if prop.minLength() or prop.minItems() %}min = {{prop.minLength()}}{{prop.minItems()}}{% endif %}{% if prop.maxLength() or prop.maxItems() %}{% if prop.minLength() or prop.minItems() %},{% endif %}max = {{prop.maxLength()}}{{prop.maxItems()}}{% endif %}){% endif %}
149149
{%- if prop.pattern() %}@Pattern(regexp="{{prop.pattern() | addBackSlashToPattern}}"){% endif %}
150-
{%- if prop.minimum() %}@Min({{prop.minimum()}}){% endif %}{% if prop.exclusiveMinimum() %}@Min({{prop.exclusiveMinimum() + 1}}){% endif %}
151-
{%- if prop.maximum() %}@Max({{prop.maximum()}}){% endif %}{% if prop.exclusiveMaximum() %}@Max({{prop.exclusiveMaximum() + 1}}){% endif %}
150+
{%- if prop.type() == 'number' and (prop.format() == 'float' or prop.format() == 'double') %}
151+
{%- if prop.minimum() %}@DecimalMin({{prop.minimum()}}, inclusive = true){% endif %}{%- if prop.exclusiveMinimum() %}@DecimalMin({{prop.exclusiveMinimum()}}, inclusive = false){% endif %}
152+
{%- if prop.maximum() %}@DecimalMax({{prop.maximum()}}, inclusive = true){% endif %}{%- if prop.exclusiveMaximum() %}@DecimalMax({{prop.exclusiveMaximum()}}, inclusive = false){% endif %}
153+
{%- else %}
154+
{%- if prop.minimum() %}@Min({{prop.minimum()}}){% endif %}{% if prop.exclusiveMinimum() %}@Min({{prop.exclusiveMinimum() + 1}}){% endif %}
155+
{%- if prop.maximum() %}@Max({{prop.maximum()}}){% endif %}{% if prop.exclusiveMaximum() %}@Max({{prop.exclusiveMaximum() + 1}}){% endif %}
156+
{%- endif %}
152157
public {{propType}} get{{className}}() {
153158
return {{varName}};
154159
}
@@ -202,4 +207,4 @@ private String toIndentedString(Object o) {
202207
}
203208
return o.toString().replace("\n", "\n ");
204209
}
205-
}
210+
}

0 commit comments

Comments
 (0)