[Java][*] Annotate deprecated operations and schemas (#9478)

Refs #3358

Ensure `deprecated` operations are annotated/documented as such on the
generated methods. Libraries updated:
  * [feign]
  * [google-api-client]
  * [microprofile]
  * [okhttp-gson]
  * [resttemplate]
  * [retrofit]
  * [retrofit/play*]
  * [webclient]
  * [vertx]

Ensure `deprecated` schemas are annotated/documented as such on the
generated classes/fields. Libraries updated:
  * [feign]
  * [google-api-client]
  * [jersey2]
  * [microprofile]
  * [native]
  * [okhttp-gson]
  * [rest-assured]
  * [resteasy]
  * [resttemplate]
  * [retrofit*]
  * [webclient]
  * [vertx]

Also fix two minor bugs to get the java sample tests working:

* Fix an invalid jackson-datatype-threetenbp version number in vertx/pom.mustache
* Fix a bad return type in webclient/api_test.mustache when uniqueItems=true

Since this commit updates petstore-with-fake-endpoints-models-for-testing.yaml,
several other samples were updated, but it's just new files to reflect the
deprecated schemas, so there should be no consequential differences.

Relevant bits of the spec:

* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#user-content-operationdeprecated
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#user-content-schemadeprecated
This commit is contained in:
Jon Jensen
2021-07-18 20:27:03 -06:00
committed by GitHub
parent c42e03e251
commit bd070308d9
2116 changed files with 229574 additions and 578 deletions

View File

@@ -26,6 +26,7 @@ docs/Client.md
docs/ComplexQuadrilateral.md
docs/DanishPig.md
docs/DefaultApi.md
docs/DeprecatedObject.md
docs/Dog.md
docs/DogAllOf.md
docs/Drawing.md
@@ -56,6 +57,7 @@ docs/Name.md
docs/NullableClass.md
docs/NullableShape.md
docs/NumberOnly.md
docs/ObjectWithDeprecatedFields.md
docs/Order.md
docs/OuterComposite.md
docs/OuterEnum.md
@@ -129,6 +131,7 @@ src/main/java/org/openapitools/client/model/ClassModel.java
src/main/java/org/openapitools/client/model/Client.java
src/main/java/org/openapitools/client/model/ComplexQuadrilateral.java
src/main/java/org/openapitools/client/model/DanishPig.java
src/main/java/org/openapitools/client/model/DeprecatedObject.java
src/main/java/org/openapitools/client/model/Dog.java
src/main/java/org/openapitools/client/model/DogAllOf.java
src/main/java/org/openapitools/client/model/Drawing.java
@@ -157,6 +160,7 @@ src/main/java/org/openapitools/client/model/Name.java
src/main/java/org/openapitools/client/model/NullableClass.java
src/main/java/org/openapitools/client/model/NullableShape.java
src/main/java/org/openapitools/client/model/NumberOnly.java
src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java
src/main/java/org/openapitools/client/model/Order.java
src/main/java/org/openapitools/client/model/OuterComposite.java
src/main/java/org/openapitools/client/model/OuterEnum.java

View File

@@ -207,6 +207,7 @@ Class | Method | HTTP request | Description
- [Client](docs/Client.md)
- [ComplexQuadrilateral](docs/ComplexQuadrilateral.md)
- [DanishPig](docs/DanishPig.md)
- [DeprecatedObject](docs/DeprecatedObject.md)
- [Dog](docs/Dog.md)
- [DogAllOf](docs/DogAllOf.md)
- [Drawing](docs/Drawing.md)
@@ -235,6 +236,7 @@ Class | Method | HTTP request | Description
- [NullableClass](docs/NullableClass.md)
- [NullableShape](docs/NullableShape.md)
- [NumberOnly](docs/NumberOnly.md)
- [ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md)
- [Order](docs/Order.md)
- [OuterComposite](docs/OuterComposite.md)
- [OuterEnum](docs/OuterEnum.md)

View File

@@ -2261,6 +2261,27 @@ components:
example: 2010-01-01T10:10:10.000111+01:00
format: date-time
type: string
DeprecatedObject:
deprecated: true
properties:
name:
type: string
type: object
ObjectWithDeprecatedFields:
properties:
uuid:
type: string
id:
deprecated: true
type: number
deprecatedRef:
$ref: '#/components/schemas/DeprecatedObject'
bars:
deprecated: true
items:
$ref: '#/components/schemas/Bar'
type: array
type: object
inline_response_default:
example:
string:

View File

@@ -0,0 +1,13 @@
# DeprecatedObject
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **String** | | [optional]

View File

@@ -0,0 +1,16 @@
# ObjectWithDeprecatedFields
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**uuid** | **String** | | [optional]
**id** | **BigDecimal** | | [optional]
**deprecatedRef** | [**DeprecatedObject**](DeprecatedObject.md) | | [optional]
**bars** | **List<String>** | | [optional]

View File

@@ -0,0 +1,111 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/**
* DeprecatedObject
* @deprecated
*/
@Deprecated
@JsonPropertyOrder({
DeprecatedObject.JSON_PROPERTY_NAME
})
@javax.annotation.processing.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class DeprecatedObject {
public static final String JSON_PROPERTY_NAME = "name";
private String name;
public DeprecatedObject name(String name) {
this.name = name;
return this;
}
/**
* Get name
* @return name
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getName() {
return name;
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(String name) {
this.name = name;
}
/**
* Return true if this DeprecatedObject object is equal to o.
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DeprecatedObject deprecatedObject = (DeprecatedObject) o;
return Objects.equals(this.name, deprecatedObject.name);
}
@Override
public int hashCode() {
return Objects.hash(name);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DeprecatedObject {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@@ -0,0 +1,223 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.openapitools.client.model.DeprecatedObject;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/**
* ObjectWithDeprecatedFields
*/
@JsonPropertyOrder({
ObjectWithDeprecatedFields.JSON_PROPERTY_UUID,
ObjectWithDeprecatedFields.JSON_PROPERTY_ID,
ObjectWithDeprecatedFields.JSON_PROPERTY_DEPRECATED_REF,
ObjectWithDeprecatedFields.JSON_PROPERTY_BARS
})
@javax.annotation.processing.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ObjectWithDeprecatedFields {
public static final String JSON_PROPERTY_UUID = "uuid";
private String uuid;
public static final String JSON_PROPERTY_ID = "id";
private BigDecimal id;
public static final String JSON_PROPERTY_DEPRECATED_REF = "deprecatedRef";
private DeprecatedObject deprecatedRef;
public static final String JSON_PROPERTY_BARS = "bars";
private List<String> bars = null;
public ObjectWithDeprecatedFields uuid(String uuid) {
this.uuid = uuid;
return this;
}
/**
* Get uuid
* @return uuid
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_UUID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getUuid() {
return uuid;
}
@JsonProperty(JSON_PROPERTY_UUID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setUuid(String uuid) {
this.uuid = uuid;
}
public ObjectWithDeprecatedFields id(BigDecimal id) {
this.id = id;
return this;
}
/**
* Get id
* @return id
* @deprecated
**/
@Deprecated
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public BigDecimal getId() {
return id;
}
@JsonProperty(JSON_PROPERTY_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setId(BigDecimal id) {
this.id = id;
}
public ObjectWithDeprecatedFields deprecatedRef(DeprecatedObject deprecatedRef) {
this.deprecatedRef = deprecatedRef;
return this;
}
/**
* Get deprecatedRef
* @return deprecatedRef
* @deprecated
**/
@Deprecated
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_DEPRECATED_REF)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public DeprecatedObject getDeprecatedRef() {
return deprecatedRef;
}
@JsonProperty(JSON_PROPERTY_DEPRECATED_REF)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setDeprecatedRef(DeprecatedObject deprecatedRef) {
this.deprecatedRef = deprecatedRef;
}
public ObjectWithDeprecatedFields bars(List<String> bars) {
this.bars = bars;
return this;
}
public ObjectWithDeprecatedFields addBarsItem(String barsItem) {
if (this.bars == null) {
this.bars = new ArrayList<>();
}
this.bars.add(barsItem);
return this;
}
/**
* Get bars
* @return bars
* @deprecated
**/
@Deprecated
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_BARS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<String> getBars() {
return bars;
}
@JsonProperty(JSON_PROPERTY_BARS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setBars(List<String> bars) {
this.bars = bars;
}
/**
* Return true if this ObjectWithDeprecatedFields object is equal to o.
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ObjectWithDeprecatedFields objectWithDeprecatedFields = (ObjectWithDeprecatedFields) o;
return Objects.equals(this.uuid, objectWithDeprecatedFields.uuid) &&
Objects.equals(this.id, objectWithDeprecatedFields.id) &&
Objects.equals(this.deprecatedRef, objectWithDeprecatedFields.deprecatedRef) &&
Objects.equals(this.bars, objectWithDeprecatedFields.bars);
}
@Override
public int hashCode() {
return Objects.hash(uuid, id, deprecatedRef, bars);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ObjectWithDeprecatedFields {\n");
sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" deprecatedRef: ").append(toIndentedString(deprecatedRef)).append("\n");
sb.append(" bars: ").append(toIndentedString(bars)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@@ -0,0 +1,50 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
/**
* Model tests for DeprecatedObject
*/
public class DeprecatedObjectTest {
private final DeprecatedObject model = new DeprecatedObject();
/**
* Model tests for DeprecatedObject
*/
@Test
public void testDeprecatedObject() {
// TODO: test DeprecatedObject
}
/**
* Test the property 'name'
*/
@Test
public void nameTest() {
// TODO: test name
}
}

View File

@@ -0,0 +1,78 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.openapitools.client.model.DeprecatedObject;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
/**
* Model tests for ObjectWithDeprecatedFields
*/
public class ObjectWithDeprecatedFieldsTest {
private final ObjectWithDeprecatedFields model = new ObjectWithDeprecatedFields();
/**
* Model tests for ObjectWithDeprecatedFields
*/
@Test
public void testObjectWithDeprecatedFields() {
// TODO: test ObjectWithDeprecatedFields
}
/**
* Test the property 'uuid'
*/
@Test
public void uuidTest() {
// TODO: test uuid
}
/**
* Test the property 'id'
*/
@Test
public void idTest() {
// TODO: test id
}
/**
* Test the property 'deprecatedRef'
*/
@Test
public void deprecatedRefTest() {
// TODO: test deprecatedRef
}
/**
* Test the property 'bars'
*/
@Test
public void barsTest() {
// TODO: test bars
}
}