[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:
cachescrubber
2022-03-16 15:50:05 +01:00
committed by GitHub
parent a3fb571a1b
commit e07c7d1617
1030 changed files with 4087 additions and 1027 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -9,6 +9,9 @@ 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.virtualan.model.BigCat;
import org.openapitools.virtualan.model.Cat;
import org.openapitools.virtualan.model.Dog;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
@@ -30,10 +33,11 @@ import javax.annotation.Generated;
@JsonSubTypes({
@JsonSubTypes.Type(value = BigCat.class, name = "BigCat"),
@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;

View File

@@ -23,7 +23,7 @@ import javax.annotation.Generated;
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ArrayOfArrayOfNumberOnly {
public class ArrayOfArrayOfNumberOnly {
@JsonProperty("ArrayArrayNumber")
@Valid

View File

@@ -23,7 +23,7 @@ import javax.annotation.Generated;
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ArrayOfNumberOnly {
public class ArrayOfNumberOnly {
@JsonProperty("ArrayNumber")
@Valid

View File

@@ -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

View File

@@ -2,8 +2,11 @@ package org.openapitools.virtualan.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 com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -22,8 +25,9 @@ import javax.annotation.Generated;
* BigCat
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class BigCat extends Cat {
public class BigCat extends Cat {
/**
* Gets or Sets kind

View File

@@ -23,7 +23,7 @@ import javax.annotation.Generated;
@JsonTypeName("BigCat_allOf")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class BigCatAllOf {
public class BigCatAllOf {
/**
* Gets or Sets kind

View File

@@ -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;

View File

@@ -2,11 +2,15 @@ package org.openapitools.virtualan.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.virtualan.model.Animal;
import org.openapitools.virtualan.model.BigCat;
import org.openapitools.virtualan.model.CatAllOf;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
@@ -21,8 +25,17 @@ import javax.annotation.Generated;
* Cat
*/
@JsonIgnoreProperties(
value = "className", // ignore manually set className, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the className to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "className", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = BigCat.class, name = "BigCat")
})
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Cat extends Animal {
public class Cat extends Animal {
@JsonProperty("declawed")
private Boolean declawed;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -2,8 +2,11 @@ package org.openapitools.virtualan.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.virtualan.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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View 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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -28,7 +28,7 @@ import javax.annotation.Generated;
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Pet {
public class Pet {
@JsonProperty("id")
private Long id;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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";

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;