From bf57fdf4130dc36ba875016083fb3fd5ddacccb4 Mon Sep 17 00:00:00 2001 From: Manjeet Date: Thu, 9 Jan 2025 23:28:03 +0530 Subject: [PATCH] Update $$objectSchema$$.java Refactored the code for applying @DecimalMin and @DecimalMax annotations to ensure it follows a consistent and streamlined structure similar to the @Min and @Max annotations. --- .../main/java/com/asyncapi/model/$$objectSchema$$.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java b/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java index d08d12c7..b69f00cc 100644 --- a/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java +++ b/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java @@ -147,8 +147,14 @@ public class {{allName}} { {%- if prop.deprecated() %}@Deprecated{% endif %} {%- 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 %} {%- if prop.pattern() %}@Pattern(regexp="{{prop.pattern() | addBackSlashToPattern}}"){% endif %} - {%- if prop.minimum() %}@Min({{prop.minimum()}}){% endif %}{% if prop.exclusiveMinimum() %}@Min({{prop.exclusiveMinimum() + 1}}){% endif %} - {%- if prop.maximum() %}@Max({{prop.maximum()}}){% endif %}{% if prop.exclusiveMaximum() %}@Max({{prop.exclusiveMaximum() + 1}}){% endif %} + {%- if prop.type() == 'number' and (prop.format() == 'float' or prop.format() == 'double') %} + {%- if prop.minimum() %}@DecimalMin({{prop.minimum()}}, inclusive = true){% endif %}{%- if prop.exclusiveMinimum() %}@DecimalMin({{prop.exclusiveMinimum() + 1}}, inclusive = false){% endif %} + {%- if prop.maximum() %}@DecimalMax({{prop.maximum()}}, inclusive = true){% endif %}{%- if prop.exclusiveMaximum() %}@DecimalMax({{prop.exclusiveMaximum() + 1}}, inclusive = false){% endif %} + {%- else %} + {%- if prop.minimum() %}@Min({{prop.minimum()}}){% endif %}{% if prop.exclusiveMinimum() %}@Min({{prop.exclusiveMinimum() + 1}}){% endif %} + {%- if prop.maximum() %}@Max({{prop.maximum()}}){% endif %}{% if prop.exclusiveMaximum() %}@Max({{prop.exclusiveMaximum() + 1}}){% endif %} + {%- endif %} + public {{propType}} get{{className}}() { return {{varName}}; }