Add samples for when using the useSealed setting for Spring (#21515)

* Add samples for when using the useSealed setting for Spring

* Add the new sample generation to the workflow
This commit is contained in:
Mattias Sehlstedt
2025-07-08 04:27:53 +02:00
committed by GitHub
parent 98b315c137
commit 63df7ca574
40 changed files with 4455 additions and 13 deletions

View File

@@ -10,6 +10,7 @@ on:
- samples/server/petstore/springboot-lombok-tostring - samples/server/petstore/springboot-lombok-tostring
- samples/server/petstore/springboot-file-delegate-optional - samples/server/petstore/springboot-file-delegate-optional
- samples/server/petstore/springboot-petstore-with-api-response-examples - samples/server/petstore/springboot-petstore-with-api-response-examples
- samples/server/petstore/spring-boot-oneof-sealed
pull_request: pull_request:
paths: paths:
- samples/openapi3/client/petstore/spring-cloud-3-with-optional - samples/openapi3/client/petstore/spring-cloud-3-with-optional
@@ -19,6 +20,7 @@ on:
- samples/server/petstore/springboot-lombok-tostring - samples/server/petstore/springboot-lombok-tostring
- samples/server/petstore/springboot-file-delegate-optional - samples/server/petstore/springboot-file-delegate-optional
- samples/server/petstore/springboot-petstore-with-api-response-examples - samples/server/petstore/springboot-petstore-with-api-response-examples
- samples/server/petstore/spring-boot-oneof-sealed
jobs: jobs:
build: build:
name: Build Java Spring (JDK17) name: Build Java Spring (JDK17)
@@ -36,6 +38,7 @@ jobs:
- samples/server/petstore/springboot-lombok-tostring - samples/server/petstore/springboot-lombok-tostring
- samples/server/petstore/springboot-file-delegate-optional - samples/server/petstore/springboot-file-delegate-optional
- samples/server/petstore/springboot-petstore-with-api-response-examples - samples/server/petstore/springboot-petstore-with-api-response-examples
- samples/server/petstore/spring-boot-oneof-sealed
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-java@v4 - uses: actions/setup-java@v4

View File

@@ -0,0 +1,13 @@
generatorName: spring
outputDir: samples/openapi3/server/petstore/spring-boot-oneof-sealed
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-sealed
snapshotVersion: "true"
hideGenerationTimestamp: "true"
generateBuilders: true
useOneOfInterfaces: true
useSealed: true

View File

@@ -1 +1 @@
{{#useSealed}}{{#permits}}{{#-first}}permits {{/-first}}{{{.}}}{{^-last}}, {{/-last}}{{/permits}} {{/useSealed}} {{#useSealed}}{{#permits}}{{#-first}}permits {{/-first}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}} {{/-last}}{{/permits}}{{/useSealed}}

View File

@@ -2294,20 +2294,23 @@ public class SpringCodegenTest {
"Apple.java", "public final class Apple extends RepresentationModel<Apple> {")}, "Apple.java", "public final class Apple extends RepresentationModel<Apple> {")},
{"oneOfDiscriminator.yaml", Map.of( {"oneOfDiscriminator.yaml", Map.of(
"FruitAllOfDisc.java", "public sealed interface FruitAllOfDisc permits AppleAllOfDisc, BananaAllOfDisc {", "FruitAllOfDisc.java", "public sealed interface FruitAllOfDisc permits AppleAllOfDisc, BananaAllOfDisc {",
"FruitReqDisc.java", "public sealed interface FruitReqDisc permits AppleReqDisc, BananaReqDisc {\n")} "AppleAllOfDisc.java", "public final class AppleAllOfDisc extends RepresentationModel<AppleAllOfDisc> implements FruitAllOfDisc {",
"BananaAllOfDisc.java", "public final class BananaAllOfDisc extends RepresentationModel<BananaAllOfDisc> implements FruitAllOfDisc {",
"FruitReqDisc.java", "public sealed interface FruitReqDisc permits AppleReqDisc, BananaReqDisc {",
"AppleReqDisc.java", "public final class AppleReqDisc extends RepresentationModel<AppleReqDisc> implements FruitReqDisc {",
"BananaReqDisc.java", "public final class BananaReqDisc extends RepresentationModel<BananaReqDisc> implements FruitReqDisc {")}
}; };
} }
@Test(dataProvider = "sealedScenarios", description = "sealed scenarios") @Test(dataProvider = "sealedScenarios", description = "sealed scenarios")
public void sealedScenarios(String apiFile, Map<String, String> definitions) throws IOException { public void sealedScenarios(String apiFile, Map<String, String> definitions) {
File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); Path output = newTempFolder();
output.deleteOnExit(); String outputPath = output.toString().replace('\\', '/');
String outputPath = output.getAbsolutePath().replace('\\', '/');
OpenAPI openAPI = new OpenAPIParser() OpenAPI openAPI = new OpenAPIParser()
.readLocation("src/test/resources/3_0/" + apiFile, null, new ParseOptions()).getOpenAPI(); .readLocation("src/test/resources/3_0/" + apiFile, null, new ParseOptions()).getOpenAPI();
SpringCodegen codegen = new SpringCodegen(); SpringCodegen codegen = new SpringCodegen();
codegen.setOutputDir(output.getAbsolutePath()); codegen.setOutputDir(outputPath);
codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
codegen.setUseOneOfInterfaces(true); codegen.setUseOneOfInterfaces(true);
codegen.setUseSealed(true); codegen.setUseSealed(true);

View File

@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@@ -0,0 +1,31 @@
README.md
pom.xml
src/main/java/org/openapitools/OpenApiGeneratorApplication.java
src/main/java/org/openapitools/RFC3339DateFormat.java
src/main/java/org/openapitools/api/ApiUtil.java
src/main/java/org/openapitools/api/BarApi.java
src/main/java/org/openapitools/api/FooApi.java
src/main/java/org/openapitools/configuration/EnumConverterConfiguration.java
src/main/java/org/openapitools/configuration/HomeController.java
src/main/java/org/openapitools/configuration/SpringDocConfiguration.java
src/main/java/org/openapitools/model/Addressable.java
src/main/java/org/openapitools/model/Apple.java
src/main/java/org/openapitools/model/Banana.java
src/main/java/org/openapitools/model/Bar.java
src/main/java/org/openapitools/model/BarCreate.java
src/main/java/org/openapitools/model/BarRef.java
src/main/java/org/openapitools/model/BarRefOrValue.java
src/main/java/org/openapitools/model/Entity.java
src/main/java/org/openapitools/model/EntityRef.java
src/main/java/org/openapitools/model/Extensible.java
src/main/java/org/openapitools/model/Foo.java
src/main/java/org/openapitools/model/FooRef.java
src/main/java/org/openapitools/model/FooRefOrValue.java
src/main/java/org/openapitools/model/Fruit.java
src/main/java/org/openapitools/model/FruitType.java
src/main/java/org/openapitools/model/Pasta.java
src/main/java/org/openapitools/model/Pizza.java
src/main/java/org/openapitools/model/PizzaSpeziale.java
src/main/resources/application.properties
src/main/resources/openapi.yaml
src/test/java/org/openapitools/OpenApiGeneratorApplicationTests.java

View File

@@ -0,0 +1 @@
7.15.0-SNAPSHOT

View File

@@ -0,0 +1,21 @@
# OpenAPI generated server
Spring Boot Server
## Overview
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework.
The underlying library integrating OpenAPI to Spring Boot is [springdoc](https://springdoc.org).
Springdoc will generate an OpenAPI v3 specification based on the generated Controller and Model classes.
The specification is available to download using the following url:
http://localhost:8080/v3/api-docs/
Start your server as a simple java application
You can view the api documentation in swagger-ui by pointing to
http://localhost:8080/swagger-ui.html
Change default port value in application.properties

View File

@@ -0,0 +1,82 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools.openapi3</groupId>
<artifactId>springboot-oneof-sealed</artifactId>
<packaging>jar</packaging>
<name>springboot-oneof-sealed</name>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springdoc.version>1.6.14</springdoc.version>
<swagger-ui.version>5.3.1</swagger-ui.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.15</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<!--SpringDoc dependencies -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc.version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,30 @@
package org.openapitools;
import com.fasterxml.jackson.databind.Module;
import org.openapitools.jackson.nullable.JsonNullableModule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
@SpringBootApplication(
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
)
@ComponentScan(
basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"},
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
)
public class OpenApiGeneratorApplication {
public static void main(String[] args) {
SpringApplication.run(OpenApiGeneratorApplication.class, args);
}
@Bean(name = "org.openapitools.OpenApiGeneratorApplication.jsonNullableModule")
public Module jsonNullableModule() {
return new JsonNullableModule();
}
}

View File

@@ -0,0 +1,38 @@
package org.openapitools;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
public class RFC3339DateFormat extends DateFormat {
private static final long serialVersionUID = 1L;
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
private final StdDateFormat fmt = new StdDateFormat()
.withTimeZone(TIMEZONE_Z)
.withColonInTimeZone(true);
public RFC3339DateFormat() {
this.calendar = new GregorianCalendar();
}
@Override
public Date parse(String source, ParsePosition pos) {
return fmt.parse(source, pos);
}
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
return fmt.format(date, toAppendTo, fieldPosition);
}
@Override
public Object clone() {
return this;
}
}

View File

@@ -0,0 +1,19 @@
package org.openapitools.api;
import org.springframework.web.context.request.NativeWebRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class ApiUtil {
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
try {
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
res.setCharacterEncoding("UTF-8");
res.addHeader("Content-Type", contentType);
res.getWriter().print(example);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,86 @@
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.15.0-SNAPSHOT).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.api;
import org.openapitools.model.Bar;
import org.openapitools.model.BarCreate;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Generated;
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
@Validated
@Tag(name = "Bar", description = "the Bar API")
public interface BarApi {
default Optional<NativeWebRequest> getRequest() {
return Optional.empty();
}
/**
* POST /bar : Create a Bar
*
* @param barCreate (required)
* @return Bar created (status code 200)
*/
@Operation(
operationId = "createBar",
summary = "Create a Bar",
tags = { "Bar" },
responses = {
@ApiResponse(responseCode = "200", description = "Bar created", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = Bar.class))
})
}
)
@RequestMapping(
method = RequestMethod.POST,
value = "/bar",
produces = { "application/json" },
consumes = { "application/json" }
)
default ResponseEntity<Bar> createBar(
@Parameter(name = "BarCreate", description = "", required = true) @Valid @RequestBody BarCreate barCreate
) {
getRequest().ifPresent(request -> {
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
String exampleString = "{ \"foo\" : { \"fooPropA\" : \"fooPropA\", \"fooPropB\" : \"fooPropB\" }, \"id\" : \"id\", \"fooPropB\" : \"fooPropB\", \"barPropA\" : \"barPropA\" }";
ApiUtil.setExampleResponse(request, "application/json", exampleString);
break;
}
}
});
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
}

View File

@@ -0,0 +1,48 @@
package org.openapitools.api;
import org.openapitools.model.Bar;
import org.openapitools.model.BarCreate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.context.request.NativeWebRequest;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Generated;
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
@Controller
@RequestMapping("${openapi.byRefOrValue.base-path:}")
public class BarApiController implements BarApi {
private final NativeWebRequest request;
@Autowired
public BarApiController(NativeWebRequest request) {
this.request = request;
}
@Override
public Optional<NativeWebRequest> getRequest() {
return Optional.ofNullable(request);
}
}

View File

@@ -0,0 +1,124 @@
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.15.0-SNAPSHOT).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.api;
import org.openapitools.model.Foo;
import org.openapitools.model.FooRefOrValue;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Generated;
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
@Validated
@Tag(name = "Foo", description = "the Foo API")
public interface FooApi {
default Optional<NativeWebRequest> getRequest() {
return Optional.empty();
}
/**
* POST /foo : Create a Foo
*
* @param foo The Foo to be created (optional)
* @return Error (status code 201)
*/
@Operation(
operationId = "createFoo",
summary = "Create a Foo",
tags = { "Foo" },
responses = {
@ApiResponse(responseCode = "201", description = "Error", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = FooRefOrValue.class))
})
}
)
@RequestMapping(
method = RequestMethod.POST,
value = "/foo",
produces = { "application/json" },
consumes = { "application/json;charset=utf-8" }
)
default ResponseEntity<FooRefOrValue> createFoo(
@Parameter(name = "Foo", description = "The Foo to be created") @Valid @RequestBody(required = false) @Nullable Foo foo
) {
getRequest().ifPresent(request -> {
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
String exampleString = "{ \"fooPropA\" : \"fooPropA\", \"fooPropB\" : \"fooPropB\" }";
ApiUtil.setExampleResponse(request, "application/json", exampleString);
break;
}
}
});
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* GET /foo : GET all Foos
*
* @return Success (status code 200)
*/
@Operation(
operationId = "getAllFoos",
summary = "GET all Foos",
tags = { "Foo" },
responses = {
@ApiResponse(responseCode = "200", description = "Success", content = {
@Content(mediaType = "application/json;charset=utf-8", array = @ArraySchema(schema = @Schema(implementation = FooRefOrValue.class)))
})
}
)
@RequestMapping(
method = RequestMethod.GET,
value = "/foo",
produces = { "application/json;charset=utf-8" }
)
default ResponseEntity<List<FooRefOrValue>> getAllFoos(
) {
getRequest().ifPresent(request -> {
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json;charset=utf-8"))) {
String exampleString = "[ { \"fooPropA\" : \"fooPropA\", \"fooPropB\" : \"fooPropB\" }, { \"fooPropA\" : \"fooPropA\", \"fooPropB\" : \"fooPropB\" } ]";
ApiUtil.setExampleResponse(request, "application/json;charset=utf-8", exampleString);
break;
}
}
});
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
}

View File

@@ -0,0 +1,48 @@
package org.openapitools.api;
import org.openapitools.model.Foo;
import org.openapitools.model.FooRefOrValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.context.request.NativeWebRequest;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Generated;
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
@Controller
@RequestMapping("${openapi.byRefOrValue.base-path:}")
public class FooApiController implements FooApi {
private final NativeWebRequest request;
@Autowired
public FooApiController(NativeWebRequest request) {
this.request = request;
}
@Override
public Optional<NativeWebRequest> getRequest() {
return Optional.ofNullable(request);
}
}

View File

@@ -0,0 +1,22 @@
package org.openapitools.configuration;
import org.openapitools.model.FruitType;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
@Configuration(value = "org.openapitools.configuration.enumConverterConfiguration")
public class EnumConverterConfiguration {
@Bean(name = "org.openapitools.configuration.EnumConverterConfiguration.fruitTypeConverter")
Converter<String, FruitType> fruitTypeConverter() {
return new Converter<String, FruitType>() {
@Override
public FruitType convert(String source) {
return FruitType.fromValue(source);
}
};
}
}

View File

@@ -0,0 +1,20 @@
package org.openapitools.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.GetMapping;
/**
* Home redirection to OpenAPI api documentation
*/
@Controller
public class HomeController {
@RequestMapping("/")
public String index() {
return "redirect:swagger-ui.html";
}
}

View File

@@ -0,0 +1,27 @@
package org.openapitools.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.security.SecurityScheme;
@Configuration
public class SpringDocConfiguration {
@Bean(name = "org.openapitools.configuration.SpringDocConfiguration.apiInfo")
OpenAPI apiInfo() {
return new OpenAPI()
.info(
new Info()
.title("ByRefOrValue")
.description("This tests for a oneOf interface representation ")
.version("0.0.1")
)
;
}
}

View File

@@ -0,0 +1,173 @@
package org.openapitools.model;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* Base schema for addressable entities
*/
@Schema(name = "Addressable", description = "Base schema for addressable entities")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class Addressable {
private @Nullable String href;
private @Nullable String id;
public Addressable href(@Nullable String href) {
this.href = href;
return this;
}
/**
* Hyperlink reference
* @return href
*/
@Schema(name = "href", description = "Hyperlink reference", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("href")
public @Nullable String getHref() {
return href;
}
public void setHref(@Nullable String href) {
this.href = href;
}
public Addressable id(@Nullable String id) {
this.id = id;
return this;
}
/**
* unique identifier
* @return id
*/
@Schema(name = "id", description = "unique identifier", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("id")
public @Nullable String getId() {
return id;
}
public void setId(@Nullable String id) {
this.id = id;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Addressable addressable = (Addressable) o;
return Objects.equals(this.href, addressable.href) &&
Objects.equals(this.id, addressable.id);
}
@Override
public int hashCode() {
return Objects.hash(href, id);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Addressable {\n");
sb.append(" href: ").append(toIndentedString(href)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder {
private Addressable instance;
public Builder() {
this(new Addressable());
}
protected Builder(Addressable instance) {
this.instance = instance;
}
protected Builder copyOf(Addressable value) {
this.instance.setHref(value.href);
this.instance.setId(value.id);
return this;
}
public Addressable.Builder href(String href) {
this.instance.href(href);
return this;
}
public Addressable.Builder id(String id) {
this.instance.id(id);
return this;
}
/**
* returns a built Addressable instance.
*
* The builder is not reusable (NullPointerException)
*/
public Addressable build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static Addressable.Builder builder() {
return new Addressable.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public Addressable.Builder toBuilder() {
Addressable.Builder builder = new Addressable.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,188 @@
package org.openapitools.model;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import org.springframework.lang.Nullable;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonValue;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* Apple
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class Apple implements Fruit {
private Integer seeds;
private FruitType fruitType;
public Apple() {
super();
}
/**
* Constructor with only required parameters
*/
public Apple(Integer seeds) {
this.seeds = seeds;
this.fruitType = fruitType;
}
public Apple seeds(Integer seeds) {
this.seeds = seeds;
return this;
}
/**
* Get seeds
* @return seeds
*/
@NotNull
@Schema(name = "seeds", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("seeds")
public Integer getSeeds() {
return seeds;
}
public void setSeeds(Integer seeds) {
this.seeds = seeds;
}
public Apple fruitType(FruitType fruitType) {
this.fruitType = fruitType;
return this;
}
/**
* Get fruitType
* @return fruitType
*/
@NotNull @Valid
@Schema(name = "fruitType", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("fruitType")
public FruitType getFruitType() {
return fruitType;
}
public void setFruitType(FruitType fruitType) {
this.fruitType = fruitType;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Apple apple = (Apple) o;
return Objects.equals(this.seeds, apple.seeds) &&
Objects.equals(this.fruitType, apple.fruitType);
}
@Override
public int hashCode() {
return Objects.hash(seeds, fruitType);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Apple {\n");
sb.append(" seeds: ").append(toIndentedString(seeds)).append("\n");
sb.append(" fruitType: ").append(toIndentedString(fruitType)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder {
private Apple instance;
public Builder() {
this(new Apple());
}
protected Builder(Apple instance) {
this.instance = instance;
}
protected Builder copyOf(Apple value) {
this.instance.setSeeds(value.seeds);
this.instance.setFruitType(value.fruitType);
return this;
}
public Apple.Builder seeds(Integer seeds) {
this.instance.seeds(seeds);
return this;
}
public Apple.Builder fruitType(FruitType fruitType) {
this.instance.fruitType(fruitType);
return this;
}
/**
* returns a built Apple instance.
*
* The builder is not reusable (NullPointerException)
*/
public Apple build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static Apple.Builder builder() {
return new Apple.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public Apple.Builder toBuilder() {
Apple.Builder builder = new Apple.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,188 @@
package org.openapitools.model;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import org.springframework.lang.Nullable;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonValue;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* Banana
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class Banana implements Fruit {
private Integer length;
private FruitType fruitType;
public Banana() {
super();
}
/**
* Constructor with only required parameters
*/
public Banana(Integer length) {
this.length = length;
this.fruitType = fruitType;
}
public Banana length(Integer length) {
this.length = length;
return this;
}
/**
* Get length
* @return length
*/
@NotNull
@Schema(name = "length", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("length")
public Integer getLength() {
return length;
}
public void setLength(Integer length) {
this.length = length;
}
public Banana fruitType(FruitType fruitType) {
this.fruitType = fruitType;
return this;
}
/**
* Get fruitType
* @return fruitType
*/
@NotNull @Valid
@Schema(name = "fruitType", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("fruitType")
public FruitType getFruitType() {
return fruitType;
}
public void setFruitType(FruitType fruitType) {
this.fruitType = fruitType;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Banana banana = (Banana) o;
return Objects.equals(this.length, banana.length) &&
Objects.equals(this.fruitType, banana.fruitType);
}
@Override
public int hashCode() {
return Objects.hash(length, fruitType);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Banana {\n");
sb.append(" length: ").append(toIndentedString(length)).append("\n");
sb.append(" fruitType: ").append(toIndentedString(fruitType)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder {
private Banana instance;
public Builder() {
this(new Banana());
}
protected Builder(Banana instance) {
this.instance = instance;
}
protected Builder copyOf(Banana value) {
this.instance.setLength(value.length);
this.instance.setFruitType(value.fruitType);
return this;
}
public Banana.Builder length(Integer length) {
this.instance.length(length);
return this;
}
public Banana.Builder fruitType(FruitType fruitType) {
this.instance.fruitType(fruitType);
return this;
}
/**
* returns a built Banana instance.
*
* The builder is not reusable (NullPointerException)
*/
public Banana build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static Banana.Builder builder() {
return new Banana.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public Banana.Builder toBuilder() {
Banana.Builder builder = new Banana.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,299 @@
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.Entity;
import org.openapitools.model.FooRefOrValue;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* Bar
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class Bar extends Entity implements BarRefOrValue {
private String id;
private @Nullable String barPropA;
private @Nullable String fooPropB;
private @Nullable FooRefOrValue foo;
public Bar() {
super();
}
/**
* Constructor with only required parameters
*/
public Bar(String id, String atType) {
super(atType);
this.id = id;
}
public Bar id(String id) {
this.id = id;
return this;
}
/**
* Get id
* @return id
*/
@NotNull
@Schema(name = "id", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("id")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Bar barPropA(@Nullable String barPropA) {
this.barPropA = barPropA;
return this;
}
/**
* Get barPropA
* @return barPropA
*/
@Schema(name = "barPropA", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("barPropA")
public @Nullable String getBarPropA() {
return barPropA;
}
public void setBarPropA(@Nullable String barPropA) {
this.barPropA = barPropA;
}
public Bar fooPropB(@Nullable String fooPropB) {
this.fooPropB = fooPropB;
return this;
}
/**
* Get fooPropB
* @return fooPropB
*/
@Schema(name = "fooPropB", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("fooPropB")
public @Nullable String getFooPropB() {
return fooPropB;
}
public void setFooPropB(@Nullable String fooPropB) {
this.fooPropB = fooPropB;
}
public Bar foo(@Nullable FooRefOrValue foo) {
this.foo = foo;
return this;
}
/**
* Get foo
* @return foo
*/
@Valid
@Schema(name = "foo", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("foo")
public @Nullable FooRefOrValue getFoo() {
return foo;
}
public void setFoo(@Nullable FooRefOrValue foo) {
this.foo = foo;
}
public Bar href(String href) {
super.href(href);
return this;
}
public Bar atSchemaLocation(String atSchemaLocation) {
super.atSchemaLocation(atSchemaLocation);
return this;
}
public Bar atBaseType(String atBaseType) {
super.atBaseType(atBaseType);
return this;
}
public Bar atType(String atType) {
super.atType(atType);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Bar bar = (Bar) o;
return Objects.equals(this.id, bar.id) &&
Objects.equals(this.barPropA, bar.barPropA) &&
Objects.equals(this.fooPropB, bar.fooPropB) &&
Objects.equals(this.foo, bar.foo) &&
super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(id, barPropA, fooPropB, foo, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Bar {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" barPropA: ").append(toIndentedString(barPropA)).append("\n");
sb.append(" fooPropB: ").append(toIndentedString(fooPropB)).append("\n");
sb.append(" foo: ").append(toIndentedString(foo)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder extends Entity.Builder {
private Bar instance;
public Builder() {
this(new Bar());
}
protected Builder(Bar instance) {
super(instance); // the parent builder shares the same instance
this.instance = instance;
}
protected Builder copyOf(Bar value) {
super.copyOf(value);
this.instance.setId(value.id);
this.instance.setBarPropA(value.barPropA);
this.instance.setFooPropB(value.fooPropB);
this.instance.setFoo(value.foo);
return this;
}
public Bar.Builder id(String id) {
this.instance.id(id);
return this;
}
public Bar.Builder barPropA(String barPropA) {
this.instance.barPropA(barPropA);
return this;
}
public Bar.Builder fooPropB(String fooPropB) {
this.instance.fooPropB(fooPropB);
return this;
}
public Bar.Builder foo(FooRefOrValue foo) {
this.instance.foo(foo);
return this;
}
@Override
public Bar.Builder href(String href) {
this.instance.href(href);
return this;
}
@Override
public Bar.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
@Override
public Bar.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
@Override
public Bar.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built Bar instance.
*
* The builder is not reusable (NullPointerException)
*/
public Bar build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
super.build();
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static Bar.Builder builder() {
return new Bar.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public Bar.Builder toBuilder() {
Bar.Builder builder = new Bar.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,281 @@
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.JsonTypeName;
import org.openapitools.model.Entity;
import org.openapitools.model.FooRefOrValue;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* BarCreate
*/
@JsonTypeName("Bar_Create")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class BarCreate extends Entity {
private @Nullable String barPropA;
private @Nullable String fooPropB;
private @Nullable FooRefOrValue foo;
public BarCreate() {
super();
}
/**
* Constructor with only required parameters
*/
public BarCreate(String atType) {
super(atType);
}
public BarCreate barPropA(@Nullable String barPropA) {
this.barPropA = barPropA;
return this;
}
/**
* Get barPropA
* @return barPropA
*/
@Schema(name = "barPropA", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("barPropA")
public @Nullable String getBarPropA() {
return barPropA;
}
public void setBarPropA(@Nullable String barPropA) {
this.barPropA = barPropA;
}
public BarCreate fooPropB(@Nullable String fooPropB) {
this.fooPropB = fooPropB;
return this;
}
/**
* Get fooPropB
* @return fooPropB
*/
@Schema(name = "fooPropB", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("fooPropB")
public @Nullable String getFooPropB() {
return fooPropB;
}
public void setFooPropB(@Nullable String fooPropB) {
this.fooPropB = fooPropB;
}
public BarCreate foo(@Nullable FooRefOrValue foo) {
this.foo = foo;
return this;
}
/**
* Get foo
* @return foo
*/
@Valid
@Schema(name = "foo", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("foo")
public @Nullable FooRefOrValue getFoo() {
return foo;
}
public void setFoo(@Nullable FooRefOrValue foo) {
this.foo = foo;
}
public BarCreate href(String href) {
super.href(href);
return this;
}
public BarCreate id(String id) {
super.id(id);
return this;
}
public BarCreate atSchemaLocation(String atSchemaLocation) {
super.atSchemaLocation(atSchemaLocation);
return this;
}
public BarCreate atBaseType(String atBaseType) {
super.atBaseType(atBaseType);
return this;
}
public BarCreate atType(String atType) {
super.atType(atType);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BarCreate barCreate = (BarCreate) o;
return Objects.equals(this.barPropA, barCreate.barPropA) &&
Objects.equals(this.fooPropB, barCreate.fooPropB) &&
Objects.equals(this.foo, barCreate.foo) &&
super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(barPropA, fooPropB, foo, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class BarCreate {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" barPropA: ").append(toIndentedString(barPropA)).append("\n");
sb.append(" fooPropB: ").append(toIndentedString(fooPropB)).append("\n");
sb.append(" foo: ").append(toIndentedString(foo)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder extends Entity.Builder {
private BarCreate instance;
public Builder() {
this(new BarCreate());
}
protected Builder(BarCreate instance) {
super(instance); // the parent builder shares the same instance
this.instance = instance;
}
protected Builder copyOf(BarCreate value) {
super.copyOf(value);
this.instance.setBarPropA(value.barPropA);
this.instance.setFooPropB(value.fooPropB);
this.instance.setFoo(value.foo);
return this;
}
public BarCreate.Builder barPropA(String barPropA) {
this.instance.barPropA(barPropA);
return this;
}
public BarCreate.Builder fooPropB(String fooPropB) {
this.instance.fooPropB(fooPropB);
return this;
}
public BarCreate.Builder foo(FooRefOrValue foo) {
this.instance.foo(foo);
return this;
}
@Override
public BarCreate.Builder href(String href) {
this.instance.href(href);
return this;
}
@Override
public BarCreate.Builder id(String id) {
this.instance.id(id);
return this;
}
@Override
public BarCreate.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
@Override
public BarCreate.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
@Override
public BarCreate.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built BarCreate instance.
*
* The builder is not reusable (NullPointerException)
*/
public BarCreate build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
super.build();
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static BarCreate.Builder builder() {
return new BarCreate.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public BarCreate.Builder toBuilder() {
BarCreate.Builder builder = new BarCreate.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,209 @@
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.EntityRef;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* BarRef
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class BarRef extends EntityRef implements BarRefOrValue {
public BarRef() {
super();
}
/**
* Constructor with only required parameters
*/
public BarRef(String atType) {
super(atType);
}
public BarRef name(String name) {
super.name(name);
return this;
}
public BarRef atReferredType(String atReferredType) {
super.atReferredType(atReferredType);
return this;
}
public BarRef href(String href) {
super.href(href);
return this;
}
public BarRef id(String id) {
super.id(id);
return this;
}
public BarRef atSchemaLocation(String atSchemaLocation) {
super.atSchemaLocation(atSchemaLocation);
return this;
}
public BarRef atBaseType(String atBaseType) {
super.atBaseType(atBaseType);
return this;
}
public BarRef atType(String atType) {
super.atType(atType);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class BarRef {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder extends EntityRef.Builder {
private BarRef instance;
public Builder() {
this(new BarRef());
}
protected Builder(BarRef instance) {
super(instance); // the parent builder shares the same instance
this.instance = instance;
}
protected Builder copyOf(BarRef value) {
super.copyOf(value);
return this;
}
@Override
public BarRef.Builder name(String name) {
this.instance.name(name);
return this;
}
@Override
public BarRef.Builder atReferredType(String atReferredType) {
this.instance.atReferredType(atReferredType);
return this;
}
@Override
public BarRef.Builder href(String href) {
this.instance.href(href);
return this;
}
@Override
public BarRef.Builder id(String id) {
this.instance.id(id);
return this;
}
@Override
public BarRef.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
@Override
public BarRef.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
@Override
public BarRef.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built BarRef instance.
*
* The builder is not reusable (NullPointerException)
*/
public BarRef build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
super.build();
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static BarRef.Builder builder() {
return new BarRef.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public BarRef.Builder toBuilder() {
BarRef.Builder builder = new BarRef.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,38 @@
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.Bar;
import org.openapitools.model.BarRef;
import org.openapitools.model.FooRefOrValue;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
@JsonIgnoreProperties(
value = "@type", // ignore manually set @type, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the @type to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = Bar.class, name = "Bar"),
@JsonSubTypes.Type(value = BarRef.class, name = "BarRef")
})
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public sealed interface BarRefOrValue permits Bar, BarRef {
public String getAtType();
}

View File

@@ -0,0 +1,290 @@
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.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* Entity
*/
@JsonIgnoreProperties(
value = "@type", // ignore manually set @type, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the @type to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = Bar.class, name = "Bar"),
@JsonSubTypes.Type(value = BarCreate.class, name = "Bar_Create"),
@JsonSubTypes.Type(value = Foo.class, name = "Foo"),
@JsonSubTypes.Type(value = Pasta.class, name = "Pasta"),
@JsonSubTypes.Type(value = Pizza.class, name = "Pizza"),
@JsonSubTypes.Type(value = PizzaSpeziale.class, name = "PizzaSpeziale")
})
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public sealed class Entity permits Bar, BarCreate, Foo, Pasta, Pizza {
private @Nullable String href;
private @Nullable String id;
private @Nullable String atSchemaLocation;
private @Nullable String atBaseType;
private String atType;
public Entity() {
super();
}
/**
* Constructor with only required parameters
*/
public Entity(String atType) {
this.atType = atType;
}
public Entity href(@Nullable String href) {
this.href = href;
return this;
}
/**
* Hyperlink reference
* @return href
*/
@Schema(name = "href", description = "Hyperlink reference", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("href")
public @Nullable String getHref() {
return href;
}
public void setHref(@Nullable String href) {
this.href = href;
}
public Entity id(@Nullable String id) {
this.id = id;
return this;
}
/**
* unique identifier
* @return id
*/
@Schema(name = "id", description = "unique identifier", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("id")
public @Nullable String getId() {
return id;
}
public void setId(@Nullable String id) {
this.id = id;
}
public Entity atSchemaLocation(@Nullable String atSchemaLocation) {
this.atSchemaLocation = atSchemaLocation;
return this;
}
/**
* A URI to a JSON-Schema file that defines additional attributes and relationships
* @return atSchemaLocation
*/
@Schema(name = "@schemaLocation", description = "A URI to a JSON-Schema file that defines additional attributes and relationships", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("@schemaLocation")
public @Nullable String getAtSchemaLocation() {
return atSchemaLocation;
}
public void setAtSchemaLocation(@Nullable String atSchemaLocation) {
this.atSchemaLocation = atSchemaLocation;
}
public Entity atBaseType(@Nullable String atBaseType) {
this.atBaseType = atBaseType;
return this;
}
/**
* When sub-classing, this defines the super-class
* @return atBaseType
*/
@Schema(name = "@baseType", description = "When sub-classing, this defines the super-class", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("@baseType")
public @Nullable String getAtBaseType() {
return atBaseType;
}
public void setAtBaseType(@Nullable String atBaseType) {
this.atBaseType = atBaseType;
}
public Entity atType(String atType) {
this.atType = atType;
return this;
}
/**
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull
@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("@type")
public String getAtType() {
return atType;
}
public void setAtType(String atType) {
this.atType = atType;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Entity entity = (Entity) o;
return Objects.equals(this.href, entity.href) &&
Objects.equals(this.id, entity.id) &&
Objects.equals(this.atSchemaLocation, entity.atSchemaLocation) &&
Objects.equals(this.atBaseType, entity.atBaseType) &&
Objects.equals(this.atType, entity.atType);
}
@Override
public int hashCode() {
return Objects.hash(href, id, atSchemaLocation, atBaseType, atType);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Entity {\n");
sb.append(" href: ").append(toIndentedString(href)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" atSchemaLocation: ").append(toIndentedString(atSchemaLocation)).append("\n");
sb.append(" atBaseType: ").append(toIndentedString(atBaseType)).append("\n");
sb.append(" atType: ").append(toIndentedString(atType)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder {
private Entity instance;
public Builder() {
this(new Entity());
}
protected Builder(Entity instance) {
this.instance = instance;
}
protected Builder copyOf(Entity value) {
this.instance.setHref(value.href);
this.instance.setId(value.id);
this.instance.setAtSchemaLocation(value.atSchemaLocation);
this.instance.setAtBaseType(value.atBaseType);
this.instance.setAtType(value.atType);
return this;
}
public Entity.Builder href(String href) {
this.instance.href(href);
return this;
}
public Entity.Builder id(String id) {
this.instance.id(id);
return this;
}
public Entity.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
public Entity.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
public Entity.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built Entity instance.
*
* The builder is not reusable (NullPointerException)
*/
public Entity build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static Entity.Builder builder() {
return new Entity.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public Entity.Builder toBuilder() {
Entity.Builder builder = new Entity.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,347 @@
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.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* Entity reference schema to be use for all entityRef class.
*/
@Schema(name = "EntityRef", description = "Entity reference schema to be use for all entityRef class.")
@JsonIgnoreProperties(
value = "@type", // ignore manually set @type, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the @type to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = BarRef.class, name = "BarRef"),
@JsonSubTypes.Type(value = FooRef.class, name = "FooRef")
})
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public sealed class EntityRef permits BarRef, FooRef {
private @Nullable String name;
private @Nullable String atReferredType;
private @Nullable String href;
private @Nullable String id;
private @Nullable String atSchemaLocation;
private @Nullable String atBaseType;
private String atType;
public EntityRef() {
super();
}
/**
* Constructor with only required parameters
*/
public EntityRef(String atType) {
this.atType = atType;
}
public EntityRef name(@Nullable String name) {
this.name = name;
return this;
}
/**
* Name of the related entity.
* @return name
*/
@Schema(name = "name", description = "Name of the related entity.", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("name")
public @Nullable String getName() {
return name;
}
public void setName(@Nullable String name) {
this.name = name;
}
public EntityRef atReferredType(@Nullable String atReferredType) {
this.atReferredType = atReferredType;
return this;
}
/**
* The actual type of the target instance when needed for disambiguation.
* @return atReferredType
*/
@Schema(name = "@referredType", description = "The actual type of the target instance when needed for disambiguation.", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("@referredType")
public @Nullable String getAtReferredType() {
return atReferredType;
}
public void setAtReferredType(@Nullable String atReferredType) {
this.atReferredType = atReferredType;
}
public EntityRef href(@Nullable String href) {
this.href = href;
return this;
}
/**
* Hyperlink reference
* @return href
*/
@Schema(name = "href", description = "Hyperlink reference", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("href")
public @Nullable String getHref() {
return href;
}
public void setHref(@Nullable String href) {
this.href = href;
}
public EntityRef id(@Nullable String id) {
this.id = id;
return this;
}
/**
* unique identifier
* @return id
*/
@Schema(name = "id", description = "unique identifier", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("id")
public @Nullable String getId() {
return id;
}
public void setId(@Nullable String id) {
this.id = id;
}
public EntityRef atSchemaLocation(@Nullable String atSchemaLocation) {
this.atSchemaLocation = atSchemaLocation;
return this;
}
/**
* A URI to a JSON-Schema file that defines additional attributes and relationships
* @return atSchemaLocation
*/
@Schema(name = "@schemaLocation", description = "A URI to a JSON-Schema file that defines additional attributes and relationships", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("@schemaLocation")
public @Nullable String getAtSchemaLocation() {
return atSchemaLocation;
}
public void setAtSchemaLocation(@Nullable String atSchemaLocation) {
this.atSchemaLocation = atSchemaLocation;
}
public EntityRef atBaseType(@Nullable String atBaseType) {
this.atBaseType = atBaseType;
return this;
}
/**
* When sub-classing, this defines the super-class
* @return atBaseType
*/
@Schema(name = "@baseType", description = "When sub-classing, this defines the super-class", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("@baseType")
public @Nullable String getAtBaseType() {
return atBaseType;
}
public void setAtBaseType(@Nullable String atBaseType) {
this.atBaseType = atBaseType;
}
public EntityRef atType(String atType) {
this.atType = atType;
return this;
}
/**
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull
@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("@type")
public String getAtType() {
return atType;
}
public void setAtType(String atType) {
this.atType = atType;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
EntityRef entityRef = (EntityRef) o;
return Objects.equals(this.name, entityRef.name) &&
Objects.equals(this.atReferredType, entityRef.atReferredType) &&
Objects.equals(this.href, entityRef.href) &&
Objects.equals(this.id, entityRef.id) &&
Objects.equals(this.atSchemaLocation, entityRef.atSchemaLocation) &&
Objects.equals(this.atBaseType, entityRef.atBaseType) &&
Objects.equals(this.atType, entityRef.atType);
}
@Override
public int hashCode() {
return Objects.hash(name, atReferredType, href, id, atSchemaLocation, atBaseType, atType);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class EntityRef {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" atReferredType: ").append(toIndentedString(atReferredType)).append("\n");
sb.append(" href: ").append(toIndentedString(href)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" atSchemaLocation: ").append(toIndentedString(atSchemaLocation)).append("\n");
sb.append(" atBaseType: ").append(toIndentedString(atBaseType)).append("\n");
sb.append(" atType: ").append(toIndentedString(atType)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder {
private EntityRef instance;
public Builder() {
this(new EntityRef());
}
protected Builder(EntityRef instance) {
this.instance = instance;
}
protected Builder copyOf(EntityRef value) {
this.instance.setName(value.name);
this.instance.setAtReferredType(value.atReferredType);
this.instance.setHref(value.href);
this.instance.setId(value.id);
this.instance.setAtSchemaLocation(value.atSchemaLocation);
this.instance.setAtBaseType(value.atBaseType);
this.instance.setAtType(value.atType);
return this;
}
public EntityRef.Builder name(String name) {
this.instance.name(name);
return this;
}
public EntityRef.Builder atReferredType(String atReferredType) {
this.instance.atReferredType(atReferredType);
return this;
}
public EntityRef.Builder href(String href) {
this.instance.href(href);
return this;
}
public EntityRef.Builder id(String id) {
this.instance.id(id);
return this;
}
public EntityRef.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
public EntityRef.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
public EntityRef.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built EntityRef instance.
*
* The builder is not reusable (NullPointerException)
*/
public EntityRef build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static EntityRef.Builder builder() {
return new EntityRef.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public EntityRef.Builder toBuilder() {
EntityRef.Builder builder = new EntityRef.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,213 @@
package org.openapitools.model;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* Extensible
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class Extensible {
private @Nullable String atSchemaLocation;
private @Nullable String atBaseType;
private String atType;
public Extensible() {
super();
}
/**
* Constructor with only required parameters
*/
public Extensible(String atType) {
this.atType = atType;
}
public Extensible atSchemaLocation(@Nullable String atSchemaLocation) {
this.atSchemaLocation = atSchemaLocation;
return this;
}
/**
* A URI to a JSON-Schema file that defines additional attributes and relationships
* @return atSchemaLocation
*/
@Schema(name = "@schemaLocation", description = "A URI to a JSON-Schema file that defines additional attributes and relationships", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("@schemaLocation")
public @Nullable String getAtSchemaLocation() {
return atSchemaLocation;
}
public void setAtSchemaLocation(@Nullable String atSchemaLocation) {
this.atSchemaLocation = atSchemaLocation;
}
public Extensible atBaseType(@Nullable String atBaseType) {
this.atBaseType = atBaseType;
return this;
}
/**
* When sub-classing, this defines the super-class
* @return atBaseType
*/
@Schema(name = "@baseType", description = "When sub-classing, this defines the super-class", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("@baseType")
public @Nullable String getAtBaseType() {
return atBaseType;
}
public void setAtBaseType(@Nullable String atBaseType) {
this.atBaseType = atBaseType;
}
public Extensible atType(String atType) {
this.atType = atType;
return this;
}
/**
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull
@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("@type")
public String getAtType() {
return atType;
}
public void setAtType(String atType) {
this.atType = atType;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Extensible extensible = (Extensible) o;
return Objects.equals(this.atSchemaLocation, extensible.atSchemaLocation) &&
Objects.equals(this.atBaseType, extensible.atBaseType) &&
Objects.equals(this.atType, extensible.atType);
}
@Override
public int hashCode() {
return Objects.hash(atSchemaLocation, atBaseType, atType);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Extensible {\n");
sb.append(" atSchemaLocation: ").append(toIndentedString(atSchemaLocation)).append("\n");
sb.append(" atBaseType: ").append(toIndentedString(atBaseType)).append("\n");
sb.append(" atType: ").append(toIndentedString(atType)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder {
private Extensible instance;
public Builder() {
this(new Extensible());
}
protected Builder(Extensible instance) {
this.instance = instance;
}
protected Builder copyOf(Extensible value) {
this.instance.setAtSchemaLocation(value.atSchemaLocation);
this.instance.setAtBaseType(value.atBaseType);
this.instance.setAtType(value.atType);
return this;
}
public Extensible.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
public Extensible.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
public Extensible.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built Extensible instance.
*
* The builder is not reusable (NullPointerException)
*/
public Extensible build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static Extensible.Builder builder() {
return new Extensible.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public Extensible.Builder toBuilder() {
Extensible.Builder builder = new Extensible.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,248 @@
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.Entity;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* Foo
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class Foo extends Entity implements FooRefOrValue {
private @Nullable String fooPropA;
private @Nullable String fooPropB;
public Foo() {
super();
}
/**
* Constructor with only required parameters
*/
public Foo(String atType) {
super(atType);
}
public Foo fooPropA(@Nullable String fooPropA) {
this.fooPropA = fooPropA;
return this;
}
/**
* Get fooPropA
* @return fooPropA
*/
@Schema(name = "fooPropA", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("fooPropA")
public @Nullable String getFooPropA() {
return fooPropA;
}
public void setFooPropA(@Nullable String fooPropA) {
this.fooPropA = fooPropA;
}
public Foo fooPropB(@Nullable String fooPropB) {
this.fooPropB = fooPropB;
return this;
}
/**
* Get fooPropB
* @return fooPropB
*/
@Schema(name = "fooPropB", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("fooPropB")
public @Nullable String getFooPropB() {
return fooPropB;
}
public void setFooPropB(@Nullable String fooPropB) {
this.fooPropB = fooPropB;
}
public Foo href(String href) {
super.href(href);
return this;
}
public Foo id(String id) {
super.id(id);
return this;
}
public Foo atSchemaLocation(String atSchemaLocation) {
super.atSchemaLocation(atSchemaLocation);
return this;
}
public Foo atBaseType(String atBaseType) {
super.atBaseType(atBaseType);
return this;
}
public Foo atType(String atType) {
super.atType(atType);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Foo foo = (Foo) o;
return Objects.equals(this.fooPropA, foo.fooPropA) &&
Objects.equals(this.fooPropB, foo.fooPropB) &&
super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(fooPropA, fooPropB, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Foo {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" fooPropA: ").append(toIndentedString(fooPropA)).append("\n");
sb.append(" fooPropB: ").append(toIndentedString(fooPropB)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder extends Entity.Builder {
private Foo instance;
public Builder() {
this(new Foo());
}
protected Builder(Foo instance) {
super(instance); // the parent builder shares the same instance
this.instance = instance;
}
protected Builder copyOf(Foo value) {
super.copyOf(value);
this.instance.setFooPropA(value.fooPropA);
this.instance.setFooPropB(value.fooPropB);
return this;
}
public Foo.Builder fooPropA(String fooPropA) {
this.instance.fooPropA(fooPropA);
return this;
}
public Foo.Builder fooPropB(String fooPropB) {
this.instance.fooPropB(fooPropB);
return this;
}
@Override
public Foo.Builder href(String href) {
this.instance.href(href);
return this;
}
@Override
public Foo.Builder id(String id) {
this.instance.id(id);
return this;
}
@Override
public Foo.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
@Override
public Foo.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
@Override
public Foo.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built Foo instance.
*
* The builder is not reusable (NullPointerException)
*/
public Foo build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
super.build();
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static Foo.Builder builder() {
return new Foo.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public Foo.Builder toBuilder() {
Foo.Builder builder = new Foo.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,240 @@
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.EntityRef;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* FooRef
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class FooRef extends EntityRef implements FooRefOrValue {
private @Nullable String foorefPropA;
public FooRef() {
super();
}
/**
* Constructor with only required parameters
*/
public FooRef(String atType) {
super(atType);
}
public FooRef foorefPropA(@Nullable String foorefPropA) {
this.foorefPropA = foorefPropA;
return this;
}
/**
* Get foorefPropA
* @return foorefPropA
*/
@Schema(name = "foorefPropA", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("foorefPropA")
public @Nullable String getFoorefPropA() {
return foorefPropA;
}
public void setFoorefPropA(@Nullable String foorefPropA) {
this.foorefPropA = foorefPropA;
}
public FooRef name(String name) {
super.name(name);
return this;
}
public FooRef atReferredType(String atReferredType) {
super.atReferredType(atReferredType);
return this;
}
public FooRef href(String href) {
super.href(href);
return this;
}
public FooRef id(String id) {
super.id(id);
return this;
}
public FooRef atSchemaLocation(String atSchemaLocation) {
super.atSchemaLocation(atSchemaLocation);
return this;
}
public FooRef atBaseType(String atBaseType) {
super.atBaseType(atBaseType);
return this;
}
public FooRef atType(String atType) {
super.atType(atType);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
FooRef fooRef = (FooRef) o;
return Objects.equals(this.foorefPropA, fooRef.foorefPropA) &&
super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(foorefPropA, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class FooRef {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" foorefPropA: ").append(toIndentedString(foorefPropA)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder extends EntityRef.Builder {
private FooRef instance;
public Builder() {
this(new FooRef());
}
protected Builder(FooRef instance) {
super(instance); // the parent builder shares the same instance
this.instance = instance;
}
protected Builder copyOf(FooRef value) {
super.copyOf(value);
this.instance.setFoorefPropA(value.foorefPropA);
return this;
}
public FooRef.Builder foorefPropA(String foorefPropA) {
this.instance.foorefPropA(foorefPropA);
return this;
}
@Override
public FooRef.Builder name(String name) {
this.instance.name(name);
return this;
}
@Override
public FooRef.Builder atReferredType(String atReferredType) {
this.instance.atReferredType(atReferredType);
return this;
}
@Override
public FooRef.Builder href(String href) {
this.instance.href(href);
return this;
}
@Override
public FooRef.Builder id(String id) {
this.instance.id(id);
return this;
}
@Override
public FooRef.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
@Override
public FooRef.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
@Override
public FooRef.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built FooRef instance.
*
* The builder is not reusable (NullPointerException)
*/
public FooRef build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
super.build();
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static FooRef.Builder builder() {
return new FooRef.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public FooRef.Builder toBuilder() {
FooRef.Builder builder = new FooRef.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,37 @@
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.Foo;
import org.openapitools.model.FooRef;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
@JsonIgnoreProperties(
value = "@type", // ignore manually set @type, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the @type to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = Foo.class, name = "Foo"),
@JsonSubTypes.Type(value = FooRef.class, name = "FooRef")
})
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public sealed interface FooRefOrValue permits Foo, FooRef {
public String getAtType();
}

View File

@@ -0,0 +1,41 @@
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.Apple;
import org.openapitools.model.Banana;
import org.openapitools.model.FruitType;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
@JsonIgnoreProperties(
value = "fruitType", // ignore manually set fruitType, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the fruitType to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "fruitType", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = Apple.class, name = "APPLE"),
@JsonSubTypes.Type(value = Banana.class, name = "BANANA"),
@JsonSubTypes.Type(value = Apple.class, name = "Apple"),
@JsonSubTypes.Type(value = Banana.class, name = "Banana")
})
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public sealed interface Fruit permits Apple, Banana {
public FruitType getFruitType();
}

View File

@@ -0,0 +1,56 @@
package org.openapitools.model;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonValue;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* Gets or Sets FruitType
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public enum FruitType {
APPLE("APPLE"),
BANANA("BANANA");
private final String value;
FruitType(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static FruitType fromValue(String value) {
for (FruitType b : FruitType.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

View File

@@ -0,0 +1,218 @@
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.Entity;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* Pasta
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class Pasta extends Entity {
private @Nullable String vendor;
public Pasta() {
super();
}
/**
* Constructor with only required parameters
*/
public Pasta(String atType) {
super(atType);
}
public Pasta vendor(@Nullable String vendor) {
this.vendor = vendor;
return this;
}
/**
* Get vendor
* @return vendor
*/
@Schema(name = "vendor", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("vendor")
public @Nullable String getVendor() {
return vendor;
}
public void setVendor(@Nullable String vendor) {
this.vendor = vendor;
}
public Pasta href(String href) {
super.href(href);
return this;
}
public Pasta id(String id) {
super.id(id);
return this;
}
public Pasta atSchemaLocation(String atSchemaLocation) {
super.atSchemaLocation(atSchemaLocation);
return this;
}
public Pasta atBaseType(String atBaseType) {
super.atBaseType(atBaseType);
return this;
}
public Pasta atType(String atType) {
super.atType(atType);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Pasta pasta = (Pasta) o;
return Objects.equals(this.vendor, pasta.vendor) &&
super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(vendor, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Pasta {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" vendor: ").append(toIndentedString(vendor)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder extends Entity.Builder {
private Pasta instance;
public Builder() {
this(new Pasta());
}
protected Builder(Pasta instance) {
super(instance); // the parent builder shares the same instance
this.instance = instance;
}
protected Builder copyOf(Pasta value) {
super.copyOf(value);
this.instance.setVendor(value.vendor);
return this;
}
public Pasta.Builder vendor(String vendor) {
this.instance.vendor(vendor);
return this;
}
@Override
public Pasta.Builder href(String href) {
this.instance.href(href);
return this;
}
@Override
public Pasta.Builder id(String id) {
this.instance.id(id);
return this;
}
@Override
public Pasta.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
@Override
public Pasta.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
@Override
public Pasta.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built Pasta instance.
*
* The builder is not reusable (NullPointerException)
*/
public Pasta build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
super.build();
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static Pasta.Builder builder() {
return new Pasta.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public Pasta.Builder toBuilder() {
Pasta.Builder builder = new Pasta.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,227 @@
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 java.math.BigDecimal;
import org.openapitools.model.Entity;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* Pizza
*/
@JsonIgnoreProperties(
value = "@type", // ignore manually set @type, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the @type to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = PizzaSpeziale.class, name = "PizzaSpeziale")
})
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public sealed class Pizza extends Entity permits PizzaSpeziale {
private @Nullable BigDecimal pizzaSize;
public Pizza() {
super();
}
/**
* Constructor with only required parameters
*/
public Pizza(String atType) {
super(atType);
}
public Pizza pizzaSize(@Nullable BigDecimal pizzaSize) {
this.pizzaSize = pizzaSize;
return this;
}
/**
* Get pizzaSize
* @return pizzaSize
*/
@Valid
@Schema(name = "pizzaSize", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("pizzaSize")
public @Nullable BigDecimal getPizzaSize() {
return pizzaSize;
}
public void setPizzaSize(@Nullable BigDecimal pizzaSize) {
this.pizzaSize = pizzaSize;
}
public Pizza href(String href) {
super.href(href);
return this;
}
public Pizza id(String id) {
super.id(id);
return this;
}
public Pizza atSchemaLocation(String atSchemaLocation) {
super.atSchemaLocation(atSchemaLocation);
return this;
}
public Pizza atBaseType(String atBaseType) {
super.atBaseType(atBaseType);
return this;
}
public Pizza atType(String atType) {
super.atType(atType);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Pizza pizza = (Pizza) o;
return Objects.equals(this.pizzaSize, pizza.pizzaSize) &&
super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(pizzaSize, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Pizza {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" pizzaSize: ").append(toIndentedString(pizzaSize)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder extends Entity.Builder {
private Pizza instance;
public Builder() {
this(new Pizza());
}
protected Builder(Pizza instance) {
super(instance); // the parent builder shares the same instance
this.instance = instance;
}
protected Builder copyOf(Pizza value) {
super.copyOf(value);
this.instance.setPizzaSize(value.pizzaSize);
return this;
}
public Pizza.Builder pizzaSize(BigDecimal pizzaSize) {
this.instance.pizzaSize(pizzaSize);
return this;
}
@Override
public Pizza.Builder href(String href) {
this.instance.href(href);
return this;
}
@Override
public Pizza.Builder id(String id) {
this.instance.id(id);
return this;
}
@Override
public Pizza.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
@Override
public Pizza.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
@Override
public Pizza.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built Pizza instance.
*
* The builder is not reusable (NullPointerException)
*/
public Pizza build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
super.build();
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static Pizza.Builder builder() {
return new Pizza.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public Pizza.Builder toBuilder() {
Pizza.Builder builder = new Pizza.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,230 @@
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 java.math.BigDecimal;
import org.openapitools.model.Pizza;
import org.springframework.lang.Nullable;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* PizzaSpeziale
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
public final class PizzaSpeziale extends Pizza {
private @Nullable String toppings;
public PizzaSpeziale() {
super();
}
/**
* Constructor with only required parameters
*/
public PizzaSpeziale(String atType) {
super(atType);
}
public PizzaSpeziale toppings(@Nullable String toppings) {
this.toppings = toppings;
return this;
}
/**
* Get toppings
* @return toppings
*/
@Schema(name = "toppings", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("toppings")
public @Nullable String getToppings() {
return toppings;
}
public void setToppings(@Nullable String toppings) {
this.toppings = toppings;
}
public PizzaSpeziale pizzaSize(BigDecimal pizzaSize) {
super.pizzaSize(pizzaSize);
return this;
}
public PizzaSpeziale href(String href) {
super.href(href);
return this;
}
public PizzaSpeziale id(String id) {
super.id(id);
return this;
}
public PizzaSpeziale atSchemaLocation(String atSchemaLocation) {
super.atSchemaLocation(atSchemaLocation);
return this;
}
public PizzaSpeziale atBaseType(String atBaseType) {
super.atBaseType(atBaseType);
return this;
}
public PizzaSpeziale atType(String atType) {
super.atType(atType);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
PizzaSpeziale pizzaSpeziale = (PizzaSpeziale) o;
return Objects.equals(this.toppings, pizzaSpeziale.toppings) &&
super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(toppings, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class PizzaSpeziale {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" toppings: ").append(toIndentedString(toppings)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static class Builder extends Pizza.Builder {
private PizzaSpeziale instance;
public Builder() {
this(new PizzaSpeziale());
}
protected Builder(PizzaSpeziale instance) {
super(instance); // the parent builder shares the same instance
this.instance = instance;
}
protected Builder copyOf(PizzaSpeziale value) {
super.copyOf(value);
this.instance.setToppings(value.toppings);
return this;
}
public PizzaSpeziale.Builder toppings(String toppings) {
this.instance.toppings(toppings);
return this;
}
@Override
public PizzaSpeziale.Builder pizzaSize(BigDecimal pizzaSize) {
this.instance.pizzaSize(pizzaSize);
return this;
}
@Override
public PizzaSpeziale.Builder href(String href) {
this.instance.href(href);
return this;
}
@Override
public PizzaSpeziale.Builder id(String id) {
this.instance.id(id);
return this;
}
@Override
public PizzaSpeziale.Builder atSchemaLocation(String atSchemaLocation) {
this.instance.atSchemaLocation(atSchemaLocation);
return this;
}
@Override
public PizzaSpeziale.Builder atBaseType(String atBaseType) {
this.instance.atBaseType(atBaseType);
return this;
}
@Override
public PizzaSpeziale.Builder atType(String atType) {
this.instance.atType(atType);
return this;
}
/**
* returns a built PizzaSpeziale instance.
*
* The builder is not reusable (NullPointerException)
*/
public PizzaSpeziale build() {
try {
return this.instance;
} finally {
// ensure that this.instance is not reused
super.build();
this.instance = null;
}
}
@Override
public String toString() {
return getClass() + "=(" + instance + ")";
}
}
/**
* Create a builder with no initialized field (except for the default values).
*/
public static PizzaSpeziale.Builder builder() {
return new PizzaSpeziale.Builder();
}
/**
* Create a builder with a shallow copy of this instance.
*/
public PizzaSpeziale.Builder toBuilder() {
PizzaSpeziale.Builder builder = new PizzaSpeziale.Builder();
return builder.copyOf(this);
}
}

View File

@@ -0,0 +1,3 @@
server.port=8080
spring.jackson.date-format=org.openapitools.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false

View File

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

View File

@@ -0,0 +1,13 @@
package org.openapitools;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class OpenApiGeneratorApplicationTests {
@Test
void contextLoads() {
}
}