diff --git a/.github/workflows/samples-spring-jdk17.yaml b/.github/workflows/samples-spring-jdk17.yaml
index 74c71ce4e8ff..8305c1820564 100644
--- a/.github/workflows/samples-spring-jdk17.yaml
+++ b/.github/workflows/samples-spring-jdk17.yaml
@@ -11,6 +11,7 @@ on:
- samples/server/petstore/springboot-file-delegate-optional
- samples/server/petstore/springboot-petstore-with-api-response-examples
- samples/server/petstore/spring-boot-oneof-sealed
+ - samples/openapi3/server/petstore/spring-boot-oneof-interface
pull_request:
paths:
- samples/openapi3/client/petstore/spring-cloud-3-with-optional
@@ -21,6 +22,7 @@ on:
- samples/server/petstore/springboot-file-delegate-optional
- samples/server/petstore/springboot-petstore-with-api-response-examples
- samples/server/petstore/spring-boot-oneof-sealed
+ - samples/openapi3/server/petstore/spring-boot-oneof-interface
jobs:
build:
name: Build Java Spring (JDK17)
@@ -39,6 +41,7 @@ jobs:
- samples/server/petstore/springboot-file-delegate-optional
- samples/server/petstore/springboot-petstore-with-api-response-examples
- samples/server/petstore/spring-boot-oneof-sealed
+ - samples/openapi3/server/petstore/spring-boot-oneof-interface
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
diff --git a/.github/workflows/samples-spring.yaml b/.github/workflows/samples-spring.yaml
index fc5bffc2a339..886b53309ed5 100644
--- a/.github/workflows/samples-spring.yaml
+++ b/.github/workflows/samples-spring.yaml
@@ -60,6 +60,7 @@ jobs:
- samples/server/petstore/springboot-spring-provide-args
- samples/server/petstore/springboot-useoptional
- samples/server/petstore/springboot-virtualan
+ - samples/openapi3/server/petstore/spring-boot-oneof-interface
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
diff --git a/bin/configs/spring-boot-oneof-interface.yaml b/bin/configs/spring-boot-oneof-interface.yaml
new file mode 100644
index 000000000000..a66a2c4bfc97
--- /dev/null
+++ b/bin/configs/spring-boot-oneof-interface.yaml
@@ -0,0 +1,12 @@
+generatorName: spring
+outputDir: samples/openapi3/server/petstore/spring-boot-oneof-interface
+inputSpec: modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml
+templateDir: modules/openapi-generator/src/main/resources/JavaSpring
+additionalProperties:
+ groupId: org.openapitools.openapi3
+ documentationProvider: springdoc
+ artifactId: springboot-oneof
+ snapshotVersion: "true"
+ hideGenerationTimestamp: "true"
+ useOneOfInterfaces: "true"
+ useDeductionForOneOfInterfaces: "true"
diff --git a/docs/generators/java-camel.md b/docs/generators/java-camel.md
index 9b1c3c37162a..b6045e5a6788 100644
--- a/docs/generators/java-camel.md
+++ b/docs/generators/java-camel.md
@@ -99,6 +99,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|title|server title name or client service name| |OpenAPI Spring|
|unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false|
|useBeanValidation|Use BeanValidation API annotations| |true|
+|useDeductionForOneOfInterfaces|whether to use deduction for generated oneOf interfaces| |false|
|useEnumCaseInsensitive|Use `equalsIgnoreCase` when String for enum comparison| |false|
|useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true|
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
diff --git a/docs/generators/spring.md b/docs/generators/spring.md
index 54d0433256e1..cf152645e5d6 100644
--- a/docs/generators/spring.md
+++ b/docs/generators/spring.md
@@ -92,6 +92,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|title|server title name or client service name| |OpenAPI Spring|
|unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false|
|useBeanValidation|Use BeanValidation API annotations| |true|
+|useDeductionForOneOfInterfaces|whether to use deduction for generated oneOf interfaces| |false|
|useEnumCaseInsensitive|Use `equalsIgnoreCase` when String for enum comparison| |false|
|useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true|
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java
index 621c91bfa84f..687fd543a544 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java
@@ -99,6 +99,7 @@ public class SpringCodegen extends AbstractJavaCodegen
public static final String USE_SEALED = "useSealed";
public static final String OPTIONAL_ACCEPT_NULLABLE = "optionalAcceptNullable";
public static final String USE_SPRING_BUILT_IN_VALIDATION = "useSpringBuiltInValidation";
+ public static final String USE_DEDUCTION_FOR_ONE_OF_INTERFACES = "useDeductionForOneOfInterfaces";
@Getter
public enum RequestMappingMode {
@@ -159,6 +160,8 @@ public enum RequestMappingMode {
protected boolean optionalAcceptNullable = true;
@Getter @Setter
protected boolean useSpringBuiltInValidation = false;
+ @Getter @Setter
+ protected boolean useDeductionForOneOfInterfaces = false;
public SpringCodegen() {
super();
@@ -276,6 +279,7 @@ public SpringCodegen() {
"Use `ofNullable` instead of just `of` to accept null values when using Optional.",
optionalAcceptNullable));
+ cliOptions.add(CliOption.newBoolean(USE_DEDUCTION_FOR_ONE_OF_INTERFACES, "whether to use deduction for generated oneOf interfaces", useDeductionForOneOfInterfaces));
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application.");
supportedLibraries.put(SPRING_CLOUD_LIBRARY,
"Spring-Cloud-Feign client with Spring-Boot auto-configured settings.");
@@ -446,6 +450,7 @@ public void processOpts() {
}
convertPropertyToBooleanAndWriteBack(OPTIONAL_ACCEPT_NULLABLE, this::setOptionalAcceptNullable);
convertPropertyToBooleanAndWriteBack(USE_SPRING_BUILT_IN_VALIDATION, this::setUseSpringBuiltInValidation);
+ convertPropertyToBooleanAndWriteBack(USE_DEDUCTION_FOR_ONE_OF_INTERFACES, this::setUseDeductionForOneOfInterfaces);
additionalProperties.put("springHttpStatus", new SpringHttpStatusLambda());
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/oneof_interface.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/oneof_interface.mustache
index f8f79802bbc8..98db2c7cf4e2 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/oneof_interface.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/oneof_interface.mustache
@@ -6,6 +6,14 @@
{{#discriminator}}
{{>typeInfoAnnotation}}
+{{/discriminator}}{{^discriminator}}{{#useDeductionForOneOfInterfaces}}
+@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
+@JsonSubTypes({
+ {{#interfaceModels}}
+ @JsonSubTypes.Type(value = {{classname}}.class){{^-last}}, {{/-last}}
+ {{/interfaceModels}}
+})
+{{/useDeductionForOneOfInterfaces}}
{{/discriminator}}
{{>generatedAnnotation}}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
index 0036c39ec9cc..62e6b3eae85c 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
@@ -1702,10 +1702,13 @@ public void testOneOfAndAllOf() throws IOException {
generator.setGeneratorPropertyDefault(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "false");
codegen.setUseOneOfInterfaces(true);
+ codegen.setUseDeductionForOneOfInterfaces(true);
codegen.setLegacyDiscriminatorBehavior(false);
generator.opts(input).generate();
+ // test deduction
+ assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Animal.java"), "@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)", "@JsonSubTypes.Type(value = Dog.class),", "@JsonSubTypes.Type(value = Cat.class)");
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Foo.java"), "public class Foo extends Entity implements FooRefOrValue");
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/FooRef.java"), "public class FooRef extends EntityRef implements FooRefOrValue");
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/FooRefOrValue.java"), "public interface FooRefOrValue");
diff --git a/modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml b/modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml
index d890e5fbfd5a..ad65b8921f73 100644
--- a/modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml
@@ -209,6 +209,20 @@ components:
properties:
length:
type: integer
+ Animal:
+ oneOf:
+ - $ref: '#/components/schemas/Dog'
+ - $ref: '#/components/schemas/Cat'
+ Cat:
+ type: object
+ properties:
+ declawed:
+ type: boolean
+ Dog:
+ type: object
+ properties:
+ bark:
+ type: boolean
requestBodies:
Foo:
diff --git a/samples/client/echo_api/java/okhttp-gson-user-defined-templates/README.md b/samples/client/echo_api/java/okhttp-gson-user-defined-templates/README.md
new file mode 100644
index 000000000000..61555e362393
--- /dev/null
+++ b/samples/client/echo_api/java/okhttp-gson-user-defined-templates/README.md
@@ -0,0 +1,184 @@
+# openapi-java-client
+
+OpenAPI Petstore
+- API version: 1.0.0
+ - Generator version: 7.6.0-SNAPSHOT
+
+This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
+
+
+*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
+
+
+## Requirements
+
+Building the API client library requires:
+1. Java 1.8+
+2. Maven (3.8.3+)/Gradle (7.2+)
+
+## Installation
+
+To install the API client library to your local Maven repository, simply execute:
+
+```shell
+mvn clean install
+```
+
+To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
+
+```shell
+mvn clean deploy
+```
+
+Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.
+
+### Maven users
+
+Add this dependency to your project's POM:
+
+```xml
+
+ org.openapitools
+ openapi-java-client
+ 1.0.0
+ compile
+
+```
+
+### Gradle users
+
+Add this dependency to your project's build file:
+
+```groovy
+ repositories {
+ mavenCentral() // Needed if the 'openapi-java-client' jar has been published to maven central.
+ mavenLocal() // Needed if the 'openapi-java-client' jar has been published to the local maven repo.
+ }
+
+ dependencies {
+ implementation "org.openapitools:openapi-java-client:1.0.0"
+ }
+```
+
+### Others
+
+At first generate the JAR by executing:
+
+```shell
+mvn clean package
+```
+
+Then manually install the following JARs:
+
+* `target/openapi-java-client-1.0.0.jar`
+* `target/lib/*.jar`
+
+## Getting Started
+
+Please follow the [installation](#installation) instruction and execute the following Java code:
+
+```java
+
+// Import classes:
+import org.openapitools.client.ApiClient;
+import org.openapitools.client.ApiException;
+import org.openapitools.client.Configuration;
+import org.openapitools.client.auth.*;
+import org.openapitools.client.models.*;
+import org.openapitools.client.api.PetApi;
+
+public class Example {
+ public static void main(String[] args) {
+ ApiClient defaultClient = Configuration.getDefaultApiClient();
+ defaultClient.setBasePath("http://petstore.swagger.io/v2");
+
+ // Configure OAuth2 access token for authorization: petstore_auth
+ OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth");
+ petstore_auth.setAccessToken("YOUR ACCESS TOKEN");
+
+ PetApi apiInstance = new PetApi(defaultClient);
+ Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store
+ try {
+ Pet result = apiInstance.addPet(pet);
+ System.out.println(result);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling PetApi#addPet");
+ System.err.println("Status code: " + e.getCode());
+ System.err.println("Reason: " + e.getResponseBody());
+ System.err.println("Response headers: " + e.getResponseHeaders());
+ e.printStackTrace();
+ }
+ }
+}
+
+```
+
+## Documentation for API Endpoints
+
+All URIs are relative to *http://petstore.swagger.io/v2*
+
+Class | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
+*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
+*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
+*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
+*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID
+*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
+*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
+*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
+*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
+*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
+*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
+*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
+*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user
+*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
+*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
+*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user
+*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name
+*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system
+*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session
+*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user
+
+
+## Documentation for Models
+
+ - [Category](docs/Category.md)
+ - [ModelApiResponse](docs/ModelApiResponse.md)
+ - [Order](docs/Order.md)
+ - [Pet](docs/Pet.md)
+ - [Tag](docs/Tag.md)
+ - [User](docs/User.md)
+
+
+
+## Documentation for Authorization
+
+
+Authentication schemes defined for the API:
+
+### petstore_auth
+
+- **Type**: OAuth
+- **Flow**: implicit
+- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
+- **Scopes**:
+ - write:pets: modify pets in your account
+ - read:pets: read your pets
+
+
+### api_key
+
+- **Type**: API key
+- **API key parameter name**: api_key
+- **Location**: HTTP header
+
+
+## Recommendation
+
+It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
+
+## Author
+
+
+
diff --git a/samples/client/others/rust/hyper/oneOf/.openapi-generator/FILES b/samples/client/others/rust/hyper/oneOf/.openapi-generator/FILES
index 7452a306cce2..f1727840902e 100644
--- a/samples/client/others/rust/hyper/oneOf/.openapi-generator/FILES
+++ b/samples/client/others/rust/hyper/oneOf/.openapi-generator/FILES
@@ -3,6 +3,7 @@
Cargo.toml
README.md
docs/Addressable.md
+docs/Animal.md
docs/Apple.md
docs/Banana.md
docs/Bar.md
@@ -10,6 +11,8 @@ docs/BarApi.md
docs/BarCreate.md
docs/BarRef.md
docs/BarRefOrValue.md
+docs/Cat.md
+docs/Dog.md
docs/Entity.md
docs/EntityRef.md
docs/Extensible.md
@@ -31,12 +34,15 @@ src/apis/mod.rs
src/apis/request.rs
src/lib.rs
src/models/addressable.rs
+src/models/animal.rs
src/models/apple.rs
src/models/banana.rs
src/models/bar.rs
src/models/bar_create.rs
src/models/bar_ref.rs
src/models/bar_ref_or_value.rs
+src/models/cat.rs
+src/models/dog.rs
src/models/entity.rs
src/models/entity_ref.rs
src/models/extensible.rs
diff --git a/samples/client/others/rust/hyper/oneOf/README.md b/samples/client/others/rust/hyper/oneOf/README.md
index 7d90d194cdfe..b68376da35d7 100644
--- a/samples/client/others/rust/hyper/oneOf/README.md
+++ b/samples/client/others/rust/hyper/oneOf/README.md
@@ -35,12 +35,15 @@ Class | Method | HTTP request | Description
## Documentation For Models
- [Addressable](docs/Addressable.md)
+ - [Animal](docs/Animal.md)
- [Apple](docs/Apple.md)
- [Banana](docs/Banana.md)
- [Bar](docs/Bar.md)
- [BarCreate](docs/BarCreate.md)
- [BarRef](docs/BarRef.md)
- [BarRefOrValue](docs/BarRefOrValue.md)
+ - [Cat](docs/Cat.md)
+ - [Dog](docs/Dog.md)
- [Entity](docs/Entity.md)
- [EntityRef](docs/EntityRef.md)
- [Extensible](docs/Extensible.md)
diff --git a/samples/client/others/rust/hyper/oneOf/docs/Animal.md b/samples/client/others/rust/hyper/oneOf/docs/Animal.md
new file mode 100644
index 000000000000..7288082ea0b1
--- /dev/null
+++ b/samples/client/others/rust/hyper/oneOf/docs/Animal.md
@@ -0,0 +1,12 @@
+# Animal
+
+## Enum Variants
+
+| Name | Description |
+|---- | -----|
+| Cat | |
+| Dog | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/others/rust/hyper/oneOf/docs/Cat.md b/samples/client/others/rust/hyper/oneOf/docs/Cat.md
new file mode 100644
index 000000000000..29a32acc867f
--- /dev/null
+++ b/samples/client/others/rust/hyper/oneOf/docs/Cat.md
@@ -0,0 +1,11 @@
+# Cat
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**declawed** | Option<**bool**> | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/others/rust/hyper/oneOf/docs/Dog.md b/samples/client/others/rust/hyper/oneOf/docs/Dog.md
new file mode 100644
index 000000000000..8cc581d43d6e
--- /dev/null
+++ b/samples/client/others/rust/hyper/oneOf/docs/Dog.md
@@ -0,0 +1,11 @@
+# Dog
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**bark** | Option<**bool**> | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/others/rust/hyper/oneOf/src/models/animal.rs b/samples/client/others/rust/hyper/oneOf/src/models/animal.rs
new file mode 100644
index 000000000000..4973966941e4
--- /dev/null
+++ b/samples/client/others/rust/hyper/oneOf/src/models/animal.rs
@@ -0,0 +1,26 @@
+/*
+ * ByRefOrValue
+ *
+ * This tests for a oneOf interface representation
+ *
+ * The version of the OpenAPI document: 0.0.1
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+use crate::models;
+use serde::{Deserialize, Serialize};
+
+#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
+#[serde(untagged)]
+pub enum Animal {
+ Dog(Box),
+ Cat(Box),
+}
+
+impl Default for Animal {
+ fn default() -> Self {
+ Self::Dog(Default::default())
+ }
+}
+
diff --git a/samples/client/others/rust/hyper/oneOf/src/models/cat.rs b/samples/client/others/rust/hyper/oneOf/src/models/cat.rs
new file mode 100644
index 000000000000..3e06691828af
--- /dev/null
+++ b/samples/client/others/rust/hyper/oneOf/src/models/cat.rs
@@ -0,0 +1,27 @@
+/*
+ * ByRefOrValue
+ *
+ * This tests for a oneOf interface representation
+ *
+ * The version of the OpenAPI document: 0.0.1
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+use crate::models;
+use serde::{Deserialize, Serialize};
+
+#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
+pub struct Cat {
+ #[serde(rename = "declawed", skip_serializing_if = "Option::is_none")]
+ pub declawed: Option,
+}
+
+impl Cat {
+ pub fn new() -> Cat {
+ Cat {
+ declawed: None,
+ }
+ }
+}
+
diff --git a/samples/client/others/rust/hyper/oneOf/src/models/dog.rs b/samples/client/others/rust/hyper/oneOf/src/models/dog.rs
new file mode 100644
index 000000000000..59c0321282df
--- /dev/null
+++ b/samples/client/others/rust/hyper/oneOf/src/models/dog.rs
@@ -0,0 +1,27 @@
+/*
+ * ByRefOrValue
+ *
+ * This tests for a oneOf interface representation
+ *
+ * The version of the OpenAPI document: 0.0.1
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+use crate::models;
+use serde::{Deserialize, Serialize};
+
+#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
+pub struct Dog {
+ #[serde(rename = "bark", skip_serializing_if = "Option::is_none")]
+ pub bark: Option,
+}
+
+impl Dog {
+ pub fn new() -> Dog {
+ Dog {
+ bark: None,
+ }
+ }
+}
+
diff --git a/samples/client/others/rust/hyper/oneOf/src/models/mod.rs b/samples/client/others/rust/hyper/oneOf/src/models/mod.rs
index 581d09587bcc..8fc7bc4efe19 100644
--- a/samples/client/others/rust/hyper/oneOf/src/models/mod.rs
+++ b/samples/client/others/rust/hyper/oneOf/src/models/mod.rs
@@ -1,5 +1,7 @@
pub mod addressable;
pub use self::addressable::Addressable;
+pub mod animal;
+pub use self::animal::Animal;
pub mod apple;
pub use self::apple::Apple;
pub mod banana;
@@ -12,6 +14,10 @@ pub mod bar_ref;
pub use self::bar_ref::BarRef;
pub mod bar_ref_or_value;
pub use self::bar_ref_or_value::BarRefOrValue;
+pub mod cat;
+pub use self::cat::Cat;
+pub mod dog;
+pub use self::dog::Dog;
pub mod entity;
pub use self::entity::Entity;
pub mod entity_ref;
diff --git a/samples/client/others/rust/reqwest/oneOf/.openapi-generator/FILES b/samples/client/others/rust/reqwest/oneOf/.openapi-generator/FILES
index a24a8ab7271b..e5d1837cbf99 100644
--- a/samples/client/others/rust/reqwest/oneOf/.openapi-generator/FILES
+++ b/samples/client/others/rust/reqwest/oneOf/.openapi-generator/FILES
@@ -3,6 +3,7 @@
Cargo.toml
README.md
docs/Addressable.md
+docs/Animal.md
docs/Apple.md
docs/Banana.md
docs/Bar.md
@@ -10,6 +11,8 @@ docs/BarApi.md
docs/BarCreate.md
docs/BarRef.md
docs/BarRefOrValue.md
+docs/Cat.md
+docs/Dog.md
docs/Entity.md
docs/EntityRef.md
docs/Extensible.md
@@ -29,12 +32,15 @@ src/apis/foo_api.rs
src/apis/mod.rs
src/lib.rs
src/models/addressable.rs
+src/models/animal.rs
src/models/apple.rs
src/models/banana.rs
src/models/bar.rs
src/models/bar_create.rs
src/models/bar_ref.rs
src/models/bar_ref_or_value.rs
+src/models/cat.rs
+src/models/dog.rs
src/models/entity.rs
src/models/entity_ref.rs
src/models/extensible.rs
diff --git a/samples/client/others/rust/reqwest/oneOf/README.md b/samples/client/others/rust/reqwest/oneOf/README.md
index e47bcfcba561..b4bbded45c30 100644
--- a/samples/client/others/rust/reqwest/oneOf/README.md
+++ b/samples/client/others/rust/reqwest/oneOf/README.md
@@ -35,12 +35,15 @@ Class | Method | HTTP request | Description
## Documentation For Models
- [Addressable](docs/Addressable.md)
+ - [Animal](docs/Animal.md)
- [Apple](docs/Apple.md)
- [Banana](docs/Banana.md)
- [Bar](docs/Bar.md)
- [BarCreate](docs/BarCreate.md)
- [BarRef](docs/BarRef.md)
- [BarRefOrValue](docs/BarRefOrValue.md)
+ - [Cat](docs/Cat.md)
+ - [Dog](docs/Dog.md)
- [Entity](docs/Entity.md)
- [EntityRef](docs/EntityRef.md)
- [Extensible](docs/Extensible.md)
diff --git a/samples/client/others/rust/reqwest/oneOf/docs/Animal.md b/samples/client/others/rust/reqwest/oneOf/docs/Animal.md
new file mode 100644
index 000000000000..7288082ea0b1
--- /dev/null
+++ b/samples/client/others/rust/reqwest/oneOf/docs/Animal.md
@@ -0,0 +1,12 @@
+# Animal
+
+## Enum Variants
+
+| Name | Description |
+|---- | -----|
+| Cat | |
+| Dog | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/others/rust/reqwest/oneOf/docs/Cat.md b/samples/client/others/rust/reqwest/oneOf/docs/Cat.md
new file mode 100644
index 000000000000..29a32acc867f
--- /dev/null
+++ b/samples/client/others/rust/reqwest/oneOf/docs/Cat.md
@@ -0,0 +1,11 @@
+# Cat
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**declawed** | Option<**bool**> | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/others/rust/reqwest/oneOf/docs/Dog.md b/samples/client/others/rust/reqwest/oneOf/docs/Dog.md
new file mode 100644
index 000000000000..8cc581d43d6e
--- /dev/null
+++ b/samples/client/others/rust/reqwest/oneOf/docs/Dog.md
@@ -0,0 +1,11 @@
+# Dog
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**bark** | Option<**bool**> | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/animal.rs b/samples/client/others/rust/reqwest/oneOf/src/models/animal.rs
new file mode 100644
index 000000000000..4973966941e4
--- /dev/null
+++ b/samples/client/others/rust/reqwest/oneOf/src/models/animal.rs
@@ -0,0 +1,26 @@
+/*
+ * ByRefOrValue
+ *
+ * This tests for a oneOf interface representation
+ *
+ * The version of the OpenAPI document: 0.0.1
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+use crate::models;
+use serde::{Deserialize, Serialize};
+
+#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
+#[serde(untagged)]
+pub enum Animal {
+ Dog(Box),
+ Cat(Box),
+}
+
+impl Default for Animal {
+ fn default() -> Self {
+ Self::Dog(Default::default())
+ }
+}
+
diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/cat.rs b/samples/client/others/rust/reqwest/oneOf/src/models/cat.rs
new file mode 100644
index 000000000000..3e06691828af
--- /dev/null
+++ b/samples/client/others/rust/reqwest/oneOf/src/models/cat.rs
@@ -0,0 +1,27 @@
+/*
+ * ByRefOrValue
+ *
+ * This tests for a oneOf interface representation
+ *
+ * The version of the OpenAPI document: 0.0.1
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+use crate::models;
+use serde::{Deserialize, Serialize};
+
+#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
+pub struct Cat {
+ #[serde(rename = "declawed", skip_serializing_if = "Option::is_none")]
+ pub declawed: Option,
+}
+
+impl Cat {
+ pub fn new() -> Cat {
+ Cat {
+ declawed: None,
+ }
+ }
+}
+
diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/dog.rs b/samples/client/others/rust/reqwest/oneOf/src/models/dog.rs
new file mode 100644
index 000000000000..59c0321282df
--- /dev/null
+++ b/samples/client/others/rust/reqwest/oneOf/src/models/dog.rs
@@ -0,0 +1,27 @@
+/*
+ * ByRefOrValue
+ *
+ * This tests for a oneOf interface representation
+ *
+ * The version of the OpenAPI document: 0.0.1
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+use crate::models;
+use serde::{Deserialize, Serialize};
+
+#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
+pub struct Dog {
+ #[serde(rename = "bark", skip_serializing_if = "Option::is_none")]
+ pub bark: Option,
+}
+
+impl Dog {
+ pub fn new() -> Dog {
+ Dog {
+ bark: None,
+ }
+ }
+}
+
diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/mod.rs b/samples/client/others/rust/reqwest/oneOf/src/models/mod.rs
index 581d09587bcc..8fc7bc4efe19 100644
--- a/samples/client/others/rust/reqwest/oneOf/src/models/mod.rs
+++ b/samples/client/others/rust/reqwest/oneOf/src/models/mod.rs
@@ -1,5 +1,7 @@
pub mod addressable;
pub use self::addressable::Addressable;
+pub mod animal;
+pub use self::animal::Animal;
pub mod apple;
pub use self::apple::Apple;
pub mod banana;
@@ -12,6 +14,10 @@ pub mod bar_ref;
pub use self::bar_ref::BarRef;
pub mod bar_ref_or_value;
pub use self::bar_ref_or_value::BarRefOrValue;
+pub mod cat;
+pub use self::cat::Cat;
+pub mod dog;
+pub use self::dog::Dog;
pub mod entity;
pub use self::entity::Entity;
pub mod entity_ref;
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator/FILES
index 5e9dbd5a0777..1c42b39a4554 100644
--- a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator/FILES
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator/FILES
@@ -2,6 +2,7 @@
README.md
analysis_options.yaml
doc/Addressable.md
+doc/Animal.md
doc/Apple.md
doc/Banana.md
doc/Bar.md
@@ -9,6 +10,8 @@ doc/BarApi.md
doc/BarCreate.md
doc/BarRef.md
doc/BarRefOrValue.md
+doc/Cat.md
+doc/Dog.md
doc/Entity.md
doc/EntityRef.md
doc/Extensible.md
@@ -33,13 +36,16 @@ lib/src/auth/bearer_auth.dart
lib/src/auth/oauth.dart
lib/src/date_serializer.dart
lib/src/model/addressable.dart
+lib/src/model/animal.dart
lib/src/model/apple.dart
lib/src/model/banana.dart
lib/src/model/bar.dart
lib/src/model/bar_create.dart
lib/src/model/bar_ref.dart
lib/src/model/bar_ref_or_value.dart
+lib/src/model/cat.dart
lib/src/model/date.dart
+lib/src/model/dog.dart
lib/src/model/entity.dart
lib/src/model/entity_ref.dart
lib/src/model/extensible.dart
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/README.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/README.md
index 93c267ab25c3..9b112cdb692f 100644
--- a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/README.md
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/README.md
@@ -74,12 +74,15 @@ Class | Method | HTTP request | Description
## Documentation For Models
- [Addressable](doc/Addressable.md)
+ - [Animal](doc/Animal.md)
- [Apple](doc/Apple.md)
- [Banana](doc/Banana.md)
- [Bar](doc/Bar.md)
- [BarCreate](doc/BarCreate.md)
- [BarRef](doc/BarRef.md)
- [BarRefOrValue](doc/BarRefOrValue.md)
+ - [Cat](doc/Cat.md)
+ - [Dog](doc/Dog.md)
- [Entity](doc/Entity.md)
- [EntityRef](doc/EntityRef.md)
- [Extensible](doc/Extensible.md)
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Animal.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Animal.md
new file mode 100644
index 000000000000..b30398312c77
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Animal.md
@@ -0,0 +1,16 @@
+# openapi.model.Animal
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**bark** | **bool** | | [optional]
+**declawed** | **bool** | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Cat.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Cat.md
new file mode 100644
index 000000000000..c1c078d2b65e
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Cat.md
@@ -0,0 +1,15 @@
+# openapi.model.Cat
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**declawed** | **bool** | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Dog.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Dog.md
new file mode 100644
index 000000000000..c6cc069e2563
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Dog.md
@@ -0,0 +1,15 @@
+# openapi.model.Dog
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**bark** | **bool** | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/openapi.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/openapi.dart
index 80b852dd0d54..62792ee50e05 100644
--- a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/openapi.dart
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/openapi.dart
@@ -14,12 +14,15 @@ export 'package:openapi/src/api/bar_api.dart';
export 'package:openapi/src/api/foo_api.dart';
export 'package:openapi/src/model/addressable.dart';
+export 'package:openapi/src/model/animal.dart';
export 'package:openapi/src/model/apple.dart';
export 'package:openapi/src/model/banana.dart';
export 'package:openapi/src/model/bar.dart';
export 'package:openapi/src/model/bar_create.dart';
export 'package:openapi/src/model/bar_ref.dart';
export 'package:openapi/src/model/bar_ref_or_value.dart';
+export 'package:openapi/src/model/cat.dart';
+export 'package:openapi/src/model/dog.dart';
export 'package:openapi/src/model/entity.dart';
export 'package:openapi/src/model/entity_ref.dart';
export 'package:openapi/src/model/extensible.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/animal.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/animal.dart
new file mode 100644
index 000000000000..78030696e949
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/animal.dart
@@ -0,0 +1,73 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/dog.dart';
+import 'package:openapi/src/model/cat.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+import 'package:one_of/one_of.dart';
+
+part 'animal.g.dart';
+
+/// Animal
+///
+/// Properties:
+/// * [bark]
+/// * [declawed]
+@BuiltValue()
+abstract class Animal implements Built {
+ /// One Of [Cat], [Dog]
+ OneOf get oneOf;
+
+ Animal._();
+
+ factory Animal([void updates(AnimalBuilder b)]) = _$Animal;
+
+ @BuiltValueHook(initializeBuilder: true)
+ static void _defaults(AnimalBuilder b) => b;
+
+ @BuiltValueSerializer(custom: true)
+ static Serializer get serializer => _$AnimalSerializer();
+}
+
+class _$AnimalSerializer implements PrimitiveSerializer {
+ @override
+ final Iterable types = const [Animal, _$Animal];
+
+ @override
+ final String wireName = r'Animal';
+
+ Iterable