From 1619b60197e55f8dc80937f71584eeb403b813e9 Mon Sep 17 00:00:00 2001 From: Wiebren Braakman Date: Tue, 8 Sep 2026 10:36:21 +0200 Subject: [PATCH 1/3] [rust] fix: discriminated-union variants keep the child's own fields A schema with a discriminator and mapped children generated a serde internally-tagged enum whose variants were inline structs built from the parent's vars - every child-specific field was silently dropped, and with duplicate mappings the variants even mixed vars across models. Wrap the mapped model in a newtype variant instead (boxed, like the oneOf variants), named by the uniquified modelName while wrapping the model's real classname. serde's internally-tagged deserialization consumes the tag key, so a wrapped child's own required discriminator property would fail with "missing field": RustClientCodegen now marks mapped children's discriminator properties (the rust var context never set isDiscriminator) and the template defaults them, skipping them back out while empty so the tag stays the only occurrence on the wire. Optional discriminator properties already tolerate absence through Option and are untouched. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz --- .../codegen/languages/RustClientCodegen.java | 42 ++++++++ .../src/main/resources/rust/model.mustache | 26 +++-- .../codegen/rust/RustClientCodegenTest.java | 28 ++++++ .../3_0/rust/discriminated-union.yaml | 50 ++++++++++ .../others/rust/hyper/oneOf/src/models/bar.rs | 2 +- .../rust/hyper/oneOf/src/models/bar_create.rs | 2 +- .../rust/hyper/oneOf/src/models/bar_ref.rs | 2 +- .../rust/hyper/oneOf/src/models/entity.rs | 97 ++----------------- .../rust/hyper/oneOf/src/models/entity_ref.rs | 51 +--------- .../others/rust/hyper/oneOf/src/models/foo.rs | 2 +- .../rust/hyper/oneOf/src/models/foo_ref.rs | 2 +- .../rust/hyper/oneOf/src/models/pasta.rs | 2 +- .../rust/hyper/oneOf/src/models/pizza.rs | 2 +- .../hyper/oneOf/src/models/pizza_speziale.rs | 2 +- .../rust/reqwest/oneOf/src/models/bar.rs | 2 +- .../reqwest/oneOf/src/models/bar_create.rs | 2 +- .../rust/reqwest/oneOf/src/models/bar_ref.rs | 2 +- .../rust/reqwest/oneOf/src/models/entity.rs | 97 ++----------------- .../reqwest/oneOf/src/models/entity_ref.rs | 51 +--------- .../rust/reqwest/oneOf/src/models/foo.rs | 2 +- .../rust/reqwest/oneOf/src/models/foo_ref.rs | 2 +- .../rust/reqwest/oneOf/src/models/pasta.rs | 2 +- .../rust/reqwest/oneOf/src/models/pizza.rs | 2 +- .../oneOf/src/models/pizza_speziale.rs | 2 +- ...inator_duplicate_enums_get_200_response.rs | 33 +------ ...inator_duplicate_enums_get_200_response.rs | 33 +------ 26 files changed, 175 insertions(+), 365 deletions(-) create mode 100644 modules/openapi-generator/src/test/resources/3_0/rust/discriminated-union.yaml diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index 3c70fb2b73b2..10ab8a315bd7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -331,6 +331,48 @@ public CodegenModel fromModel(String name, Schema model) { return mdl; } + @Override + public Map postProcessAllModels(Map objs) { + objs = super.postProcessAllModels(objs); + + // The discriminator enum is internally tagged, and serde's tag consumes the + // discriminator key before the wrapped child model deserializes - so the child's own + // (typically required) discriminator property would fail with "missing field". Mark it, + // so the template can default it and skip serializing it while empty: the variant name + // carries the type information and the tag stays the only occurrence on the wire. + Map modelsByClassname = new HashMap<>(); + for (ModelsMap modelsMap : objs.values()) { + for (ModelMap modelMap : modelsMap.getModels()) { + modelsByClassname.put(modelMap.getModel().classname, modelMap.getModel()); + } + } + for (CodegenModel cm : modelsByClassname.values()) { + if (cm.discriminator == null || cm.discriminator.getMappedModels() == null) { + continue; + } + String propertyBaseName = cm.discriminator.getPropertyBaseName(); + for (CodegenDiscriminator.MappedModel mappedModel : cm.discriminator.getMappedModels()) { + // getModel() survives the duplicate-mapping rename above, which suffixes + // modelName for variant uniqueness while the model keeps its classname + CodegenModel child = mappedModel.getModel() != null + ? mappedModel.getModel() + : modelsByClassname.get(mappedModel.getModelName()); + if (child == null) { + continue; + } + for (List vars : List.of(child.vars, child.allVars, child.requiredVars, child.readWriteVars)) { + for (CodegenProperty var : vars) { + if (propertyBaseName.equals(var.baseName)) { + var.isDiscriminator = true; + } + } + } + } + } + + return objs; + } + @Override public ModelsMap postProcessModels(ModelsMap objs) { for (ModelMap model : objs.getModels()) { diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache index a2c60b117a45..420c4a2f1372 100644 --- a/modules/openapi-generator/src/main/resources/rust/model.mustache +++ b/modules/openapi-generator/src/main/resources/rust/model.mustache @@ -83,16 +83,12 @@ impl Default for {{{classname}}} { pub enum {{{classname}}} { {{^oneOf}} {{#mappedModels}} + {{!-- a newtype variant wrapping the mapped model, so the child's own fields survive: + an inline struct built from the parent's vars silently dropped every field the + child adds. The variant is named by modelName (made unique when several mapping + entries share one schema) while the wrapped type is the model's real classname --}} #[serde(rename="{{mappingName}}")] - {{{modelName}}} { - {{#vars}} - {{#description}} - /// {{{.}}} - {{/description}} - #[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})] - {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}}, - {{/vars}} - }, + {{{modelName}}}({{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}models::{{#model}}{{{classname}}}{{/model}}{{^model}}{{{modelName}}}{{/model}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}), {{/mappedModels}} {{/oneOf}} {{^oneOf.isEmpty}} @@ -110,11 +106,7 @@ pub enum {{{classname}}} { impl Default for {{classname}} { fn default() -> Self { - {{^oneOf}}{{#mappedModels}}{{#-first}}Self::{{modelName}} { - {{#vars}} - {{{name}}}: Default::default(), - {{/vars}} - }{{/-first}}{{/mappedModels}} + {{^oneOf}}{{#mappedModels}}{{#-first}}Self::{{modelName}}(Default::default()){{/-first}}{{/mappedModels}} {{/oneOf}}{{^oneOf.isEmpty}}{{#composedSchemas.oneOf}}{{#-first}}Self::{{{name}}}(Default::default()){{/-first}}{{/composedSchemas.oneOf}}{{/oneOf.isEmpty}} } } @@ -133,7 +125,11 @@ pub struct {{{classname}}} { {{#isByteArray}} {{#vendorExtensions.isMandatory}}#[serde_as(as = "serde_with::base64::Base64")]{{/vendorExtensions.isMandatory}}{{^vendorExtensions.isMandatory}}#[serde_as(as = "{{^serdeAsDoubleOption}}Option{{/serdeAsDoubleOption}}{{#serdeAsDoubleOption}}super::DoubleOption{{/serdeAsDoubleOption}}")]{{/vendorExtensions.isMandatory}} {{/isByteArray}} - #[serde(rename = "{{{baseName}}}"{{^required}}{{#isNullable}}, default{{^isByteArray}}, with = "::serde_with::rust::double_option"{{/isByteArray}}{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})] + {{!-- a required discriminator property doubles as the union's serde tag, which consumes + the key before this struct sees it - default it, and skip it back out while empty + so the tag stays the only occurrence on the wire (an optional one already + tolerates absence through Option) --}} + #[serde(rename = "{{{baseName}}}"{{#isDiscriminator}}{{#required}}, default, skip_serializing_if = "String::is_empty"{{/required}}{{/isDiscriminator}}{{^required}}{{#isNullable}}, default{{^isByteArray}}, with = "::serde_with::rust::double_option"{{/isByteArray}}{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})] pub {{{name}}}: {{! ### Option Start }}{{#isNullable}}Option<{{/isNullable}}{{^required}}Option<{{/required}}{{! diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java index d4bc7c1845ec..e63ab58a5550 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java @@ -293,6 +293,34 @@ public void testIntegerPropertyEnum() throws IOException { TestUtils.assertFileNotContains(outputPath, linearize("#[serde(rename = \"0\")]")); } + @Test + public void testDiscriminatedUnionKeepsChildFields() throws IOException { + Path target = Files.createTempDirectory("test"); + target.toFile().deleteOnExit(); + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("rust") + .setInputSpec("src/test/resources/3_0/rust/discriminated-union.yaml") + .setSkipOverwrite(false) + .setOutputDir(target.toAbsolutePath().toString().replace("\\", "/")); + new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); + + // the variants wrap the mapped models, so the child's own fields survive - an inline + // struct built from the parent's vars silently dropped every field the child adds + Path unionPath = Path.of(target.toString(), "/src/models/api_error.rs"); + TestUtils.assertFileContains(unionPath, "ObjectExists(Box),"); + TestUtils.assertFileContains(unionPath, "ValidationError(Box),"); + TestUtils.assertFileContains(unionPath, "Self::ObjectExists(Default::default())"); + TestUtils.assertFileNotContains(unionPath, "ObjectExists {"); + + // serde's internally-tagged deserialization consumes the tag key, so the wrapped + // child's own discriminator property defaults instead of failing "missing field", + // and skips back out while empty so the tag stays the only occurrence on the wire + Path childPath = Path.of(target.toString(), "/src/models/object_exists.rs"); + TestUtils.assertFileContains(childPath, + "#[serde(rename = \"type\", default, skip_serializing_if = \"String::is_empty\")]"); + TestUtils.assertFileContains(childPath, "pub identifier: String,"); + } + @Test public void testArrayWithObjectEnumValues() throws IOException { Path target = Files.createTempDirectory("test"); diff --git a/modules/openapi-generator/src/test/resources/3_0/rust/discriminated-union.yaml b/modules/openapi-generator/src/test/resources/3_0/rust/discriminated-union.yaml new file mode 100644 index 000000000000..af7687897c80 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/rust/discriminated-union.yaml @@ -0,0 +1,50 @@ +openapi: 3.0.3 +info: + title: discriminated union + version: 1.0.0 +paths: + /errors: + get: + operationId: getError + responses: + '200': + description: ok + content: + application/json: + schema: + $ref: '#/components/schemas/ApiError' +components: + schemas: + ApiError: + type: object + required: + - type + - message + properties: + type: + type: string + message: + type: string + discriminator: + propertyName: type + mapping: + ObjectExists: '#/components/schemas/ObjectExists' + ValidationError: '#/components/schemas/ValidationError' + ObjectExists: + allOf: + - $ref: '#/components/schemas/ApiError' + - type: object + required: + - identifier + properties: + identifier: + type: string + objectType: + type: string + ValidationError: + allOf: + - $ref: '#/components/schemas/ApiError' + - type: object + properties: + field: + type: string diff --git a/samples/client/others/rust/hyper/oneOf/src/models/bar.rs b/samples/client/others/rust/hyper/oneOf/src/models/bar.rs index ed85518807f2..0e5acbf27e4d 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/bar.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/bar.rs @@ -25,7 +25,7 @@ pub struct Bar { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs b/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs index 98481c64e2f9..3a0da7cd7500 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs @@ -26,7 +26,7 @@ pub struct BarCreate { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs b/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs index ce4ee09caf9d..07ca991d8627 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs @@ -26,7 +26,7 @@ pub struct BarRef { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/others/rust/hyper/oneOf/src/models/entity.rs b/samples/client/others/rust/hyper/oneOf/src/models/entity.rs index bfb1aac3382c..6f6c47efe667 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/entity.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/entity.rs @@ -15,105 +15,22 @@ use serde::{Deserialize, Serialize}; #[serde(tag = "@type")] pub enum Entity { #[serde(rename="Bar")] - Bar { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + Bar(Box), #[serde(rename="Bar_Create")] - BarCreate { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + BarCreate(Box), #[serde(rename="Foo")] - Foo { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + Foo(Box), #[serde(rename="Pasta")] - Pasta { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + Pasta(Box), #[serde(rename="Pizza")] - Pizza { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + Pizza(Box), #[serde(rename="PizzaSpeziale")] - PizzaSpeziale { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + PizzaSpeziale(Box), } impl Default for Entity { fn default() -> Self { - Self::Bar { - href: Default::default(), - id: Default::default(), - at_schema_location: Default::default(), - at_base_type: Default::default(), - } + Self::Bar(Default::default()) } } diff --git a/samples/client/others/rust/hyper/oneOf/src/models/entity_ref.rs b/samples/client/others/rust/hyper/oneOf/src/models/entity_ref.rs index d1a9853dc89b..ea762128d931 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/entity_ref.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/entity_ref.rs @@ -15,59 +15,14 @@ use serde::{Deserialize, Serialize}; #[serde(tag = "@type")] pub enum EntityRef { #[serde(rename="BarRef")] - BarRef { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - /// Name of the related entity. - #[serde(rename = "name", skip_serializing_if = "Option::is_none")] - name: Option, - /// The actual type of the target instance when needed for disambiguation. - #[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")] - at_referred_type: Option, - }, + BarRef(Box), #[serde(rename="FooRef")] - FooRef { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - /// Name of the related entity. - #[serde(rename = "name", skip_serializing_if = "Option::is_none")] - name: Option, - /// The actual type of the target instance when needed for disambiguation. - #[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")] - at_referred_type: Option, - }, + FooRef(Box), } impl Default for EntityRef { fn default() -> Self { - Self::BarRef { - href: Default::default(), - id: Default::default(), - at_schema_location: Default::default(), - at_base_type: Default::default(), - name: Default::default(), - at_referred_type: Default::default(), - } + Self::BarRef(Default::default()) } } diff --git a/samples/client/others/rust/hyper/oneOf/src/models/foo.rs b/samples/client/others/rust/hyper/oneOf/src/models/foo.rs index becc6957dd5d..6365749a7432 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/foo.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/foo.rs @@ -26,7 +26,7 @@ pub struct Foo { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "fooPropA", skip_serializing_if = "Option::is_none")] pub foo_prop_a: Option, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs b/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs index f4b3a2837fb7..09d760d3bae1 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs @@ -26,7 +26,7 @@ pub struct FooRef { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs b/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs index 5352c0da9d41..a6dec55be07b 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs @@ -26,7 +26,7 @@ pub struct Pasta { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "vendor", skip_serializing_if = "Option::is_none")] pub vendor: Option, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs b/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs index b99e41a1a354..a0c7390b126f 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs @@ -26,7 +26,7 @@ pub struct Pizza { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs b/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs index f3cfea721eff..40133bbf0304 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs @@ -26,7 +26,7 @@ pub struct PizzaSpeziale { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs b/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs index ed85518807f2..0e5acbf27e4d 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs @@ -25,7 +25,7 @@ pub struct Bar { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs b/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs index 98481c64e2f9..3a0da7cd7500 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs @@ -26,7 +26,7 @@ pub struct BarCreate { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs b/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs index ce4ee09caf9d..07ca991d8627 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs @@ -26,7 +26,7 @@ pub struct BarRef { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/entity.rs b/samples/client/others/rust/reqwest/oneOf/src/models/entity.rs index bfb1aac3382c..6f6c47efe667 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/entity.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/entity.rs @@ -15,105 +15,22 @@ use serde::{Deserialize, Serialize}; #[serde(tag = "@type")] pub enum Entity { #[serde(rename="Bar")] - Bar { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + Bar(Box), #[serde(rename="Bar_Create")] - BarCreate { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + BarCreate(Box), #[serde(rename="Foo")] - Foo { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + Foo(Box), #[serde(rename="Pasta")] - Pasta { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + Pasta(Box), #[serde(rename="Pizza")] - Pizza { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + Pizza(Box), #[serde(rename="PizzaSpeziale")] - PizzaSpeziale { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - }, + PizzaSpeziale(Box), } impl Default for Entity { fn default() -> Self { - Self::Bar { - href: Default::default(), - id: Default::default(), - at_schema_location: Default::default(), - at_base_type: Default::default(), - } + Self::Bar(Default::default()) } } diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/entity_ref.rs b/samples/client/others/rust/reqwest/oneOf/src/models/entity_ref.rs index d1a9853dc89b..ea762128d931 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/entity_ref.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/entity_ref.rs @@ -15,59 +15,14 @@ use serde::{Deserialize, Serialize}; #[serde(tag = "@type")] pub enum EntityRef { #[serde(rename="BarRef")] - BarRef { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - /// Name of the related entity. - #[serde(rename = "name", skip_serializing_if = "Option::is_none")] - name: Option, - /// The actual type of the target instance when needed for disambiguation. - #[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")] - at_referred_type: Option, - }, + BarRef(Box), #[serde(rename="FooRef")] - FooRef { - /// Hyperlink reference - #[serde(rename = "href", skip_serializing_if = "Option::is_none")] - href: Option, - /// unique identifier - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - id: Option, - /// A URI to a JSON-Schema file that defines additional attributes and relationships - #[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")] - at_schema_location: Option, - /// When sub-classing, this defines the super-class - #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] - at_base_type: Option, - /// Name of the related entity. - #[serde(rename = "name", skip_serializing_if = "Option::is_none")] - name: Option, - /// The actual type of the target instance when needed for disambiguation. - #[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")] - at_referred_type: Option, - }, + FooRef(Box), } impl Default for EntityRef { fn default() -> Self { - Self::BarRef { - href: Default::default(), - id: Default::default(), - at_schema_location: Default::default(), - at_base_type: Default::default(), - name: Default::default(), - at_referred_type: Default::default(), - } + Self::BarRef(Default::default()) } } diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs b/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs index becc6957dd5d..6365749a7432 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs @@ -26,7 +26,7 @@ pub struct Foo { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "fooPropA", skip_serializing_if = "Option::is_none")] pub foo_prop_a: Option, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs b/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs index f4b3a2837fb7..09d760d3bae1 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs @@ -26,7 +26,7 @@ pub struct FooRef { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs b/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs index 5352c0da9d41..a6dec55be07b 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs @@ -26,7 +26,7 @@ pub struct Pasta { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "vendor", skip_serializing_if = "Option::is_none")] pub vendor: Option, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs b/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs index b99e41a1a354..a0c7390b126f 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs @@ -26,7 +26,7 @@ pub struct Pizza { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs b/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs index f3cfea721eff..40133bbf0304 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs @@ -26,7 +26,7 @@ pub struct PizzaSpeziale { #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type")] + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, diff --git a/samples/client/petstore/rust/hyper/test-duplicates/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/hyper/test-duplicates/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs index 91ae6492101b..a7886f3c293f 100644 --- a/samples/client/petstore/rust/hyper/test-duplicates/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs +++ b/samples/client/petstore/rust/hyper/test-duplicates/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -15,41 +15,16 @@ use serde::{Deserialize, Serialize}; #[serde(tag = "objectType")] pub enum TestsDiscriminatorDuplicateEnumsGet200Response { #[serde(rename="car")] - Vehicle { - #[serde(rename = "type")] - r#type: String, - #[serde(rename = "name")] - name: String, - #[serde(rename = "speed")] - speed: f64, - }, + Vehicle(Box), #[serde(rename="student")] - PersonStudent { - #[serde(rename = "type")] - r#type: String, - #[serde(rename = "name")] - name: String, - #[serde(rename = "speed")] - speed: f64, - }, + PersonStudent(Box), #[serde(rename="teacher")] - PersonTeacher { - #[serde(rename = "type")] - r#type: String, - #[serde(rename = "name")] - name: String, - #[serde(rename = "speed")] - speed: f64, - }, + PersonTeacher(Box), } impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { fn default() -> Self { - Self::Vehicle { - r#type: Default::default(), - name: Default::default(), - speed: Default::default(), - } + Self::Vehicle(Default::default()) } } diff --git a/samples/client/petstore/rust/reqwest/test-duplicates/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/reqwest/test-duplicates/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs index 91ae6492101b..a7886f3c293f 100644 --- a/samples/client/petstore/rust/reqwest/test-duplicates/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs +++ b/samples/client/petstore/rust/reqwest/test-duplicates/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -15,41 +15,16 @@ use serde::{Deserialize, Serialize}; #[serde(tag = "objectType")] pub enum TestsDiscriminatorDuplicateEnumsGet200Response { #[serde(rename="car")] - Vehicle { - #[serde(rename = "type")] - r#type: String, - #[serde(rename = "name")] - name: String, - #[serde(rename = "speed")] - speed: f64, - }, + Vehicle(Box), #[serde(rename="student")] - PersonStudent { - #[serde(rename = "type")] - r#type: String, - #[serde(rename = "name")] - name: String, - #[serde(rename = "speed")] - speed: f64, - }, + PersonStudent(Box), #[serde(rename="teacher")] - PersonTeacher { - #[serde(rename = "type")] - r#type: String, - #[serde(rename = "name")] - name: String, - #[serde(rename = "speed")] - speed: f64, - }, + PersonTeacher(Box), } impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { fn default() -> Self { - Self::Vehicle { - r#type: Default::default(), - name: Default::default(), - speed: Default::default(), - } + Self::Vehicle(Default::default()) } } From 9939a944d72fe5bcc7b956369d973bee1d8310bd Mon Sep 17 00:00:00 2001 From: Wiebren Braakman Date: Tue, 8 Sep 2026 11:36:10 +0200 Subject: [PATCH 2/3] [rust] rework: remove the discriminator property from mapped children Review found the serde-attribute approach broke on a required nullable discriminator (String::is_empty on an Option does not compile) and could duplicate the tag when a caller populated the child's field. Remove the property from mapped children instead, exactly as postProcessModels already removes it from the discriminating parent: the variant name carries the type information, deserialization never misses a consumed tag key, and the tag is structurally the only occurrence on the wire. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz --- .../codegen/languages/RustClientCodegen.java | 16 +++++++--------- .../src/main/resources/rust/model.mustache | 6 +----- .../codegen/rust/RustClientCodegenTest.java | 10 ++++++---- .../rust/hyper/composed-oneof/docs/ObjA.md | 1 - .../rust/hyper/composed-oneof/docs/ObjB.md | 1 - .../rust/hyper/composed-oneof/docs/ObjC.md | 1 - .../rust/hyper/composed-oneof/docs/ObjD.md | 1 - .../hyper/composed-oneof/src/models/obj_a.rs | 3 --- .../hyper/composed-oneof/src/models/obj_b.rs | 3 --- .../hyper/composed-oneof/src/models/obj_c.rs | 3 --- .../hyper/composed-oneof/src/models/obj_d.rs | 3 --- .../client/others/rust/hyper/oneOf/docs/Bar.md | 1 - .../others/rust/hyper/oneOf/docs/BarCreate.md | 1 - .../others/rust/hyper/oneOf/docs/BarRef.md | 1 - .../client/others/rust/hyper/oneOf/docs/Foo.md | 1 - .../others/rust/hyper/oneOf/docs/FooRef.md | 1 - .../client/others/rust/hyper/oneOf/docs/Pasta.md | 1 - .../client/others/rust/hyper/oneOf/docs/Pizza.md | 1 - .../rust/hyper/oneOf/docs/PizzaSpeziale.md | 1 - .../others/rust/hyper/oneOf/src/models/bar.rs | 6 +----- .../rust/hyper/oneOf/src/models/bar_create.rs | 6 +----- .../rust/hyper/oneOf/src/models/bar_ref.rs | 6 +----- .../others/rust/hyper/oneOf/src/models/foo.rs | 6 +----- .../rust/hyper/oneOf/src/models/foo_ref.rs | 6 +----- .../others/rust/hyper/oneOf/src/models/pasta.rs | 6 +----- .../others/rust/hyper/oneOf/src/models/pizza.rs | 6 +----- .../hyper/oneOf/src/models/pizza_speziale.rs | 6 +----- .../rust/reqwest/composed-oneof/docs/ObjA.md | 1 - .../rust/reqwest/composed-oneof/docs/ObjB.md | 1 - .../rust/reqwest/composed-oneof/docs/ObjC.md | 1 - .../rust/reqwest/composed-oneof/docs/ObjD.md | 1 - .../reqwest/composed-oneof/src/models/obj_a.rs | 3 --- .../reqwest/composed-oneof/src/models/obj_b.rs | 3 --- .../reqwest/composed-oneof/src/models/obj_c.rs | 3 --- .../reqwest/composed-oneof/src/models/obj_d.rs | 3 --- .../client/others/rust/reqwest/oneOf/docs/Bar.md | 1 - .../others/rust/reqwest/oneOf/docs/BarCreate.md | 1 - .../others/rust/reqwest/oneOf/docs/BarRef.md | 1 - .../client/others/rust/reqwest/oneOf/docs/Foo.md | 1 - .../others/rust/reqwest/oneOf/docs/FooRef.md | 1 - .../others/rust/reqwest/oneOf/docs/Pasta.md | 1 - .../others/rust/reqwest/oneOf/docs/Pizza.md | 1 - .../rust/reqwest/oneOf/docs/PizzaSpeziale.md | 1 - .../others/rust/reqwest/oneOf/src/models/bar.rs | 6 +----- .../rust/reqwest/oneOf/src/models/bar_create.rs | 6 +----- .../rust/reqwest/oneOf/src/models/bar_ref.rs | 6 +----- .../others/rust/reqwest/oneOf/src/models/foo.rs | 6 +----- .../rust/reqwest/oneOf/src/models/foo_ref.rs | 6 +----- .../rust/reqwest/oneOf/src/models/pasta.rs | 6 +----- .../rust/reqwest/oneOf/src/models/pizza.rs | 6 +----- .../reqwest/oneOf/src/models/pizza_speziale.rs | 6 +----- 51 files changed, 30 insertions(+), 146 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index 10ab8a315bd7..04bdd4dc2782 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -337,9 +337,10 @@ public Map postProcessAllModels(Map objs) // The discriminator enum is internally tagged, and serde's tag consumes the // discriminator key before the wrapped child model deserializes - so the child's own - // (typically required) discriminator property would fail with "missing field". Mark it, - // so the template can default it and skip serializing it while empty: the variant name - // carries the type information and the tag stays the only occurrence on the wire. + // (typically required) discriminator property would fail with "missing field", and + // serializing it back out would duplicate the tag. Remove the property from the mapped + // children, exactly as postProcessModels already removes it from the discriminating + // parent: the variant name carries the type information. Map modelsByClassname = new HashMap<>(); for (ModelsMap modelsMap : objs.values()) { for (ModelMap modelMap : modelsMap.getModels()) { @@ -360,13 +361,10 @@ public Map postProcessAllModels(Map objs) if (child == null) { continue; } - for (List vars : List.of(child.vars, child.allVars, child.requiredVars, child.readWriteVars)) { - for (CodegenProperty var : vars) { - if (propertyBaseName.equals(var.baseName)) { - var.isDiscriminator = true; - } - } + for (List vars : List.of(child.vars, child.allVars, child.requiredVars, child.readWriteVars, child.optionalVars)) { + vars.removeIf(var -> propertyBaseName.equals(var.baseName)); } + child.setHasRequired(!child.requiredVars.isEmpty()); } } diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache index 420c4a2f1372..e9ded84dd8f9 100644 --- a/modules/openapi-generator/src/main/resources/rust/model.mustache +++ b/modules/openapi-generator/src/main/resources/rust/model.mustache @@ -125,11 +125,7 @@ pub struct {{{classname}}} { {{#isByteArray}} {{#vendorExtensions.isMandatory}}#[serde_as(as = "serde_with::base64::Base64")]{{/vendorExtensions.isMandatory}}{{^vendorExtensions.isMandatory}}#[serde_as(as = "{{^serdeAsDoubleOption}}Option{{/serdeAsDoubleOption}}{{#serdeAsDoubleOption}}super::DoubleOption{{/serdeAsDoubleOption}}")]{{/vendorExtensions.isMandatory}} {{/isByteArray}} - {{!-- a required discriminator property doubles as the union's serde tag, which consumes - the key before this struct sees it - default it, and skip it back out while empty - so the tag stays the only occurrence on the wire (an optional one already - tolerates absence through Option) --}} - #[serde(rename = "{{{baseName}}}"{{#isDiscriminator}}{{#required}}, default, skip_serializing_if = "String::is_empty"{{/required}}{{/isDiscriminator}}{{^required}}{{#isNullable}}, default{{^isByteArray}}, with = "::serde_with::rust::double_option"{{/isByteArray}}{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})] + #[serde(rename = "{{{baseName}}}"{{^required}}{{#isNullable}}, default{{^isByteArray}}, with = "::serde_with::rust::double_option"{{/isByteArray}}{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})] pub {{{name}}}: {{! ### Option Start }}{{#isNullable}}Option<{{/isNullable}}{{^required}}Option<{{/required}}{{! diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java index e63ab58a5550..bb38883934c7 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java @@ -313,12 +313,14 @@ public void testDiscriminatedUnionKeepsChildFields() throws IOException { TestUtils.assertFileNotContains(unionPath, "ObjectExists {"); // serde's internally-tagged deserialization consumes the tag key, so the wrapped - // child's own discriminator property defaults instead of failing "missing field", - // and skips back out while empty so the tag stays the only occurrence on the wire + // child cannot require it - the property is removed from mapped children the same + // way it is removed from the discriminating parent, and the variant name carries + // the type information (also keeping the tag the only occurrence on serialization) Path childPath = Path.of(target.toString(), "/src/models/object_exists.rs"); - TestUtils.assertFileContains(childPath, - "#[serde(rename = \"type\", default, skip_serializing_if = \"String::is_empty\")]"); + TestUtils.assertFileNotContains(childPath, "pub r#type"); + TestUtils.assertFileNotContains(childPath, "r#type: String"); TestUtils.assertFileContains(childPath, "pub identifier: String,"); + TestUtils.assertFileContains(childPath, "pub fn new(message: String, identifier: String) -> ObjectExists {"); } @Test diff --git a/samples/client/others/rust/hyper/composed-oneof/docs/ObjA.md b/samples/client/others/rust/hyper/composed-oneof/docs/ObjA.md index 40f6d31a64c9..fbfb0ed545dd 100644 --- a/samples/client/others/rust/hyper/composed-oneof/docs/ObjA.md +++ b/samples/client/others/rust/hyper/composed-oneof/docs/ObjA.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**realtype** | Option<**String**> | | [optional] **message** | Option<**String**> | | [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/composed-oneof/docs/ObjB.md b/samples/client/others/rust/hyper/composed-oneof/docs/ObjB.md index e232623e9eca..1fc17ed4aceb 100644 --- a/samples/client/others/rust/hyper/composed-oneof/docs/ObjB.md +++ b/samples/client/others/rust/hyper/composed-oneof/docs/ObjB.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**realtype** | Option<**String**> | | [optional] **description** | Option<**String**> | | [optional] **code** | Option<**i32**> | | [optional] diff --git a/samples/client/others/rust/hyper/composed-oneof/docs/ObjC.md b/samples/client/others/rust/hyper/composed-oneof/docs/ObjC.md index 52a0bf9f1be0..175b5b06528b 100644 --- a/samples/client/others/rust/hyper/composed-oneof/docs/ObjC.md +++ b/samples/client/others/rust/hyper/composed-oneof/docs/ObjC.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**realtype** | Option<**String**> | | [optional] **state** | Option<**String**> | | [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/composed-oneof/docs/ObjD.md b/samples/client/others/rust/hyper/composed-oneof/docs/ObjD.md index 91d67f513118..9038ee5d29f1 100644 --- a/samples/client/others/rust/hyper/composed-oneof/docs/ObjD.md +++ b/samples/client/others/rust/hyper/composed-oneof/docs/ObjD.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**realtype** | Option<**String**> | | [optional] **color** | Option<**String**> | | [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/composed-oneof/src/models/obj_a.rs b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_a.rs index 0d581be15d95..50d41b9ce857 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_a.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_a.rs @@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjA { - #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] - pub realtype: Option, #[serde(rename = "message", skip_serializing_if = "Option::is_none")] pub message: Option, } @@ -22,7 +20,6 @@ pub struct ObjA { impl ObjA { pub fn new() -> ObjA { ObjA { - realtype: None, message: None, } } diff --git a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_b.rs b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_b.rs index d0c508338d86..f1c357809732 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_b.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_b.rs @@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjB { - #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] - pub realtype: Option, #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "code", skip_serializing_if = "Option::is_none")] @@ -24,7 +22,6 @@ pub struct ObjB { impl ObjB { pub fn new() -> ObjB { ObjB { - realtype: None, description: None, code: None, } diff --git a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_c.rs b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_c.rs index df21df238a32..c60c90f39a58 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_c.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_c.rs @@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjC { - #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] - pub realtype: Option, #[serde(rename = "state", skip_serializing_if = "Option::is_none")] pub state: Option, } @@ -22,7 +20,6 @@ pub struct ObjC { impl ObjC { pub fn new() -> ObjC { ObjC { - realtype: None, state: None, } } diff --git a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_d.rs b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_d.rs index 37640c7b418c..484937fd82fe 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_d.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_d.rs @@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjD { - #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] - pub realtype: Option, #[serde(rename = "color", skip_serializing_if = "Option::is_none")] pub color: Option, } @@ -22,7 +20,6 @@ pub struct ObjD { impl ObjD { pub fn new() -> ObjD { ObjD { - realtype: None, color: None, } } diff --git a/samples/client/others/rust/hyper/oneOf/docs/Bar.md b/samples/client/others/rust/hyper/oneOf/docs/Bar.md index 605fc68fce3e..bac3bc8970c1 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/Bar.md +++ b/samples/client/others/rust/hyper/oneOf/docs/Bar.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | **String** | | **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **bar_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] **foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/docs/BarCreate.md b/samples/client/others/rust/hyper/oneOf/docs/BarCreate.md index 4fb0d42c7cbd..2b084d948946 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/BarCreate.md +++ b/samples/client/others/rust/hyper/oneOf/docs/BarCreate.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **bar_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] **foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/docs/BarRef.md b/samples/client/others/rust/hyper/oneOf/docs/BarRef.md index a785dc57aacc..8fe6edda462f 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/BarRef.md +++ b/samples/client/others/rust/hyper/oneOf/docs/BarRef.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **name** | Option<**String**> | Name of the related entity. | [optional] **at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/docs/Foo.md b/samples/client/others/rust/hyper/oneOf/docs/Foo.md index 330abd09799b..96af7b441b10 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/Foo.md +++ b/samples/client/others/rust/hyper/oneOf/docs/Foo.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **foo_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/docs/FooRef.md b/samples/client/others/rust/hyper/oneOf/docs/FooRef.md index 27e20258e078..c5185528106f 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/FooRef.md +++ b/samples/client/others/rust/hyper/oneOf/docs/FooRef.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **name** | Option<**String**> | Name of the related entity. | [optional] **at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional] **fooref_prop_a** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/docs/Pasta.md b/samples/client/others/rust/hyper/oneOf/docs/Pasta.md index dc6afc170067..69ae4e9ff23b 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/Pasta.md +++ b/samples/client/others/rust/hyper/oneOf/docs/Pasta.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **vendor** | Option<**String**> | | [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/Pizza.md b/samples/client/others/rust/hyper/oneOf/docs/Pizza.md index dfba87813c1f..e4bb136a44a6 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/Pizza.md +++ b/samples/client/others/rust/hyper/oneOf/docs/Pizza.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **pizza_size** | Option<**f64**> | | [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/PizzaSpeziale.md b/samples/client/others/rust/hyper/oneOf/docs/PizzaSpeziale.md index 79d3aceedfb2..4125ff33c178 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/PizzaSpeziale.md +++ b/samples/client/others/rust/hyper/oneOf/docs/PizzaSpeziale.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **pizza_size** | Option<**f64**> | | [optional] **toppings** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/src/models/bar.rs b/samples/client/others/rust/hyper/oneOf/src/models/bar.rs index 0e5acbf27e4d..3697836f1f95 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/bar.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/bar.rs @@ -24,9 +24,6 @@ pub struct Bar { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -36,13 +33,12 @@ pub struct Bar { } impl Bar { - pub fn new(id: String, at_type: String) -> Bar { + pub fn new(id: String) -> Bar { Bar { href: None, id, at_schema_location: None, at_base_type: None, - at_type, bar_prop_a: None, foo_prop_b: None, foo: None, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs b/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs index 3a0da7cd7500..2cce454acbfc 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs @@ -25,9 +25,6 @@ pub struct BarCreate { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -37,13 +34,12 @@ pub struct BarCreate { } impl BarCreate { - pub fn new(at_type: String) -> BarCreate { + pub fn new() -> BarCreate { BarCreate { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, bar_prop_a: None, foo_prop_b: None, foo: None, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs b/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs index 07ca991d8627..9c3f1f3dd199 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs @@ -25,9 +25,6 @@ pub struct BarRef { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -37,13 +34,12 @@ pub struct BarRef { } impl BarRef { - pub fn new(at_type: String) -> BarRef { + pub fn new() -> BarRef { BarRef { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, name: None, at_referred_type: None, } diff --git a/samples/client/others/rust/hyper/oneOf/src/models/foo.rs b/samples/client/others/rust/hyper/oneOf/src/models/foo.rs index 6365749a7432..bd5167ecf0cd 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/foo.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/foo.rs @@ -25,9 +25,6 @@ pub struct Foo { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "fooPropA", skip_serializing_if = "Option::is_none")] pub foo_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -35,13 +32,12 @@ pub struct Foo { } impl Foo { - pub fn new(at_type: String) -> Foo { + pub fn new() -> Foo { Foo { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, foo_prop_a: None, foo_prop_b: None, } diff --git a/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs b/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs index 09d760d3bae1..1a1705d0de02 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs @@ -25,9 +25,6 @@ pub struct FooRef { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -39,13 +36,12 @@ pub struct FooRef { } impl FooRef { - pub fn new(at_type: String) -> FooRef { + pub fn new() -> FooRef { FooRef { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, name: None, at_referred_type: None, fooref_prop_a: None, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs b/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs index a6dec55be07b..845e9ecc6a87 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs @@ -25,21 +25,17 @@ pub struct Pasta { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "vendor", skip_serializing_if = "Option::is_none")] pub vendor: Option, } impl Pasta { - pub fn new(at_type: String) -> Pasta { + pub fn new() -> Pasta { Pasta { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, vendor: None, } } diff --git a/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs b/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs index a0c7390b126f..5780a2a59121 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs @@ -25,21 +25,17 @@ pub struct Pizza { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, } impl Pizza { - pub fn new(at_type: String) -> Pizza { + pub fn new() -> Pizza { Pizza { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, pizza_size: None, } } diff --git a/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs b/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs index 40133bbf0304..70c6144b4d7b 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs @@ -25,9 +25,6 @@ pub struct PizzaSpeziale { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, #[serde(rename = "toppings", skip_serializing_if = "Option::is_none")] @@ -35,13 +32,12 @@ pub struct PizzaSpeziale { } impl PizzaSpeziale { - pub fn new(at_type: String) -> PizzaSpeziale { + pub fn new() -> PizzaSpeziale { PizzaSpeziale { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, pizza_size: None, toppings: None, } diff --git a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjA.md b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjA.md index 40f6d31a64c9..fbfb0ed545dd 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjA.md +++ b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjA.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**realtype** | Option<**String**> | | [optional] **message** | Option<**String**> | | [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/composed-oneof/docs/ObjB.md b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjB.md index e232623e9eca..1fc17ed4aceb 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjB.md +++ b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjB.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**realtype** | Option<**String**> | | [optional] **description** | Option<**String**> | | [optional] **code** | Option<**i32**> | | [optional] diff --git a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjC.md b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjC.md index 52a0bf9f1be0..175b5b06528b 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjC.md +++ b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjC.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**realtype** | Option<**String**> | | [optional] **state** | Option<**String**> | | [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/composed-oneof/docs/ObjD.md b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjD.md index 91d67f513118..9038ee5d29f1 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjD.md +++ b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjD.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**realtype** | Option<**String**> | | [optional] **color** | Option<**String**> | | [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/composed-oneof/src/models/obj_a.rs b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_a.rs index 0d581be15d95..50d41b9ce857 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_a.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_a.rs @@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjA { - #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] - pub realtype: Option, #[serde(rename = "message", skip_serializing_if = "Option::is_none")] pub message: Option, } @@ -22,7 +20,6 @@ pub struct ObjA { impl ObjA { pub fn new() -> ObjA { ObjA { - realtype: None, message: None, } } diff --git a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_b.rs b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_b.rs index d0c508338d86..f1c357809732 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_b.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_b.rs @@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjB { - #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] - pub realtype: Option, #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "code", skip_serializing_if = "Option::is_none")] @@ -24,7 +22,6 @@ pub struct ObjB { impl ObjB { pub fn new() -> ObjB { ObjB { - realtype: None, description: None, code: None, } diff --git a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_c.rs b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_c.rs index df21df238a32..c60c90f39a58 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_c.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_c.rs @@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjC { - #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] - pub realtype: Option, #[serde(rename = "state", skip_serializing_if = "Option::is_none")] pub state: Option, } @@ -22,7 +20,6 @@ pub struct ObjC { impl ObjC { pub fn new() -> ObjC { ObjC { - realtype: None, state: None, } } diff --git a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_d.rs b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_d.rs index 37640c7b418c..484937fd82fe 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_d.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_d.rs @@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjD { - #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] - pub realtype: Option, #[serde(rename = "color", skip_serializing_if = "Option::is_none")] pub color: Option, } @@ -22,7 +20,6 @@ pub struct ObjD { impl ObjD { pub fn new() -> ObjD { ObjD { - realtype: None, color: None, } } diff --git a/samples/client/others/rust/reqwest/oneOf/docs/Bar.md b/samples/client/others/rust/reqwest/oneOf/docs/Bar.md index 605fc68fce3e..bac3bc8970c1 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/Bar.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/Bar.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | **String** | | **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **bar_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] **foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/docs/BarCreate.md b/samples/client/others/rust/reqwest/oneOf/docs/BarCreate.md index 4fb0d42c7cbd..2b084d948946 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/BarCreate.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/BarCreate.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **bar_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] **foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/docs/BarRef.md b/samples/client/others/rust/reqwest/oneOf/docs/BarRef.md index a785dc57aacc..8fe6edda462f 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/BarRef.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/BarRef.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **name** | Option<**String**> | Name of the related entity. | [optional] **at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/docs/Foo.md b/samples/client/others/rust/reqwest/oneOf/docs/Foo.md index 330abd09799b..96af7b441b10 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/Foo.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/Foo.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **foo_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/docs/FooRef.md b/samples/client/others/rust/reqwest/oneOf/docs/FooRef.md index 27e20258e078..c5185528106f 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/FooRef.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/FooRef.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **name** | Option<**String**> | Name of the related entity. | [optional] **at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional] **fooref_prop_a** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/docs/Pasta.md b/samples/client/others/rust/reqwest/oneOf/docs/Pasta.md index dc6afc170067..69ae4e9ff23b 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/Pasta.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/Pasta.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **vendor** | Option<**String**> | | [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/Pizza.md b/samples/client/others/rust/reqwest/oneOf/docs/Pizza.md index dfba87813c1f..e4bb136a44a6 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/Pizza.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/Pizza.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **pizza_size** | Option<**f64**> | | [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/PizzaSpeziale.md b/samples/client/others/rust/reqwest/oneOf/docs/PizzaSpeziale.md index 79d3aceedfb2..4125ff33c178 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/PizzaSpeziale.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/PizzaSpeziale.md @@ -8,7 +8,6 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] -**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **pizza_size** | Option<**f64**> | | [optional] **toppings** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs b/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs index 0e5acbf27e4d..3697836f1f95 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs @@ -24,9 +24,6 @@ pub struct Bar { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -36,13 +33,12 @@ pub struct Bar { } impl Bar { - pub fn new(id: String, at_type: String) -> Bar { + pub fn new(id: String) -> Bar { Bar { href: None, id, at_schema_location: None, at_base_type: None, - at_type, bar_prop_a: None, foo_prop_b: None, foo: None, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs b/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs index 3a0da7cd7500..2cce454acbfc 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs @@ -25,9 +25,6 @@ pub struct BarCreate { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -37,13 +34,12 @@ pub struct BarCreate { } impl BarCreate { - pub fn new(at_type: String) -> BarCreate { + pub fn new() -> BarCreate { BarCreate { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, bar_prop_a: None, foo_prop_b: None, foo: None, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs b/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs index 07ca991d8627..9c3f1f3dd199 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs @@ -25,9 +25,6 @@ pub struct BarRef { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -37,13 +34,12 @@ pub struct BarRef { } impl BarRef { - pub fn new(at_type: String) -> BarRef { + pub fn new() -> BarRef { BarRef { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, name: None, at_referred_type: None, } diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs b/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs index 6365749a7432..bd5167ecf0cd 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs @@ -25,9 +25,6 @@ pub struct Foo { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "fooPropA", skip_serializing_if = "Option::is_none")] pub foo_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -35,13 +32,12 @@ pub struct Foo { } impl Foo { - pub fn new(at_type: String) -> Foo { + pub fn new() -> Foo { Foo { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, foo_prop_a: None, foo_prop_b: None, } diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs b/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs index 09d760d3bae1..1a1705d0de02 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs @@ -25,9 +25,6 @@ pub struct FooRef { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -39,13 +36,12 @@ pub struct FooRef { } impl FooRef { - pub fn new(at_type: String) -> FooRef { + pub fn new() -> FooRef { FooRef { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, name: None, at_referred_type: None, fooref_prop_a: None, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs b/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs index a6dec55be07b..845e9ecc6a87 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs @@ -25,21 +25,17 @@ pub struct Pasta { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "vendor", skip_serializing_if = "Option::is_none")] pub vendor: Option, } impl Pasta { - pub fn new(at_type: String) -> Pasta { + pub fn new() -> Pasta { Pasta { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, vendor: None, } } diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs b/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs index a0c7390b126f..5780a2a59121 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs @@ -25,21 +25,17 @@ pub struct Pizza { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, } impl Pizza { - pub fn new(at_type: String) -> Pizza { + pub fn new() -> Pizza { Pizza { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, pizza_size: None, } } diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs b/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs index 40133bbf0304..70c6144b4d7b 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs @@ -25,9 +25,6 @@ pub struct PizzaSpeziale { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, - /// When sub-classing, this defines the sub-class Extensible name - #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] - pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, #[serde(rename = "toppings", skip_serializing_if = "Option::is_none")] @@ -35,13 +32,12 @@ pub struct PizzaSpeziale { } impl PizzaSpeziale { - pub fn new(at_type: String) -> PizzaSpeziale { + pub fn new() -> PizzaSpeziale { PizzaSpeziale { href: None, id: None, at_schema_location: None, at_base_type: None, - at_type, pizza_size: None, toppings: None, } From a88754431d3140c0d622a8d0e8cc2a655c869d8d Mon Sep 17 00:00:00 2001 From: Wiebren Braakman Date: Wed, 9 Sep 2026 08:57:33 +0200 Subject: [PATCH 3/3] [rust] fix: keep the child's discriminator, tolerate the consumed serde tag Removing the property from mapped children went too far: getMappedModels() covers every allOf descendant, and those models are also returned and accepted standalone (create_bar returns Bar, create_foo takes Foo), so they lost a required field and their new() signature changed. Keep the property declared and mark it instead, so the template defaults it - the internally-tagged union consumes the key before the child deserializes - and skips it back out while unset, keeping the tag the only occurrence on the wire. The skip predicate follows the type: Option::is_none for a nullable discriminator, String::is_empty for a non-nullable string, which is what the first attempt got wrong. Standalone use is unchanged: the caller sets and reads the discriminator as before. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz --- .../codegen/languages/RustClientCodegen.java | 16 +++++++++----- .../src/main/resources/rust/model.mustache | 7 +++++- .../codegen/rust/RustClientCodegenTest.java | 22 +++++++++++++------ .../3_0/rust/discriminated-union.yaml | 22 +++++++++++++++++++ .../rust/hyper/composed-oneof/docs/ObjA.md | 1 + .../rust/hyper/composed-oneof/docs/ObjB.md | 1 + .../rust/hyper/composed-oneof/docs/ObjC.md | 1 + .../rust/hyper/composed-oneof/docs/ObjD.md | 1 + .../hyper/composed-oneof/src/models/obj_a.rs | 3 +++ .../hyper/composed-oneof/src/models/obj_b.rs | 3 +++ .../hyper/composed-oneof/src/models/obj_c.rs | 3 +++ .../hyper/composed-oneof/src/models/obj_d.rs | 3 +++ .../others/rust/hyper/oneOf/docs/Bar.md | 1 + .../others/rust/hyper/oneOf/docs/BarCreate.md | 1 + .../others/rust/hyper/oneOf/docs/BarRef.md | 1 + .../others/rust/hyper/oneOf/docs/Foo.md | 1 + .../others/rust/hyper/oneOf/docs/FooRef.md | 1 + .../others/rust/hyper/oneOf/docs/Pasta.md | 1 + .../others/rust/hyper/oneOf/docs/Pizza.md | 1 + .../rust/hyper/oneOf/docs/PizzaSpeziale.md | 1 + .../others/rust/hyper/oneOf/src/models/bar.rs | 6 ++++- .../rust/hyper/oneOf/src/models/bar_create.rs | 6 ++++- .../rust/hyper/oneOf/src/models/bar_ref.rs | 6 ++++- .../others/rust/hyper/oneOf/src/models/foo.rs | 6 ++++- .../rust/hyper/oneOf/src/models/foo_ref.rs | 6 ++++- .../rust/hyper/oneOf/src/models/pasta.rs | 6 ++++- .../rust/hyper/oneOf/src/models/pizza.rs | 6 ++++- .../hyper/oneOf/src/models/pizza_speziale.rs | 6 ++++- .../rust/reqwest/composed-oneof/docs/ObjA.md | 1 + .../rust/reqwest/composed-oneof/docs/ObjB.md | 1 + .../rust/reqwest/composed-oneof/docs/ObjC.md | 1 + .../rust/reqwest/composed-oneof/docs/ObjD.md | 1 + .../composed-oneof/src/models/obj_a.rs | 3 +++ .../composed-oneof/src/models/obj_b.rs | 3 +++ .../composed-oneof/src/models/obj_c.rs | 3 +++ .../composed-oneof/src/models/obj_d.rs | 3 +++ .../others/rust/reqwest/oneOf/docs/Bar.md | 1 + .../rust/reqwest/oneOf/docs/BarCreate.md | 1 + .../others/rust/reqwest/oneOf/docs/BarRef.md | 1 + .../others/rust/reqwest/oneOf/docs/Foo.md | 1 + .../others/rust/reqwest/oneOf/docs/FooRef.md | 1 + .../others/rust/reqwest/oneOf/docs/Pasta.md | 1 + .../others/rust/reqwest/oneOf/docs/Pizza.md | 1 + .../rust/reqwest/oneOf/docs/PizzaSpeziale.md | 1 + .../rust/reqwest/oneOf/src/models/bar.rs | 6 ++++- .../reqwest/oneOf/src/models/bar_create.rs | 6 ++++- .../rust/reqwest/oneOf/src/models/bar_ref.rs | 6 ++++- .../rust/reqwest/oneOf/src/models/foo.rs | 6 ++++- .../rust/reqwest/oneOf/src/models/foo_ref.rs | 6 ++++- .../rust/reqwest/oneOf/src/models/pasta.rs | 6 ++++- .../rust/reqwest/oneOf/src/models/pizza.rs | 6 ++++- .../oneOf/src/models/pizza_speziale.rs | 6 ++++- 52 files changed, 181 insertions(+), 30 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index 04bdd4dc2782..1d4801778a44 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -338,9 +338,10 @@ public Map postProcessAllModels(Map objs) // The discriminator enum is internally tagged, and serde's tag consumes the // discriminator key before the wrapped child model deserializes - so the child's own // (typically required) discriminator property would fail with "missing field", and - // serializing it back out would duplicate the tag. Remove the property from the mapped - // children, exactly as postProcessModels already removes it from the discriminating - // parent: the variant name carries the type information. + // serializing it back out would duplicate the tag. Mark it, so the template can default + // it and skip serializing it while unset. The property stays declared: getMappedModels() + // covers every allOf descendant, and those models are also returned and accepted + // standalone, where the caller sets and reads the discriminator normally. Map modelsByClassname = new HashMap<>(); for (ModelsMap modelsMap : objs.values()) { for (ModelMap modelMap : modelsMap.getModels()) { @@ -361,10 +362,13 @@ public Map postProcessAllModels(Map objs) if (child == null) { continue; } - for (List vars : List.of(child.vars, child.allVars, child.requiredVars, child.readWriteVars, child.optionalVars)) { - vars.removeIf(var -> propertyBaseName.equals(var.baseName)); + for (List vars : List.of(child.vars, child.allVars, child.requiredVars, child.readWriteVars)) { + for (CodegenProperty var : vars) { + if (propertyBaseName.equals(var.baseName)) { + var.isDiscriminator = true; + } + } } - child.setHasRequired(!child.requiredVars.isEmpty()); } } diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache index e9ded84dd8f9..ed77a681fe05 100644 --- a/modules/openapi-generator/src/main/resources/rust/model.mustache +++ b/modules/openapi-generator/src/main/resources/rust/model.mustache @@ -125,7 +125,12 @@ pub struct {{{classname}}} { {{#isByteArray}} {{#vendorExtensions.isMandatory}}#[serde_as(as = "serde_with::base64::Base64")]{{/vendorExtensions.isMandatory}}{{^vendorExtensions.isMandatory}}#[serde_as(as = "{{^serdeAsDoubleOption}}Option{{/serdeAsDoubleOption}}{{#serdeAsDoubleOption}}super::DoubleOption{{/serdeAsDoubleOption}}")]{{/vendorExtensions.isMandatory}} {{/isByteArray}} - #[serde(rename = "{{{baseName}}}"{{^required}}{{#isNullable}}, default{{^isByteArray}}, with = "::serde_with::rust::double_option"{{/isByteArray}}{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})] + {{!-- a mapped child's discriminator property doubles as the union's serde tag, which is + consumed before this struct deserializes: default it so the missing key is not an + error, and skip it back out while unset so the tag stays the only occurrence. The + property itself stays declared - these models are also used standalone, where the + caller sets and reads it normally. --}} + #[serde(rename = "{{{baseName}}}"{{#isDiscriminator}}{{#required}}, default{{#isNullable}}, skip_serializing_if = "Option::is_none"{{/isNullable}}{{^isNullable}}{{#isString}}, skip_serializing_if = "String::is_empty"{{/isString}}{{/isNullable}}{{/required}}{{/isDiscriminator}}{{^required}}{{#isNullable}}, default{{^isByteArray}}, with = "::serde_with::rust::double_option"{{/isByteArray}}{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}{{^isDiscriminator}}, deserialize_with = "Option::deserialize"{{/isDiscriminator}}{{/isNullable}}{{/required}})] pub {{{name}}}: {{! ### Option Start }}{{#isNullable}}Option<{{/isNullable}}{{^required}}Option<{{/required}}{{! diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java index bb38883934c7..7de2717034fd 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java @@ -312,15 +312,23 @@ public void testDiscriminatedUnionKeepsChildFields() throws IOException { TestUtils.assertFileContains(unionPath, "Self::ObjectExists(Default::default())"); TestUtils.assertFileNotContains(unionPath, "ObjectExists {"); - // serde's internally-tagged deserialization consumes the tag key, so the wrapped - // child cannot require it - the property is removed from mapped children the same - // way it is removed from the discriminating parent, and the variant name carries - // the type information (also keeping the tag the only occurrence on serialization) + // serde's internally-tagged deserialization consumes the tag key, so the wrapped child + // defaults it instead of failing "missing field" and skips it back out while unset, so + // the tag stays the only occurrence on the wire. The property itself stays declared: + // these models are also returned and accepted standalone. Path childPath = Path.of(target.toString(), "/src/models/object_exists.rs"); - TestUtils.assertFileNotContains(childPath, "pub r#type"); - TestUtils.assertFileNotContains(childPath, "r#type: String"); + TestUtils.assertFileContains(childPath, + "#[serde(rename = \"type\", default, skip_serializing_if = \"String::is_empty\")]"); TestUtils.assertFileContains(childPath, "pub identifier: String,"); - TestUtils.assertFileContains(childPath, "pub fn new(message: String, identifier: String) -> ObjectExists {"); + TestUtils.assertFileContains(childPath, + "pub fn new(r#type: String, message: String, identifier: String) -> ObjectExists {"); + + // a nullable discriminator is an Option, so the predicate must be + // Option::is_none - String::is_empty would not compile against it + Path nullableChildPath = Path.of(target.toString(), "/src/models/alpha.rs"); + TestUtils.assertFileContains(nullableChildPath, + "#[serde(rename = \"kind\", default, skip_serializing_if = \"Option::is_none\")]"); + TestUtils.assertFileNotContains(nullableChildPath, "String::is_empty"); } @Test diff --git a/modules/openapi-generator/src/test/resources/3_0/rust/discriminated-union.yaml b/modules/openapi-generator/src/test/resources/3_0/rust/discriminated-union.yaml index af7687897c80..dbc7e79fb518 100644 --- a/modules/openapi-generator/src/test/resources/3_0/rust/discriminated-union.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/rust/discriminated-union.yaml @@ -48,3 +48,25 @@ components: properties: field: type: string + # a nullable discriminator: the skip predicate must be Option::is_none, not String::is_empty + NullableTagged: + type: object + required: + - kind + properties: + kind: + type: string + nullable: true + label: + type: string + discriminator: + propertyName: kind + mapping: + Alpha: '#/components/schemas/Alpha' + Alpha: + allOf: + - $ref: '#/components/schemas/NullableTagged' + - type: object + properties: + alphaOnly: + type: string diff --git a/samples/client/others/rust/hyper/composed-oneof/docs/ObjA.md b/samples/client/others/rust/hyper/composed-oneof/docs/ObjA.md index fbfb0ed545dd..40f6d31a64c9 100644 --- a/samples/client/others/rust/hyper/composed-oneof/docs/ObjA.md +++ b/samples/client/others/rust/hyper/composed-oneof/docs/ObjA.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**realtype** | Option<**String**> | | [optional] **message** | Option<**String**> | | [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/composed-oneof/docs/ObjB.md b/samples/client/others/rust/hyper/composed-oneof/docs/ObjB.md index 1fc17ed4aceb..e232623e9eca 100644 --- a/samples/client/others/rust/hyper/composed-oneof/docs/ObjB.md +++ b/samples/client/others/rust/hyper/composed-oneof/docs/ObjB.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**realtype** | Option<**String**> | | [optional] **description** | Option<**String**> | | [optional] **code** | Option<**i32**> | | [optional] diff --git a/samples/client/others/rust/hyper/composed-oneof/docs/ObjC.md b/samples/client/others/rust/hyper/composed-oneof/docs/ObjC.md index 175b5b06528b..52a0bf9f1be0 100644 --- a/samples/client/others/rust/hyper/composed-oneof/docs/ObjC.md +++ b/samples/client/others/rust/hyper/composed-oneof/docs/ObjC.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**realtype** | Option<**String**> | | [optional] **state** | Option<**String**> | | [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/composed-oneof/docs/ObjD.md b/samples/client/others/rust/hyper/composed-oneof/docs/ObjD.md index 9038ee5d29f1..91d67f513118 100644 --- a/samples/client/others/rust/hyper/composed-oneof/docs/ObjD.md +++ b/samples/client/others/rust/hyper/composed-oneof/docs/ObjD.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**realtype** | Option<**String**> | | [optional] **color** | Option<**String**> | | [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/composed-oneof/src/models/obj_a.rs b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_a.rs index 50d41b9ce857..0d581be15d95 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_a.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_a.rs @@ -13,6 +13,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjA { + #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] + pub realtype: Option, #[serde(rename = "message", skip_serializing_if = "Option::is_none")] pub message: Option, } @@ -20,6 +22,7 @@ pub struct ObjA { impl ObjA { pub fn new() -> ObjA { ObjA { + realtype: None, message: None, } } diff --git a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_b.rs b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_b.rs index f1c357809732..d0c508338d86 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_b.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_b.rs @@ -13,6 +13,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjB { + #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] + pub realtype: Option, #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "code", skip_serializing_if = "Option::is_none")] @@ -22,6 +24,7 @@ pub struct ObjB { impl ObjB { pub fn new() -> ObjB { ObjB { + realtype: None, description: None, code: None, } diff --git a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_c.rs b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_c.rs index c60c90f39a58..df21df238a32 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_c.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_c.rs @@ -13,6 +13,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjC { + #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] + pub realtype: Option, #[serde(rename = "state", skip_serializing_if = "Option::is_none")] pub state: Option, } @@ -20,6 +22,7 @@ pub struct ObjC { impl ObjC { pub fn new() -> ObjC { ObjC { + realtype: None, state: None, } } diff --git a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_d.rs b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_d.rs index 484937fd82fe..37640c7b418c 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/models/obj_d.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/models/obj_d.rs @@ -13,6 +13,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjD { + #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] + pub realtype: Option, #[serde(rename = "color", skip_serializing_if = "Option::is_none")] pub color: Option, } @@ -20,6 +22,7 @@ pub struct ObjD { impl ObjD { pub fn new() -> ObjD { ObjD { + realtype: None, color: None, } } diff --git a/samples/client/others/rust/hyper/oneOf/docs/Bar.md b/samples/client/others/rust/hyper/oneOf/docs/Bar.md index bac3bc8970c1..605fc68fce3e 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/Bar.md +++ b/samples/client/others/rust/hyper/oneOf/docs/Bar.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | **String** | | **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **bar_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] **foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/docs/BarCreate.md b/samples/client/others/rust/hyper/oneOf/docs/BarCreate.md index 2b084d948946..4fb0d42c7cbd 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/BarCreate.md +++ b/samples/client/others/rust/hyper/oneOf/docs/BarCreate.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **bar_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] **foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/docs/BarRef.md b/samples/client/others/rust/hyper/oneOf/docs/BarRef.md index 8fe6edda462f..a785dc57aacc 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/BarRef.md +++ b/samples/client/others/rust/hyper/oneOf/docs/BarRef.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **name** | Option<**String**> | Name of the related entity. | [optional] **at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/docs/Foo.md b/samples/client/others/rust/hyper/oneOf/docs/Foo.md index 96af7b441b10..330abd09799b 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/Foo.md +++ b/samples/client/others/rust/hyper/oneOf/docs/Foo.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **foo_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/docs/FooRef.md b/samples/client/others/rust/hyper/oneOf/docs/FooRef.md index c5185528106f..27e20258e078 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/FooRef.md +++ b/samples/client/others/rust/hyper/oneOf/docs/FooRef.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **name** | Option<**String**> | Name of the related entity. | [optional] **at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional] **fooref_prop_a** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/docs/Pasta.md b/samples/client/others/rust/hyper/oneOf/docs/Pasta.md index 69ae4e9ff23b..dc6afc170067 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/Pasta.md +++ b/samples/client/others/rust/hyper/oneOf/docs/Pasta.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **vendor** | Option<**String**> | | [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/Pizza.md b/samples/client/others/rust/hyper/oneOf/docs/Pizza.md index e4bb136a44a6..dfba87813c1f 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/Pizza.md +++ b/samples/client/others/rust/hyper/oneOf/docs/Pizza.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **pizza_size** | Option<**f64**> | | [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/PizzaSpeziale.md b/samples/client/others/rust/hyper/oneOf/docs/PizzaSpeziale.md index 4125ff33c178..79d3aceedfb2 100644 --- a/samples/client/others/rust/hyper/oneOf/docs/PizzaSpeziale.md +++ b/samples/client/others/rust/hyper/oneOf/docs/PizzaSpeziale.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **pizza_size** | Option<**f64**> | | [optional] **toppings** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/hyper/oneOf/src/models/bar.rs b/samples/client/others/rust/hyper/oneOf/src/models/bar.rs index 3697836f1f95..0e5acbf27e4d 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/bar.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/bar.rs @@ -24,6 +24,9 @@ pub struct Bar { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -33,12 +36,13 @@ pub struct Bar { } impl Bar { - pub fn new(id: String) -> Bar { + pub fn new(id: String, at_type: String) -> Bar { Bar { href: None, id, at_schema_location: None, at_base_type: None, + at_type, bar_prop_a: None, foo_prop_b: None, foo: None, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs b/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs index 2cce454acbfc..3a0da7cd7500 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs @@ -25,6 +25,9 @@ pub struct BarCreate { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -34,12 +37,13 @@ pub struct BarCreate { } impl BarCreate { - pub fn new() -> BarCreate { + pub fn new(at_type: String) -> BarCreate { BarCreate { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, bar_prop_a: None, foo_prop_b: None, foo: None, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs b/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs index 9c3f1f3dd199..07ca991d8627 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs @@ -25,6 +25,9 @@ pub struct BarRef { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -34,12 +37,13 @@ pub struct BarRef { } impl BarRef { - pub fn new() -> BarRef { + pub fn new(at_type: String) -> BarRef { BarRef { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, name: None, at_referred_type: None, } diff --git a/samples/client/others/rust/hyper/oneOf/src/models/foo.rs b/samples/client/others/rust/hyper/oneOf/src/models/foo.rs index bd5167ecf0cd..6365749a7432 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/foo.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/foo.rs @@ -25,6 +25,9 @@ pub struct Foo { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "fooPropA", skip_serializing_if = "Option::is_none")] pub foo_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -32,12 +35,13 @@ pub struct Foo { } impl Foo { - pub fn new() -> Foo { + pub fn new(at_type: String) -> Foo { Foo { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, foo_prop_a: None, foo_prop_b: None, } diff --git a/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs b/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs index 1a1705d0de02..09d760d3bae1 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs @@ -25,6 +25,9 @@ pub struct FooRef { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -36,12 +39,13 @@ pub struct FooRef { } impl FooRef { - pub fn new() -> FooRef { + pub fn new(at_type: String) -> FooRef { FooRef { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, name: None, at_referred_type: None, fooref_prop_a: None, diff --git a/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs b/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs index 845e9ecc6a87..a6dec55be07b 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/pasta.rs @@ -25,17 +25,21 @@ pub struct Pasta { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "vendor", skip_serializing_if = "Option::is_none")] pub vendor: Option, } impl Pasta { - pub fn new() -> Pasta { + pub fn new(at_type: String) -> Pasta { Pasta { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, vendor: None, } } diff --git a/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs b/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs index 5780a2a59121..a0c7390b126f 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/pizza.rs @@ -25,17 +25,21 @@ pub struct Pizza { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, } impl Pizza { - pub fn new() -> Pizza { + pub fn new(at_type: String) -> Pizza { Pizza { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, pizza_size: None, } } diff --git a/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs b/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs index 70c6144b4d7b..40133bbf0304 100644 --- a/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs +++ b/samples/client/others/rust/hyper/oneOf/src/models/pizza_speziale.rs @@ -25,6 +25,9 @@ pub struct PizzaSpeziale { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, #[serde(rename = "toppings", skip_serializing_if = "Option::is_none")] @@ -32,12 +35,13 @@ pub struct PizzaSpeziale { } impl PizzaSpeziale { - pub fn new() -> PizzaSpeziale { + pub fn new(at_type: String) -> PizzaSpeziale { PizzaSpeziale { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, pizza_size: None, toppings: None, } diff --git a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjA.md b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjA.md index fbfb0ed545dd..40f6d31a64c9 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjA.md +++ b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjA.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**realtype** | Option<**String**> | | [optional] **message** | Option<**String**> | | [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/composed-oneof/docs/ObjB.md b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjB.md index 1fc17ed4aceb..e232623e9eca 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjB.md +++ b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjB.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**realtype** | Option<**String**> | | [optional] **description** | Option<**String**> | | [optional] **code** | Option<**i32**> | | [optional] diff --git a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjC.md b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjC.md index 175b5b06528b..52a0bf9f1be0 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjC.md +++ b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjC.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**realtype** | Option<**String**> | | [optional] **state** | Option<**String**> | | [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/composed-oneof/docs/ObjD.md b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjD.md index 9038ee5d29f1..91d67f513118 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/docs/ObjD.md +++ b/samples/client/others/rust/reqwest/composed-oneof/docs/ObjD.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**realtype** | Option<**String**> | | [optional] **color** | Option<**String**> | | [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/composed-oneof/src/models/obj_a.rs b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_a.rs index 50d41b9ce857..0d581be15d95 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_a.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_a.rs @@ -13,6 +13,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjA { + #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] + pub realtype: Option, #[serde(rename = "message", skip_serializing_if = "Option::is_none")] pub message: Option, } @@ -20,6 +22,7 @@ pub struct ObjA { impl ObjA { pub fn new() -> ObjA { ObjA { + realtype: None, message: None, } } diff --git a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_b.rs b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_b.rs index f1c357809732..d0c508338d86 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_b.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_b.rs @@ -13,6 +13,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjB { + #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] + pub realtype: Option, #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "code", skip_serializing_if = "Option::is_none")] @@ -22,6 +24,7 @@ pub struct ObjB { impl ObjB { pub fn new() -> ObjB { ObjB { + realtype: None, description: None, code: None, } diff --git a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_c.rs b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_c.rs index c60c90f39a58..df21df238a32 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_c.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_c.rs @@ -13,6 +13,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjC { + #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] + pub realtype: Option, #[serde(rename = "state", skip_serializing_if = "Option::is_none")] pub state: Option, } @@ -20,6 +22,7 @@ pub struct ObjC { impl ObjC { pub fn new() -> ObjC { ObjC { + realtype: None, state: None, } } diff --git a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_d.rs b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_d.rs index 484937fd82fe..37640c7b418c 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_d.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/models/obj_d.rs @@ -13,6 +13,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ObjD { + #[serde(rename = "realtype", skip_serializing_if = "Option::is_none")] + pub realtype: Option, #[serde(rename = "color", skip_serializing_if = "Option::is_none")] pub color: Option, } @@ -20,6 +22,7 @@ pub struct ObjD { impl ObjD { pub fn new() -> ObjD { ObjD { + realtype: None, color: None, } } diff --git a/samples/client/others/rust/reqwest/oneOf/docs/Bar.md b/samples/client/others/rust/reqwest/oneOf/docs/Bar.md index bac3bc8970c1..605fc68fce3e 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/Bar.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/Bar.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | **String** | | **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **bar_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] **foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/docs/BarCreate.md b/samples/client/others/rust/reqwest/oneOf/docs/BarCreate.md index 2b084d948946..4fb0d42c7cbd 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/BarCreate.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/BarCreate.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **bar_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] **foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/docs/BarRef.md b/samples/client/others/rust/reqwest/oneOf/docs/BarRef.md index 8fe6edda462f..a785dc57aacc 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/BarRef.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/BarRef.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **name** | Option<**String**> | Name of the related entity. | [optional] **at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/docs/Foo.md b/samples/client/others/rust/reqwest/oneOf/docs/Foo.md index 96af7b441b10..330abd09799b 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/Foo.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/Foo.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **foo_prop_a** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/docs/FooRef.md b/samples/client/others/rust/reqwest/oneOf/docs/FooRef.md index c5185528106f..27e20258e078 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/FooRef.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/FooRef.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **name** | Option<**String**> | Name of the related entity. | [optional] **at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional] **fooref_prop_a** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/docs/Pasta.md b/samples/client/others/rust/reqwest/oneOf/docs/Pasta.md index 69ae4e9ff23b..dc6afc170067 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/Pasta.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/Pasta.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **vendor** | Option<**String**> | | [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/Pizza.md b/samples/client/others/rust/reqwest/oneOf/docs/Pizza.md index e4bb136a44a6..dfba87813c1f 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/Pizza.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/Pizza.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **pizza_size** | Option<**f64**> | | [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/PizzaSpeziale.md b/samples/client/others/rust/reqwest/oneOf/docs/PizzaSpeziale.md index 4125ff33c178..79d3aceedfb2 100644 --- a/samples/client/others/rust/reqwest/oneOf/docs/PizzaSpeziale.md +++ b/samples/client/others/rust/reqwest/oneOf/docs/PizzaSpeziale.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | Option<**String**> | unique identifier | [optional] **at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] **at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional] +**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name | **pizza_size** | Option<**f64**> | | [optional] **toppings** | Option<**String**> | | [optional] diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs b/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs index 3697836f1f95..0e5acbf27e4d 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/bar.rs @@ -24,6 +24,9 @@ pub struct Bar { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -33,12 +36,13 @@ pub struct Bar { } impl Bar { - pub fn new(id: String) -> Bar { + pub fn new(id: String, at_type: String) -> Bar { Bar { href: None, id, at_schema_location: None, at_base_type: None, + at_type, bar_prop_a: None, foo_prop_b: None, foo: None, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs b/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs index 2cce454acbfc..3a0da7cd7500 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/bar_create.rs @@ -25,6 +25,9 @@ pub struct BarCreate { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")] pub bar_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -34,12 +37,13 @@ pub struct BarCreate { } impl BarCreate { - pub fn new() -> BarCreate { + pub fn new(at_type: String) -> BarCreate { BarCreate { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, bar_prop_a: None, foo_prop_b: None, foo: None, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs b/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs index 9c3f1f3dd199..07ca991d8627 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/bar_ref.rs @@ -25,6 +25,9 @@ pub struct BarRef { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -34,12 +37,13 @@ pub struct BarRef { } impl BarRef { - pub fn new() -> BarRef { + pub fn new(at_type: String) -> BarRef { BarRef { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, name: None, at_referred_type: None, } diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs b/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs index bd5167ecf0cd..6365749a7432 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/foo.rs @@ -25,6 +25,9 @@ pub struct Foo { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "fooPropA", skip_serializing_if = "Option::is_none")] pub foo_prop_a: Option, #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] @@ -32,12 +35,13 @@ pub struct Foo { } impl Foo { - pub fn new() -> Foo { + pub fn new(at_type: String) -> Foo { Foo { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, foo_prop_a: None, foo_prop_b: None, } diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs b/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs index 1a1705d0de02..09d760d3bae1 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/foo_ref.rs @@ -25,6 +25,9 @@ pub struct FooRef { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, /// Name of the related entity. #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -36,12 +39,13 @@ pub struct FooRef { } impl FooRef { - pub fn new() -> FooRef { + pub fn new(at_type: String) -> FooRef { FooRef { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, name: None, at_referred_type: None, fooref_prop_a: None, diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs b/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs index 845e9ecc6a87..a6dec55be07b 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/pasta.rs @@ -25,17 +25,21 @@ pub struct Pasta { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "vendor", skip_serializing_if = "Option::is_none")] pub vendor: Option, } impl Pasta { - pub fn new() -> Pasta { + pub fn new(at_type: String) -> Pasta { Pasta { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, vendor: None, } } diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs b/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs index 5780a2a59121..a0c7390b126f 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/pizza.rs @@ -25,17 +25,21 @@ pub struct Pizza { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, } impl Pizza { - pub fn new() -> Pizza { + pub fn new(at_type: String) -> Pizza { Pizza { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, pizza_size: None, } } diff --git a/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs b/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs index 70c6144b4d7b..40133bbf0304 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/models/pizza_speziale.rs @@ -25,6 +25,9 @@ pub struct PizzaSpeziale { /// When sub-classing, this defines the super-class #[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")] pub at_base_type: Option, + /// When sub-classing, this defines the sub-class Extensible name + #[serde(rename = "@type", default, skip_serializing_if = "String::is_empty")] + pub at_type: String, #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] pub pizza_size: Option, #[serde(rename = "toppings", skip_serializing_if = "Option::is_none")] @@ -32,12 +35,13 @@ pub struct PizzaSpeziale { } impl PizzaSpeziale { - pub fn new() -> PizzaSpeziale { + pub fn new(at_type: String) -> PizzaSpeziale { PizzaSpeziale { href: None, id: None, at_schema_location: None, at_base_type: None, + at_type, pizza_size: None, toppings: None, }