Skip to content
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 @@ -17,7 +17,7 @@ public class CodegenOperation {
isListContainer, isMultipart, hasMore = true,
isResponseBinary = false, isResponseFile = false, hasReference = false,
isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
isRestful;
isRestful, isDeprecated;
public String path, operationId, returnType, httpMethod, returnBaseType,
returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse, discriminator;
public List<Map<String, String>> consumes, produces, prioritizedContentTypes;
Expand Down Expand Up @@ -221,6 +221,8 @@ public boolean equals(Object o) {
return false;
if (isResponseFile != that.isResponseFile)
return false;
if (isDeprecated != that.isDeprecated)
return false;
if (path != null ? !path.equals(that.path) : that.path != null)
return false;
if (operationId != null ? !operationId.equals(that.operationId) : that.operationId != null)
Expand Down Expand Up @@ -305,6 +307,7 @@ public int hashCode() {
result = 31 * result + (isResponseBinary ? 13:31);
result = 31 * result + (isResponseFile ? 13:31);
result = 31 * result + (hasReference ? 13:31);
result = 31 * result + (isDeprecated ? 13:31);
result = 31 * result + (path != null ? path.hashCode() : 0);
result = 31 * result + (operationId != null ? operationId.hashCode() : 0);
result = 31 * result + (returnType != null ? returnType.hashCode() : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,9 @@ public CodegenOperation fromOperation(String path,
op.notes = escapeText(operation.getDescription());
op.hasConsumes = false;
op.hasProduces = false;
if (operation.isDeprecated() != null) {
op.isDeprecated = operation.isDeprecated();
}

List<String> consumes = new ArrayList<String>();
if (operation.getConsumes() != null) {
Expand Down
3 changes: 3 additions & 0 deletions modules/swagger-codegen/src/main/resources/Java/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class {{classname}} {
* @return {{returnType}}
{{/returnType}}
* @throws ApiException if fails to make API call
{{#isDeprecated}}
* @Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

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

@hisener Isn't this a javadoc comment and not an annotation because the line starts with *?

{{/isDeprecated}}
*/
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class {{classname}} {
* @return {{returnType}}
{{/returnType}}
* @throws ApiException if fails to make API call
{{#isDeprecated}}
* @Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

{{/isDeprecated}}
*/
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class {{classname}} {
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}{{#returnType}}
* @return {{{returnType}}}{{/returnType}}
* @throws ApiException if fails to make API call
{{#isDeprecated}}
* @Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

{{/isDeprecated}}
*/
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,15 @@ private static Swagger parseAndPrepareSwagger(String path) {
new InlineModelResolver().flatten(swagger);
return swagger;
}

@Test(description = "isDeprecated is present")
public void deprecatedParamTest() {
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/petstore.json");
final DefaultCodegen codegen = new DefaultCodegen();
final String path = "/pet/findByTags";
final Operation p = model.getPaths().get(path).getGet();
final CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions());

Assert.assertTrue(op.isDeprecated);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ paths:
- petstore_auth:
- 'write:pets'
- 'read:pets'
deprecated: true
'/pet/{petId}':
get:
tags:
Expand Down
3 changes: 2 additions & 1 deletion modules/swagger-codegen/src/test/resources/2_0/petstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@
"read:pets"
]
}
]
],
"deprecated": "true"
}
},
"/pet/{petId}": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ paths:
- petstore_auth:
- 'write:pets'
- 'read:pets'
deprecated: true
'/pet/{petId}':
get:
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public List<Pet> findPetsByStatus(List<String> status) throws ApiException {
* @param tags Tags to filter by (required)
* @return List&lt;Pet&gt;
* @throws ApiException if fails to make API call
* @Deprecated
*/
public List<Pet> findPetsByTags(List<String> tags) throws ApiException {
Object localVarPostBody = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public List<Pet> findPetsByStatus(List<String> status) throws ApiException {
* @param tags Tags to filter by (required)
* @return List&lt;Pet&gt;
* @throws ApiException if fails to make API call
* @Deprecated
*/
public List<Pet> findPetsByTags(List<String> tags) throws ApiException {
Object localVarPostBody = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public List<Pet> findPetsByStatus(List<String> status) throws ApiException {
* @param tags Tags to filter by (required)
* @return List&lt;Pet&gt;
* @throws ApiException if fails to make API call
* @Deprecated
*/
public List<Pet> findPetsByTags(List<String> tags) throws ApiException {
Object localVarPostBody = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public List<Pet> findPetsByStatus(List<String> status) throws ApiException {
* @param tags Tags to filter by (required)
* @return List<Pet>
* @throws ApiException if fails to make API call
* @Deprecated
*/
public List<Pet> findPetsByTags(List<String> tags) throws ApiException {
Object localVarPostBody = null;
Expand Down