diff --git a/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java b/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java index de7ccc3b4..d08d12c7a 100644 --- a/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java +++ b/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java @@ -144,6 +144,7 @@ public class {{allName}} { */{% endif %} @JsonProperty("{{propName}}") {%- if propName | isRequired(schema.required()) %}@NotNull{% endif %} + {%- 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 %} @@ -151,7 +152,9 @@ public class {{allName}} { public {{propType}} get{{className}}() { return {{varName}}; } - +{% if prop.deprecated() %} + @Deprecated +{%- endif %} public void set{{className}}({{propType}} {{varName}}) { this.{{varName}} = {{varName}}; } diff --git a/tests/__snapshots__/additional-formats.test.js.snap b/tests/__snapshots__/additional-formats.test.js.snap index 93a7ce2fe..261fd77e6 100644 --- a/tests/__snapshots__/additional-formats.test.js.snap +++ b/tests/__snapshots__/additional-formats.test.js.snap @@ -30,6 +30,8 @@ public class SongPayload { private @Valid java.math.BigDecimal rating; + private @Valid Integer stars; + @@ -97,6 +99,20 @@ public class SongPayload { this.rating = rating; } + + /** + * Number of stars. Deprecated: Use rating + */ + @JsonProperty("stars")@Deprecated + public Integer getStars() { + return stars; + } + + @Deprecated + public void setStars(Integer stars) { + this.stars = stars; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -111,12 +127,13 @@ public class SongPayload { Objects.equals(this.title, songPayload.title) && Objects.equals(this.uri, songPayload.uri) && Objects.equals(this.email, songPayload.email) && - Objects.equals(this.rating, songPayload.rating); + Objects.equals(this.rating, songPayload.rating) && + Objects.equals(this.stars, songPayload.stars); } @Override public int hashCode() { - return Objects.hash(id, title, uri, email, rating); + return Objects.hash(id, title, uri, email, rating, stars); } @Override @@ -128,6 +145,7 @@ public class SongPayload { " uri: " + toIndentedString(uri) + "\\n" + " email: " + toIndentedString(email) + "\\n" + " rating: " + toIndentedString(rating) + "\\n" + + " stars: " + toIndentedString(stars) + "\\n" + "}"; } diff --git a/tests/mocks/additional-type-formats.yml b/tests/mocks/additional-type-formats.yml index 1d4c572a9..13ae8d826 100644 --- a/tests/mocks/additional-type-formats.yml +++ b/tests/mocks/additional-type-formats.yml @@ -41,4 +41,8 @@ components: rating: description: Title rating type: string - format: decimal \ No newline at end of file + format: decimal + stars: + description: "Number of stars. Deprecated: Use rating" + type: integer + deprecated: true \ No newline at end of file