add test case for nullable parent property (#16552)

* add nullable case to spring test spec

* generate samples for changed spring input

* add nullable case to general test spec

* generate samples for changed general input

* generate samples again

* generates samples again

* re-build from new sources, generates samples again
This commit is contained in:
martin-mfg
2023-09-12 09:59:58 +02:00
committed by GitHub
parent 196c2b1642
commit d6695056fe
346 changed files with 20471 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ src/main/java/org/openapitools/model/BigCat.java
src/main/java/org/openapitools/model/Capitalization.java
src/main/java/org/openapitools/model/Cat.java
src/main/java/org/openapitools/model/Category.java
src/main/java/org/openapitools/model/ChildWithNullable.java
src/main/java/org/openapitools/model/ClassModel.java
src/main/java/org/openapitools/model/Client.java
src/main/java/org/openapitools/model/ContainerDefaultValue.java
@@ -46,6 +47,7 @@ src/main/java/org/openapitools/model/NumberOnly.java
src/main/java/org/openapitools/model/Order.java
src/main/java/org/openapitools/model/OuterComposite.java
src/main/java/org/openapitools/model/OuterEnum.java
src/main/java/org/openapitools/model/ParentWithNullable.java
src/main/java/org/openapitools/model/Pet.java
src/main/java/org/openapitools/model/ReadOnlyFirst.java
src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java

View File

@@ -6,6 +6,7 @@
package org.openapitools.api;
import java.math.BigDecimal;
import org.openapitools.model.ChildWithNullable;
import org.openapitools.model.Client;
import org.springframework.format.annotation.DateTimeFormat;
import org.openapitools.model.FileSchemaTestClass;
@@ -321,6 +322,24 @@ public interface FakeApi {
);
/**
* POST /fake/nullable : test nullable parent property
*
*
* @param childWithNullable request body (required)
* @return successful operation (status code 200)
*/
@HttpExchange(
method = "POST",
value = "/fake/nullable",
accept = "application/json",
contentType = "application/json"
)
Mono<ResponseEntity<Void>> testNullable(
@RequestBody Mono<ChildWithNullable> childWithNullable
);
/**
* PUT /fake/test-query-parameters
* To test the collection format in query parameters

View File

@@ -0,0 +1,111 @@
package org.openapitools.model;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
import org.openapitools.jackson.nullable.JsonNullable;
import org.openapitools.model.ParentWithNullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import jakarta.validation.constraints.NotNull;
import java.util.*;
import jakarta.annotation.Generated;
/**
* ChildWithNullable
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ChildWithNullable extends ParentWithNullable {
private String otherProperty;
public ChildWithNullable otherProperty(String otherProperty) {
this.otherProperty = otherProperty;
return this;
}
/**
* Get otherProperty
* @return otherProperty
*/
@JsonProperty("otherProperty")
public String getOtherProperty() {
return otherProperty;
}
public void setOtherProperty(String otherProperty) {
this.otherProperty = otherProperty;
}
public ChildWithNullable type(TypeEnum type) {
super.type(type);
return this;
}
public ChildWithNullable nullableProperty(String nullableProperty) {
super.nullableProperty(nullableProperty);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ChildWithNullable childWithNullable = (ChildWithNullable) o;
return Objects.equals(this.otherProperty, childWithNullable.otherProperty) &&
super.equals(o);
}
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> 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(otherProperty, super.hashCode());
}
private static <T> int hashCodeNullable(JsonNullable<T> a) {
if (a == null) {
return 1;
}
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ChildWithNullable {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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,163 @@
package org.openapitools.model;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import jakarta.validation.constraints.NotNull;
import java.util.*;
import jakarta.annotation.Generated;
/**
* ParentWithNullable
*/
@JsonIgnoreProperties(
value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the type to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable")
})
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ParentWithNullable {
/**
* Gets or Sets type
*/
public enum TypeEnum {
CHILDWITHNULLABLE("ChildWithNullable");
private String value;
TypeEnum(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static TypeEnum fromValue(String value) {
for (TypeEnum b : TypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
private TypeEnum type;
private JsonNullable<String> nullableProperty = JsonNullable.<String>undefined();
public ParentWithNullable type(TypeEnum type) {
this.type = type;
return this;
}
/**
* Get type
* @return type
*/
@JsonProperty("type")
public TypeEnum getType() {
return type;
}
public void setType(TypeEnum type) {
this.type = type;
}
public ParentWithNullable nullableProperty(String nullableProperty) {
this.nullableProperty = JsonNullable.of(nullableProperty);
return this;
}
/**
* Get nullableProperty
* @return nullableProperty
*/
@JsonProperty("nullableProperty")
public JsonNullable<String> getNullableProperty() {
return nullableProperty;
}
public void setNullableProperty(JsonNullable<String> nullableProperty) {
this.nullableProperty = nullableProperty;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ParentWithNullable parentWithNullable = (ParentWithNullable) o;
return Objects.equals(this.type, parentWithNullable.type) &&
equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty);
}
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> 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(type, hashCodeNullable(nullableProperty));
}
private static <T> int hashCodeNullable(JsonNullable<T> a) {
if (a == null) {
return 1;
}
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ParentWithNullable {\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 ");
}
}