diff --git a/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml b/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml index 0b5d6425f40e..704dc12186d9 100644 --- a/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml @@ -1125,3 +1125,6 @@ components: - "object" - "null" $ref: '#/components/schemas/Pet' + second_property: + description: just null type + type: null diff --git a/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml b/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml index 6c8d12078e36..45d0e4167627 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml +++ b/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml @@ -1204,6 +1204,8 @@ components: properties: first_property: $ref: "#/components/schemas/Pet" + second_property: + description: just null type updatePetWithForm_request: properties: name: diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/PetWithTypesObjectNullAndRef.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/PetWithTypesObjectNullAndRef.md index 618d36cc0b19..f2554b172d33 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/PetWithTypesObjectNullAndRef.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/PetWithTypesObjectNullAndRef.md @@ -8,6 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**firstProperty** | [**Pet**](Pet.md) | | [optional] | +|**secondProperty** | **Object** | just null type | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/PetWithTypesObjectNullAndRef.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/PetWithTypesObjectNullAndRef.java index 1fcc9f858e46..4b0e53dc8bce 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/PetWithTypesObjectNullAndRef.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/PetWithTypesObjectNullAndRef.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.Arrays; import org.openapitools.client.model.Pet; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -57,6 +58,11 @@ public class PetWithTypesObjectNullAndRef { @javax.annotation.Nullable private Pet firstProperty; + public static final String SERIALIZED_NAME_SECOND_PROPERTY = "second_property"; + @SerializedName(SERIALIZED_NAME_SECOND_PROPERTY) + @javax.annotation.Nullable + private Object secondProperty = null; + public PetWithTypesObjectNullAndRef() { } @@ -78,6 +84,25 @@ public void setFirstProperty(@javax.annotation.Nullable Pet firstProperty) { this.firstProperty = firstProperty; } + + public PetWithTypesObjectNullAndRef secondProperty(@javax.annotation.Nullable Object secondProperty) { + this.secondProperty = secondProperty; + return this; + } + + /** + * just null type + * @return secondProperty + */ + @javax.annotation.Nullable + public Object getSecondProperty() { + return secondProperty; + } + + public void setSecondProperty(@javax.annotation.Nullable Object secondProperty) { + this.secondProperty = secondProperty; + } + /** * A container for additional, undeclared properties. * This is a holder for any undeclared properties as specified with @@ -133,13 +158,25 @@ public boolean equals(Object o) { return false; } PetWithTypesObjectNullAndRef petWithTypesObjectNullAndRef = (PetWithTypesObjectNullAndRef) o; - return Objects.equals(this.firstProperty, petWithTypesObjectNullAndRef.firstProperty)&& + return Objects.equals(this.firstProperty, petWithTypesObjectNullAndRef.firstProperty) && + Objects.equals(this.secondProperty, petWithTypesObjectNullAndRef.secondProperty)&& Objects.equals(this.additionalProperties, petWithTypesObjectNullAndRef.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + @Override public int hashCode() { - return Objects.hash(firstProperty, additionalProperties); + return Objects.hash(firstProperty, secondProperty, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; } @Override @@ -147,6 +184,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PetWithTypesObjectNullAndRef {\n"); sb.append(" firstProperty: ").append(toIndentedString(firstProperty)).append("\n"); + sb.append(" secondProperty: ").append(toIndentedString(secondProperty)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -166,7 +204,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("first_property")); + openapiFields = new HashSet(Arrays.asList("first_property", "second_property")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(0);