mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 00:43:46 +00:00
[Java] better default value handling (#14130)
* add test for array default value * update null return * minor fixes * move default value tests to echo api spec * add new files * remove unused files * fix enum array default, add tests * better array init * Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java Co-authored-by: Leonard Brünings <lord_damokles@gmx.net> * Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java Co-authored-by: Leonard Brünings <lord_damokles@gmx.net> * revert the fix * improve default value handling * update native samples, add tests * update samples * fix tests * use conditional test for timezone * add tests to apache http client echo api * add option to default container to null * fix map default value * minor refactoring * update samples * fix javadoc * fix pom.xml * add tests in java native echo client * add java apache client echo tests * fix test * fix test --------- Co-authored-by: Leonard Brünings <lord_damokles@gmx.net>
This commit is contained in:
@@ -10,6 +10,7 @@ docs/BodyApi.md
|
||||
docs/Category.md
|
||||
docs/DataQuery.md
|
||||
docs/DataQueryAllOf.md
|
||||
docs/DefaultValue.md
|
||||
docs/PathApi.md
|
||||
docs/Pet.md
|
||||
docs/Query.md
|
||||
@@ -46,6 +47,7 @@ src/main/java/org/openapitools/client/model/Bird.java
|
||||
src/main/java/org/openapitools/client/model/Category.java
|
||||
src/main/java/org/openapitools/client/model/DataQuery.java
|
||||
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
|
||||
src/main/java/org/openapitools/client/model/DefaultValue.java
|
||||
src/main/java/org/openapitools/client/model/Pet.java
|
||||
src/main/java/org/openapitools/client/model/Query.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
|
||||
@@ -122,6 +122,7 @@ Class | Method | HTTP request | Description
|
||||
- [Category](docs/Category.md)
|
||||
- [DataQuery](docs/DataQuery.md)
|
||||
- [DataQueryAllOf](docs/DataQueryAllOf.md)
|
||||
- [DefaultValue](docs/DefaultValue.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Query](docs/Query.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
|
||||
@@ -301,6 +301,47 @@ components:
|
||||
type: object
|
||||
xml:
|
||||
name: pet
|
||||
DefaultValue:
|
||||
description: to test the default value of properties
|
||||
properties:
|
||||
array_string_enum_default:
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
items:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
type: array
|
||||
array_string_default:
|
||||
default:
|
||||
- failure
|
||||
- skipped
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
array_integer_default:
|
||||
default:
|
||||
- 1
|
||||
- 3
|
||||
items:
|
||||
type: integer
|
||||
type: array
|
||||
array_string:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
array_string_nullable:
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
type: array
|
||||
string_nullable:
|
||||
nullable: true
|
||||
type: string
|
||||
type: object
|
||||
Bird:
|
||||
properties:
|
||||
size:
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
|
||||
# DefaultValue
|
||||
|
||||
to test the default value of properties
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**arrayStringEnumDefault** | [**List<ArrayStringEnumDefaultEnum>**](#List<ArrayStringEnumDefaultEnum>) | | [optional] |
|
||||
|**arrayStringDefault** | **List<String>** | | [optional] |
|
||||
|**arrayIntegerDefault** | **List<Integer>** | | [optional] |
|
||||
|**arrayString** | **List<String>** | | [optional] |
|
||||
|**arrayStringNullable** | **List<String>** | | [optional] |
|
||||
|**stringNullable** | **String** | | [optional] |
|
||||
|
||||
|
||||
|
||||
## Enum: List<ArrayStringEnumDefaultEnum>
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| SUCCESS | "success" |
|
||||
| FAILURE | "failure" |
|
||||
| UNCLASSIFIED | "unclassified" |
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,496 @@
|
||||
/*
|
||||
* Echo Server API
|
||||
* Echo Server API
|
||||
*
|
||||
* The version of the OpenAPI document: 0.1.0
|
||||
* Contact: team@openapitools.org
|
||||
*
|
||||
* 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.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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* to test the default value of properties
|
||||
*/
|
||||
@JsonPropertyOrder({
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_INTEGER_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_NULLABLE,
|
||||
DefaultValue.JSON_PROPERTY_STRING_NULLABLE
|
||||
})
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class DefaultValue {
|
||||
/**
|
||||
* Gets or Sets arrayStringEnumDefault
|
||||
*/
|
||||
public enum ArrayStringEnumDefaultEnum {
|
||||
SUCCESS("success"),
|
||||
|
||||
FAILURE("failure"),
|
||||
|
||||
UNCLASSIFIED("unclassified");
|
||||
|
||||
private String value;
|
||||
|
||||
ArrayStringEnumDefaultEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static ArrayStringEnumDefaultEnum fromValue(String value) {
|
||||
for (ArrayStringEnumDefaultEnum b : ArrayStringEnumDefaultEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default";
|
||||
private List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default";
|
||||
private List<String> arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default";
|
||||
private List<Integer> arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING = "array_string";
|
||||
private List<String> arrayString = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_NULLABLE = "array_string_nullable";
|
||||
private JsonNullable<List<String>> arrayStringNullable = JsonNullable.<List<String>>undefined();
|
||||
|
||||
public static final String JSON_PROPERTY_STRING_NULLABLE = "string_nullable";
|
||||
private JsonNullable<String> stringNullable = JsonNullable.<String>undefined();
|
||||
|
||||
public DefaultValue() {
|
||||
}
|
||||
|
||||
public DefaultValue arrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) {
|
||||
if (this.arrayStringEnumDefault == null) {
|
||||
this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
|
||||
}
|
||||
this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringEnumDefault
|
||||
* @return arrayStringEnumDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public List<ArrayStringEnumDefaultEnum> getArrayStringEnumDefault() {
|
||||
return arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringDefault(List<String> arrayStringDefault) {
|
||||
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) {
|
||||
if (this.arrayStringDefault == null) {
|
||||
this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
|
||||
}
|
||||
this.arrayStringDefault.add(arrayStringDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringDefault
|
||||
* @return arrayStringDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public List<String> getArrayStringDefault() {
|
||||
return arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayStringDefault(List<String> arrayStringDefault) {
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) {
|
||||
if (this.arrayIntegerDefault == null) {
|
||||
this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
|
||||
}
|
||||
this.arrayIntegerDefault.add(arrayIntegerDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayIntegerDefault
|
||||
* @return arrayIntegerDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public List<Integer> getArrayIntegerDefault() {
|
||||
return arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayString(List<String> arrayString) {
|
||||
|
||||
this.arrayString = arrayString;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringItem(String arrayStringItem) {
|
||||
if (this.arrayString == null) {
|
||||
this.arrayString = new ArrayList<>();
|
||||
}
|
||||
this.arrayString.add(arrayStringItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayString
|
||||
* @return arrayString
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public List<String> getArrayString() {
|
||||
return arrayString;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayString(List<String> arrayString) {
|
||||
this.arrayString = arrayString;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringNullable(List<String> arrayStringNullable) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>of(arrayStringNullable);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) {
|
||||
if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>of(null);
|
||||
}
|
||||
try {
|
||||
this.arrayStringNullable.get().add(arrayStringNullableItem);
|
||||
} catch (java.util.NoSuchElementException e) {
|
||||
// this can never happen, as we make sure above that the value is present
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringNullable
|
||||
* @return arrayStringNullable
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonIgnore
|
||||
|
||||
public List<String> getArrayStringNullable() {
|
||||
return arrayStringNullable.orElse(null);
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public JsonNullable<List<String>> getArrayStringNullable_JsonNullable() {
|
||||
return arrayStringNullable;
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
|
||||
public void setArrayStringNullable_JsonNullable(JsonNullable<List<String>> arrayStringNullable) {
|
||||
this.arrayStringNullable = arrayStringNullable;
|
||||
}
|
||||
|
||||
public void setArrayStringNullable(List<String> arrayStringNullable) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>of(arrayStringNullable);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue stringNullable(String stringNullable) {
|
||||
this.stringNullable = JsonNullable.<String>of(stringNullable);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stringNullable
|
||||
* @return stringNullable
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonIgnore
|
||||
|
||||
public String getStringNullable() {
|
||||
return stringNullable.orElse(null);
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public JsonNullable<String> getStringNullable_JsonNullable() {
|
||||
return stringNullable;
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
|
||||
public void setStringNullable_JsonNullable(JsonNullable<String> stringNullable) {
|
||||
this.stringNullable = stringNullable;
|
||||
}
|
||||
|
||||
public void setStringNullable(String stringNullable) {
|
||||
this.stringNullable = JsonNullable.<String>of(stringNullable);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DefaultValue defaultValue = (DefaultValue) o;
|
||||
return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
|
||||
Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
|
||||
Objects.equals(this.arrayString, defaultValue.arrayString) &&
|
||||
equalsNullable(this.arrayStringNullable, defaultValue.arrayStringNullable) &&
|
||||
equalsNullable(this.stringNullable, defaultValue.stringNullable);
|
||||
}
|
||||
|
||||
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(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, hashCodeNullable(arrayStringNullable), hashCodeNullable(stringNullable));
|
||||
}
|
||||
|
||||
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 DefaultValue {\n");
|
||||
sb.append(" arrayStringEnumDefault: ").append(toIndentedString(arrayStringEnumDefault)).append("\n");
|
||||
sb.append(" arrayStringDefault: ").append(toIndentedString(arrayStringDefault)).append("\n");
|
||||
sb.append(" arrayIntegerDefault: ").append(toIndentedString(arrayIntegerDefault)).append("\n");
|
||||
sb.append(" arrayString: ").append(toIndentedString(arrayString)).append("\n");
|
||||
sb.append(" arrayStringNullable: ").append(toIndentedString(arrayStringNullable)).append("\n");
|
||||
sb.append(" stringNullable: ").append(toIndentedString(stringNullable)).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 ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the instance into URL query string.
|
||||
*
|
||||
* @return URL query string
|
||||
*/
|
||||
public String toUrlQueryString() {
|
||||
return toUrlQueryString(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the instance into URL query string.
|
||||
*
|
||||
* @param prefix prefix of the query string
|
||||
* @return URL query string
|
||||
*/
|
||||
public String toUrlQueryString(String prefix) {
|
||||
String suffix = "";
|
||||
String containerSuffix = "";
|
||||
String containerPrefix = "";
|
||||
if (prefix == null) {
|
||||
// style=form, explode=true, e.g. /pet?name=cat&type=manx
|
||||
prefix = "";
|
||||
} else {
|
||||
// deepObject style e.g. /pet?id[name]=cat&id[type]=manx
|
||||
prefix = prefix + "[";
|
||||
suffix = "]";
|
||||
containerSuffix = "]";
|
||||
containerPrefix = "[";
|
||||
}
|
||||
|
||||
StringJoiner joiner = new StringJoiner("&");
|
||||
|
||||
// add `array_string_enum_default` to the URL query string
|
||||
if (getArrayStringEnumDefault() != null) {
|
||||
for (int i = 0; i < getArrayStringEnumDefault().size(); i++) {
|
||||
try {
|
||||
joiner.add(String.format("%sarray_string_enum_default%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayStringEnumDefault().get(i)), "UTF-8").replaceAll("\\+", "%20")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Should never happen, UTF-8 is always supported
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add `array_string_default` to the URL query string
|
||||
if (getArrayStringDefault() != null) {
|
||||
for (int i = 0; i < getArrayStringDefault().size(); i++) {
|
||||
try {
|
||||
joiner.add(String.format("%sarray_string_default%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayStringDefault().get(i)), "UTF-8").replaceAll("\\+", "%20")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Should never happen, UTF-8 is always supported
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add `array_integer_default` to the URL query string
|
||||
if (getArrayIntegerDefault() != null) {
|
||||
for (int i = 0; i < getArrayIntegerDefault().size(); i++) {
|
||||
try {
|
||||
joiner.add(String.format("%sarray_integer_default%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayIntegerDefault().get(i)), "UTF-8").replaceAll("\\+", "%20")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Should never happen, UTF-8 is always supported
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add `array_string` to the URL query string
|
||||
if (getArrayString() != null) {
|
||||
for (int i = 0; i < getArrayString().size(); i++) {
|
||||
try {
|
||||
joiner.add(String.format("%sarray_string%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayString().get(i)), "UTF-8").replaceAll("\\+", "%20")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Should never happen, UTF-8 is always supported
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add `array_string_nullable` to the URL query string
|
||||
if (getArrayStringNullable() != null) {
|
||||
for (int i = 0; i < getArrayStringNullable().size(); i++) {
|
||||
try {
|
||||
joiner.add(String.format("%sarray_string_nullable%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayStringNullable().get(i)), "UTF-8").replaceAll("\\+", "%20")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Should never happen, UTF-8 is always supported
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add `string_nullable` to the URL query string
|
||||
if (getStringNullable() != null) {
|
||||
try {
|
||||
joiner.add(String.format("%sstring_nullable%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringNullable()), "UTF-8").replaceAll("\\+", "%20")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Should never happen, UTF-8 is always supported
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return joiner.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Pet {
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_TAGS = "tags";
|
||||
private List<Tag> tags = null;
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
|
||||
@@ -78,7 +78,7 @@ public class Query {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_OUTCOMES = "outcomes";
|
||||
private List<OutcomesEnum> outcomes = null;
|
||||
private List<OutcomesEnum> outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
|
||||
|
||||
public Query() {
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class Query {
|
||||
|
||||
public Query addOutcomesItem(OutcomesEnum outcomesItem) {
|
||||
if (this.outcomes == null) {
|
||||
this.outcomes = new ArrayList<>();
|
||||
this.outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
|
||||
}
|
||||
this.outcomes.add(outcomesItem);
|
||||
return this;
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.util.StringJoiner;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
|
||||
public static final String JSON_PROPERTY_VALUES = "values";
|
||||
private List<String> values = null;
|
||||
private List<String> values = new ArrayList<>();
|
||||
|
||||
public TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() {
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
package org.openapitools.client;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Assert;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.api.*;
|
||||
@@ -20,6 +21,7 @@ import org.openapitools.client.model.*;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -138,4 +140,106 @@ public class CustomTest {
|
||||
Assert.assertEquals("/query/integer/boolean/string?integer_query=1&boolean_query=true&string_query=Hello%20World", p.path);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayDefaultValues() {
|
||||
// test array default values
|
||||
DefaultValue d = new DefaultValue();
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(1), "skipped");
|
||||
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
|
||||
|
||||
Assert.assertNull(d.getArrayStringNullable());
|
||||
Assert.assertEquals(d.getArrayString().size(), 0);
|
||||
|
||||
// test addItem
|
||||
d.addArrayStringEnumDefaultItem(DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 3);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(2), DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
|
||||
|
||||
d.addArrayStringDefaultItem("new item");
|
||||
Assert.assertEquals(d.getArrayStringDefault().size(), 3);
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(2), "new item");
|
||||
|
||||
d.addArrayIntegerDefaultItem(5);
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().size(), 3);
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(2), Integer.valueOf(5));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultValuesSerializationWithEmptyPayload() throws IOException {
|
||||
ApiClient apiClient = new ApiClient();
|
||||
|
||||
String str = "{}";
|
||||
|
||||
DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference<DefaultValue>() {
|
||||
});
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(1), "skipped");
|
||||
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
|
||||
|
||||
Assert.assertNull(d.getArrayStringNullable());
|
||||
Assert.assertEquals(d.getArrayString().size(), 0);
|
||||
|
||||
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_default\":[\"success\",\"failure\"],\"array_string_default\":[\"failure\",\"skipped\"],\"array_integer_default\":[1,3],\"array_string\":[],\"array_string_nullable\":{\"present\":false},\"string_nullable\":{\"present\":false}}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultValuesSerializationWithJSONString() throws IOException {
|
||||
ApiClient apiClient = new ApiClient();
|
||||
|
||||
String str = "{ \"array_string_enum_default\": [\"unclassified\"], \"array_string_default\": [\"failure\"] }";
|
||||
|
||||
DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference<DefaultValue>() {
|
||||
});
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 1);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringDefault().size(), 1);
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
|
||||
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
|
||||
|
||||
Assert.assertNull(d.getArrayStringNullable());
|
||||
Assert.assertEquals(d.getArrayString().size(), 0);
|
||||
|
||||
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_default\":[\"unclassified\"],\"array_string_default\":[\"failure\"],\"array_integer_default\":[1,3],\"array_string\":[],\"array_string_nullable\":{\"present\":false},\"string_nullable\":{\"present\":false}}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultValuesSerializationWithIncorrectDefaultValues() throws IOException {
|
||||
ApiClient apiClient = new ApiClient();
|
||||
|
||||
String str = "{ \"array_string_enum_default\": [\"invalid\"] }";
|
||||
|
||||
try {
|
||||
DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference<DefaultValue>() {
|
||||
});
|
||||
Assert.assertTrue(false); // the test should not reach this line
|
||||
} catch (com.fasterxml.jackson.databind.exc.ValueInstantiationException e) {
|
||||
Assert.assertEquals(e.getMessage(), "Cannot construct instance of `org.openapitools.client.model.DefaultValue$ArrayStringEnumDefaultEnum`, problem: Unexpected value 'invalid'\n" +
|
||||
" at [Source: (String)\"{ \"array_string_enum_default\": [\"invalid\"] }\"; line: 1, column: 33] (through reference chain: org.openapitools.client.model.DefaultValue[\"array_string_enum_default\"]->java.util.ArrayList[0])");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Echo Server API
|
||||
* Echo Server API
|
||||
*
|
||||
* The version of the OpenAPI document: 0.1.0
|
||||
* Contact: team@openapitools.org
|
||||
*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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 DefaultValue
|
||||
*/
|
||||
public class DefaultValueTest {
|
||||
private final DefaultValue model = new DefaultValue();
|
||||
|
||||
/**
|
||||
* Model tests for DefaultValue
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultValue() {
|
||||
// TODO: test DefaultValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringEnumDefault'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringEnumDefaultTest() {
|
||||
// TODO: test arrayStringEnumDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringDefault'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringDefaultTest() {
|
||||
// TODO: test arrayStringDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayIntegerDefault'
|
||||
*/
|
||||
@Test
|
||||
public void arrayIntegerDefaultTest() {
|
||||
// TODO: test arrayIntegerDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayString'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringTest() {
|
||||
// TODO: test arrayString
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringNullable'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringNullableTest() {
|
||||
// TODO: test arrayStringNullable
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'stringNullable'
|
||||
*/
|
||||
@Test
|
||||
public void stringNullableTest() {
|
||||
// TODO: test stringNullable
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ src/main/java/org/openapitools/client/model/Bird.java
|
||||
src/main/java/org/openapitools/client/model/Category.java
|
||||
src/main/java/org/openapitools/client/model/DataQuery.java
|
||||
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
|
||||
src/main/java/org/openapitools/client/model/DefaultValue.java
|
||||
src/main/java/org/openapitools/client/model/Pet.java
|
||||
src/main/java/org/openapitools/client/model/Query.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
|
||||
@@ -301,6 +301,47 @@ components:
|
||||
type: object
|
||||
xml:
|
||||
name: pet
|
||||
DefaultValue:
|
||||
description: to test the default value of properties
|
||||
properties:
|
||||
array_string_enum_default:
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
items:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
type: array
|
||||
array_string_default:
|
||||
default:
|
||||
- failure
|
||||
- skipped
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
array_integer_default:
|
||||
default:
|
||||
- 1
|
||||
- 3
|
||||
items:
|
||||
type: integer
|
||||
type: array
|
||||
array_string:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
array_string_nullable:
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
type: array
|
||||
string_nullable:
|
||||
nullable: true
|
||||
type: string
|
||||
type: object
|
||||
Bird:
|
||||
properties:
|
||||
size:
|
||||
|
||||
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
* Echo Server API
|
||||
* Echo Server API
|
||||
*
|
||||
* The version of the OpenAPI document: 0.1.0
|
||||
* Contact: team@openapitools.org
|
||||
*
|
||||
* 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.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
|
||||
/**
|
||||
* to test the default value of properties
|
||||
*/
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class DefaultValue {
|
||||
/**
|
||||
* Gets or Sets arrayStringEnumDefault
|
||||
*/
|
||||
@JsonAdapter(ArrayStringEnumDefaultEnum.Adapter.class)
|
||||
public enum ArrayStringEnumDefaultEnum {
|
||||
SUCCESS("success"),
|
||||
|
||||
FAILURE("failure"),
|
||||
|
||||
UNCLASSIFIED("unclassified");
|
||||
|
||||
private String value;
|
||||
|
||||
ArrayStringEnumDefaultEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
public static ArrayStringEnumDefaultEnum fromValue(String value) {
|
||||
for (ArrayStringEnumDefaultEnum b : ArrayStringEnumDefaultEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
|
||||
public static class Adapter extends TypeAdapter<ArrayStringEnumDefaultEnum> {
|
||||
@Override
|
||||
public void write(final JsonWriter jsonWriter, final ArrayStringEnumDefaultEnum enumeration) throws IOException {
|
||||
jsonWriter.value(enumeration.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOException {
|
||||
String value = jsonReader.nextString();
|
||||
return ArrayStringEnumDefaultEnum.fromValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT)
|
||||
private List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_DEFAULT = "array_string_default";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_DEFAULT)
|
||||
private List<String> arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT = "array_integer_default";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT)
|
||||
private List<Integer> arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING = "array_string";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING)
|
||||
private List<String> arrayString = new ArrayList<>();
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_NULLABLE = "array_string_nullable";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_NULLABLE)
|
||||
private List<String> arrayStringNullable = null;
|
||||
|
||||
public static final String SERIALIZED_NAME_STRING_NULLABLE = "string_nullable";
|
||||
@SerializedName(SERIALIZED_NAME_STRING_NULLABLE)
|
||||
private String stringNullable;
|
||||
|
||||
public DefaultValue() {
|
||||
}
|
||||
|
||||
public DefaultValue arrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) {
|
||||
if (this.arrayStringEnumDefault == null) {
|
||||
this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
|
||||
}
|
||||
this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringEnumDefault
|
||||
* @return arrayStringEnumDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<ArrayStringEnumDefaultEnum> getArrayStringEnumDefault() {
|
||||
return arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringDefault(List<String> arrayStringDefault) {
|
||||
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) {
|
||||
if (this.arrayStringDefault == null) {
|
||||
this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
|
||||
}
|
||||
this.arrayStringDefault.add(arrayStringDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringDefault
|
||||
* @return arrayStringDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<String> getArrayStringDefault() {
|
||||
return arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringDefault(List<String> arrayStringDefault) {
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) {
|
||||
if (this.arrayIntegerDefault == null) {
|
||||
this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
|
||||
}
|
||||
this.arrayIntegerDefault.add(arrayIntegerDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayIntegerDefault
|
||||
* @return arrayIntegerDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<Integer> getArrayIntegerDefault() {
|
||||
return arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayString(List<String> arrayString) {
|
||||
|
||||
this.arrayString = arrayString;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringItem(String arrayStringItem) {
|
||||
if (this.arrayString == null) {
|
||||
this.arrayString = new ArrayList<>();
|
||||
}
|
||||
this.arrayString.add(arrayStringItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayString
|
||||
* @return arrayString
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<String> getArrayString() {
|
||||
return arrayString;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayString(List<String> arrayString) {
|
||||
this.arrayString = arrayString;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringNullable(List<String> arrayStringNullable) {
|
||||
|
||||
this.arrayStringNullable = arrayStringNullable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) {
|
||||
if (this.arrayStringNullable == null) {
|
||||
this.arrayStringNullable = null;
|
||||
}
|
||||
this.arrayStringNullable.add(arrayStringNullableItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringNullable
|
||||
* @return arrayStringNullable
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<String> getArrayStringNullable() {
|
||||
return arrayStringNullable;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringNullable(List<String> arrayStringNullable) {
|
||||
this.arrayStringNullable = arrayStringNullable;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue stringNullable(String stringNullable) {
|
||||
|
||||
this.stringNullable = stringNullable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stringNullable
|
||||
* @return stringNullable
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public String getStringNullable() {
|
||||
return stringNullable;
|
||||
}
|
||||
|
||||
|
||||
public void setStringNullable(String stringNullable) {
|
||||
this.stringNullable = stringNullable;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DefaultValue defaultValue = (DefaultValue) o;
|
||||
return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
|
||||
Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
|
||||
Objects.equals(this.arrayString, defaultValue.arrayString) &&
|
||||
Objects.equals(this.arrayStringNullable, defaultValue.arrayStringNullable) &&
|
||||
Objects.equals(this.stringNullable, defaultValue.stringNullable);
|
||||
}
|
||||
|
||||
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(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, arrayStringNullable, stringNullable);
|
||||
}
|
||||
|
||||
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 DefaultValue {\n");
|
||||
sb.append(" arrayStringEnumDefault: ").append(toIndentedString(arrayStringEnumDefault)).append("\n");
|
||||
sb.append(" arrayStringDefault: ").append(toIndentedString(arrayStringDefault)).append("\n");
|
||||
sb.append(" arrayIntegerDefault: ").append(toIndentedString(arrayIntegerDefault)).append("\n");
|
||||
sb.append(" arrayString: ").append(toIndentedString(arrayString)).append("\n");
|
||||
sb.append(" arrayStringNullable: ").append(toIndentedString(arrayStringNullable)).append("\n");
|
||||
sb.append(" stringNullable: ").append(toIndentedString(stringNullable)).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 ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Pet {
|
||||
|
||||
public static final String SERIALIZED_NAME_TAGS = "tags";
|
||||
@SerializedName(SERIALIZED_NAME_TAGS)
|
||||
private List<Tag> tags = null;
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
|
||||
@@ -84,7 +84,7 @@ public class Query {
|
||||
|
||||
public static final String SERIALIZED_NAME_OUTCOMES = "outcomes";
|
||||
@SerializedName(SERIALIZED_NAME_OUTCOMES)
|
||||
private List<OutcomesEnum> outcomes = null;
|
||||
private List<OutcomesEnum> outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
|
||||
|
||||
public Query() {
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class Query {
|
||||
|
||||
public Query addOutcomesItem(OutcomesEnum outcomesItem) {
|
||||
if (this.outcomes == null) {
|
||||
this.outcomes = new ArrayList<>();
|
||||
this.outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
|
||||
}
|
||||
this.outcomes.add(outcomesItem);
|
||||
return this;
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
|
||||
public static final String SERIALIZED_NAME_VALUES = "values";
|
||||
@SerializedName(SERIALIZED_NAME_VALUES)
|
||||
private List<String> values = null;
|
||||
private List<String> values = new ArrayList<>();
|
||||
|
||||
public TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Echo Server API
|
||||
* Echo Server API
|
||||
*
|
||||
* The version of the OpenAPI document: 0.1.0
|
||||
* Contact: team@openapitools.org
|
||||
*
|
||||
* 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.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for DefaultValue
|
||||
*/
|
||||
class DefaultValueTest {
|
||||
private final DefaultValue model = new DefaultValue();
|
||||
|
||||
/**
|
||||
* Model tests for DefaultValue
|
||||
*/
|
||||
@Test
|
||||
void testDefaultValue() {
|
||||
// TODO: test DefaultValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringEnumDefault'
|
||||
*/
|
||||
@Test
|
||||
void arrayStringEnumDefaultTest() {
|
||||
// TODO: test arrayStringEnumDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringDefault'
|
||||
*/
|
||||
@Test
|
||||
void arrayStringDefaultTest() {
|
||||
// TODO: test arrayStringDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayIntegerDefault'
|
||||
*/
|
||||
@Test
|
||||
void arrayIntegerDefaultTest() {
|
||||
// TODO: test arrayIntegerDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayString'
|
||||
*/
|
||||
@Test
|
||||
void arrayStringTest() {
|
||||
// TODO: test arrayString
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringNullable'
|
||||
*/
|
||||
@Test
|
||||
void arrayStringNullableTest() {
|
||||
// TODO: test arrayStringNullable
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'stringNullable'
|
||||
*/
|
||||
@Test
|
||||
void stringNullableTest() {
|
||||
// TODO: test stringNullable
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ docs/BodyApi.md
|
||||
docs/Category.md
|
||||
docs/DataQuery.md
|
||||
docs/DataQueryAllOf.md
|
||||
docs/DefaultValue.md
|
||||
docs/PathApi.md
|
||||
docs/Pet.md
|
||||
docs/Query.md
|
||||
@@ -43,6 +44,7 @@ src/main/java/org/openapitools/client/model/Bird.java
|
||||
src/main/java/org/openapitools/client/model/Category.java
|
||||
src/main/java/org/openapitools/client/model/DataQuery.java
|
||||
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
|
||||
src/main/java/org/openapitools/client/model/DefaultValue.java
|
||||
src/main/java/org/openapitools/client/model/Pet.java
|
||||
src/main/java/org/openapitools/client/model/Query.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
|
||||
@@ -129,6 +129,7 @@ Class | Method | HTTP request | Description
|
||||
- [Category](docs/Category.md)
|
||||
- [DataQuery](docs/DataQuery.md)
|
||||
- [DataQueryAllOf](docs/DataQueryAllOf.md)
|
||||
- [DefaultValue](docs/DefaultValue.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Query](docs/Query.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
|
||||
@@ -301,6 +301,47 @@ components:
|
||||
type: object
|
||||
xml:
|
||||
name: pet
|
||||
DefaultValue:
|
||||
description: to test the default value of properties
|
||||
properties:
|
||||
array_string_enum_default:
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
items:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
type: array
|
||||
array_string_default:
|
||||
default:
|
||||
- failure
|
||||
- skipped
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
array_integer_default:
|
||||
default:
|
||||
- 1
|
||||
- 3
|
||||
items:
|
||||
type: integer
|
||||
type: array
|
||||
array_string:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
array_string_nullable:
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
type: array
|
||||
string_nullable:
|
||||
nullable: true
|
||||
type: string
|
||||
type: object
|
||||
Bird:
|
||||
properties:
|
||||
size:
|
||||
|
||||
29
samples/client/echo_api/java/native/docs/DefaultValue.md
Normal file
29
samples/client/echo_api/java/native/docs/DefaultValue.md
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
|
||||
# DefaultValue
|
||||
|
||||
to test the default value of properties
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**arrayStringEnumDefault** | [**List<ArrayStringEnumDefaultEnum>**](#List<ArrayStringEnumDefaultEnum>) | | [optional] |
|
||||
|**arrayStringDefault** | **List<String>** | | [optional] |
|
||||
|**arrayIntegerDefault** | **List<Integer>** | | [optional] |
|
||||
|**arrayString** | **List<String>** | | [optional] |
|
||||
|**arrayStringNullable** | **List<String>** | | [optional] |
|
||||
|**stringNullable** | **String** | | [optional] |
|
||||
|
||||
|
||||
|
||||
## Enum: List<ArrayStringEnumDefaultEnum>
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| SUCCESS | "success" |
|
||||
| FAILURE | "failure" |
|
||||
| UNCLASSIFIED | "unclassified" |
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
* Echo Server API
|
||||
* Echo Server API
|
||||
*
|
||||
* The version of the OpenAPI document: 0.1.0
|
||||
* Contact: team@openapitools.org
|
||||
*
|
||||
* 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.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.StringJoiner;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* to test the default value of properties
|
||||
*/
|
||||
@JsonPropertyOrder({
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_INTEGER_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_NULLABLE,
|
||||
DefaultValue.JSON_PROPERTY_STRING_NULLABLE
|
||||
})
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class DefaultValue {
|
||||
/**
|
||||
* Gets or Sets arrayStringEnumDefault
|
||||
*/
|
||||
public enum ArrayStringEnumDefaultEnum {
|
||||
SUCCESS("success"),
|
||||
|
||||
FAILURE("failure"),
|
||||
|
||||
UNCLASSIFIED("unclassified");
|
||||
|
||||
private String value;
|
||||
|
||||
ArrayStringEnumDefaultEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static ArrayStringEnumDefaultEnum fromValue(String value) {
|
||||
for (ArrayStringEnumDefaultEnum b : ArrayStringEnumDefaultEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default";
|
||||
private List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default";
|
||||
private List<String> arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default";
|
||||
private List<Integer> arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING = "array_string";
|
||||
private List<String> arrayString = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_NULLABLE = "array_string_nullable";
|
||||
private JsonNullable<List<String>> arrayStringNullable = JsonNullable.<List<String>>undefined();
|
||||
|
||||
public static final String JSON_PROPERTY_STRING_NULLABLE = "string_nullable";
|
||||
private JsonNullable<String> stringNullable = JsonNullable.<String>undefined();
|
||||
|
||||
public DefaultValue() {
|
||||
}
|
||||
|
||||
public DefaultValue arrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) {
|
||||
if (this.arrayStringEnumDefault == null) {
|
||||
this.arrayStringEnumDefault = new ArrayList<>();
|
||||
}
|
||||
this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringEnumDefault
|
||||
* @return arrayStringEnumDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public List<ArrayStringEnumDefaultEnum> getArrayStringEnumDefault() {
|
||||
return arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringDefault(List<String> arrayStringDefault) {
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) {
|
||||
if (this.arrayStringDefault == null) {
|
||||
this.arrayStringDefault = new ArrayList<>();
|
||||
}
|
||||
this.arrayStringDefault.add(arrayStringDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringDefault
|
||||
* @return arrayStringDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public List<String> getArrayStringDefault() {
|
||||
return arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayStringDefault(List<String> arrayStringDefault) {
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) {
|
||||
if (this.arrayIntegerDefault == null) {
|
||||
this.arrayIntegerDefault = new ArrayList<>();
|
||||
}
|
||||
this.arrayIntegerDefault.add(arrayIntegerDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayIntegerDefault
|
||||
* @return arrayIntegerDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public List<Integer> getArrayIntegerDefault() {
|
||||
return arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayString(List<String> arrayString) {
|
||||
this.arrayString = arrayString;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringItem(String arrayStringItem) {
|
||||
if (this.arrayString == null) {
|
||||
this.arrayString = new ArrayList<>();
|
||||
}
|
||||
this.arrayString.add(arrayStringItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayString
|
||||
* @return arrayString
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public List<String> getArrayString() {
|
||||
return arrayString;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayString(List<String> arrayString) {
|
||||
this.arrayString = arrayString;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringNullable(List<String> arrayStringNullable) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>of(arrayStringNullable);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) {
|
||||
if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>of(null);
|
||||
}
|
||||
try {
|
||||
this.arrayStringNullable.get().add(arrayStringNullableItem);
|
||||
} catch (java.util.NoSuchElementException e) {
|
||||
// this can never happen, as we make sure above that the value is present
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringNullable
|
||||
* @return arrayStringNullable
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonIgnore
|
||||
|
||||
public List<String> getArrayStringNullable() {
|
||||
return arrayStringNullable.orElse(null);
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public JsonNullable<List<String>> getArrayStringNullable_JsonNullable() {
|
||||
return arrayStringNullable;
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
|
||||
public void setArrayStringNullable_JsonNullable(JsonNullable<List<String>> arrayStringNullable) {
|
||||
this.arrayStringNullable = arrayStringNullable;
|
||||
}
|
||||
|
||||
public void setArrayStringNullable(List<String> arrayStringNullable) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>of(arrayStringNullable);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue stringNullable(String stringNullable) {
|
||||
this.stringNullable = JsonNullable.<String>of(stringNullable);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stringNullable
|
||||
* @return stringNullable
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonIgnore
|
||||
|
||||
public String getStringNullable() {
|
||||
return stringNullable.orElse(null);
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public JsonNullable<String> getStringNullable_JsonNullable() {
|
||||
return stringNullable;
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
|
||||
public void setStringNullable_JsonNullable(JsonNullable<String> stringNullable) {
|
||||
this.stringNullable = stringNullable;
|
||||
}
|
||||
|
||||
public void setStringNullable(String stringNullable) {
|
||||
this.stringNullable = JsonNullable.<String>of(stringNullable);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if this DefaultValue object is equal to o.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DefaultValue defaultValue = (DefaultValue) o;
|
||||
return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
|
||||
Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
|
||||
Objects.equals(this.arrayString, defaultValue.arrayString) &&
|
||||
equalsNullable(this.arrayStringNullable, defaultValue.arrayStringNullable) &&
|
||||
equalsNullable(this.stringNullable, defaultValue.stringNullable);
|
||||
}
|
||||
|
||||
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(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, hashCodeNullable(arrayStringNullable), hashCodeNullable(stringNullable));
|
||||
}
|
||||
|
||||
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 DefaultValue {\n");
|
||||
sb.append(" arrayStringEnumDefault: ").append(toIndentedString(arrayStringEnumDefault)).append("\n");
|
||||
sb.append(" arrayStringDefault: ").append(toIndentedString(arrayStringDefault)).append("\n");
|
||||
sb.append(" arrayIntegerDefault: ").append(toIndentedString(arrayIntegerDefault)).append("\n");
|
||||
sb.append(" arrayString: ").append(toIndentedString(arrayString)).append("\n");
|
||||
sb.append(" arrayStringNullable: ").append(toIndentedString(arrayStringNullable)).append("\n");
|
||||
sb.append(" stringNullable: ").append(toIndentedString(stringNullable)).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 ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the instance into URL query string.
|
||||
*
|
||||
* @return URL query string
|
||||
*/
|
||||
public String toUrlQueryString() {
|
||||
return toUrlQueryString(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the instance into URL query string.
|
||||
*
|
||||
* @param prefix prefix of the query string
|
||||
* @return URL query string
|
||||
*/
|
||||
public String toUrlQueryString(String prefix) {
|
||||
String suffix = "";
|
||||
String containerSuffix = "";
|
||||
String containerPrefix = "";
|
||||
if (prefix == null) {
|
||||
// style=form, explode=true, e.g. /pet?name=cat&type=manx
|
||||
prefix = "";
|
||||
} else {
|
||||
// deepObject style e.g. /pet?id[name]=cat&id[type]=manx
|
||||
prefix = prefix + "[";
|
||||
suffix = "]";
|
||||
containerSuffix = "]";
|
||||
containerPrefix = "[";
|
||||
}
|
||||
|
||||
StringJoiner joiner = new StringJoiner("&");
|
||||
|
||||
// add `array_string_enum_default` to the URL query string
|
||||
if (getArrayStringEnumDefault() != null) {
|
||||
for (int i = 0; i < getArrayStringEnumDefault().size(); i++) {
|
||||
joiner.add(String.format("%sarray_string_enum_default%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayStringEnumDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
|
||||
}
|
||||
}
|
||||
|
||||
// add `array_string_default` to the URL query string
|
||||
if (getArrayStringDefault() != null) {
|
||||
for (int i = 0; i < getArrayStringDefault().size(); i++) {
|
||||
joiner.add(String.format("%sarray_string_default%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayStringDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
|
||||
}
|
||||
}
|
||||
|
||||
// add `array_integer_default` to the URL query string
|
||||
if (getArrayIntegerDefault() != null) {
|
||||
for (int i = 0; i < getArrayIntegerDefault().size(); i++) {
|
||||
joiner.add(String.format("%sarray_integer_default%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayIntegerDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
|
||||
}
|
||||
}
|
||||
|
||||
// add `array_string` to the URL query string
|
||||
if (getArrayString() != null) {
|
||||
for (int i = 0; i < getArrayString().size(); i++) {
|
||||
joiner.add(String.format("%sarray_string%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayString().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
|
||||
}
|
||||
}
|
||||
|
||||
// add `array_string_nullable` to the URL query string
|
||||
if (getArrayStringNullable() != null) {
|
||||
for (int i = 0; i < getArrayStringNullable().size(); i++) {
|
||||
joiner.add(String.format("%sarray_string_nullable%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayStringNullable().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
|
||||
}
|
||||
}
|
||||
|
||||
// add `string_nullable` to the URL query string
|
||||
if (getStringNullable() != null) {
|
||||
joiner.add(String.format("%sstring_nullable%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringNullable()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
|
||||
}
|
||||
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Pet {
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_TAGS = "tags";
|
||||
private List<Tag> tags = null;
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
|
||||
@@ -80,7 +80,7 @@ public class Query {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_OUTCOMES = "outcomes";
|
||||
private List<OutcomesEnum> outcomes = null;
|
||||
private List<OutcomesEnum> outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
|
||||
|
||||
public Query() {
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
|
||||
public static final String JSON_PROPERTY_VALUES = "values";
|
||||
private List<String> values = null;
|
||||
private List<String> values = new ArrayList<>();
|
||||
|
||||
public TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() {
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
package org.openapitools.client;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Assert;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.api.*;
|
||||
@@ -20,9 +21,9 @@ import org.openapitools.client.model.*;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* API tests for QueryApi
|
||||
*/
|
||||
@@ -143,4 +144,105 @@ public class CustomTest {
|
||||
org.openapitools.client.EchoServerResponseParser p = new org.openapitools.client.EchoServerResponseParser(response);
|
||||
Assert.assertEquals("/query/style_form/explode_true/array_string?values=hello%20world%201&values=hello%20world%202", p.path);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayDefaultValues() {
|
||||
// test array default values
|
||||
DefaultValue d = new DefaultValue();
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(1), "skipped");
|
||||
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
|
||||
|
||||
Assert.assertNull(d.getArrayStringNullable());
|
||||
Assert.assertEquals(d.getArrayString().size(), 0);
|
||||
|
||||
// test addItem
|
||||
d.addArrayStringEnumDefaultItem(DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 3);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(2), DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
|
||||
|
||||
d.addArrayStringDefaultItem("new item");
|
||||
Assert.assertEquals(d.getArrayStringDefault().size(), 3);
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(2), "new item");
|
||||
|
||||
d.addArrayIntegerDefaultItem(5);
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().size(), 3);
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(2), Integer.valueOf(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultValuesSerializationWithEmptyPayload() throws IOException {
|
||||
ApiClient apiClient = new ApiClient();
|
||||
|
||||
String str = "{}";
|
||||
|
||||
DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference<DefaultValue>() {
|
||||
});
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(1), "skipped");
|
||||
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
|
||||
|
||||
Assert.assertNull(d.getArrayStringNullable());
|
||||
Assert.assertEquals(d.getArrayString().size(), 0);
|
||||
|
||||
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_default\":[\"success\",\"failure\"],\"array_string_default\":[\"failure\",\"skipped\"],\"array_integer_default\":[1,3],\"array_string\":[]}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultValuesSerializationWithJSONString() throws IOException {
|
||||
ApiClient apiClient = new ApiClient();
|
||||
|
||||
String str = "{ \"array_string_enum_default\": [\"unclassified\"], \"array_string_default\": [\"failure\"] }";
|
||||
|
||||
DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference<DefaultValue>() {
|
||||
});
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 1);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringDefault().size(), 1);
|
||||
Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
|
||||
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
|
||||
Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
|
||||
|
||||
Assert.assertNull(d.getArrayStringNullable());
|
||||
Assert.assertEquals(d.getArrayString().size(), 0);
|
||||
|
||||
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_default\":[\"unclassified\"],\"array_string_default\":[\"failure\"],\"array_integer_default\":[1,3],\"array_string\":[]}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultValuesSerializationWithIncorrectDefaultValues() throws IOException {
|
||||
ApiClient apiClient = new ApiClient();
|
||||
|
||||
String str = "{ \"array_string_enum_default\": [\"invalid\"] }";
|
||||
|
||||
try {
|
||||
DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference<DefaultValue>() {
|
||||
});
|
||||
Assert.assertTrue(false); // the test should not reach this line
|
||||
} catch (com.fasterxml.jackson.databind.exc.ValueInstantiationException e) {
|
||||
Assert.assertEquals(e.getMessage(), "Cannot construct instance of `org.openapitools.client.model.DefaultValue$ArrayStringEnumDefaultEnum`, problem: Unexpected value 'invalid'\n" +
|
||||
" at [Source: (String)\"{ \"array_string_enum_default\": [\"invalid\"] }\"; line: 1, column: 33] (through reference chain: org.openapitools.client.model.DefaultValue[\"array_string_enum_default\"]->java.util.ArrayList[0])");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Echo Server API
|
||||
* Echo Server API
|
||||
*
|
||||
* The version of the OpenAPI document: 0.1.0
|
||||
* Contact: team@openapitools.org
|
||||
*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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 DefaultValue
|
||||
*/
|
||||
public class DefaultValueTest {
|
||||
private final DefaultValue model = new DefaultValue();
|
||||
|
||||
/**
|
||||
* Model tests for DefaultValue
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultValue() {
|
||||
// TODO: test DefaultValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringEnumDefault'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringEnumDefaultTest() {
|
||||
// TODO: test arrayStringEnumDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringDefault'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringDefaultTest() {
|
||||
// TODO: test arrayStringDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayString'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringTest() {
|
||||
// TODO: test arrayString
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringNullable'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringNullableTest() {
|
||||
// TODO: test arrayStringNullable
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'stringNullable'
|
||||
*/
|
||||
@Test
|
||||
public void stringNullableTest() {
|
||||
// TODO: test stringNullable
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ docs/BodyApi.md
|
||||
docs/Category.md
|
||||
docs/DataQuery.md
|
||||
docs/DataQueryAllOf.md
|
||||
docs/DefaultValue.md
|
||||
docs/PathApi.md
|
||||
docs/Pet.md
|
||||
docs/Query.md
|
||||
@@ -51,6 +52,7 @@ src/main/java/org/openapitools/client/model/Bird.java
|
||||
src/main/java/org/openapitools/client/model/Category.java
|
||||
src/main/java/org/openapitools/client/model/DataQuery.java
|
||||
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
|
||||
src/main/java/org/openapitools/client/model/DefaultValue.java
|
||||
src/main/java/org/openapitools/client/model/Pet.java
|
||||
src/main/java/org/openapitools/client/model/Query.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
|
||||
@@ -129,6 +129,7 @@ Class | Method | HTTP request | Description
|
||||
- [Category](docs/Category.md)
|
||||
- [DataQuery](docs/DataQuery.md)
|
||||
- [DataQueryAllOf](docs/DataQueryAllOf.md)
|
||||
- [DefaultValue](docs/DefaultValue.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Query](docs/Query.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
|
||||
@@ -301,6 +301,47 @@ components:
|
||||
type: object
|
||||
xml:
|
||||
name: pet
|
||||
DefaultValue:
|
||||
description: to test the default value of properties
|
||||
properties:
|
||||
array_string_enum_default:
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
items:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
type: array
|
||||
array_string_default:
|
||||
default:
|
||||
- failure
|
||||
- skipped
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
array_integer_default:
|
||||
default:
|
||||
- 1
|
||||
- 3
|
||||
items:
|
||||
type: integer
|
||||
type: array
|
||||
array_string:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
array_string_nullable:
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
type: array
|
||||
string_nullable:
|
||||
nullable: true
|
||||
type: string
|
||||
type: object
|
||||
Bird:
|
||||
properties:
|
||||
size:
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
|
||||
# DefaultValue
|
||||
|
||||
to test the default value of properties
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**arrayStringEnumDefault** | [**List<ArrayStringEnumDefaultEnum>**](#List<ArrayStringEnumDefaultEnum>) | | [optional] |
|
||||
|**arrayStringDefault** | **List<String>** | | [optional] |
|
||||
|**arrayIntegerDefault** | **List<Integer>** | | [optional] |
|
||||
|**arrayString** | **List<String>** | | [optional] |
|
||||
|**arrayStringNullable** | **List<String>** | | [optional] |
|
||||
|**stringNullable** | **String** | | [optional] |
|
||||
|
||||
|
||||
|
||||
## Enum: List<ArrayStringEnumDefaultEnum>
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| SUCCESS | "success" |
|
||||
| FAILURE | "failure" |
|
||||
| UNCLASSIFIED | "unclassified" |
|
||||
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ public class JSON {
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Category.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DataQuery.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DataQueryAllOf.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DefaultValue.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Pet.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Tag.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.CustomTypeAdapterFactory());
|
||||
|
||||
@@ -0,0 +1,473 @@
|
||||
/*
|
||||
* Echo Server API
|
||||
* Echo Server API
|
||||
*
|
||||
* The version of the OpenAPI document: 0.1.0
|
||||
* Contact: team@openapitools.org
|
||||
*
|
||||
* 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.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* to test the default value of properties
|
||||
*/
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class DefaultValue {
|
||||
/**
|
||||
* Gets or Sets arrayStringEnumDefault
|
||||
*/
|
||||
@JsonAdapter(ArrayStringEnumDefaultEnum.Adapter.class)
|
||||
public enum ArrayStringEnumDefaultEnum {
|
||||
SUCCESS("success"),
|
||||
|
||||
FAILURE("failure"),
|
||||
|
||||
UNCLASSIFIED("unclassified");
|
||||
|
||||
private String value;
|
||||
|
||||
ArrayStringEnumDefaultEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
public static ArrayStringEnumDefaultEnum fromValue(String value) {
|
||||
for (ArrayStringEnumDefaultEnum b : ArrayStringEnumDefaultEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
|
||||
public static class Adapter extends TypeAdapter<ArrayStringEnumDefaultEnum> {
|
||||
@Override
|
||||
public void write(final JsonWriter jsonWriter, final ArrayStringEnumDefaultEnum enumeration) throws IOException {
|
||||
jsonWriter.value(enumeration.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOException {
|
||||
String value = jsonReader.nextString();
|
||||
return ArrayStringEnumDefaultEnum.fromValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT)
|
||||
private List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault = null;
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_DEFAULT = "array_string_default";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_DEFAULT)
|
||||
private List<String> arrayStringDefault = null;
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT = "array_integer_default";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT)
|
||||
private List<Integer> arrayIntegerDefault = null;
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING = "array_string";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING)
|
||||
private List<String> arrayString = null;
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_NULLABLE = "array_string_nullable";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_NULLABLE)
|
||||
private List<String> arrayStringNullable = null;
|
||||
|
||||
public static final String SERIALIZED_NAME_STRING_NULLABLE = "string_nullable";
|
||||
@SerializedName(SERIALIZED_NAME_STRING_NULLABLE)
|
||||
private String stringNullable;
|
||||
|
||||
public DefaultValue() {
|
||||
}
|
||||
|
||||
public DefaultValue arrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) {
|
||||
if (this.arrayStringEnumDefault == null) {
|
||||
this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
|
||||
}
|
||||
this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringEnumDefault
|
||||
* @return arrayStringEnumDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<ArrayStringEnumDefaultEnum> getArrayStringEnumDefault() {
|
||||
return arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringDefault(List<String> arrayStringDefault) {
|
||||
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) {
|
||||
if (this.arrayStringDefault == null) {
|
||||
this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
|
||||
}
|
||||
this.arrayStringDefault.add(arrayStringDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringDefault
|
||||
* @return arrayStringDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<String> getArrayStringDefault() {
|
||||
return arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringDefault(List<String> arrayStringDefault) {
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) {
|
||||
if (this.arrayIntegerDefault == null) {
|
||||
this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
|
||||
}
|
||||
this.arrayIntegerDefault.add(arrayIntegerDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayIntegerDefault
|
||||
* @return arrayIntegerDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<Integer> getArrayIntegerDefault() {
|
||||
return arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayString(List<String> arrayString) {
|
||||
|
||||
this.arrayString = arrayString;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringItem(String arrayStringItem) {
|
||||
if (this.arrayString == null) {
|
||||
this.arrayString = new ArrayList<>();
|
||||
}
|
||||
this.arrayString.add(arrayStringItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayString
|
||||
* @return arrayString
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<String> getArrayString() {
|
||||
return arrayString;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayString(List<String> arrayString) {
|
||||
this.arrayString = arrayString;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringNullable(List<String> arrayStringNullable) {
|
||||
|
||||
this.arrayStringNullable = arrayStringNullable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) {
|
||||
if (this.arrayStringNullable == null) {
|
||||
this.arrayStringNullable = null;
|
||||
}
|
||||
this.arrayStringNullable.add(arrayStringNullableItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringNullable
|
||||
* @return arrayStringNullable
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<String> getArrayStringNullable() {
|
||||
return arrayStringNullable;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringNullable(List<String> arrayStringNullable) {
|
||||
this.arrayStringNullable = arrayStringNullable;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue stringNullable(String stringNullable) {
|
||||
|
||||
this.stringNullable = stringNullable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stringNullable
|
||||
* @return stringNullable
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public String getStringNullable() {
|
||||
return stringNullable;
|
||||
}
|
||||
|
||||
|
||||
public void setStringNullable(String stringNullable) {
|
||||
this.stringNullable = stringNullable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DefaultValue defaultValue = (DefaultValue) o;
|
||||
return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
|
||||
Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
|
||||
Objects.equals(this.arrayString, defaultValue.arrayString) &&
|
||||
Objects.equals(this.arrayStringNullable, defaultValue.arrayStringNullable) &&
|
||||
Objects.equals(this.stringNullable, defaultValue.stringNullable);
|
||||
}
|
||||
|
||||
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(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, arrayStringNullable, stringNullable);
|
||||
}
|
||||
|
||||
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 DefaultValue {\n");
|
||||
sb.append(" arrayStringEnumDefault: ").append(toIndentedString(arrayStringEnumDefault)).append("\n");
|
||||
sb.append(" arrayStringDefault: ").append(toIndentedString(arrayStringDefault)).append("\n");
|
||||
sb.append(" arrayIntegerDefault: ").append(toIndentedString(arrayIntegerDefault)).append("\n");
|
||||
sb.append(" arrayString: ").append(toIndentedString(arrayString)).append("\n");
|
||||
sb.append(" arrayStringNullable: ").append(toIndentedString(arrayStringNullable)).append("\n");
|
||||
sb.append(" stringNullable: ").append(toIndentedString(stringNullable)).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 ");
|
||||
}
|
||||
|
||||
|
||||
public static HashSet<String> openapiFields;
|
||||
public static HashSet<String> openapiRequiredFields;
|
||||
|
||||
static {
|
||||
// a set of all properties/fields (JSON key names)
|
||||
openapiFields = new HashSet<String>();
|
||||
openapiFields.add("array_string_enum_default");
|
||||
openapiFields.add("array_string_default");
|
||||
openapiFields.add("array_integer_default");
|
||||
openapiFields.add("array_string");
|
||||
openapiFields.add("array_string_nullable");
|
||||
openapiFields.add("string_nullable");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to DefaultValue
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!DefaultValue.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in DefaultValue is not found in the empty JSON string", DefaultValue.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!DefaultValue.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DefaultValue` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
// ensure the optional json data is an array if present
|
||||
if (jsonObj.get("array_string_enum_default") != null && !jsonObj.get("array_string_enum_default").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `array_string_enum_default` to be an array in the JSON string but got `%s`", jsonObj.get("array_string_enum_default").toString()));
|
||||
}
|
||||
// ensure the optional json data is an array if present
|
||||
if (jsonObj.get("array_string_default") != null && !jsonObj.get("array_string_default").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `array_string_default` to be an array in the JSON string but got `%s`", jsonObj.get("array_string_default").toString()));
|
||||
}
|
||||
// ensure the optional json data is an array if present
|
||||
if (jsonObj.get("array_integer_default") != null && !jsonObj.get("array_integer_default").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `array_integer_default` to be an array in the JSON string but got `%s`", jsonObj.get("array_integer_default").toString()));
|
||||
}
|
||||
// ensure the optional json data is an array if present
|
||||
if (jsonObj.get("array_string") != null && !jsonObj.get("array_string").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `array_string` to be an array in the JSON string but got `%s`", jsonObj.get("array_string").toString()));
|
||||
}
|
||||
// ensure the optional json data is an array if present
|
||||
if (jsonObj.get("array_string_nullable") != null && !jsonObj.get("array_string_nullable").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `array_string_nullable` to be an array in the JSON string but got `%s`", jsonObj.get("array_string_nullable").toString()));
|
||||
}
|
||||
if ((jsonObj.get("string_nullable") != null && !jsonObj.get("string_nullable").isJsonNull()) && !jsonObj.get("string_nullable").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `string_nullable` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string_nullable").toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!DefaultValue.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'DefaultValue' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<DefaultValue> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(DefaultValue.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<DefaultValue>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, DefaultValue value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultValue read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of DefaultValue given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of DefaultValue
|
||||
* @throws IOException if the JSON string is invalid with respect to DefaultValue
|
||||
*/
|
||||
public static DefaultValue fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, DefaultValue.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of DefaultValue to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class Query {
|
||||
|
||||
public Query addOutcomesItem(OutcomesEnum outcomesItem) {
|
||||
if (this.outcomes == null) {
|
||||
this.outcomes = new ArrayList<>();
|
||||
this.outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
|
||||
}
|
||||
this.outcomes.add(outcomesItem);
|
||||
return this;
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Echo Server API
|
||||
* Echo Server API
|
||||
*
|
||||
* The version of the OpenAPI document: 0.1.0
|
||||
* Contact: team@openapitools.org
|
||||
*
|
||||
* 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.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for DefaultValue
|
||||
*/
|
||||
public class DefaultValueTest {
|
||||
private final DefaultValue model = new DefaultValue();
|
||||
|
||||
/**
|
||||
* Model tests for DefaultValue
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultValue() {
|
||||
// TODO: test DefaultValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringEnumDefault'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringEnumDefaultTest() {
|
||||
// TODO: test arrayStringEnumDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringDefault'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringDefaultTest() {
|
||||
// TODO: test arrayStringDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayIntegerDefault'
|
||||
*/
|
||||
@Test
|
||||
public void arrayIntegerDefaultTest() {
|
||||
// TODO: test arrayIntegerDefault
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayString'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringTest() {
|
||||
// TODO: test arrayString
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayStringNullable'
|
||||
*/
|
||||
@Test
|
||||
public void arrayStringNullableTest() {
|
||||
// TODO: test arrayStringNullable
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'stringNullable'
|
||||
*/
|
||||
@Test
|
||||
public void stringNullableTest() {
|
||||
// TODO: test stringNullable
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user