-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[java][resttemplate] Fix model combining properties and additional pr…
…operties
- Loading branch information
Showing
121 changed files
with
1,057 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...i-generator/src/main/resources/Java/libraries/resttemplate/additional_properties.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{{#additionalPropertiesType}} | ||
/** | ||
* A container for additional, undeclared properties. | ||
* This is a holder for any undeclared properties as specified with | ||
* the 'additionalProperties' keyword in the OAS document. | ||
*/ | ||
private Map<String, {{{.}}}> additionalProperties; | ||
|
||
/** | ||
* Set the additional (undeclared) property with the specified name and value. | ||
* If the property does not already exist, create it otherwise replace it. | ||
* @param key the name of the property | ||
* @param value the value of the property | ||
* @return self reference | ||
*/ | ||
@JsonAnySetter | ||
public {{classname}} putAdditionalProperty(String key, {{{.}}} value) { | ||
if (this.additionalProperties == null) { | ||
this.additionalProperties = new HashMap<String, {{{.}}}>(); | ||
} | ||
this.additionalProperties.put(key, value); | ||
return this; | ||
} | ||
|
||
/** | ||
* Return the additional (undeclared) properties. | ||
* @return the additional (undeclared) properties | ||
*/ | ||
@JsonAnyGetter | ||
public Map<String, {{{.}}}> getAdditionalProperties() { | ||
return additionalProperties; | ||
} | ||
|
||
/** | ||
* Return the additional (undeclared) property with the specified name. | ||
* @param key the name of the property | ||
* @return the additional (undeclared) property with the specified name | ||
*/ | ||
public {{{.}}} getAdditionalProperty(String key) { | ||
if (this.additionalProperties == null) { | ||
return null; | ||
} | ||
return this.additionalProperties.get(key); | ||
} | ||
{{/additionalPropertiesType}} |
78 changes: 78 additions & 0 deletions
78
modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/model.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{{>licenseInfo}} | ||
|
||
package {{package}}; | ||
|
||
{{#useReflectionEqualsHashCode}} | ||
import org.apache.commons.lang3.builder.EqualsBuilder; | ||
import org.apache.commons.lang3.builder.HashCodeBuilder; | ||
{{/useReflectionEqualsHashCode}} | ||
{{#models}} | ||
{{#model}} | ||
{{#additionalPropertiesType}} | ||
import java.util.Map; | ||
import java.util.HashMap; | ||
import com.fasterxml.jackson.annotation.JsonAnyGetter; | ||
import com.fasterxml.jackson.annotation.JsonAnySetter; | ||
{{/additionalPropertiesType}} | ||
{{/model}} | ||
{{/models}} | ||
import java.util.Objects; | ||
import java.util.Arrays; | ||
{{#imports}} | ||
import {{import}}; | ||
{{/imports}} | ||
{{#serializableModel}} | ||
import java.io.Serializable; | ||
{{/serializableModel}} | ||
{{#jackson}} | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
{{#withXml}} | ||
import com.fasterxml.jackson.dataformat.xml.annotation.*; | ||
{{/withXml}} | ||
{{#vendorExtensions.x-has-readonly-properties}} | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
{{/vendorExtensions.x-has-readonly-properties}} | ||
{{/jackson}} | ||
{{#withXml}} | ||
import {{javaxPackage}}.xml.bind.annotation.*; | ||
import {{javaxPackage}}.xml.bind.annotation.adapters.*; | ||
import io.github.threetenjaxb.core.*; | ||
{{/withXml}} | ||
{{#jsonb}} | ||
import java.lang.reflect.Type; | ||
import {{javaxPackage}}.json.bind.annotation.JsonbTypeDeserializer; | ||
import {{javaxPackage}}.json.bind.annotation.JsonbTypeSerializer; | ||
import {{javaxPackage}}.json.bind.serializer.DeserializationContext; | ||
import {{javaxPackage}}.json.bind.serializer.JsonbDeserializer; | ||
import {{javaxPackage}}.json.bind.serializer.JsonbSerializer; | ||
import {{javaxPackage}}.json.bind.serializer.SerializationContext; | ||
import {{javaxPackage}}.json.stream.JsonGenerator; | ||
import {{javaxPackage}}.json.stream.JsonParser; | ||
import {{javaxPackage}}.json.bind.annotation.JsonbProperty; | ||
{{#vendorExtensions.x-has-readonly-properties}} | ||
import {{javaxPackage}}.json.bind.annotation.JsonbCreator; | ||
{{/vendorExtensions.x-has-readonly-properties}} | ||
{{/jsonb}} | ||
{{#parcelableModel}} | ||
import android.os.Parcelable; | ||
import android.os.Parcel; | ||
{{/parcelableModel}} | ||
{{#useBeanValidation}} | ||
import {{javaxPackage}}.validation.constraints.*; | ||
import {{javaxPackage}}.validation.Valid; | ||
{{/useBeanValidation}} | ||
{{#performBeanValidation}} | ||
import org.hibernate.validator.constraints.*; | ||
{{/performBeanValidation}} | ||
{{#supportUrlQuery}} | ||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLEncoder; | ||
import java.util.StringJoiner; | ||
{{/supportUrlQuery}} | ||
|
||
{{#models}} | ||
{{#model}} | ||
{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{#vendorExtensions.x-is-one-of-interface}}{{>oneof_interface}}{{/vendorExtensions.x-is-one-of-interface}}{{^vendorExtensions.x-is-one-of-interface}}{{>pojo}}{{/vendorExtensions.x-is-one-of-interface}}{{/isEnum}} | ||
{{/model}} | ||
{{/models}} |
Oops, something went wrong.