forked from loafle/openapi-generator-original
[Feature][Java/Spring] Support Discriminator Based OneOf Interface (#11650)
* Fix OpenAPITools#5381 added x-is-one-of-interface extension for oneOf interface in mustache template * Fix OpenAPITools#5381 fixed name of model from UNKNOWN_BASE_TYPE to right one in api: operationId + OneOf Fix OpenAPITools#5381 parcelableModel is not required * Fix OpenAPITools#5381 removed not needed methods * Fix OpenAPITools#5381 catch NPE cases in preprocessOpenAPI updated samples * Fix OpenAPITools#5381 fixed generation of oneOf Models * Fix OpenAPITools#5381 addOneOfInterfaceModel only for cases when useOneOfInterfaces is true and for spring * Fix OpenAPITools#5381 NPE fix * Fix OpenAPITools#5381 spring: fixed use of oneOf Models in API * Fix OpenAPITools#5381 implementing oneOf for spring lib overriding methods with different behavior from default * Fix OpenAPITools#5381 added x-is-one-of-interface extension for oneOf interface in mustache template * Fix OpenAPITools#5381 fixed name of model from UNKNOWN_BASE_TYPE to right one in api: operationId + OneOf Fix OpenAPITools#5381 removed not needed methods Fix OpenAPITools#5381 fixed generation of oneOf Models Fix OpenAPITools#5381 addOneOfInterfaceModel only for cases when useOneOfInterfaces is true and for spring Fix OpenAPITools#5381 NPE fix for tests * Fix OpenAPITools#5381 fixed handing of composed schema with array * Fix OpenAPITools#5381 fixed NPE in addOneOfInterfaceModel * Fix OpenAPITools#5381 fixed generation of oneOf models with descriminator * Initial merge of 5.0 * Aligned with master formatting * Corrected spacing for class names to align with samples. * Merged master * Updated samples * Consolidate methods from JavaClient and SpringCodegen (mov up to AbstractJavaCodegen) * set useLegacyDiscriminator to false, format templates * Suport JsonTypeName, fq class name for spring.io.Resource * Generate Samples * Test full qualified usage of the spring Resource interface. * Add java-camel to samples.circleci.spring profile * Add more complex example combining inheritance and oneof-interface * Remove x-implements Serializable from JavaClientCodegen (moved to AbstractJavaCodegen) * Fix spacing before opening brace after extends/implements * Generate Samples * Add more complex example combining inheritance and oneof-interface * Generate Samples * Fix JsonTypeName annotation handling in Java and JavaSpring * Content mediatype is hardcoded in api.mustache #11511 * Generate Samples * OAS3 incorrect data type when providing a default value #11367 * Generate Samples * Fix JsonTypeName annotation handling in Java and JavaSpring * Generate Samples * getIsClassnameSanitized: use null safe equals * Fix JsonTypeName annotation handling in Java and JavaSpring (merge) * Generate Samples * Generate Samples * Add oneof sample * Generate Samples * Giv example oas spec a meaningful name, demo usage of oneOf in Model * Generate Samples * Remove unnecessary JsonTypeName include, add example for JsonTypeName (Bar_Create) * Generate Samples * Generate Samples Co-authored-by: Alexej <oleksejk@gmail.com> Co-authored-by: JBurgess <joel.burgess@gmail.com> Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class AdditionalPropertiesAnyType extends HashMap<String, Object> {
|
||||
public class AdditionalPropertiesAnyType extends HashMap<String, Object> {
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class AdditionalPropertiesArray extends HashMap<String, List> {
|
||||
public class AdditionalPropertiesArray extends HashMap<String, List> {
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class AdditionalPropertiesBoolean extends HashMap<String, Boolean> {
|
||||
public class AdditionalPropertiesBoolean extends HashMap<String, Boolean> {
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class AdditionalPropertiesClass {
|
||||
public class AdditionalPropertiesClass {
|
||||
|
||||
@JsonProperty("map_string")
|
||||
@Valid
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class AdditionalPropertiesInteger extends HashMap<String, Integer> {
|
||||
public class AdditionalPropertiesInteger extends HashMap<String, Integer> {
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class AdditionalPropertiesNumber extends HashMap<String, BigDecimal> {
|
||||
public class AdditionalPropertiesNumber extends HashMap<String, BigDecimal> {
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class AdditionalPropertiesObject extends HashMap<String, Map> {
|
||||
public class AdditionalPropertiesObject extends HashMap<String, Map> {
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class AdditionalPropertiesString extends HashMap<String, String> {
|
||||
public class AdditionalPropertiesString extends HashMap<String, String> {
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.model.Cat;
|
||||
import org.openapitools.model.Dog;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import javax.validation.Valid;
|
||||
@@ -29,10 +31,11 @@ import javax.annotation.Generated;
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "className", visible = true)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = Cat.class, name = "Cat"),
|
||||
@JsonSubTypes.Type(value = Dog.class, name = "Dog"),
|
||||
@JsonSubTypes.Type(value = Dog.class, name = "Dog")
|
||||
})
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Animal {
|
||||
public class Animal {
|
||||
|
||||
@JsonProperty("className")
|
||||
private String className;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class ArrayOfArrayOfNumberOnly {
|
||||
public class ArrayOfArrayOfNumberOnly {
|
||||
|
||||
@JsonProperty("ArrayArrayNumber")
|
||||
@Valid
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class ArrayOfNumberOnly {
|
||||
public class ArrayOfNumberOnly {
|
||||
|
||||
@JsonProperty("ArrayNumber")
|
||||
@Valid
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class ArrayTest {
|
||||
public class ArrayTest {
|
||||
|
||||
@JsonProperty("array_of_string")
|
||||
@Valid
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Capitalization {
|
||||
public class Capitalization {
|
||||
|
||||
@JsonProperty("smallCamel")
|
||||
private String smallCamel;
|
||||
|
||||
@@ -2,8 +2,11 @@ package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.model.Animal;
|
||||
@@ -21,8 +24,9 @@ import javax.annotation.Generated;
|
||||
* Cat
|
||||
*/
|
||||
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Cat extends Animal {
|
||||
public class Cat extends Animal {
|
||||
|
||||
@JsonProperty("declawed")
|
||||
private Boolean declawed;
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@JsonTypeName("Cat_allOf")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class CatAllOf {
|
||||
public class CatAllOf {
|
||||
|
||||
@JsonProperty("declawed")
|
||||
private Boolean declawed;
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Category {
|
||||
public class Category {
|
||||
|
||||
@JsonProperty("id")
|
||||
private Long id;
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@ApiModel(description = "Model for testing model with \"_class\" property")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class ClassModel {
|
||||
public class ClassModel {
|
||||
|
||||
@JsonProperty("_class")
|
||||
private String propertyClass;
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Client {
|
||||
public class Client {
|
||||
|
||||
@JsonProperty("client")
|
||||
private String client;
|
||||
|
||||
@@ -2,8 +2,11 @@ package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.model.Animal;
|
||||
@@ -21,8 +24,9 @@ import javax.annotation.Generated;
|
||||
* Dog
|
||||
*/
|
||||
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Dog extends Animal {
|
||||
public class Dog extends Animal {
|
||||
|
||||
@JsonProperty("breed")
|
||||
private String breed;
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@JsonTypeName("Dog_allOf")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class DogAllOf {
|
||||
public class DogAllOf {
|
||||
|
||||
@JsonProperty("breed")
|
||||
private String breed;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class EnumArrays {
|
||||
public class EnumArrays {
|
||||
|
||||
/**
|
||||
* Gets or Sets justSymbol
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@JsonTypeName("Enum_Test")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class EnumTest {
|
||||
public class EnumTest {
|
||||
|
||||
/**
|
||||
* Gets or Sets enumString
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@ApiModel(description = "Must be named `File` for test.")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class File {
|
||||
public class File {
|
||||
|
||||
@JsonProperty("sourceURI")
|
||||
private String sourceURI;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class FileSchemaTestClass {
|
||||
public class FileSchemaTestClass {
|
||||
|
||||
@JsonProperty("file")
|
||||
private File file;
|
||||
|
||||
@@ -28,7 +28,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@JsonTypeName("format_test")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class FormatTest {
|
||||
public class FormatTest {
|
||||
|
||||
@JsonProperty("integer")
|
||||
private Integer integer;
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@JsonTypeName("hasOnlyReadOnly")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class HasOnlyReadOnly {
|
||||
public class HasOnlyReadOnly {
|
||||
|
||||
@JsonProperty("bar")
|
||||
private String bar;
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class MapTest {
|
||||
public class MapTest {
|
||||
|
||||
@JsonProperty("map_map_of_string")
|
||||
@Valid
|
||||
|
||||
@@ -27,7 +27,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
|
||||
@JsonProperty("uuid")
|
||||
private UUID uuid;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
@ApiModel(description = "Model for testing model name starting with number")
|
||||
@JsonTypeName("200_response")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Model200Response {
|
||||
public class Model200Response {
|
||||
|
||||
@JsonProperty("name")
|
||||
private Integer name;
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@JsonTypeName("ApiResponse")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class ModelApiResponse {
|
||||
public class ModelApiResponse {
|
||||
|
||||
@JsonProperty("code")
|
||||
private Integer code;
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@JsonTypeName("List")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class ModelList {
|
||||
public class ModelList {
|
||||
|
||||
@JsonProperty("123-list")
|
||||
private String _123list;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
@ApiModel(description = "Model for testing reserved words")
|
||||
@JsonTypeName("Return")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class ModelReturn {
|
||||
public class ModelReturn {
|
||||
|
||||
@JsonProperty("return")
|
||||
private Integer _return;
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@ApiModel(description = "Model for testing model name same as property name")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Name {
|
||||
public class Name {
|
||||
|
||||
@JsonProperty("name")
|
||||
private Integer name;
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class NumberOnly {
|
||||
public class NumberOnly {
|
||||
|
||||
@JsonProperty("JustNumber")
|
||||
private BigDecimal justNumber;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Order {
|
||||
public class Order {
|
||||
|
||||
@JsonProperty("id")
|
||||
private Long id;
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class OuterComposite {
|
||||
public class OuterComposite {
|
||||
|
||||
@JsonProperty("my_number")
|
||||
private BigDecimal myNumber;
|
||||
|
||||
@@ -25,7 +25,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Pet {
|
||||
public class Pet {
|
||||
|
||||
@JsonProperty("id")
|
||||
private Long id;
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class ReadOnlyFirst {
|
||||
public class ReadOnlyFirst {
|
||||
|
||||
@JsonProperty("bar")
|
||||
private String bar;
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Generated;
|
||||
|
||||
@JsonTypeName("$special[model.name]")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class SpecialModelName {
|
||||
public class SpecialModelName {
|
||||
|
||||
@JsonProperty("$special[property.name]")
|
||||
private Long $specialPropertyName;
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Tag {
|
||||
public class Tag {
|
||||
|
||||
@JsonProperty("id")
|
||||
private Long id;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class TypeHolderDefault {
|
||||
public class TypeHolderDefault {
|
||||
|
||||
@JsonProperty("string_item")
|
||||
private String stringItem = "what";
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class TypeHolderExample {
|
||||
public class TypeHolderExample {
|
||||
|
||||
@JsonProperty("string_item")
|
||||
private String stringItem;
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class User {
|
||||
public class User {
|
||||
|
||||
@JsonProperty("id")
|
||||
private Long id;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Generated;
|
||||
*/
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class XmlItem {
|
||||
public class XmlItem {
|
||||
|
||||
@JsonProperty("attribute_string")
|
||||
private String attributeString;
|
||||
|
||||
Reference in New Issue
Block a user