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

feat: mark deprecated properties with @Deprecated #421

Merged
merged 2 commits into from
Nov 26, 2024
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 @@ -144,14 +144,17 @@ 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 %}
{%- if prop.maximum() %}@Max({{prop.maximum()}}){% endif %}{% if prop.exclusiveMaximum() %}@Max({{prop.exclusiveMaximum() + 1}}){% endif %}
public {{propType}} get{{className}}() {
return {{varName}};
}

{% if prop.deprecated() %}
@Deprecated
{%- endif %}
public void set{{className}}({{propType}} {{varName}}) {
this.{{varName}} = {{varName}};
}
Expand Down
22 changes: 20 additions & 2 deletions tests/__snapshots__/additional-formats.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class SongPayload {

private @Valid java.math.BigDecimal rating;

private @Valid Integer stars;




Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -128,6 +145,7 @@ public class SongPayload {
" uri: " + toIndentedString(uri) + "\\n" +
" email: " + toIndentedString(email) + "\\n" +
" rating: " + toIndentedString(rating) + "\\n" +
" stars: " + toIndentedString(stars) + "\\n" +
"}";
}

Expand Down
6 changes: 5 additions & 1 deletion tests/mocks/additional-type-formats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ components:
rating:
description: Title rating
type: string
format: decimal
format: decimal
stars:
description: "Number of stars. Deprecated: Use rating"
type: integer
deprecated: true
Loading