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
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
{{/deprecated}}
public {{classname}} {{name}}({{#useJspecify}}{{#lambda.jSpecifyNullable}}{{^required}}{{^useOptional}}@Nullable {{/useOptional}}{{#useOptional}}{{#optionalAcceptNullable}}@Nullable {{/optionalAcceptNullable}}{{/useOptional}}{{/required}}{{/lambda.jSpecifyNullable}}{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}{{/useJspecify}}{{^useJspecify}}{{>nullableAnnotation_default}}{{{datatypeWithEnum}}}{{/useJspecify}} {{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}}
public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
{{#openApiNullable}}
if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent(){{/isNullable}}) {
Expand All @@ -183,6 +195,12 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
{{/isArray}}
{{#isMap}}

{{#deprecated}}
/**
* @deprecated
*/
@Deprecated
{{/deprecated}}
public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
{{#openApiNullable}}
if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent(){{/isNullable}}) {
Expand Down Expand Up @@ -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}}
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
super.{{name}}({{name}});
return this;
}
{{#isArray}}

{{#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}}
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\n */\n @Deprecated\n public Example deprecatedProperty(",
" /**\n * @deprecated\n */\n @Deprecated\n public Example deprecatedValues(",
" /**\n * @deprecated\n */\n @Deprecated\n public Example addDeprecatedValuesItem(",
" /**\n * @deprecated\n */\n @Deprecated\n public Example deprecatedMap(",
" /**\n * @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

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 @deprecated javadoc tag is emitted with no description text, so javadoc builds of the generated code emit the warning @deprecated tag has no <Text> and users get no guidance on what to use instead. Add the replacement guidance in the tag, e.g. * @deprecated Use {@link #getPhotoUrls()} instead, matching the @Deprecated indication.

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

<comment>The `@deprecated` javadoc tag is emitted with no description text, so javadoc builds of the generated code emit the warning `@deprecated tag has no <Text>` and users get no guidance on what to use instead. Add the replacement guidance in the tag, e.g. `* @deprecated Use {@link #getPhotoUrls()} instead`, matching the `@Deprecated` indication.</comment>

<file context>
@@ -161,12 +161,18 @@ public void setName(JsonNullable<String> name) {
   }
 
+  /**
+   * @deprecated
+   */
   @Deprecated
</file context>

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

/**
* @deprecated
*/
@Deprecated
public Pet addPhotoUrlsItem(String photoUrlsItem) {
if (this.photoUrls == null) {
this.photoUrls = new ArrayList<>();
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public PetDto status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public PetDto status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public PetDto status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public PetDto status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public PetDto status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ public void setTags(List<@Valid Tag> tags) {
this.tags = tags;
}

/**
* @deprecated
*/
@Deprecated
public Pet status(StatusEnum status) {
this.status = Optional.ofNullable(status);
return this;
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public Pet status(StatusEnum status) {
this.status = status;
return this;
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ public void setTags(List<@Valid Tag> tags) {
this.tags = tags;
}

/**
* @deprecated
*/
@Deprecated
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
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
public Pet status(@Nullable StatusEnum status) {
this.status = status;
return this;
Expand Down
Loading