Skip to content
Open
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 @@ -154,6 +154,12 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
{{^lombok.Data}}

{{! begin feature: fluent setter methods }}
{{#deprecated}}
/**
* @deprecated deprecated
*/
@Deprecated
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
{{/deprecated}}
public {{classname}} {{name}}({{>nullableArgument_chainSetter}} {{name}}) {
{{#openApiNullable}}
this.{{name}} = {{#isNullable}}JsonNullable.of({{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional.of{{#optionalAcceptNullable}}Nullable{{/optionalAcceptNullable}}({{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{name}}{{#isNullable}}){{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}){{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}};
Expand All @@ -165,6 +171,12 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
}
{{#isArray}}

{{#deprecated}}
/**
* @deprecated deprecated
*/
@Deprecated
{{/deprecated}}
public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
{{#openApiNullable}}
if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent() || this.{{name}}.get() == null{{/isNullable}}) {
Expand All @@ -183,6 +195,12 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
{{/isArray}}
{{#isMap}}

{{#deprecated}}
/**
* @deprecated deprecated
*/
@Deprecated
{{/deprecated}}
public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
{{#openApiNullable}}
if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent() || this.{{name}}.get() == null{{/isNullable}}) {
Expand Down Expand Up @@ -247,7 +265,7 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
{{^lombok.Setter}}
{{#deprecated}}
/**
* @deprecated
* @deprecated deprecated
*/
{{/deprecated}}
{{#vendorExtensions.x-setter-extra-annotation}}
Expand All @@ -270,19 +288,37 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}

{{^lombok.Setter}}
{{! begin feature: fluent setter methods for inherited properties }}
{{#deprecated}}
/**
* @deprecated deprecated
*/
@Deprecated
{{/deprecated}}
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
super.{{name}}({{name}});
return this;
}
{{#isArray}}

{{#deprecated}}
/**
* @deprecated deprecated
*/
@Deprecated
{{/deprecated}}
public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
super.add{{nameInPascalCase}}Item({{name}}Item);
return this;
}
{{/isArray}}
{{#isMap}}

{{#deprecated}}
/**
* @deprecated deprecated
*/
@Deprecated
{{/deprecated}}
public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
super.put{{nameInPascalCase}}Item(key, {{name}}Item);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3254,6 +3254,48 @@ public void contractWithDeprecatedEnumGeneratesDeprecatedAnnotation() throws IOE
.fileDoesNotContain("@Deprecated");
}

@Test
public void contractWithDeprecatedPropertiesAnnotatesFluentSettersAndCollectionHelpers() throws IOException {
Map<String, File> output = generateFromContract(
"src/test/resources/3_0/spring/issue_24704.yaml",
SPRING_BOOT,
Map.of(GENERATE_BUILDERS, true)
);

JavaFileAssert.assertThat(output.get("Example.java"))
.fileContains(
" /**\n * @deprecated deprecated\n */\n @Deprecated\n public Example deprecatedProperty(",
" /**\n * @deprecated deprecated\n */\n @Deprecated\n public Example deprecatedValues(",
" /**\n * @deprecated deprecated\n */\n @Deprecated\n public Example addDeprecatedValuesItem(",
" /**\n * @deprecated deprecated\n */\n @Deprecated\n public Example deprecatedMap(",
" /**\n * @deprecated deprecated\n */\n @Deprecated\n public Example putDeprecatedMapItem("
)
.assertMethod("deprecatedProperty", "String")
.hasAnnotation("Deprecated")
.toFileAssert()
.assertMethod("deprecatedValues")
.hasAnnotation("Deprecated")
.toFileAssert()
.assertMethod("deprecatedMap")
.hasAnnotation("Deprecated")
.toFileAssert()
.assertMethod("addDeprecatedValuesItem", "String")
.hasAnnotation("Deprecated")
.toFileAssert()
.assertMethod("putDeprecatedMapItem", "String", "String")
.hasAnnotation("Deprecated")
.toFileAssert()
.assertMethod("currentProperty", "String")
.doesNotHaveAnnotation("Deprecated")
.toFileAssert()
.assertInnerClass("Builder")
.assertMethod("deprecatedProperty", "String")
.hasAnnotation("Deprecated")
.toInnerClassAssert()
.assertMethod("currentProperty", "String")
.doesNotHaveAnnotation("Deprecated");
}

@Test
public void contractWithResolvedInnerEnumContainsEnumConverter() throws IOException {
File output = Files.createTempDirectory("test").toFile();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
openapi: 3.0.3
info:
title: Deprecated property example
version: 1.0.0
paths:
/example:
get:
operationId: getExample
responses:
"200":
description: Example response
content:
application/json:
schema:
$ref: "#/components/schemas/Example"
components:
schemas:
Example:
type: object
properties:
currentProperty:
type: string
deprecatedProperty:
type: string
deprecated: true
deprecatedValues:
type: array
deprecated: true
items:
type: string
deprecatedMap:
type: object
deprecated: true
additionalProperties:
type: string
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,19 @@ public void setName(JsonNullable<String> name) {
this.name = name;
}

/**
* @deprecated deprecated
*/
@Deprecated
public Pet photoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
return this;
}

/**
* @deprecated deprecated
*/
@Deprecated
public Pet addPhotoUrlsItem(String photoUrlsItem) {
if (this.photoUrls == null) {
this.photoUrls = new ArrayList<>();
Expand All @@ -188,7 +196,7 @@ public List<String> getPhotoUrls() {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("photoUrls")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ public void setTags(List<@Valid Tag> tags) {
this.tags = tags;
}

/**
* @deprecated deprecated
*/
@Deprecated
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand All @@ -240,7 +244,7 @@ public Pet status(@Nullable StatusEnum status) {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ public void setTags(List<@Valid Tag> tags) {
this.tags = tags;
}

/**
* @deprecated deprecated
*/
@Deprecated
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand All @@ -240,7 +244,7 @@ public Pet status(@Nullable StatusEnum status) {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ public void setTags(List<@Valid TagDto> tags) {
this.tags = tags;
}

/**
* @deprecated deprecated
*/
@Deprecated
public PetDto status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand All @@ -230,7 +234,7 @@ public PetDto status(@Nullable StatusEnum status) {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ public void setTags(List<TagDto> tags) {
this.tags = tags;
}

/**
* @deprecated deprecated
*/
@Deprecated
public PetDto status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand All @@ -229,7 +233,7 @@ public PetDto status(@Nullable StatusEnum status) {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ public void setTags(List<TagDto> tags) {
this.tags = tags;
}

/**
* @deprecated deprecated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The generated javadoc @deprecated deprecated repeats the tag name as its message, so the rendered docs read "Deprecated. Deprecated." and add no information. It is also inconsistent with the getter (e.g. getStatus) which still emits a bare @deprecated with no text for the same property. Use a useful message (the property name or a replacement) or omit the text for consistency with the getter.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/spring-http-interface-oauth/src/main/java/org/openapitools/model/PetDto.java, line 216:

<comment>The generated javadoc `@deprecated deprecated` repeats the tag name as its message, so the rendered docs read "Deprecated. Deprecated." and add no information. It is also inconsistent with the getter (e.g. `getStatus`) which still emits a bare `@deprecated` with no text for the same property. Use a useful message (the property name or a replacement) or omit the text for consistency with the getter.</comment>

<file context>
@@ -213,7 +213,7 @@ public void setTags(List<TagDto> tags) {
 
   /**
-   * @deprecated
+   * @deprecated deprecated
    */
   @Deprecated
</file context>
Suggested change
* @deprecated deprecated
* @deprecated

*/
@Deprecated
public PetDto status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand All @@ -230,7 +234,7 @@ public PetDto status(@Nullable StatusEnum status) {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ public void setTags(List<@Valid Tag> tags) {
this.tags = tags;
}

/**
* @deprecated deprecated
*/
@Deprecated
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand All @@ -236,7 +240,7 @@ public Pet status(@Nullable StatusEnum status) {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ public void setTags(List<Tag> tags) {
this.tags = tags;
}

/**
* @deprecated deprecated
*/
@Deprecated
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand All @@ -235,7 +239,7 @@ public Pet status(@Nullable StatusEnum status) {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ public void setTags(List<Tag> tags) {
this.tags = tags;
}

/**
* @deprecated deprecated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: For the same deprecated property, the fluent status(...) and setStatus(...) javadoc now read @deprecated deprecated, but getStatus() still emits a bare @deprecated. Within one property the generated javadoc is now inconsistent. If the added tag text is meant to be the standard description, apply it to the getter's @deprecated tag in pojo.mustache as well for consistency (or drop it everywhere and keep the bare tag).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/Pet.java, line 221:

<comment>For the same deprecated property, the fluent `status(...)` and `setStatus(...)` javadoc now read `@deprecated deprecated`, but `getStatus()` still emits a bare `@deprecated`. Within one property the generated javadoc is now inconsistent. If the added tag text is meant to be the standard description, apply it to the getter's `@deprecated` tag in pojo.mustache as well for consistency (or drop it everywhere and keep the bare tag).</comment>

<file context>
@@ -218,7 +218,7 @@ public void setTags(List<Tag> tags) {
 
   /**
-   * @deprecated
+   * @deprecated deprecated
    */
   @Deprecated
</file context>

*/
@Deprecated
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand All @@ -235,7 +239,7 @@ public Pet status(@Nullable StatusEnum status) {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ public void setTags(List<@Valid TagDto> tags) {
this.tags = tags;
}

/**
* @deprecated deprecated
*/
@Deprecated
public PetDto status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand All @@ -236,7 +240,7 @@ public PetDto status(@Nullable StatusEnum status) {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ public void setTags(List<@Valid Tag> tags) {
this.tags = tags;
}

/**
* @deprecated deprecated
*/
@Deprecated
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand All @@ -237,7 +241,7 @@ public Pet status(@Nullable StatusEnum status) {
}

/**
* @deprecated
* @deprecated deprecated
*/
@Deprecated
@JsonProperty("status")
Expand Down
Loading