[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1030 changed files with 4087 additions and 1027 deletions

View File

@ -39,6 +39,7 @@ jobs:
- samples/openapi3/server/petstore/springboot-delegate
- samples/server/petstore/spring-boot-nullable-set
- samples/server/petstore/spring-boot-defaultInterface-unhandledException
- samples/openapi3/server/petstore/spring-boot-oneof
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v2

View File

@ -0,0 +1,10 @@
generatorName: spring
outputDir: samples/openapi3/server/petstore/spring-boot-oneof
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
groupId: org.openapitools.openapi3
documentationProvider: springdoc
artifactId: springboot-oneof
snapshotVersion: "true"
hideGenerationTimestamp: "true"

View File

@ -843,7 +843,7 @@ public class DefaultCodegen implements CodegenConfig {
@Override
@SuppressWarnings("unused")
public void preprocessOpenAPI(OpenAPI openAPI) {
if (useOneOfInterfaces) {
if (useOneOfInterfaces && openAPI.getComponents() != null) {
// we process the openapi schema here to find oneOf schemas and create interface models for them
Map<String, Schema> schemas = new HashMap<>(openAPI.getComponents().getSchemas());
if (schemas == null) {

View File

@ -1313,7 +1313,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
// recursively add import for mapping one type to multiple imports
@ -1333,14 +1332,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
}
List<Object> models = (List<Object>) objs.get("models");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
// add x-implements for serializable to all models
List<Map<String, Object>> models = (List<Map<String, Object>>) objs.get("models");
for (Map<String, Object> mo : models) {
CodegenModel cm = (CodegenModel) mo.get("model");
cm.getVendorExtensions().putIfAbsent("x-implements", new ArrayList<String>());
if (this.serializableModel) {
cm.getVendorExtensions().putIfAbsent("x-implements", new ArrayList<String>());
((ArrayList<String>) cm.getVendorExtensions().get("x-implements")).add("Serializable");
}
}
@ -2054,6 +2051,18 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return StringUtils.isNotBlank(implicitHeadersRegex) && parameter.baseName.matches(implicitHeadersRegex);
}
@Override
public void addImportsToOneOfInterface(List<Map<String, String>> imports) {
if (additionalProperties.containsKey(JACKSON)) {
for (String i : Arrays.asList("JsonSubTypes", "JsonTypeInfo")) {
Map<String, String> oneImport = new HashMap<>();
oneImport.put("import", importMapping.get(i));
if (!imports.contains(oneImport)) {
imports.add(oneImport);
}
}
}
}
@Override
public List<VendorExtension> getSupportedVendorExtensions() {
List<VendorExtension> extensions = super.getSupportedVendorExtensions();

View File

@ -281,6 +281,8 @@ public class SpringCodegen extends AbstractJavaCodegen
}
super.processOpts();
useOneOfInterfaces = true;
legacyDiscriminatorBehavior = false;
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
LOGGER.warn("The springfox documentation provider is deprecated for removal. Use the springdoc provider instead.");

View File

@ -46,7 +46,7 @@ import javax.annotation.Generated;
{{>enumOuterClass}}
{{/isEnum}}
{{^isEnum}}
{{>pojo}}
{{#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}}

View File

@ -0,0 +1,13 @@
{{>additionalModelTypeAnnotations}}
{{#withXml}}
{{>xmlAnnotation}}
{{/withXml}}
{{#discriminator}}
{{>typeInfoAnnotation}}
{{/discriminator}}
{{>generatedAnnotation}}
public interface {{classname}}{{#vendorExtensions.x-implements}}{{#-first}} extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} {
{{#discriminator}}
public {{propertyType}} {{propertyGetter}}();
{{/discriminator}}
}

View File

@ -25,7 +25,7 @@
{{#vendorExtensions.x-class-extra-annotation}}
{{{vendorExtensions.x-class-extra-annotation}}}
{{/vendorExtensions.x-class-extra-annotation}}
public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{^parent}}{{#hateoas}}extends RepresentationModel<{{classname}}> {{/hateoas}}{{/parent}} {{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} {
public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}{{#hateoas}} extends RepresentationModel<{{classname}}> {{/hateoas}}{{/parent}}{{#vendorExtensions.x-implements}}{{#-first}} implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} {
{{#serializableModel}}
private static final long serialVersionUID = 1L;

View File

@ -1,11 +1,21 @@
{{#jackson}}
{{#discriminator.mappedModels}}
{{#-first}}
@JsonIgnoreProperties(
value = "{{{discriminator.propertyBaseName}}}", // ignore manually set {{{discriminator.propertyBaseName}}}, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the {{{discriminator.propertyBaseName}}} to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true)
@JsonSubTypes({
{{#discriminator.mappedModels}}
@JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
{{/discriminator.mappedModels}}
}){{/jackson}}
{{/-first}}
{{^vendorExtensions.x-discriminator-value}}
@JsonSubTypes.Type(value = {{modelName}}.class, name = "{{{mappingName}}}"){{^-last}},{{/-last}}
{{/vendorExtensions.x-discriminator-value}}
{{#vendorExtensions.x-discriminator-value}}
@JsonSubTypes.Type(value = {{modelName}}.class, name = "{{{vendorExtensions.x-discriminator-value}}}"){{^-last}},{{/-last}}
{{/vendorExtensions.x-discriminator-value}}
{{#-last}}
})
{{/-last}}
{{/discriminator.mappedModels}}
{{/jackson}}

View File

@ -947,6 +947,44 @@ public class SpringCodegenTest {
}
@Test
public void oneOf_5381() throws IOException {
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
output.deleteOnExit();
String outputPath = output.getAbsolutePath().replace('\\', '/');
OpenAPI openAPI = new OpenAPIParser()
.readLocation("src/test/resources/3_0/issue_5381.yaml", null, new ParseOptions()).getOpenAPI();
SpringCodegen codegen = new SpringCodegen();
codegen.setOutputDir(output.getAbsolutePath());
codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
codegen.setUseOneOfInterfaces(true);
ClientOptInput input = new ClientOptInput();
input.openAPI(openAPI);
input.config(codegen);
DefaultGenerator generator = new DefaultGenerator();
codegen.setHateoas(true);
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
//generator.setGeneratorPropertyDefault(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, "true");
generator.setGeneratorPropertyDefault(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "false");
codegen.setUseOneOfInterfaces(true);
codegen.setLegacyDiscriminatorBehavior(false);
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
generator.opts(input).generate();
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Foo.java"), "public class Foo implements FooRefOrValue");
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/FooRef.java"), "public class FooRef implements FooRefOrValue");
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/FooRefOrValue.java"), "public interface FooRefOrValue");
}
@Test
public void testTypeMappings() {
final SpringCodegen codegen = new SpringCodegen();

View File

@ -0,0 +1,134 @@
openapi: 3.0.1
info:
title: ByRefOrValue
description: >
This tests for a oneOf interface representation
version: 0.0.1
servers:
- url: "http://localhost:8080"
tags:
- name: Foo
paths:
/foo:
get:
tags:
- Foo
summary: GET all Foos
operationId: getAllFoos
responses:
'200':
$ref: '#/components/responses/200FooArray'
post:
tags:
- Foo
summary: Create a Foo
operationId: createFoo
requestBody:
$ref: '#/components/requestBodies/Foo'
responses:
'201':
$ref: '#/components/responses/201Foo'
components:
schemas:
Entity:
type: object
allOf:
- "$ref": "#/components/schemas/Addressable"
- "$ref": "#/components/schemas/Extensible"
EntityRef:
description: Entity reference schema to be use for all entityRef class.
type: object
properties:
name:
type: string
description: Name of the related entity.
'@referredType':
type: string
description: The actual type of the target instance when needed for disambiguation.
allOf:
- $ref: '#/components/schemas/Addressable'
- "$ref": "#/components/schemas/Extensible"
Addressable:
type: object
properties:
href:
type: string
description: Hyperlink reference
id:
type: string
description: unique identifier
description: Base schema for adressable entities
Extensible:
type: object
properties:
"@schemaLocation":
type: string
description: A URI to a JSON-Schema file that defines additional attributes
and relationships
"@baseType":
type: string
description: When sub-classing, this defines the super-class
"@type":
type: string
description: When sub-classing, this defines the sub-class Extensible name
required:
- '@type'
FooRefOrValue:
type: object
oneOf:
- $ref: "#/components/schemas/Foo"
- $ref: "#/components/schemas/FooRef"
discriminator:
propertyName: "@type"
mapping:
Foo: "#/components/schemas/Foo"
FooRef: "#/components/schemas/FooRef"
Foo:
type: object
properties:
fooPropA:
type: string
fooPropB:
type: string
allOf:
- $ref: '#/components/schemas/Entity'
FooRef:
type: object
properties:
foorefPropA:
type: string
allOf:
- $ref: '#/components/schemas/EntityRef'
requestBodies:
Foo:
description: The Foo to be created
content:
application/json;charset=utf-8:
schema:
$ref: '#/components/schemas/Foo'
responses:
'204':
description: Deleted
content: { }
201Foo:
description: Error
content:
application/json:
schema:
$ref: '#/components/schemas/FooRefOrValue'
200FooArray:
description: Success
content:
application/json;charset=utf-8:
schema:
type: array
items:
$ref: '#/components/schemas/FooRefOrValue'

View File

@ -0,0 +1,178 @@
openapi: 3.0.1
info:
title: ByRefOrValue
description: >
This tests for a oneOf interface representation
version: 0.0.1
servers:
- url: "http://localhost:8080"
tags:
- name: Foo
- name: Bar
paths:
/foo:
get:
tags:
- Foo
summary: GET all Foos
operationId: getAllFoos
responses:
'200':
$ref: '#/components/responses/200FooArray'
post:
tags:
- Foo
summary: Create a Foo
operationId: createFoo
requestBody:
$ref: '#/components/requestBodies/Foo'
responses:
'201':
$ref: '#/components/responses/201Foo'
/bar:
post:
tags:
- Bar
summary: Create a Bar
operationId: createBar
requestBody:
required: true
content:
'application/json':
schema:
$ref: '#/components/schemas/Bar_Create'
responses:
200:
description: Bar created
content:
'application/json':
schema:
$ref: '#/components/schemas/Bar'
components:
schemas:
Addressable:
type: object
properties:
href:
type: string
description: Hyperlink reference
id:
type: string
description: unique identifier
description: Base schema for adressable entities
Extensible:
type: object
properties:
"@schemaLocation":
type: string
description: A URI to a JSON-Schema file that defines additional attributes
and relationships
"@baseType":
type: string
description: When sub-classing, this defines the super-class
"@type":
type: string
description: When sub-classing, this defines the sub-class Extensible name
required:
- '@type'
Entity:
type: object
discriminator:
propertyName: '@type'
allOf:
- "$ref": "#/components/schemas/Addressable"
- "$ref": "#/components/schemas/Extensible"
EntityRef:
type: object
discriminator:
propertyName: '@type'
description: Entity reference schema to be use for all entityRef class.
properties:
name:
type: string
description: Name of the related entity.
'@referredType':
type: string
description: The actual type of the target instance when needed for disambiguation.
allOf:
- $ref: '#/components/schemas/Addressable'
- "$ref": "#/components/schemas/Extensible"
FooRefOrValue:
type: object
oneOf:
- $ref: "#/components/schemas/Foo"
- $ref: "#/components/schemas/FooRef"
discriminator:
propertyName: "@type"
Foo:
type: object
properties:
fooPropA:
type: string
fooPropB:
type: string
allOf:
- $ref: '#/components/schemas/Entity'
FooRef:
type: object
discriminator:
propertyName: '@type'
properties:
foorefPropA:
type: string
allOf:
- $ref: '#/components/schemas/EntityRef'
Bar_Create:
type: object
properties:
barPropA:
type: string
fooPropB:
type: string
foo:
$ref: '#/components/schemas/FooRefOrValue'
allOf:
- $ref: '#/components/schemas/Entity'
Bar:
type: object
required:
- id
properties:
id:
type: string
barPropA:
type: string
fooPropB:
type: string
foo:
$ref: '#/components/schemas/FooRefOrValue'
allOf:
- $ref: '#/components/schemas/Entity'
requestBodies:
Foo:
description: The Foo to be created
content:
application/json;charset=utf-8:
schema:
$ref: '#/components/schemas/Foo'
responses:
'204':
description: Deleted
content: { }
201Foo:
description: Error
content:
application/json:
schema:
$ref: '#/components/schemas/FooRefOrValue'
200FooArray:
description: Success
content:
application/json;charset=utf-8:
schema:
type: array
items:
$ref: '#/components/schemas/FooRefOrValue'

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A category for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Category {
public class Category {
@JsonProperty("id")
private Long id;

View File

@ -23,7 +23,7 @@ import javax.annotation.Generated;
@ApiModel(description = "Describes the result of uploading an image resource")
@JsonTypeName("ApiResponse")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ModelApiResponse {
public class ModelApiResponse {
@JsonProperty("code")
private Integer code;

View File

@ -24,7 +24,7 @@ import javax.annotation.Generated;
@ApiModel(description = "An order for a pets from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Order {
public class Order {
@JsonProperty("id")
private Long id;

View File

@ -26,7 +26,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A pet for sale in the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Pet {
public class Pet {
@JsonProperty("id")
private Long id;

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A tag for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Tag {
public class Tag {
@JsonProperty("id")
private Long id;

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A User who is purchasing from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class User {
public class User {
@JsonProperty("id")
private Long id;

View File

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

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A category for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Category {
public class Category {
@JsonProperty("id")
private Long id;

View File

@ -23,7 +23,7 @@ import javax.annotation.Generated;
@ApiModel(description = "Describes the result of uploading an image resource")
@JsonTypeName("ApiResponse")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ModelApiResponse {
public class ModelApiResponse {
@JsonProperty("code")
private Integer code;

View File

@ -24,7 +24,7 @@ import javax.annotation.Generated;
@ApiModel(description = "An order for a pets from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Order {
public class Order {
@JsonProperty("id")
private Long id;

View File

@ -26,7 +26,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A pet for sale in the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Pet {
public class Pet {
@JsonProperty("id")
private Long id;

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A tag for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Tag {
public class Tag {
@JsonProperty("id")
private Long id;

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A User who is purchasing from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class User {
public class User {
@JsonProperty("id")
private Long id;

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A category for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Category {
public class Category {
@JsonProperty("id")
private Long id;

View File

@ -23,7 +23,7 @@ import javax.annotation.Generated;
@ApiModel(description = "Describes the result of uploading an image resource")
@JsonTypeName("ApiResponse")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ModelApiResponse {
public class ModelApiResponse {
@JsonProperty("code")
private Integer code;

View File

@ -24,7 +24,7 @@ import javax.annotation.Generated;
@ApiModel(description = "An order for a pets from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Order {
public class Order {
@JsonProperty("id")
private Long id;

View File

@ -26,7 +26,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A pet for sale in the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Pet {
public class Pet {
@JsonProperty("id")
private Long id;

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A tag for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Tag {
public class Tag {
@JsonProperty("id")
private Long id;

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A User who is purchasing from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class User {
public class User {
@JsonProperty("id")
private Long id;

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A category for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Category {
public class Category {
@JsonProperty("id")
private Long id;

View File

@ -23,7 +23,7 @@ import javax.annotation.Generated;
@ApiModel(description = "Describes the result of uploading an image resource")
@JsonTypeName("ApiResponse")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ModelApiResponse {
public class ModelApiResponse {
@JsonProperty("code")
private Integer code;

View File

@ -24,7 +24,7 @@ import javax.annotation.Generated;
@ApiModel(description = "An order for a pets from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Order {
public class Order {
@JsonProperty("id")
private Long id;

View File

@ -26,7 +26,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A pet for sale in the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Pet {
public class Pet {
@JsonProperty("id")
private Long id;

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A tag for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Tag {
public class Tag {
@JsonProperty("id")
private Long id;

View File

@ -21,7 +21,7 @@ import javax.annotation.Generated;
@ApiModel(description = "A User who is purchasing from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class User {
public class User {
@JsonProperty("id")
private Long id;

View File

@ -20,7 +20,7 @@ import javax.annotation.Generated;
@Schema(name = "Category", description = "A category for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Category {
public class Category {
@JsonProperty("id")
private Long id;

View File

@ -22,7 +22,7 @@ import javax.annotation.Generated;
@Schema(name = "ApiResponse", description = "Describes the result of uploading an image resource")
@JsonTypeName("ApiResponse")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ModelApiResponse {
public class ModelApiResponse {
@JsonProperty("code")
private Integer code;

View File

@ -23,7 +23,7 @@ import javax.annotation.Generated;
@Schema(name = "Order", description = "An order for a pets from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Order {
public class Order {
@JsonProperty("id")
private Long id;

View File

@ -25,7 +25,7 @@ import javax.annotation.Generated;
@Schema(name = "Pet", description = "A pet for sale in the pet store")
@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;
@Schema(name = "Tag", description = "A tag for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Tag {
public class Tag {
@JsonProperty("id")
private Long id;

View File

@ -20,7 +20,7 @@ import javax.annotation.Generated;
@Schema(name = "User", description = "A User who is purchasing from the pet store")
@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 Pet {
public class Pet {
@JsonProperty("@type")
private String atType = "Pet";

View File

@ -21,7 +21,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

@ -22,7 +22,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

@ -21,7 +21,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

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

View File

@ -21,7 +21,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

@ -22,7 +22,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

@ -21,7 +21,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

@ -21,7 +21,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

@ -7,6 +7,9 @@ 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 org.openapitools.model.BigCat;
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 +32,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

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

View File

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

View File

@ -22,7 +22,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.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 org.openapitools.model.BigCatAllOf;
import org.openapitools.model.Cat;
@ -21,8 +24,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

@ -22,7 +22,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

@ -19,7 +19,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,9 +2,13 @@ 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 org.openapitools.model.Animal;
import org.openapitools.model.BigCat;
import org.openapitools.model.CatAllOf;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
@ -20,8 +24,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

@ -21,7 +21,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

@ -19,7 +19,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

@ -20,7 +20,7 @@ import javax.annotation.Generated;
@Schema(name = "ClassModel", 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

@ -19,7 +19,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.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 org.openapitools.model.Animal;
import org.openapitools.model.DogAllOf;
import org.openapitools.jackson.nullable.JsonNullable;
@ -20,8 +23,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

@ -21,7 +21,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

@ -22,7 +22,7 @@ import javax.annotation.Generated;
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class EnumArrays {
public class EnumArrays {
/**
* Gets or Sets justSymbol

View File

@ -23,7 +23,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

@ -20,7 +20,7 @@ import javax.annotation.Generated;
@Schema(name = "File", 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

@ -22,7 +22,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

@ -27,7 +27,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

@ -21,7 +21,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

@ -23,7 +23,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

@ -26,7 +26,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

@ -22,7 +22,7 @@ import javax.annotation.Generated;
@Schema(name = "200_response", 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

@ -21,7 +21,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

@ -21,7 +21,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

@ -22,7 +22,7 @@ import javax.annotation.Generated;
@Schema(name = "Return", 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

@ -20,7 +20,7 @@ import javax.annotation.Generated;
@Schema(name = "Name", 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

@ -20,7 +20,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

@ -22,7 +22,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

@ -20,7 +20,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

@ -27,7 +27,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

@ -19,7 +19,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

@ -21,7 +21,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

@ -19,7 +19,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

@ -22,7 +22,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

@ -22,7 +22,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

@ -19,7 +19,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

@ -22,7 +22,7 @@ import javax.annotation.Generated;
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class XmlItem {
public class XmlItem {
@JsonProperty("attribute_string")
private String attributeString;

View File

@ -20,7 +20,7 @@ import javax.annotation.Generated;
@Schema(name = "Category", description = "A category for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Category {
public class Category {
@JsonProperty("id")
private Long id;

View File

@ -22,7 +22,7 @@ import javax.annotation.Generated;
@Schema(name = "ApiResponse", description = "Describes the result of uploading an image resource")
@JsonTypeName("ApiResponse")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ModelApiResponse {
public class ModelApiResponse {
@JsonProperty("code")
private Integer code;

View File

@ -23,7 +23,7 @@ import javax.annotation.Generated;
@Schema(name = "Order", description = "An order for a pets from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Order {
public class Order {
@JsonProperty("id")
private Long id;

View File

@ -25,7 +25,7 @@ import javax.annotation.Generated;
@Schema(name = "Pet", description = "A pet for sale in the pet store")
@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;
@Schema(name = "Tag", description = "A tag for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Tag {
public class Tag {
@JsonProperty("id")
private Long id;

View File

@ -20,7 +20,7 @@ import javax.annotation.Generated;
@Schema(name = "User", description = "A User who is purchasing from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class User {
public class User {
@JsonProperty("id")
private Long id;

View File

@ -20,7 +20,7 @@ import javax.annotation.Generated;
@Schema(name = "Category", description = "A category for a pet")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Category {
public class Category {
@JsonProperty("id")
private Long id;

View File

@ -22,7 +22,7 @@ import javax.annotation.Generated;
@Schema(name = "ApiResponse", description = "Describes the result of uploading an image resource")
@JsonTypeName("ApiResponse")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ModelApiResponse {
public class ModelApiResponse {
@JsonProperty("code")
private Integer code;

View File

@ -23,7 +23,7 @@ import javax.annotation.Generated;
@Schema(name = "Order", description = "An order for a pets from the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Order {
public class Order {
@JsonProperty("id")
private Long id;

View File

@ -25,7 +25,7 @@ import javax.annotation.Generated;
@Schema(name = "Pet", description = "A pet for sale in the pet store")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Pet {
public class Pet {
@JsonProperty("id")
private Long id;

Some files were not shown because too many files have changed in this diff Show More