forked from loafle/openapi-generator-original
[java][feign] Fix model combining properties and additional properties (#19713)
This commit is contained in:
parent
c3c2e7aeca
commit
8167aa1852
@ -53,6 +53,8 @@
|
||||
sha256: 15eeb6d8a9a79d0f1930b861540d9c5780d6c49ea4fdb68269ac3e7ec481e142
|
||||
- filename: "samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/JacksonTest.java"
|
||||
sha256: 45cdaba3d2adc212cd4f0184ad475419a95e2326254c2ef84175e210c922b2f3
|
||||
- filename: "samples/client/petstore/java/feign/src/test/java/org/openapitools/client/JacksonTest.java"
|
||||
sha256: 45cdaba3d2adc212cd4f0184ad475419a95e2326254c2ef84175e210c922b2f3
|
||||
# rust axum test files
|
||||
- filename: "samples/server/petstore/rust-axum/output/rust-axum-oneof/tests/oneof_with_discriminator.rs"
|
||||
sha256: 2d4f5a069fdcb3057bb078d5e75b3de63cd477b97725e457079df24bd2c30600
|
||||
|
@ -506,6 +506,14 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
supportingFiles.add(new SupportingFile("ParamExpander.mustache", invokerFolder, "ParamExpander.java"));
|
||||
}
|
||||
supportingFiles.add(new SupportingFile("EncodingUtils.mustache", invokerFolder, "EncodingUtils.java"));
|
||||
|
||||
// Composed schemas can have the 'additionalProperties' keyword, as specified in JSON schema.
|
||||
// In principle, this should be enabled by default for all code generators. However due to limitations
|
||||
// in other code generators, support needs to be enabled on a case-by-case basis.
|
||||
// The flag below should be set for all Java libraries, but the templates need to be ported
|
||||
// one by one for each library.
|
||||
supportsAdditionalPropertiesWithComposedSchema = true;
|
||||
|
||||
} else if (OKHTTP_GSON.equals(getLibrary()) || StringUtils.isEmpty(getLibrary())) {
|
||||
// the "okhttp-gson" library template requires "ApiCallback.mustache" for async call
|
||||
supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java"));
|
||||
|
@ -263,7 +263,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
}{{#hasVars}}
|
||||
{{classname}} {{classVarName}} = ({{classname}}) o;
|
||||
return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} &&
|
||||
{{/-last}}{{/vars}}{{#parent}} &&
|
||||
{{/-last}}{{/vars}}{{#additionalPropertiesType}} &&
|
||||
Objects.equals(this.additionalProperties, {{classVarName}}.additionalProperties){{/additionalPropertiesType}}{{#parent}} &&
|
||||
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
|
||||
return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}}
|
||||
{{/useReflectionEqualsHashCode}}
|
||||
@ -279,7 +280,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
return HashCodeBuilder.reflectionHashCode(this);
|
||||
{{/useReflectionEqualsHashCode}}
|
||||
{{^useReflectionEqualsHashCode}}
|
||||
return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
|
||||
return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#additionalPropertiesType}}, additionalProperties{{/additionalPropertiesType}});
|
||||
{{/useReflectionEqualsHashCode}}
|
||||
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||
|
||||
@ -300,6 +301,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#vars}}
|
||||
sb.append(" {{name}}: ").append({{#isPassword}}"*"{{/isPassword}}{{^isPassword}}toIndentedString({{name}}){{/isPassword}}).append("\n");
|
||||
{{/vars}}
|
||||
{{#additionalPropertiesType}}
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
{{/additionalPropertiesType}}
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -28,8 +28,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
@ -41,13 +39,12 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
})
|
||||
@javax.annotation.concurrent.Immutable
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.12.0-SNAPSHOT")
|
||||
public class AdditionalPropertiesAnyType extends HashMap<String, Object> {
|
||||
public class AdditionalPropertiesAnyType {
|
||||
public static final String JSON_PROPERTY_NAME = "name";
|
||||
@javax.annotation.Nullable
|
||||
private String name;
|
||||
|
||||
public AdditionalPropertiesAnyType() {
|
||||
|
||||
}
|
||||
|
||||
public AdditionalPropertiesAnyType name(@javax.annotation.Nullable String name) {
|
||||
@ -134,8 +131,8 @@ public class AdditionalPropertiesAnyType extends HashMap<String, Object> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesAnyType {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -28,9 +28,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
@ -42,13 +40,12 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
})
|
||||
@javax.annotation.concurrent.Immutable
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.12.0-SNAPSHOT")
|
||||
public class AdditionalPropertiesArray extends HashMap<String, List> {
|
||||
public class AdditionalPropertiesArray {
|
||||
public static final String JSON_PROPERTY_NAME = "name";
|
||||
@javax.annotation.Nullable
|
||||
private String name;
|
||||
|
||||
public AdditionalPropertiesArray() {
|
||||
|
||||
}
|
||||
|
||||
public AdditionalPropertiesArray name(@javax.annotation.Nullable String name) {
|
||||
@ -135,8 +132,8 @@ public class AdditionalPropertiesArray extends HashMap<String, List> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesArray {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -28,8 +28,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
@ -41,13 +39,12 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
})
|
||||
@javax.annotation.concurrent.Immutable
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.12.0-SNAPSHOT")
|
||||
public class AdditionalPropertiesBoolean extends HashMap<String, Boolean> {
|
||||
public class AdditionalPropertiesBoolean {
|
||||
public static final String JSON_PROPERTY_NAME = "name";
|
||||
@javax.annotation.Nullable
|
||||
private String name;
|
||||
|
||||
public AdditionalPropertiesBoolean() {
|
||||
|
||||
}
|
||||
|
||||
public AdditionalPropertiesBoolean name(@javax.annotation.Nullable String name) {
|
||||
@ -134,8 +131,8 @@ public class AdditionalPropertiesBoolean extends HashMap<String, Boolean> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesBoolean {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -28,8 +28,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
@ -41,13 +39,12 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
})
|
||||
@javax.annotation.concurrent.Immutable
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.12.0-SNAPSHOT")
|
||||
public class AdditionalPropertiesInteger extends HashMap<String, Integer> {
|
||||
public class AdditionalPropertiesInteger {
|
||||
public static final String JSON_PROPERTY_NAME = "name";
|
||||
@javax.annotation.Nullable
|
||||
private String name;
|
||||
|
||||
public AdditionalPropertiesInteger() {
|
||||
|
||||
}
|
||||
|
||||
public AdditionalPropertiesInteger name(@javax.annotation.Nullable String name) {
|
||||
@ -134,8 +131,8 @@ public class AdditionalPropertiesInteger extends HashMap<String, Integer> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesInteger {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -29,8 +29,6 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
@ -42,13 +40,12 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
})
|
||||
@javax.annotation.concurrent.Immutable
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.12.0-SNAPSHOT")
|
||||
public class AdditionalPropertiesNumber extends HashMap<String, BigDecimal> {
|
||||
public class AdditionalPropertiesNumber {
|
||||
public static final String JSON_PROPERTY_NAME = "name";
|
||||
@javax.annotation.Nullable
|
||||
private String name;
|
||||
|
||||
public AdditionalPropertiesNumber() {
|
||||
|
||||
}
|
||||
|
||||
public AdditionalPropertiesNumber name(@javax.annotation.Nullable String name) {
|
||||
@ -135,8 +132,8 @@ public class AdditionalPropertiesNumber extends HashMap<String, BigDecimal> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesNumber {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@ -41,13 +40,12 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
})
|
||||
@javax.annotation.concurrent.Immutable
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.12.0-SNAPSHOT")
|
||||
public class AdditionalPropertiesObject extends HashMap<String, Map> {
|
||||
public class AdditionalPropertiesObject {
|
||||
public static final String JSON_PROPERTY_NAME = "name";
|
||||
@javax.annotation.Nullable
|
||||
private String name;
|
||||
|
||||
public AdditionalPropertiesObject() {
|
||||
|
||||
}
|
||||
|
||||
public AdditionalPropertiesObject name(@javax.annotation.Nullable String name) {
|
||||
@ -134,8 +132,8 @@ public class AdditionalPropertiesObject extends HashMap<String, Map> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesObject {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -28,8 +28,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
@ -41,13 +39,12 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
})
|
||||
@javax.annotation.concurrent.Immutable
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.12.0-SNAPSHOT")
|
||||
public class AdditionalPropertiesString extends HashMap<String, String> {
|
||||
public class AdditionalPropertiesString {
|
||||
public static final String JSON_PROPERTY_NAME = "name";
|
||||
@javax.annotation.Nullable
|
||||
private String name;
|
||||
|
||||
public AdditionalPropertiesString() {
|
||||
|
||||
}
|
||||
|
||||
public AdditionalPropertiesString name(@javax.annotation.Nullable String name) {
|
||||
@ -134,8 +131,8 @@ public class AdditionalPropertiesString extends HashMap<String, String> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesString {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
NullableClass.JSON_PROPERTY_OBJECT_ITEMS_NULLABLE
|
||||
})
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.12.0-SNAPSHOT")
|
||||
public class NullableClass extends HashMap<String, Object> {
|
||||
public class NullableClass {
|
||||
public static final String JSON_PROPERTY_INTEGER_PROP = "integer_prop";
|
||||
private JsonNullable<Integer> integerProp = JsonNullable.<Integer>undefined();
|
||||
|
||||
@ -97,7 +97,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
private Map<String, Object> objectItemsNullable = new HashMap<>();
|
||||
|
||||
public NullableClass() {
|
||||
|
||||
}
|
||||
|
||||
public NullableClass integerProp(@javax.annotation.Nullable Integer integerProp) {
|
||||
@ -620,7 +619,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
equalsNullable(this.objectNullableProp, nullableClass.objectNullableProp) &&
|
||||
equalsNullable(this.objectAndItemsNullableProp, nullableClass.objectAndItemsNullableProp) &&
|
||||
Objects.equals(this.objectItemsNullable, nullableClass.objectItemsNullable) &&
|
||||
super.equals(o);
|
||||
Objects.equals(this.additionalProperties, nullableClass.additionalProperties);
|
||||
}
|
||||
|
||||
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
||||
@ -629,7 +628,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(hashCodeNullable(integerProp), hashCodeNullable(numberProp), hashCodeNullable(booleanProp), hashCodeNullable(stringProp), hashCodeNullable(dateProp), hashCodeNullable(datetimeProp), hashCodeNullable(arrayNullableProp), hashCodeNullable(arrayAndItemsNullableProp), arrayItemsNullable, hashCodeNullable(objectNullableProp), hashCodeNullable(objectAndItemsNullableProp), objectItemsNullable, super.hashCode());
|
||||
return Objects.hash(hashCodeNullable(integerProp), hashCodeNullable(numberProp), hashCodeNullable(booleanProp), hashCodeNullable(stringProp), hashCodeNullable(dateProp), hashCodeNullable(datetimeProp), hashCodeNullable(arrayNullableProp), hashCodeNullable(arrayAndItemsNullableProp), arrayItemsNullable, hashCodeNullable(objectNullableProp), hashCodeNullable(objectAndItemsNullableProp), objectItemsNullable, additionalProperties);
|
||||
}
|
||||
|
||||
private static <T> int hashCodeNullable(JsonNullable<T> a) {
|
||||
@ -643,7 +642,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class NullableClass {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" integerProp: ").append(toIndentedString(integerProp)).append("\n");
|
||||
sb.append(" numberProp: ").append(toIndentedString(numberProp)).append("\n");
|
||||
sb.append(" booleanProp: ").append(toIndentedString(booleanProp)).append("\n");
|
||||
@ -656,6 +654,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
sb.append(" objectNullableProp: ").append(toIndentedString(objectNullableProp)).append("\n");
|
||||
sb.append(" objectAndItemsNullableProp: ").append(toIndentedString(objectAndItemsNullableProp)).append("\n");
|
||||
sb.append(" objectItemsNullable: ").append(toIndentedString(objectItemsNullable)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -24,8 +24,6 @@ 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.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
@ -37,13 +35,12 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
})
|
||||
@JsonTypeName("testInlineFreeformAdditionalProperties_request")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.12.0-SNAPSHOT")
|
||||
public class TestInlineFreeformAdditionalPropertiesRequest extends HashMap<String, Object> {
|
||||
public class TestInlineFreeformAdditionalPropertiesRequest {
|
||||
public static final String JSON_PROPERTY_SOME_PROPERTY = "someProperty";
|
||||
@javax.annotation.Nullable
|
||||
private String someProperty;
|
||||
|
||||
public TestInlineFreeformAdditionalPropertiesRequest() {
|
||||
|
||||
}
|
||||
|
||||
public TestInlineFreeformAdditionalPropertiesRequest someProperty(@javax.annotation.Nullable String someProperty) {
|
||||
@ -125,20 +122,20 @@ public class TestInlineFreeformAdditionalPropertiesRequest extends HashMap<Strin
|
||||
}
|
||||
TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest = (TestInlineFreeformAdditionalPropertiesRequest) o;
|
||||
return Objects.equals(this.someProperty, testInlineFreeformAdditionalPropertiesRequest.someProperty) &&
|
||||
super.equals(o);
|
||||
Objects.equals(this.additionalProperties, testInlineFreeformAdditionalPropertiesRequest.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(someProperty, super.hashCode());
|
||||
return Objects.hash(someProperty, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class TestInlineFreeformAdditionalPropertiesRequest {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" someProperty: ").append(toIndentedString(someProperty)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package org.openapitools.client;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openapitools.client.model.TestInlineFreeformAdditionalPropertiesRequest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class JacksonTest {
|
||||
|
||||
private ObjectMapper mapper;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
mapper = JsonMapper.builder()
|
||||
// For determinist serialization results
|
||||
.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)
|
||||
.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerializeAdditionalProperties() throws JsonProcessingException {
|
||||
// Given
|
||||
TestInlineFreeformAdditionalPropertiesRequest model = new TestInlineFreeformAdditionalPropertiesRequest()
|
||||
.someProperty("value")
|
||||
.putAdditionalProperty("someString", "someValue")
|
||||
.putAdditionalProperty("someNumber", 1.23)
|
||||
.putAdditionalProperty("someBoolean", true);
|
||||
|
||||
// When
|
||||
String string = mapper.writeValueAsString(model);
|
||||
|
||||
// Then
|
||||
String expectedString = "{\"someProperty\":\"value\",\"someBoolean\":true,\"someNumber\":1.23,\"someString\":\"someValue\"}";
|
||||
assertEquals(expectedString, string);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeserializeAdditionalProperties() throws JsonProcessingException {
|
||||
// Given
|
||||
String string = "{\"someProperty\":\"value\",\"someBoolean\":true,\"someNumber\":1.23,\"someString\":\"someValue\"}";
|
||||
|
||||
// When
|
||||
TestInlineFreeformAdditionalPropertiesRequest model = mapper.readValue(
|
||||
string,
|
||||
TestInlineFreeformAdditionalPropertiesRequest.class
|
||||
);
|
||||
|
||||
// Then
|
||||
TestInlineFreeformAdditionalPropertiesRequest expectedModel = new TestInlineFreeformAdditionalPropertiesRequest()
|
||||
.someProperty("value")
|
||||
.putAdditionalProperty("someString", "someValue")
|
||||
.putAdditionalProperty("someNumber", 1.23)
|
||||
.putAdditionalProperty("someBoolean", true);
|
||||
assertEquals(expectedModel, model);
|
||||
|
||||
TestInlineFreeformAdditionalPropertiesRequest invalidModel = new TestInlineFreeformAdditionalPropertiesRequest()
|
||||
.someProperty("value");
|
||||
assertNotEquals(invalidModel, model);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user