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

@@ -3,6 +3,7 @@ package org.openapitools.client.api;
import org.openapitools.client.ApiClient;
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;
@@ -1449,6 +1450,75 @@ public class FakeApi {
public ResponseSpec testJsonFormDataWithResponseSpec(String param, String param2) throws WebClientResponseException {
return testJsonFormDataRequestCreation(param, param2);
}
/**
* test nullable parent property
*
* <p><b>200</b> - successful operation
* @param childWithNullable request body
* @throws WebClientResponseException if an error occurs while attempting to invoke the API
*/
private ResponseSpec testNullableRequestCreation(ChildWithNullable childWithNullable) throws WebClientResponseException {
Object postBody = childWithNullable;
// verify the required parameter 'childWithNullable' is set
if (childWithNullable == null) {
throw new WebClientResponseException("Missing the required parameter 'childWithNullable' when calling testNullable", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null);
}
// create path and map variables
final Map<String, Object> pathParams = new HashMap<String, Object>();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
final String[] localVarAccepts = { };
final List<MediaType> localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
"application/json"
};
final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { };
ParameterizedTypeReference<Void> localVarReturnType = new ParameterizedTypeReference<Void>() {};
return apiClient.invokeAPI("/fake/nullable", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
/**
* test nullable parent property
*
* <p><b>200</b> - successful operation
* @param childWithNullable request body
* @throws WebClientResponseException if an error occurs while attempting to invoke the API
*/
public Mono<Void> testNullable(ChildWithNullable childWithNullable) throws WebClientResponseException {
ParameterizedTypeReference<Void> localVarReturnType = new ParameterizedTypeReference<Void>() {};
return testNullableRequestCreation(childWithNullable).bodyToMono(localVarReturnType);
}
/**
* test nullable parent property
*
* <p><b>200</b> - successful operation
* @param childWithNullable request body
* @throws WebClientResponseException if an error occurs while attempting to invoke the API
*/
public Mono<ResponseEntity<Void>> testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws WebClientResponseException {
ParameterizedTypeReference<Void> localVarReturnType = new ParameterizedTypeReference<Void>() {};
return testNullableRequestCreation(childWithNullable).toEntity(localVarReturnType);
}
/**
* test nullable parent property
*
* <p><b>200</b> - successful operation
* @param childWithNullable request body
* @return ResponseSpec
* @throws WebClientResponseException if an error occurs while attempting to invoke the API
*/
public ResponseSpec testNullableWithResponseSpec(ChildWithNullable childWithNullable) throws WebClientResponseException {
return testNullableRequestCreation(childWithNullable);
}
/**
*
* To test the collection format in query parameters

View File

@@ -0,0 +1,142 @@
/*
* 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 io.swagger.v3.oas.annotations.media.Schema;
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
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "")
@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 ChildWithNullable type(TypeEnum type) {
this.setType(type);
return this;
}
@Override
public ChildWithNullable nullableProperty(String nullableProperty) {
this.setNullableProperty(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,206 @@
/*
* 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 io.swagger.v3.oas.annotations.media.Schema;
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
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "")
@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
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "")
@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,69 @@
/*
* 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 io.swagger.v3.oas.annotations.media.Schema;
import org.openapitools.client.model.ParentWithNullable;
import org.openapitools.jackson.nullable.JsonNullable;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
/**
* Model tests for ChildWithNullable
*/
public class ChildWithNullableTest {
private final ChildWithNullable model = new ChildWithNullable();
/**
* Model tests for ChildWithNullable
*/
@Test
public void testChildWithNullable() {
// TODO: test ChildWithNullable
}
/**
* Test the property 'type'
*/
@Test
public void typeTest() {
// TODO: test type
}
/**
* Test the property 'nullableProperty'
*/
@Test
public void nullablePropertyTest() {
// TODO: test nullableProperty
}
/**
* Test the property 'otherProperty'
*/
@Test
public void otherPropertyTest() {
// TODO: test otherProperty
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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 io.swagger.v3.oas.annotations.media.Schema;
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.Assert;
import org.junit.Ignore;
import org.junit.Test;
/**
* Model tests for ParentWithNullable
*/
public class ParentWithNullableTest {
private final ParentWithNullable model = new ParentWithNullable();
/**
* Model tests for ParentWithNullable
*/
@Test
public void testParentWithNullable() {
// TODO: test ParentWithNullable
}
/**
* Test the property 'type'
*/
@Test
public void typeTest() {
// TODO: test type
}
/**
* Test the property 'nullableProperty'
*/
@Test
public void nullablePropertyTest() {
// TODO: test nullableProperty
}
}