mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
[java] Fix enum ref issue in array default value (#14638)
* fix enum ref issue in array default value (java) * update samples * update tests * update samples
This commit is contained in:
parent
cda3517891
commit
bbc42696ab
@ -3946,7 +3946,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (!ModelUtils.isArraySchema(p) && !ModelUtils.isMapSchema(p) && !isFreeFormObject(p) && !isAnyTypeWithNothingElseSet) {
|
||||
/* schemas that are not Array, not ModelUtils.isMapSchema, not isFreeFormObject, not AnyType with nothing else set
|
||||
* so primitive schemas int, str, number, referenced schemas, AnyType schemas with properties, enums, or composition
|
||||
* so primitive schemas int, str, number, referenced schemas, AnyType schemas with properties, enums, or composition
|
||||
*/
|
||||
String type = getSchemaType(p);
|
||||
setNonArrayMapProperty(property, type);
|
||||
|
@ -1004,7 +1004,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
String defaultValue = "";
|
||||
|
||||
if (cp.items.isEnum) { // enum
|
||||
if (cp.items.getIsEnumOrRef()) { // inline or ref enum
|
||||
List<String> defaultValues = new ArrayList<>();
|
||||
for (String _value : _values) {
|
||||
defaultValues.add(cp.items.datatypeWithEnum + "." + toEnumVarName(_value, cp.items.dataType));
|
||||
|
@ -365,10 +365,23 @@ components:
|
||||
- sold
|
||||
xml:
|
||||
name: pet
|
||||
StringEnumRef:
|
||||
type: string
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
DefaultValue:
|
||||
type: object
|
||||
description: to test the default value of properties
|
||||
properties:
|
||||
array_string_enum_ref_default:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
array_string_enum_default:
|
||||
type: array
|
||||
items:
|
||||
|
@ -2,6 +2,6 @@
|
||||
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
|
||||
"spaces": 2,
|
||||
"generator-cli": {
|
||||
"version": "6.2.1"
|
||||
"version": "6.3.0"
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ docs/PathApi.md
|
||||
docs/Pet.md
|
||||
docs/Query.md
|
||||
docs/QueryApi.md
|
||||
docs/StringEnumRef.md
|
||||
docs/Tag.md
|
||||
docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md
|
||||
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
|
||||
@ -54,6 +55,7 @@ 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/StringEnumRef.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java
|
||||
src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
|
||||
|
@ -128,6 +128,7 @@ Class | Method | HTTP request | Description
|
||||
- [DefaultValue](docs/DefaultValue.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Query](docs/Query.md)
|
||||
- [StringEnumRef](docs/StringEnumRef.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md)
|
||||
- [TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md)
|
||||
|
@ -377,9 +377,22 @@ components:
|
||||
type: object
|
||||
xml:
|
||||
name: pet
|
||||
StringEnumRef:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
DefaultValue:
|
||||
description: to test the default value of properties
|
||||
properties:
|
||||
array_string_enum_ref_default:
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
items:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
type: array
|
||||
array_string_enum_default:
|
||||
default:
|
||||
- success
|
||||
|
@ -8,6 +8,7 @@ to test the default value of properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**arrayStringEnumRefDefault** | **List<StringEnumRef>** | | [optional] |
|
||||
|**arrayStringEnumDefault** | [**List<ArrayStringEnumDefaultEnum>**](#List<ArrayStringEnumDefaultEnum>) | | [optional] |
|
||||
|**arrayStringDefault** | **List<String>** | | [optional] |
|
||||
|**arrayIntegerDefault** | **List<Integer>** | | [optional] |
|
||||
|
@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
# StringEnumRef
|
||||
|
||||
## Enum
|
||||
|
||||
|
||||
* `SUCCESS` (value: `"success"`)
|
||||
|
||||
* `FAILURE` (value: `"failure"`)
|
||||
|
||||
* `UNCLASSIFIED` (value: `"unclassified"`)
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
@ -36,6 +37,7 @@ import java.util.StringJoiner;
|
||||
* to test the default value of properties
|
||||
*/
|
||||
@JsonPropertyOrder({
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_INTEGER_DEFAULT,
|
||||
@ -45,6 +47,9 @@ import java.util.StringJoiner;
|
||||
})
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class DefaultValue {
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default";
|
||||
private List<StringEnumRef> arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE));
|
||||
|
||||
/**
|
||||
* Gets or Sets arrayStringEnumDefault
|
||||
*/
|
||||
@ -103,6 +108,40 @@ public class DefaultValue {
|
||||
public DefaultValue() {
|
||||
}
|
||||
|
||||
public DefaultValue arrayStringEnumRefDefault(List<StringEnumRef> arrayStringEnumRefDefault) {
|
||||
|
||||
this.arrayStringEnumRefDefault = arrayStringEnumRefDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEnumRefDefaultItem) {
|
||||
if (this.arrayStringEnumRefDefault == null) {
|
||||
this.arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE));
|
||||
}
|
||||
this.arrayStringEnumRefDefault.add(arrayStringEnumRefDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringEnumRefDefault
|
||||
* @return arrayStringEnumRefDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public List<StringEnumRef> getArrayStringEnumRefDefault() {
|
||||
return arrayStringEnumRefDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayStringEnumRefDefault(List<StringEnumRef> arrayStringEnumRefDefault) {
|
||||
this.arrayStringEnumRefDefault = arrayStringEnumRefDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
@ -328,7 +367,8 @@ public class DefaultValue {
|
||||
return false;
|
||||
}
|
||||
DefaultValue defaultValue = (DefaultValue) o;
|
||||
return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
return Objects.equals(this.arrayStringEnumRefDefault, defaultValue.arrayStringEnumRefDefault) &&
|
||||
Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
|
||||
Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
|
||||
Objects.equals(this.arrayString, defaultValue.arrayString) &&
|
||||
@ -342,7 +382,7 @@ public class DefaultValue {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, hashCodeNullable(arrayStringNullable), hashCodeNullable(stringNullable));
|
||||
return Objects.hash(arrayStringEnumRefDefault, arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, hashCodeNullable(arrayStringNullable), hashCodeNullable(stringNullable));
|
||||
}
|
||||
|
||||
private static <T> int hashCodeNullable(JsonNullable<T> a) {
|
||||
@ -356,6 +396,7 @@ public class DefaultValue {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class DefaultValue {\n");
|
||||
sb.append(" arrayStringEnumRefDefault: ").append(toIndentedString(arrayStringEnumRefDefault)).append("\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");
|
||||
@ -409,6 +450,22 @@ public class DefaultValue {
|
||||
|
||||
StringJoiner joiner = new StringJoiner("&");
|
||||
|
||||
// add `array_string_enum_ref_default` to the URL query string
|
||||
if (getArrayStringEnumRefDefault() != null) {
|
||||
for (int i = 0; i < getArrayStringEnumRefDefault().size(); i++) {
|
||||
if (getArrayStringEnumRefDefault().get(i) != null) {
|
||||
try {
|
||||
joiner.add(String.format("%sarray_string_enum_ref_default%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayStringEnumRefDefault().get(i)), "UTF-8").replaceAll("\\+", "%20")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Should never happen, UTF-8 is always supported
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add `array_string_enum_default` to the URL query string
|
||||
if (getArrayStringEnumDefault() != null) {
|
||||
for (int i = 0; i < getArrayStringEnumDefault().size(); i++) {
|
||||
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets StringEnumRef
|
||||
*/
|
||||
public enum StringEnumRef {
|
||||
|
||||
SUCCESS("success"),
|
||||
|
||||
FAILURE("failure"),
|
||||
|
||||
UNCLASSIFIED("unclassified");
|
||||
|
||||
private String value;
|
||||
|
||||
StringEnumRef(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static StringEnumRef fromValue(String value) {
|
||||
for (StringEnumRef b : StringEnumRef.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the instance into URL query string.
|
||||
*
|
||||
* @param prefix prefix of the query string
|
||||
* @return URL query string
|
||||
*/
|
||||
public String toUrlQueryString(String prefix) {
|
||||
if (prefix == null) {
|
||||
prefix = "";
|
||||
}
|
||||
|
||||
return String.format("%s=%s", prefix, this.toString());
|
||||
}
|
||||
}
|
||||
|
@ -158,6 +158,10 @@ public class CustomTest {
|
||||
public void testArrayDefaultValues() {
|
||||
// test array default values
|
||||
DefaultValue d = new DefaultValue();
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().get(0), StringEnumRef.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().get(1), StringEnumRef.FAILURE);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
|
||||
@ -197,6 +201,10 @@ public class CustomTest {
|
||||
DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference<DefaultValue>() {
|
||||
});
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().get(0), StringEnumRef.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().get(1), StringEnumRef.FAILURE);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
|
||||
@ -212,18 +220,21 @@ public class CustomTest {
|
||||
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}}");
|
||||
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_ref_default\":[\"success\",\"failure\"],\"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\"] }";
|
||||
String str = "{ \"array_string_enum_ref_default\": [\"unclassified\"], \"array_string_enum_default\": [\"unclassified\"], \"array_string_default\": [\"failure\"] }";
|
||||
|
||||
DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference<DefaultValue>() {
|
||||
});
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().size(), 1);
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().get(0), StringEnumRef.UNCLASSIFIED);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 1);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
|
||||
|
||||
@ -237,7 +248,7 @@ public class CustomTest {
|
||||
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}}");
|
||||
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_ref_default\":[\"unclassified\"],\"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
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for StringEnumRef
|
||||
*/
|
||||
public class StringEnumRefTest {
|
||||
/**
|
||||
* Model tests for StringEnumRef
|
||||
*/
|
||||
@Test
|
||||
public void testStringEnumRef() {
|
||||
// TODO: test StringEnumRef
|
||||
}
|
||||
|
||||
}
|
@ -35,6 +35,7 @@ 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/StringEnumRef.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java
|
||||
src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
|
||||
|
@ -377,9 +377,22 @@ components:
|
||||
type: object
|
||||
xml:
|
||||
name: pet
|
||||
StringEnumRef:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
DefaultValue:
|
||||
description: to test the default value of properties
|
||||
properties:
|
||||
array_string_enum_ref_default:
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
items:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
type: array
|
||||
array_string_enum_default:
|
||||
default:
|
||||
- success
|
||||
|
@ -23,6 +23,7 @@ import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
|
||||
/**
|
||||
@ -30,6 +31,10 @@ import org.openapitools.jackson.nullable.JsonNullable;
|
||||
*/
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class DefaultValue {
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT)
|
||||
private List<StringEnumRef> arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE));
|
||||
|
||||
/**
|
||||
* Gets or Sets arrayStringEnumDefault
|
||||
*/
|
||||
@ -106,6 +111,36 @@ public class DefaultValue {
|
||||
public DefaultValue() {
|
||||
}
|
||||
|
||||
public DefaultValue arrayStringEnumRefDefault(List<StringEnumRef> arrayStringEnumRefDefault) {
|
||||
|
||||
this.arrayStringEnumRefDefault = arrayStringEnumRefDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEnumRefDefaultItem) {
|
||||
if (this.arrayStringEnumRefDefault == null) {
|
||||
this.arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE));
|
||||
}
|
||||
this.arrayStringEnumRefDefault.add(arrayStringEnumRefDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringEnumRefDefault
|
||||
* @return arrayStringEnumRefDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<StringEnumRef> getArrayStringEnumRefDefault() {
|
||||
return arrayStringEnumRefDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringEnumRefDefault(List<StringEnumRef> arrayStringEnumRefDefault) {
|
||||
this.arrayStringEnumRefDefault = arrayStringEnumRefDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
@ -287,7 +322,8 @@ public class DefaultValue {
|
||||
return false;
|
||||
}
|
||||
DefaultValue defaultValue = (DefaultValue) o;
|
||||
return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
return Objects.equals(this.arrayStringEnumRefDefault, defaultValue.arrayStringEnumRefDefault) &&
|
||||
Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
|
||||
Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
|
||||
Objects.equals(this.arrayString, defaultValue.arrayString) &&
|
||||
@ -301,7 +337,7 @@ public class DefaultValue {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, arrayStringNullable, stringNullable);
|
||||
return Objects.hash(arrayStringEnumRefDefault, arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, arrayStringNullable, stringNullable);
|
||||
}
|
||||
|
||||
private static <T> int hashCodeNullable(JsonNullable<T> a) {
|
||||
@ -315,6 +351,7 @@ public class DefaultValue {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class DefaultValue {\n");
|
||||
sb.append(" arrayStringEnumRefDefault: ").append(toIndentedString(arrayStringEnumRefDefault)).append("\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");
|
||||
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.annotations.SerializedName;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
/**
|
||||
* Gets or Sets StringEnumRef
|
||||
*/
|
||||
@JsonAdapter(StringEnumRef.Adapter.class)
|
||||
public enum StringEnumRef {
|
||||
|
||||
SUCCESS("success"),
|
||||
|
||||
FAILURE("failure"),
|
||||
|
||||
UNCLASSIFIED("unclassified");
|
||||
|
||||
private String value;
|
||||
|
||||
StringEnumRef(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
public static StringEnumRef fromValue(String value) {
|
||||
for (StringEnumRef b : StringEnumRef.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
|
||||
public static class Adapter extends TypeAdapter<StringEnumRef> {
|
||||
@Override
|
||||
public void write(final JsonWriter jsonWriter, final StringEnumRef enumeration) throws IOException {
|
||||
jsonWriter.value(enumeration.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringEnumRef read(final JsonReader jsonReader) throws IOException {
|
||||
String value = jsonReader.nextString();
|
||||
return StringEnumRef.fromValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.annotations.SerializedName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for StringEnumRef
|
||||
*/
|
||||
class StringEnumRefTest {
|
||||
/**
|
||||
* Model tests for StringEnumRef
|
||||
*/
|
||||
@Test
|
||||
void testStringEnumRef() {
|
||||
// TODO: test StringEnumRef
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,7 @@ docs/PathApi.md
|
||||
docs/Pet.md
|
||||
docs/Query.md
|
||||
docs/QueryApi.md
|
||||
docs/StringEnumRef.md
|
||||
docs/Tag.md
|
||||
docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md
|
||||
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
|
||||
@ -51,6 +52,7 @@ 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/StringEnumRef.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java
|
||||
src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
|
||||
|
@ -138,6 +138,7 @@ Class | Method | HTTP request | Description
|
||||
- [DefaultValue](docs/DefaultValue.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Query](docs/Query.md)
|
||||
- [StringEnumRef](docs/StringEnumRef.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md)
|
||||
- [TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md)
|
||||
|
@ -377,9 +377,22 @@ components:
|
||||
type: object
|
||||
xml:
|
||||
name: pet
|
||||
StringEnumRef:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
DefaultValue:
|
||||
description: to test the default value of properties
|
||||
properties:
|
||||
array_string_enum_ref_default:
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
items:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
type: array
|
||||
array_string_enum_default:
|
||||
default:
|
||||
- success
|
||||
|
@ -8,6 +8,7 @@ to test the default value of properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**arrayStringEnumRefDefault** | **List<StringEnumRef>** | | [optional] |
|
||||
|**arrayStringEnumDefault** | [**List<ArrayStringEnumDefaultEnum>**](#List<ArrayStringEnumDefaultEnum>) | | [optional] |
|
||||
|**arrayStringDefault** | **List<String>** | | [optional] |
|
||||
|**arrayIntegerDefault** | **List<Integer>** | | [optional] |
|
||||
|
15
samples/client/echo_api/java/native/docs/EnumStringRef.md
Normal file
15
samples/client/echo_api/java/native/docs/EnumStringRef.md
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
# EnumStringRef
|
||||
|
||||
## Enum
|
||||
|
||||
|
||||
* `SUCCESS` (value: `"success"`)
|
||||
|
||||
* `FAILURE` (value: `"failure"`)
|
||||
|
||||
* `UNCLASSIFIED` (value: `"unclassified"`)
|
||||
|
||||
|
||||
|
15
samples/client/echo_api/java/native/docs/StringEnumRef.md
Normal file
15
samples/client/echo_api/java/native/docs/StringEnumRef.md
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
# StringEnumRef
|
||||
|
||||
## Enum
|
||||
|
||||
|
||||
* `SUCCESS` (value: `"success"`)
|
||||
|
||||
* `FAILURE` (value: `"failure"`)
|
||||
|
||||
* `UNCLASSIFIED` (value: `"unclassified"`)
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
@ -38,6 +39,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
* to test the default value of properties
|
||||
*/
|
||||
@JsonPropertyOrder({
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_STRING_DEFAULT,
|
||||
DefaultValue.JSON_PROPERTY_ARRAY_INTEGER_DEFAULT,
|
||||
@ -47,6 +49,9 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
})
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class DefaultValue {
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default";
|
||||
private List<StringEnumRef> arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE));
|
||||
|
||||
/**
|
||||
* Gets or Sets arrayStringEnumDefault
|
||||
*/
|
||||
@ -105,6 +110,39 @@ public class DefaultValue {
|
||||
public DefaultValue() {
|
||||
}
|
||||
|
||||
public DefaultValue arrayStringEnumRefDefault(List<StringEnumRef> arrayStringEnumRefDefault) {
|
||||
this.arrayStringEnumRefDefault = arrayStringEnumRefDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEnumRefDefaultItem) {
|
||||
if (this.arrayStringEnumRefDefault == null) {
|
||||
this.arrayStringEnumRefDefault = new ArrayList<>();
|
||||
}
|
||||
this.arrayStringEnumRefDefault.add(arrayStringEnumRefDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringEnumRefDefault
|
||||
* @return arrayStringEnumRefDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public List<StringEnumRef> getArrayStringEnumRefDefault() {
|
||||
return arrayStringEnumRefDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayStringEnumRefDefault(List<StringEnumRef> arrayStringEnumRefDefault) {
|
||||
this.arrayStringEnumRefDefault = arrayStringEnumRefDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
return this;
|
||||
@ -327,7 +365,8 @@ public class DefaultValue {
|
||||
return false;
|
||||
}
|
||||
DefaultValue defaultValue = (DefaultValue) o;
|
||||
return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
return Objects.equals(this.arrayStringEnumRefDefault, defaultValue.arrayStringEnumRefDefault) &&
|
||||
Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
|
||||
Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
|
||||
Objects.equals(this.arrayString, defaultValue.arrayString) &&
|
||||
@ -341,7 +380,7 @@ public class DefaultValue {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, hashCodeNullable(arrayStringNullable), hashCodeNullable(stringNullable));
|
||||
return Objects.hash(arrayStringEnumRefDefault, arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, hashCodeNullable(arrayStringNullable), hashCodeNullable(stringNullable));
|
||||
}
|
||||
|
||||
private static <T> int hashCodeNullable(JsonNullable<T> a) {
|
||||
@ -355,6 +394,7 @@ public class DefaultValue {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class DefaultValue {\n");
|
||||
sb.append(" arrayStringEnumRefDefault: ").append(toIndentedString(arrayStringEnumRefDefault)).append("\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");
|
||||
@ -408,6 +448,17 @@ public class DefaultValue {
|
||||
|
||||
StringJoiner joiner = new StringJoiner("&");
|
||||
|
||||
// add `array_string_enum_ref_default` to the URL query string
|
||||
if (getArrayStringEnumRefDefault() != null) {
|
||||
for (int i = 0; i < getArrayStringEnumRefDefault().size(); i++) {
|
||||
if (getArrayStringEnumRefDefault().get(i) != null) {
|
||||
joiner.add(String.format("%sarray_string_enum_ref_default%s%s=%s", prefix, suffix,
|
||||
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
|
||||
URLEncoder.encode(String.valueOf(getArrayStringEnumRefDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add `array_string_enum_default` to the URL query string
|
||||
if (getArrayStringEnumDefault() != null) {
|
||||
for (int i = 0; i < getArrayStringEnumDefault().size(); i++) {
|
||||
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.JsonPropertyOrder;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets EnumStringRef
|
||||
*/
|
||||
public enum EnumStringRef {
|
||||
|
||||
SUCCESS("success"),
|
||||
|
||||
FAILURE("failure"),
|
||||
|
||||
UNCLASSIFIED("unclassified");
|
||||
|
||||
private String value;
|
||||
|
||||
EnumStringRef(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static EnumStringRef fromValue(String value) {
|
||||
for (EnumStringRef b : EnumStringRef.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the instance into URL query string.
|
||||
*
|
||||
* @param prefix prefix of the query string
|
||||
* @return URL query string
|
||||
*/
|
||||
public String toUrlQueryString(String prefix) {
|
||||
if (prefix == null) {
|
||||
prefix = "";
|
||||
}
|
||||
|
||||
return String.format("%s=%s", prefix, this.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.JsonPropertyOrder;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets StringEnumRef
|
||||
*/
|
||||
public enum StringEnumRef {
|
||||
|
||||
SUCCESS("success"),
|
||||
|
||||
FAILURE("failure"),
|
||||
|
||||
UNCLASSIFIED("unclassified");
|
||||
|
||||
private String value;
|
||||
|
||||
StringEnumRef(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static StringEnumRef fromValue(String value) {
|
||||
for (StringEnumRef b : StringEnumRef.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the instance into URL query string.
|
||||
*
|
||||
* @param prefix prefix of the query string
|
||||
* @return URL query string
|
||||
*/
|
||||
public String toUrlQueryString(String prefix) {
|
||||
if (prefix == null) {
|
||||
prefix = "";
|
||||
}
|
||||
|
||||
return String.format("%s=%s", prefix, this.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -150,6 +150,10 @@ public class CustomTest {
|
||||
public void testArrayDefaultValues() {
|
||||
// test array default values
|
||||
DefaultValue d = new DefaultValue();
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().get(0), StringEnumRef.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().get(1), StringEnumRef.FAILURE);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
|
||||
@ -188,6 +192,10 @@ public class CustomTest {
|
||||
DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference<DefaultValue>() {
|
||||
});
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().get(0), StringEnumRef.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().get(1), StringEnumRef.FAILURE);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
|
||||
@ -203,18 +211,21 @@ public class CustomTest {
|
||||
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\":[]}");
|
||||
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_ref_default\":[\"success\",\"failure\"],\"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\"] }";
|
||||
String str = "{ \"array_string_enum_ref_default\": [\"unclassified\"], \"array_string_enum_default\": [\"unclassified\"], \"array_string_default\": [\"failure\"] }";
|
||||
|
||||
DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference<DefaultValue>() {
|
||||
});
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().size(), 1);
|
||||
Assert.assertEquals(d.getArrayStringEnumRefDefault().get(0), StringEnumRef.UNCLASSIFIED);
|
||||
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().size(), 1);
|
||||
Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
|
||||
|
||||
@ -228,7 +239,7 @@ public class CustomTest {
|
||||
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\":[]}");
|
||||
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_ref_default\":[\"unclassified\"],\"array_string_enum_default\":[\"unclassified\"],\"array_string_default\":[\"failure\"],\"array_integer_default\":[1,3],\"array_string\":[]}");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -247,7 +258,6 @@ public class CustomTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test form parameter(s)
|
||||
*
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for EnumStringRef
|
||||
*/
|
||||
public class EnumStringRefTest {
|
||||
/**
|
||||
* Model tests for EnumStringRef
|
||||
*/
|
||||
@Test
|
||||
public void testEnumStringRef() {
|
||||
// TODO: test EnumStringRef
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for StringEnumRef
|
||||
*/
|
||||
public class StringEnumRefTest {
|
||||
/**
|
||||
* Model tests for StringEnumRef
|
||||
*/
|
||||
@Test
|
||||
public void testStringEnumRef() {
|
||||
// TODO: test StringEnumRef
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,7 @@ docs/PathApi.md
|
||||
docs/Pet.md
|
||||
docs/Query.md
|
||||
docs/QueryApi.md
|
||||
docs/StringEnumRef.md
|
||||
docs/Tag.md
|
||||
docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md
|
||||
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
|
||||
@ -59,6 +60,7 @@ 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/StringEnumRef.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java
|
||||
src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
|
||||
|
@ -135,6 +135,7 @@ Class | Method | HTTP request | Description
|
||||
- [DefaultValue](docs/DefaultValue.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Query](docs/Query.md)
|
||||
- [StringEnumRef](docs/StringEnumRef.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md)
|
||||
- [TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md)
|
||||
|
@ -377,9 +377,22 @@ components:
|
||||
type: object
|
||||
xml:
|
||||
name: pet
|
||||
StringEnumRef:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
DefaultValue:
|
||||
description: to test the default value of properties
|
||||
properties:
|
||||
array_string_enum_ref_default:
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
items:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
type: array
|
||||
array_string_enum_default:
|
||||
default:
|
||||
- success
|
||||
|
@ -8,6 +8,7 @@ to test the default value of properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**arrayStringEnumRefDefault** | **List<StringEnumRef>** | | [optional] |
|
||||
|**arrayStringEnumDefault** | [**List<ArrayStringEnumDefaultEnum>**](#List<ArrayStringEnumDefaultEnum>) | | [optional] |
|
||||
|**arrayStringDefault** | **List<String>** | | [optional] |
|
||||
|**arrayIntegerDefault** | **List<Integer>** | | [optional] |
|
||||
|
@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
# StringEnumRef
|
||||
|
||||
## Enum
|
||||
|
||||
|
||||
* `SUCCESS` (value: `"success"`)
|
||||
|
||||
* `FAILURE` (value: `"failure"`)
|
||||
|
||||
* `UNCLASSIFIED` (value: `"unclassified"`)
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@ -51,6 +52,10 @@ import org.openapitools.client.JSON;
|
||||
*/
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class DefaultValue {
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT)
|
||||
private List<StringEnumRef> arrayStringEnumRefDefault = null;
|
||||
|
||||
/**
|
||||
* Gets or Sets arrayStringEnumDefault
|
||||
*/
|
||||
@ -127,6 +132,36 @@ public class DefaultValue {
|
||||
public DefaultValue() {
|
||||
}
|
||||
|
||||
public DefaultValue arrayStringEnumRefDefault(List<StringEnumRef> arrayStringEnumRefDefault) {
|
||||
|
||||
this.arrayStringEnumRefDefault = arrayStringEnumRefDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEnumRefDefaultItem) {
|
||||
if (this.arrayStringEnumRefDefault == null) {
|
||||
this.arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE));
|
||||
}
|
||||
this.arrayStringEnumRefDefault.add(arrayStringEnumRefDefaultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayStringEnumRefDefault
|
||||
* @return arrayStringEnumRefDefault
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
|
||||
public List<StringEnumRef> getArrayStringEnumRefDefault() {
|
||||
return arrayStringEnumRefDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringEnumRefDefault(List<StringEnumRef> arrayStringEnumRefDefault) {
|
||||
this.arrayStringEnumRefDefault = arrayStringEnumRefDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
@ -309,7 +344,8 @@ public class DefaultValue {
|
||||
return false;
|
||||
}
|
||||
DefaultValue defaultValue = (DefaultValue) o;
|
||||
return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
return Objects.equals(this.arrayStringEnumRefDefault, defaultValue.arrayStringEnumRefDefault) &&
|
||||
Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
|
||||
Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
|
||||
Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
|
||||
Objects.equals(this.arrayString, defaultValue.arrayString) &&
|
||||
@ -323,7 +359,7 @@ public class DefaultValue {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, arrayStringNullable, stringNullable);
|
||||
return Objects.hash(arrayStringEnumRefDefault, arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, arrayStringNullable, stringNullable);
|
||||
}
|
||||
|
||||
private static <T> int hashCodeNullable(JsonNullable<T> a) {
|
||||
@ -337,6 +373,7 @@ public class DefaultValue {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class DefaultValue {\n");
|
||||
sb.append(" arrayStringEnumRefDefault: ").append(toIndentedString(arrayStringEnumRefDefault)).append("\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");
|
||||
@ -365,6 +402,7 @@ public class DefaultValue {
|
||||
static {
|
||||
// a set of all properties/fields (JSON key names)
|
||||
openapiFields = new HashSet<String>();
|
||||
openapiFields.add("array_string_enum_ref_default");
|
||||
openapiFields.add("array_string_enum_default");
|
||||
openapiFields.add("array_string_default");
|
||||
openapiFields.add("array_integer_default");
|
||||
@ -397,6 +435,10 @@ public class DefaultValue {
|
||||
}
|
||||
}
|
||||
// ensure the optional json data is an array if present
|
||||
if (jsonObj.get("array_string_enum_ref_default") != null && !jsonObj.get("array_string_enum_ref_default").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `array_string_enum_ref_default` to be an array in the JSON string but got `%s`", jsonObj.get("array_string_enum_ref_default").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()));
|
||||
}
|
||||
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.annotations.SerializedName;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
/**
|
||||
* Gets or Sets StringEnumRef
|
||||
*/
|
||||
@JsonAdapter(StringEnumRef.Adapter.class)
|
||||
public enum StringEnumRef {
|
||||
|
||||
SUCCESS("success"),
|
||||
|
||||
FAILURE("failure"),
|
||||
|
||||
UNCLASSIFIED("unclassified");
|
||||
|
||||
private String value;
|
||||
|
||||
StringEnumRef(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
public static StringEnumRef fromValue(String value) {
|
||||
for (StringEnumRef b : StringEnumRef.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
|
||||
public static class Adapter extends TypeAdapter<StringEnumRef> {
|
||||
@Override
|
||||
public void write(final JsonWriter jsonWriter, final StringEnumRef enumeration) throws IOException {
|
||||
jsonWriter.value(enumeration.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringEnumRef read(final JsonReader jsonReader) throws IOException {
|
||||
String value = jsonReader.nextString();
|
||||
return StringEnumRef.fromValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.annotations.SerializedName;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for StringEnumRef
|
||||
*/
|
||||
public class StringEnumRefTest {
|
||||
/**
|
||||
* Model tests for StringEnumRef
|
||||
*/
|
||||
@Test
|
||||
public void testStringEnumRef() {
|
||||
// TODO: test StringEnumRef
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user