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

@@ -48,6 +48,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java
src/main/java/org/openapitools/client/model/Capitalization.java
src/main/java/org/openapitools/client/model/Cat.java
src/main/java/org/openapitools/client/model/Category.java
src/main/java/org/openapitools/client/model/ChildWithNullable.java
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/DeprecatedObject.java
@@ -80,6 +81,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java
src/main/java/org/openapitools/client/model/OuterEnumInteger.java
src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java
src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java
src/main/java/org/openapitools/client/model/ParentWithNullable.java
src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/ReadOnlyFirst.java
src/main/java/org/openapitools/client/model/SingleRefType.java

View File

@@ -1031,6 +1031,25 @@ paths:
- fake
x-content-type: application/json
x-accepts: application/json
/fake/nullable:
post:
description: ""
operationId: testNullable
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ChildWithNullable'
description: request body
required: true
responses:
"200":
description: successful operation
summary: test nullable parent property
tags:
- fake
x-content-type: application/json
x-accepts: application/json
/fake/body-with-query-params:
put:
operationId: testBodyWithQueryParams
@@ -1862,6 +1881,25 @@ components:
OuterBoolean:
type: boolean
x-codegen-body-parameter-name: boolean_post_body
ParentWithNullable:
discriminator:
propertyName: type
properties:
type:
enum:
- ChildWithNullable
type: string
nullableProperty:
nullable: true
type: string
type: object
ChildWithNullable:
allOf:
- $ref: '#/components/schemas/ParentWithNullable'
- properties:
otherProperty:
type: string
type: object
StringBooleanMap:
additionalProperties:
type: boolean

View File

@@ -5,6 +5,7 @@ import org.openapitools.client.EncodingUtils;
import org.openapitools.client.model.ApiResponse;
import java.math.BigDecimal;
import org.openapitools.client.model.ChildWithNullable;
import org.openapitools.client.model.Client;
import org.openapitools.client.model.EnumClass;
import org.openapitools.client.model.FakeBigDecimalMap200Response;
@@ -839,6 +840,33 @@ public interface FakeApi extends ApiClient.Api {
/**
* test nullable parent property
*
* @param childWithNullable request body (required)
*/
@RequestLine("POST /fake/nullable")
@Headers({
"Content-Type: application/json",
"Accept: application/json",
})
void testNullable(ChildWithNullable childWithNullable);
/**
* test nullable parent property
* Similar to <code>testNullable</code> but it also returns the http response headers .
*
* @param childWithNullable request body (required)
*/
@RequestLine("POST /fake/nullable")
@Headers({
"Content-Type: application/json",
"Accept: application/json",
})
ApiResponse<Void> testNullableWithHttpInfo(ChildWithNullable childWithNullable);
/**
*
* To test the collection format in query parameters

View File

@@ -0,0 +1,129 @@
/*
* 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 com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
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.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import org.openapitools.client.model.ParentWithNullable;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
/**
* ChildWithNullable
*/
@JsonPropertyOrder({
ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
@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)
public class ChildWithNullable extends ParentWithNullable {
public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty";
private String otherProperty;
public ChildWithNullable() {
}
public ChildWithNullable otherProperty(String otherProperty) {
this.otherProperty = otherProperty;
return this;
}
/**
* Get otherProperty
* @return otherProperty
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_OTHER_PROPERTY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getOtherProperty() {
return otherProperty;
}
@JsonProperty(JSON_PROPERTY_OTHER_PROPERTY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setOtherProperty(String otherProperty) {
this.otherProperty = otherProperty;
}
@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,204 @@
/*
* 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 com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
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.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
/**
* ParentWithNullable
*/
@JsonPropertyOrder({
ParentWithNullable.JSON_PROPERTY_TYPE,
ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
@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"),
})
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 + "'");
}
}
public static final String JSON_PROPERTY_TYPE = "type";
protected TypeEnum type;
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
private JsonNullable<String> nullableProperty = JsonNullable.<String>undefined();
public ParentWithNullable() {
}
public ParentWithNullable type(TypeEnum type) {
this.type = type;
return this;
}
/**
* Get type
* @return type
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_TYPE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public TypeEnum getType() {
return type;
}
@JsonProperty(JSON_PROPERTY_TYPE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setType(TypeEnum type) {
this.type = type;
}
public ParentWithNullable nullableProperty(String nullableProperty) {
this.nullableProperty = JsonNullable.<String>of(nullableProperty);
return this;
}
/**
* Get nullableProperty
* @return nullableProperty
**/
@javax.annotation.Nullable
@JsonIgnore
public String getNullableProperty() {
return nullableProperty.orElse(null);
}
@JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public JsonNullable<String> getNullableProperty_JsonNullable() {
return nullableProperty;
}
@JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY)
public void setNullableProperty_JsonNullable(JsonNullable<String> nullableProperty) {
this.nullableProperty = nullableProperty;
}
public void setNullableProperty(String nullableProperty) {
this.nullableProperty = JsonNullable.<String>of(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 ");
}
}

View File

@@ -0,0 +1,66 @@
/*
* 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.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
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.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import org.openapitools.client.model.ParentWithNullable;
import org.openapitools.jackson.nullable.JsonNullable;
import org.junit.jupiter.api.Test;
/**
* Model tests for ChildWithNullable
*/
class ChildWithNullableTest {
private final ChildWithNullable model = new ChildWithNullable();
/**
* Model tests for ChildWithNullable
*/
@Test
void testChildWithNullable() {
// TODO: test ChildWithNullable
}
/**
* Test the property 'type'
*/
@Test
void typeTest() {
// TODO: test type
}
/**
* Test the property 'nullableProperty'
*/
@Test
void nullablePropertyTest() {
// TODO: test nullableProperty
}
/**
* Test the property 'otherProperty'
*/
@Test
void otherPropertyTest() {
// TODO: test otherProperty
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
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.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;
import org.junit.jupiter.api.Test;
/**
* Model tests for ParentWithNullable
*/
class ParentWithNullableTest {
private final ParentWithNullable model = new ParentWithNullable();
/**
* Model tests for ParentWithNullable
*/
@Test
void testParentWithNullable() {
// TODO: test ParentWithNullable
}
/**
* Test the property 'type'
*/
@Test
void typeTest() {
// TODO: test type
}
/**
* Test the property 'nullableProperty'
*/
@Test
void nullablePropertyTest() {
// TODO: test nullableProperty
}
}