diff --git a/bin/configs/dart-dio-oneof-polymorphism-and-inheritance.yaml b/bin/configs/dart-dio-oneof-polymorphism-and-inheritance.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..d3d5b622bc0f8bd4273a941df591a292a3114e04
--- /dev/null
+++ b/bin/configs/dart-dio-oneof-polymorphism-and-inheritance.yaml
@@ -0,0 +1,11 @@
+generatorName: dart-dio
+outputDir: samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance
+inputSpec: modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml
+templateDir: modules/openapi-generator/src/main/resources/dart/libraries/dio
+typeMappings:
+  Client: "ModelClient"
+  File: "ModelFile"
+  EnumClass: "ModelEnumClass"
+additionalProperties:
+  hideGenerationTimestamp: "true"
+  enumUnknownDefaultCase: "true"
diff --git a/bin/configs/dart-dio-oneof-primitive.yaml b/bin/configs/dart-dio-oneof-primitive.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..29130b5dc468caa90c6109da0937e89964f8b5cc
--- /dev/null
+++ b/bin/configs/dart-dio-oneof-primitive.yaml
@@ -0,0 +1,11 @@
+generatorName: dart-dio
+outputDir: samples/openapi3/client/petstore/dart-dio/oneof_primitive
+inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_primitive.yaml
+templateDir: modules/openapi-generator/src/main/resources/dart/libraries/dio
+typeMappings:
+  Client: "ModelClient"
+  File: "ModelFile"
+  EnumClass: "ModelEnumClass"
+additionalProperties:
+  hideGenerationTimestamp: "true"
+  enumUnknownDefaultCase: "true"
diff --git a/bin/configs/dart-dio-oneof.yaml b/bin/configs/dart-dio-oneof.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..865312cdd4934247d7215bf381e03fdf5f64eb73
--- /dev/null
+++ b/bin/configs/dart-dio-oneof.yaml
@@ -0,0 +1,11 @@
+generatorName: dart-dio
+outputDir: samples/openapi3/client/petstore/dart-dio/oneof
+inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf.yaml
+templateDir: modules/openapi-generator/src/main/resources/dart/libraries/dio
+typeMappings:
+  Client: "ModelClient"
+  File: "ModelFile"
+  EnumClass: "ModelEnumClass"
+additionalProperties:
+  hideGenerationTimestamp: "true"
+  enumUnknownDefaultCase: "true"
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java
index b8ec826fd9466aa1291d7c8864bb6cc4cd00dc86..711a111be6a82784f887fe36c6a4cf6c87201b4a 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java
@@ -20,6 +20,7 @@ import com.google.common.collect.Sets;
 import com.samskivert.mustache.Mustache;
 import com.samskivert.mustache.Template;
 import io.swagger.v3.oas.models.media.Schema;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.openapitools.codegen.*;
 import org.openapitools.codegen.api.TemplatePathLocator;
@@ -27,6 +28,7 @@ import org.openapitools.codegen.config.GlobalSettings;
 import org.openapitools.codegen.meta.GeneratorMetadata;
 import org.openapitools.codegen.meta.Stability;
 import org.openapitools.codegen.meta.features.ClientModificationFeature;
+import org.openapitools.codegen.meta.features.SchemaSupportFeature;
 import org.openapitools.codegen.model.ModelMap;
 import org.openapitools.codegen.model.ModelsMap;
 import org.openapitools.codegen.model.OperationMap;
@@ -43,6 +45,7 @@ import org.slf4j.LoggerFactory;
 import java.io.File;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import static org.openapitools.codegen.utils.StringUtils.underscore;
 
@@ -78,6 +81,13 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
                 .includeClientModificationFeatures(
                         ClientModificationFeature.Authorizations,
                         ClientModificationFeature.UserAgent
+                ).includeSchemaSupportFeatures(                    
+                    SchemaSupportFeature.Polymorphism,
+                    SchemaSupportFeature.Union,
+                    SchemaSupportFeature.Composite,
+                    SchemaSupportFeature.allOf,
+                    SchemaSupportFeature.oneOf,
+                    SchemaSupportFeature.anyOf
                 )
         );
         generatorMetadata = GeneratorMetadata.newBuilder()
@@ -150,6 +160,9 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
             LOGGER.debug("Serialization library not set, using default {}", SERIALIZATION_LIBRARY_DEFAULT);
         }
         setLibrary(additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY).toString());
+        if (SERIALIZATION_LIBRARY_BUILT_VALUE.equals(library)) {
+            this.setLegacyDiscriminatorBehavior(false);
+        }
 
         if (!additionalProperties.containsKey(DATE_LIBRARY)) {
             additionalProperties.put(DATE_LIBRARY, DATE_LIBRARY_DEFAULT);
@@ -331,6 +344,213 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
         return objs;
     }
 
+    /// Gets all ancestors of a given model, and puts it in accumulator
+    private void getAncestors(CodegenModel cm, Map<String, CodegenModel> allModels, Set<String> accumulator) {
+
+        // get direct parents
+        Set<String> directParentNames = cm.allOf;
+        if (directParentNames != null && !directParentNames.isEmpty()) {
+            for (String directParentName : directParentNames) {
+                if (accumulator.add(directParentName)) {
+                    CodegenModel parent = allModels.get(directParentName);
+                    getAncestors(parent, allModels, accumulator);
+                }
+            }
+        }
+    }
+
+    private void syncRootTypesWithInnerVars(Map<String, ModelsMap> objs) {
+        Map<String, CodegenModel> allModels = new HashMap<>();
+        for (ModelsMap modelsEntries : objs.values()) {
+            for (ModelMap modelsMap : modelsEntries.getModels()) {
+                CodegenModel model = modelsMap.getModel();
+                allModels.put(model.getClassname(), model);
+            }
+        }
+
+        for (CodegenModel model : allModels.values()) {            
+            syncRootTypesWithInnerVars(allModels, model);
+        }
+    }
+    private void syncRootTypesWithInnerVars(Map<String, CodegenModel> objs, CodegenModel model) {
+        List<CodegenProperty> allVars = new ArrayList<>();        
+        allVars.addAll(((Collection<CodegenProperty>) model.vendorExtensions.get(kSelfAndAncestorOnlyProps)));
+        allVars.addAll(((Collection<CodegenProperty>) model.vendorExtensions.get(kSelfOnlyProps)));
+        allVars.addAll(((Collection<CodegenProperty>) model.vendorExtensions.get(kAncestorOnlyProps)));
+
+        for (CodegenProperty prop : allVars) {
+            //check if type exists in parent map
+            String type = prop.openApiType;
+            if (objs.containsKey(type)) {
+                //get the type
+                CodegenModel relatedModel = objs.get(type);
+                //fill the property's VendorExtensions with the type's VendorExtensions
+                prop.getVendorExtensions().put(kIsParent, relatedModel.getVendorExtensions().get(kIsParent));
+                prop.isEnum = relatedModel.isEnum;
+                
+            }            
+        }
+    }
+    private final String kIsChild = "x-is-child";
+    private final String kIsParent = "x-is-parent";
+    private final String kIsPure = "x-is-pure";
+    private final String kSelfOnlyProps = "x-self-only-props";
+    private final String kHasSelfOnlyProps = "x-has-self-only-props";
+    private final String kAncestorOnlyProps = "x-ancestor-only-props";
+    private final String kHasAncestorOnlyProps = "x-has-ancestor-only-props";
+    private final String kSelfAndAncestorOnlyProps = "x-self-and-ancestor-only-props";
+    private final String kHasSelfAndAncestorOnlyProps = "x-has-self-and-ancestor-only-props";
+    
+    // adapts codegen models and property to dart rules of inheritance
+    private void adaptToDartInheritance(Map<String, ModelsMap> objs) {
+        // get all models
+        Map<String, CodegenModel> allModels = new HashMap<>();
+        for (ModelsMap modelsEntries : objs.values()) {
+            for (ModelMap modelsMap : modelsEntries.getModels()) {
+                CodegenModel model = modelsMap.getModel();
+                allModels.put(model.getClassname(), model);
+            }
+        }
+
+        // all ancestors
+        Set<String> allAncestorsForAllModelsFlat = new HashSet<>();
+        // maps a model to its ancestors
+        Map<String, Set<String>> allAncestorsForAllModels = new HashMap<>();
+        for (java.util.Map.Entry<String, CodegenModel> cm : allModels.entrySet()) {
+            Set<String> allAncestors = new HashSet<>();
+            // get all ancestors
+            // TODO: optimize this logic ?
+            getAncestors(cm.getValue(), allModels, allAncestors);
+            // just in case, a model can't be its own ancestor
+            allAncestors.remove(cm.getKey());
+
+            allAncestorsForAllModels.put(cm.getKey(), allAncestors);
+            allAncestorsForAllModelsFlat.addAll(allAncestors);
+        }
+
+        
+
+        Set<String> allPureClasses = new HashSet<>();
+        // set isChild,isParent,isPure
+        for (java.util.Map.Entry<String, CodegenModel> cmEntry : allModels.entrySet()) {
+            String key = cmEntry.getKey();
+            CodegenModel cm = cmEntry.getValue();
+            // get all ancestors
+            Set<String> allAncestors = allAncestorsForAllModels.get(key);
+
+            // a class is a parent when it's an ancestor to another class
+            boolean isParent = allAncestorsForAllModelsFlat.contains(key);
+            // a class is a child when it has any ancestor
+            boolean isChild = !allAncestors.isEmpty();
+            // a class is pure when it's not a child, and has no oneOf nor anyOf
+            boolean isPure = !isChild && (cm.oneOf == null || cm.oneOf.isEmpty())
+                    && (cm.anyOf == null || cm.anyOf.isEmpty());
+
+            cm.vendorExtensions.put(kIsChild, isChild);
+            cm.vendorExtensions.put(kIsParent, isParent);
+            cm.vendorExtensions.put(kIsPure, isPure);
+            // when pure:
+            // vars = allVars = selfOnlyProperties = kSelfAndAncestorOnlyProps
+            // ancestorOnlyProps = empty
+            if (isPure) {
+                cm.vendorExtensions.put(kSelfOnlyProps, new ArrayList<>(cm.getVars()));
+                cm.vendorExtensions.put(kHasSelfOnlyProps, !cm.getVars().isEmpty());
+                cm.vendorExtensions.put(kAncestorOnlyProps, new ArrayList<CodegenProperty>());
+                cm.vendorExtensions.put(kHasAncestorOnlyProps, false);
+                cm.vendorExtensions.put(kSelfAndAncestorOnlyProps, new ArrayList<>(cm.getVars()));
+                cm.vendorExtensions.put(kHasSelfAndAncestorOnlyProps, !cm.getVars().isEmpty());
+
+                allPureClasses.add(key);
+            }
+        }
+
+        // handle impure models
+        for (java.util.Map.Entry<String, CodegenModel> cmEntry : allModels.entrySet()) {
+            String key = cmEntry.getKey();
+            CodegenModel cm = cmEntry.getValue();
+            if (allPureClasses.contains(key)) {
+                continue;
+            }
+            // get all ancestors
+            Set<String> allAncestors = allAncestorsForAllModels.get(key);
+
+            // get direct parents
+            // Set<String> directParentNames = cm.allOf == null ? new HashSet<>() :
+            // cm.allOf;
+            Set<String> compositeProperties = new HashSet<>();
+
+            Set<String> compositeModelNames = new HashSet<String>();
+            compositeModelNames.addAll(ObjectUtils.firstNonNull(cm.oneOf, new HashSet<>()));
+            compositeModelNames.addAll(ObjectUtils.firstNonNull(cm.anyOf, new HashSet<>()));
+            compositeModelNames.addAll(allAncestors);
+
+            for (String compositeModelName : compositeModelNames) {
+                CodegenModel model = allModels.get(compositeModelName);
+                if (model == null)
+                    continue;
+                List<CodegenProperty> allVars = ObjectUtils.firstNonNull(model.getAllVars(), new ArrayList<>());
+                for (CodegenProperty prop : allVars) {
+                    compositeProperties.add(prop.getName());
+                }
+            }
+            // dart classes declare selfOnlyProperties as direct members (they exist in
+            // "vars")
+            // for pure models, this will equal vars
+            Map<String, CodegenProperty> selfOnlyProperties = new HashMap<>();
+
+            // ancestorOnlyProperties are properties defined by all ancestors
+            // NOTE: oneOf,anyOf are NOT considered ancestors
+            // since a child in dart must implment ALL OF the parent (using implements)
+            Map<String, CodegenProperty> ancestorOnlyProperties = new HashMap<>();
+
+            // combines both selfOnlyProperties and ancestorOnlyProperties
+            // this will be used by the custom serializer as "x-handled-vars" and
+            // "x-has-handled-vars"
+            Map<String, CodegenProperty> selfAndAncestorOnlyProperties = new HashMap<>();
+
+            // STEP 1: calculating selfOnlyProperties
+            // get all vars of all ancestors and add them to ancestorPropNames
+            // Set<String> _ancestorPropNames = new HashSet<>();
+            for (String ancestorKey : allAncestors) {
+                CodegenModel ancestorCM = allModels.get(ancestorKey);
+                for (CodegenProperty prop : ancestorCM.getVars()) {
+                    ancestorOnlyProperties.put(prop.getName(), prop);
+                }
+            }
+            for (CodegenProperty p : cm.getVars()) {
+                p.isInherited = ancestorOnlyProperties.containsKey(p.getName());
+                if (!p.isInherited && !compositeProperties.contains(p.getName())) {
+                    selfOnlyProperties.put(p.getName(), p);
+                }
+            }
+            selfAndAncestorOnlyProperties.putAll(selfOnlyProperties);
+            selfAndAncestorOnlyProperties.putAll(ancestorOnlyProperties);
+
+            cm.vendorExtensions.put(kSelfOnlyProps, new ArrayList<>(selfOnlyProperties.values()));
+            cm.vendorExtensions.put(kHasSelfOnlyProps, !selfOnlyProperties.isEmpty());
+            cm.vendorExtensions.put(kAncestorOnlyProps, new ArrayList<>(ancestorOnlyProperties.values()));
+            cm.vendorExtensions.put(kHasAncestorOnlyProps, !ancestorOnlyProperties.isEmpty());
+            cm.vendorExtensions.put(kSelfAndAncestorOnlyProps, new ArrayList<>(selfAndAncestorOnlyProperties.values()));
+            cm.vendorExtensions.put(kHasSelfAndAncestorOnlyProps, !selfAndAncestorOnlyProperties.isEmpty());
+            // fixes missing imports
+            Set<String> interfaceImports = new HashSet<String>();
+            interfaceImports.addAll(cm.allOf);
+            interfaceImports.addAll(cm.oneOf);
+            interfaceImports.addAll(cm.anyOf);
+            cm.imports.addAll(rewriteImports(interfaceImports, true));
+        }
+    }
+
+    @Override
+    public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
+        objs = super.postProcessAllModels(objs);
+        if (SERIALIZATION_LIBRARY_BUILT_VALUE.equals(library)) {
+            adaptToDartInheritance(objs);
+            syncRootTypesWithInnerVars(objs);
+        }
+        return objs;
+    }
+
     @Override
     public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
         super.postProcessModelProperty(model, property);
@@ -361,7 +581,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
     public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
         super.postProcessOperationsWithModels(objs, allModels);
         OperationMap operations = objs.getOperations();
-        List<CodegenOperation> operationList =  operations.getOperation();
+        List<CodegenOperation> operationList = operations.getOperation();
 
         Set<String> resultImports = new HashSet<>();
 
@@ -403,7 +623,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
                 for (CodegenParameter param : op.allParams) {
                     // Generate serializer factories for all container type parameters.
                     // But skip binary and file parameters, JSON serializers don't make sense there.
-                    if (param.isContainer && !(param.isBinary || param.isFile )) {
+                    if (param.isContainer && !(param.isBinary || param.isFile)) {
                         addBuiltValueSerializer(new BuiltValueSerializer(
                                 param.isArray,
                                 param.uniqueItems,
@@ -459,6 +679,14 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
     private Set<String> rewriteImports(Set<String> originalImports, boolean isModel) {
         Set<String> resultImports = Sets.newHashSet();
         for (String modelImport : originalImports) {
+            if (modelImport.startsWith("BuiltList", 0)) {
+                modelImport = "BuiltList";
+            } else if (modelImport.startsWith("BuiltSet", 0)) {
+                modelImport = "BuiltSet";
+            } else if (modelImport.startsWith("BuiltMap", 0)) {
+                modelImport = "BuiltMap";
+            }
+
             if (imports.containsKey(modelImport)) {
                 String i = imports.get(modelImport);
                 if (Objects.equals(i, DIO_IMPORT) && !isModel) {
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/model.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/model.mustache
index 5fdbb1b77c8c195b4873745eee273bc695e77db0..1917decaf6c6c48d6119249087f88cc7cc0e56c9 100644
--- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/model.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/model.mustache
@@ -1,4 +1,5 @@
 {{>header}}
+// ignore_for_file: unused_element
 {{#models}}
     {{#model}}
         {{#imports}}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache
index 4a919c21c04ff74af483f57ee6c6ab2973458972..4faed4e3dc45b4376f2be79bd6108a681c5b86cb 100644
--- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache
@@ -14,8 +14,10 @@ environment:
 dependencies:
   dio: '>=4.0.1 <5.0.0'
 {{#useBuiltValue}}
-  built_value: '>=8.1.0 <9.0.0'
-  built_collection: '>=5.1.0 <6.0.0'
+  one_of: '>=1.5.0 <2.0.0'
+  one_of_serializer: '>=1.5.0 <2.0.0'
+  built_value: '>=8.4.0 <9.0.0'
+  built_collection: '>=5.1.1 <6.0.0'
 {{/useBuiltValue}}
 {{#useJsonSerializable}}
   json_annotation: '^4.4.0'
@@ -26,7 +28,7 @@ dependencies:
 
 dev_dependencies:
 {{#useBuiltValue}}
-  built_value_generator: '>=8.1.0 <9.0.0'
+  built_value_generator: '>=8.4.0 <9.0.0'
   build_runner: any
 {{/useBuiltValue}}
 {{#useJsonSerializable}}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class.mustache
index 66fe59788b0f04271d2fdac010df02077e98f2e6..a8a1339c630006dafcffe2704c531f3c65877686 100644
--- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class.mustache
@@ -1,154 +1,17 @@
 import 'package:built_value/built_value.dart';
-import 'package:built_value/serializer.dart';
+import 'package:built_value/serializer.dart';{{#oneOf}}{{#-first}}
+import 'package:one_of/one_of.dart';{{/-first}}{{/oneOf}}{{#anyOf}}{{#-first}}
+import 'package:one_of/any_of.dart';{{/-first}}{{/anyOf}}
 
+{{#imports}}
+{{/imports}}
 part '{{classFilename}}.g.dart';
 
-{{!
-    Classes with polymorphism or composition may generate unused imports,
-    these need to be ignored for said classes so that there are no lint errors.
-}}
-{{#parentModel}}
-// ignore_for_file: unused_import
-
-{{/parentModel}}
-/// {{{description}}}{{^description}}{{classname}}{{/description}}
-{{#hasVars}}
-///
-/// Properties:
-{{#allVars}}
-/// * [{{{name}}}] {{#description}}- {{{.}}}{{/description}}
-{{/allVars}}
-{{/hasVars}}
-abstract class {{classname}} implements Built<{{classname}}, {{classname}}Builder> {
-{{#vars}}
-    {{#description}}
-    /// {{{.}}}
-    {{/description}}
-    @BuiltValueField(wireName: r'{{baseName}}')
-    {{>serialization/built_value/variable_type}}{{^isNullable}}{{^required}}?{{/required}}{{/isNullable}} get {{name}};
-    {{#allowableValues}}
-    // {{#min}}range from {{{min}}} to {{{max}}}{{/min}}{{^min}}enum {{name}}Enum { {{#values}} {{{.}}}, {{/values}} };{{/min}}
-    {{/allowableValues}}
-
-{{/vars}}
-    {{classname}}._();
-
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults({{{classname}}}Builder b) => b{{#vars}}{{#defaultValue}}
-        ..{{{name}}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{defaultValue}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}}{{/vars}};
-
-    factory {{classname}}([void updates({{classname}}Builder b)]) = _${{classname}};
-
-    @BuiltValueSerializer(custom: true)
-    static Serializer<{{classname}}> get serializer => _${{classname}}Serializer();
-}
-
-{{!
-    Generate a custom serializer in order to support combinations of required and nullable.
-    By default built_value does not serialize null fields.
-}}
-class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
-    @override
-    final Iterable<Type> types = const [{{classname}}, _${{classname}}];
-
-    @override
-    final String wireName = r'{{classname}}';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, {{{classname}}} object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        {{#vars}}
-        {{#required}}
-        {{!
-            A required property need to always be part of the serialized output.
-            When it is nullable, null is serialized, otherwise it is an error if it is null.
-        }}
-        result
-            ..add(r'{{baseName}}')
-            ..add({{#isNullable}}object.{{{name}}} == null ? null : {{/isNullable}}serializers.serialize(object.{{{name}}},
-                specifiedType: const {{>serialization/built_value/variable_serializer_type}}));
-        {{/required}}
-        {{^required}}
-        if (object.{{{name}}} != null) {
-            {{! Non-required properties are only serialized if not null. }}
-            result
-                ..add(r'{{baseName}}')
-                ..add(serializers.serialize(object.{{{name}}},
-                    specifiedType: const {{>serialization/built_value/variable_serializer_type}}));
-        }
-        {{/required}}
-        {{/vars}}
-        return result;
-    }
-
-    @override
-    {{classname}} deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = {{classname}}Builder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                {{#vars}}
-                case r'{{baseName}}':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const {{>serialization/built_value/variable_serializer_type}}) as {{>serialization/built_value/variable_type}};
-                    {{#isNullable}}
-                    if (valueDes == null) continue;
-                    {{/isNullable}}
-                    {{#isContainer}}
-                    result.{{{name}}}.replace(valueDes);
-                    {{/isContainer}}
-                    {{^isContainer}}
-                    {{#isEnum}}
-                    result.{{{name}}} = valueDes;
-                    {{/isEnum}}
-                    {{^isEnum}}
-                    {{#isModel}}
-                    {{#isPrimitiveType}}
-                    {{! These are models that have been manually marked as primitive via generator param. }}
-                    result.{{{name}}} = valueDes;
-                    {{/isPrimitiveType}}
-                    {{^isPrimitiveType}}
-                    result.{{{name}}}.replace(valueDes);
-                    {{/isPrimitiveType}}
-                    {{/isModel}}
-                    {{^isModel}}
-                    result.{{{name}}} = valueDes;
-                    {{/isModel}}
-                    {{/isEnum}}
-                    {{/isContainer}}
-                    break;
-                {{/vars}}
-            }
-        }
-        return result.build();
-    }
+{{>serialization/built_value/class_header}} {
+{{>serialization/built_value/class_members}}
 }
-{{!
-    Generate an enum for any variables that are declared as inline enums
-    isEnum is only true for inline variables that are enums.
-    If an enum is declared as a definition, isEnum is false and the enum is generated from the
-    enum.mustache template.
-}}
-{{#vars}}
-    {{^isModel}}
-    {{#isEnum}}
-        {{^isContainer}}
 
-{{>serialization/built_value/enum_inline}}
-        {{/isContainer}}
-        {{#isContainer}}
-            {{#mostInnerItems}}
+{{>serialization/built_value/class_serializer}}{{#vendorExtensions.x-is-parent}}
 
-{{>serialization/built_value/enum_inline}}
-            {{/mostInnerItems}}
-        {{/isContainer}}
-    {{/isEnum}}
-    {{/isModel}}
-{{/vars}}
\ No newline at end of file
+{{>serialization/built_value/class_concrete}}{{/vendorExtensions.x-is-parent}}
+{{>serialization/built_value/class_inline_enums}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_concrete.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_concrete.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..44cad763010aacec38bdd678b23c9bd76b500660
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_concrete.mustache
@@ -0,0 +1,56 @@
+/// a concrete implementation of [{{classname}}], since [{{classname}}] is not instantiable
+@BuiltValue(instantiable: true)
+abstract class ${{classname}} implements {{classname}}, Built<${{classname}}, ${{classname}}Builder> {
+  ${{classname}}._();
+
+  factory ${{classname}}([void Function(${{classname}}Builder)? updates]) = _$${{classname}};
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(${{classname}}Builder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<${{classname}}> get serializer => _$${{classname}}Serializer();
+}
+
+class _$${{classname}}Serializer implements PrimitiveSerializer<${{classname}}> {
+  @override
+  final Iterable<Type> types = const [${{classname}}, _$${{classname}}];
+
+  @override
+  final String wireName = r'${{classname}}';
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    ${{{classname}}} object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.serialize(object, specifiedType: FullType({{classname}}))!;
+  }
+
+{{#vendorExtensions.x-has-self-and-ancestor-only-props}}{{>serialization/built_value/deserialize_properties}}
+
+{{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+  @override
+  ${{classname}} deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ${{classname}}Builder();
+    {{#vendorExtensions.x-has-self-and-ancestor-only-props}}
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    {{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+    {{! when discriminator is involved, read it, then return based on value }}
+    return result.build();
+  }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_header.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_header.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..e0b80af1dbe01ce5fd1e5351f48d281cb748f917
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_header.mustache
@@ -0,0 +1,10 @@
+/// {{{description}}}{{^description}}{{classname}}{{/description}}
+{{#hasVars}}
+///
+/// Properties:
+{{#allVars}}
+/// * [{{{name}}}] {{#description}}- {{{.}}}{{/description}}
+{{/allVars}}
+{{/hasVars}}
+@BuiltValue({{#vendorExtensions.x-is-parent}}instantiable: false{{/vendorExtensions.x-is-parent}})
+abstract class {{classname}} {{^allOf}}{{^vendorExtensions.x-is-parent}}implements {{/vendorExtensions.x-is-parent}}{{/allOf}}{{#allOf}}{{#-first}}implements {{/-first}}{{/allOf}}{{#allOf}}{{{.}}}{{^-last}}, {{/-last}}{{/allOf}}{{^vendorExtensions.x-is-parent}}{{#allOf}}{{#-first}}, {{/-first}}{{/allOf}}{{/vendorExtensions.x-is-parent}}{{^vendorExtensions.x-is-parent}}Built<{{classname}}, {{classname}}Builder>{{/vendorExtensions.x-is-parent}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_inline_enums.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_inline_enums.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..1105c1b70b10a7c891749130370a04114705310e
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_inline_enums.mustache
@@ -0,0 +1,23 @@
+{{!
+    Generate an enum for any variables that are declared as inline enums
+    isEnum is only true for inline variables that are enums.
+    If an enum is declared as a definition, isEnum is false and the enum is generated from the
+    enum.mustache template.
+    enumName only exists for inline enums
+}}
+{{#vars}}
+    {{^isModel}}
+    {{#enumName}}
+        {{^isContainer}}
+
+{{>serialization/built_value/enum_inline}}
+        {{/isContainer}}
+        {{#isContainer}}
+            {{#mostInnerItems}}
+
+{{>serialization/built_value/enum_inline}}
+            {{/mostInnerItems}}
+        {{/isContainer}}
+    {{/enumName}}
+    {{/isModel}}
+{{/vars}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_members.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_members.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..ad2e2b0650be75a814249672753206c0453154ea
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_members.mustache
@@ -0,0 +1,35 @@
+{{! define variables that aren't inherited from allOf/anyOf/oneOf }}
+{{#vendorExtensions.x-self-only-props}}
+  {{#description}}
+  /// {{{.}}}
+  {{/description}}
+  @BuiltValueField(wireName: r'{{baseName}}')
+  {{>serialization/built_value/variable_type}}{{^isNullable}}{{^required}}?{{/required}}{{/isNullable}} get {{name}};
+  {{#allowableValues}}
+  // {{#min}}range from {{{min}}} to {{{max}}}{{/min}}{{^min}}enum {{name}}Enum { {{#values}} {{{.}}}, {{/values}} };{{/min}}
+  {{/allowableValues}}
+
+{{/vendorExtensions.x-self-only-props}}{{#anyOf}}{{#-first}}  /// Any Of {{#anyOf}}[{{{.}}}]{{^-last}}, {{/-last}}{{/anyOf}}
+  AnyOf get anyOf;
+
+{{/-first}}{{/anyOf}}{{#oneOf}}{{#-first}}  /// One Of {{#oneOf}}[{{{.}}}]{{^-last}}, {{/-last}}{{/oneOf}}
+  OneOf get oneOf;
+
+{{/-first}}{{/oneOf}}{{#discriminator}}  static const String discriminatorFieldName = r'{{propertyName}}';{{#hasDiscriminatorWithNonEmptyMapping}}
+
+  static const Map<String, Type> discriminatorMapping = {
+    {{#mappedModels}}
+    r'{{mappingName}}': {{modelName}},
+    {{/mappedModels}}
+  };{{/hasDiscriminatorWithNonEmptyMapping}}
+
+{{/discriminator}}{{^vendorExtensions.x-is-parent}}  {{classname}}._();
+
+  factory {{classname}}([void updates({{classname}}Builder b)]) = _${{classname}};
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults({{{classname}}}Builder b) => b{{#vendorExtensions.x-self-and-ancestor-only-props}}{{#defaultValue}}
+      ..{{{name}}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{defaultValue}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}}{{/vendorExtensions.x-self-and-ancestor-only-props}};
+
+{{/vendorExtensions.x-is-parent}}  @BuiltValueSerializer(custom: true)
+  static Serializer<{{classname}}> get serializer => _${{classname}}Serializer();
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_serializer.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_serializer.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..d3b3d8916ca6fe26138a7ba3f4a2aeb522b10c5d
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_serializer.mustache
@@ -0,0 +1,306 @@
+class _${{classname}}Serializer implements PrimitiveSerializer<{{classname}}> {
+  @override
+  final Iterable<Type> types = const [{{classname}}{{^vendorExtensions.x-is-parent}}, _${{classname}}{{/vendorExtensions.x-is-parent}}];
+
+  @override
+  final String wireName = r'{{classname}}';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    {{{classname}}} object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    {{#vendorExtensions.x-self-and-ancestor-only-props}}
+    {{#required}}
+    {{!
+        A required property need to always be part of the serialized output.
+        When it is nullable, null is serialized, otherwise it is an error if it is null.
+    }}
+    yield r'{{baseName}}';
+    yield {{#isNullable}}object.{{{name}}} == null ? null : {{/isNullable}}serializers.serialize(
+      object.{{{name}}},
+      specifiedType: const {{>serialization/built_value/variable_serializer_type}},
+    );
+    {{/required}}
+    {{^required}}
+    if (object.{{{name}}} != null) {
+      {{! Non-required properties are only serialized if not null. }}
+      yield r'{{baseName}}';
+      yield serializers.serialize(
+        object.{{{name}}},
+        specifiedType: const {{>serialization/built_value/variable_serializer_type}},
+      );
+    }
+    {{/required}}
+    {{/vendorExtensions.x-self-and-ancestor-only-props}}
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    {{{classname}}} object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    {{! oneOf }}
+    {{#oneOf}}
+    {{#-first}}
+    final oneOf = object.oneOf;
+    {{#vendorExtensions.x-self-and-ancestor-only-props}}
+    final result = _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+    result.addAll(serializers.serialize(oneOf.value, specifiedType: FullType(oneOf.valueType)) as Iterable<Object?>);
+    return result;
+    {{/vendorExtensions.x-self-and-ancestor-only-props}}
+    {{^vendorExtensions.x-self-and-ancestor-only-props}}
+    return serializers.serialize(oneOf.value, specifiedType: FullType(oneOf.valueType))!;
+    {{/vendorExtensions.x-self-and-ancestor-only-props}}
+    {{/-first}}
+    {{/oneOf}}
+    {{! anyOf }}
+    {{#anyOf}}
+    {{#-first}}
+    final anyOf = object.anyOf;
+    final result = {{^vendorExtensions.x-has-self-and-ancestor-only-props}}<Object?>[]{{/vendorExtensions.x-has-self-and-ancestor-only-props}}{{#vendorExtensions.x-has-self-and-ancestor-only-props}}_serializeProperties(serializers, object, specifiedType: specifiedType).toList(){{/vendorExtensions.x-has-self-and-ancestor-only-props}};
+    for (var _valueEntry in anyOf.values.entries) {
+      final _typeIndex = _valueEntry.key;
+      final _type = anyOf.types[_typeIndex];
+      final _value = _valueEntry.value;
+      result.addAll(serializers.serialize(_value, specifiedType: FullType(_type)) as Iterable<Object?>);
+    }
+    return result;
+    {{/-first}}
+    {{/anyOf}}
+    {{^oneOf}}
+    {{^anyOf}}
+    {{#hasDiscriminatorWithNonEmptyMapping}}
+    {{#discriminator}}
+    {{! handle discriminator }}
+    {{#mappedModels}}
+    if (object is {{modelName}}) {
+      return serializers.serialize(object, specifiedType: FullType({{modelName}}))!;
+    }
+    {{/mappedModels}}
+    {{/discriminator}}
+    {{/hasDiscriminatorWithNonEmptyMapping}}
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+    {{/anyOf}}
+    {{/oneOf}}
+  }
+
+{{#vendorExtensions.x-has-self-and-ancestor-only-props}}{{^vendorExtensions.x-is-parent}}{{>serialization/built_value/deserialize_properties}}
+
+{{/vendorExtensions.x-is-parent}}{{/vendorExtensions.x-has-self-and-ancestor-only-props}}  @override
+  {{classname}} deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    {{! oneOf }}
+    {{#oneOf}}
+    {{#-first}}
+    final result = {{#vendorExtensions.x-is-parent}}${{/vendorExtensions.x-is-parent}}{{classname}}Builder();
+    Object? oneOfDataSrc;
+    {{#hasDiscriminatorWithNonEmptyMapping}}
+    {{#discriminator}}
+    {{! has props, assign them to result, and extract unhandled }}
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final discIndex = serializedList.indexOf({{classname}}.discriminatorFieldName) + 1;
+    final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String;
+    {{#vendorExtensions.x-has-self-and-ancestor-only-props}}
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result
+    );
+    {{! only deserialize unhandled props }}
+    oneOfDataSrc = unhandled;
+    {{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+    {{^vendorExtensions.x-has-self-and-ancestor-only-props}}
+    oneOfDataSrc = serialized;
+    {{! has no probs at all, pass the serialized as is }}
+    {{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+    final oneOfTypes = [{{#mappedModels}}{{modelName}}, {{/mappedModels}}{{#vendorExtensions.x-is-parent}}${{classname}}{{/vendorExtensions.x-is-parent}}];
+    Object oneOfResult;
+    Type oneOfType;
+    switch (discValue) {
+      {{#mappedModels}}
+      case '{{mappingName}}':
+        oneOfResult = serializers.deserialize(
+          oneOfDataSrc,
+          specifiedType: FullType({{modelName}}),
+        ) as {{modelName}};
+        oneOfType = {{modelName}};
+        break;
+      {{/mappedModels}}
+      default:
+        {{#vendorExtensions.x-is-parent}}
+        oneOfResult = serializers.deserialize(
+          oneOfDataSrc,
+          specifiedType: FullType(${{classname}}),
+        ) as ${{classname}};
+        oneOfType = ${{classname}};
+        {{/vendorExtensions.x-is-parent}}
+        {{^vendorExtensions.x-is-parent}}
+        throw UnsupportedError("Couldn't deserialize oneOf for the discriminator value: ${discValue}");
+        {{/vendorExtensions.x-is-parent}}
+    }
+    result.oneOf = OneOfDynamic(typeIndex: oneOfTypes.indexOf(oneOfType), types: oneOfTypes, value: oneOfResult);
+    {{/discriminator}}
+    {{/hasDiscriminatorWithNonEmptyMapping}}
+    {{^hasDiscriminatorWithNonEmptyMapping}}
+    {{! use the OneOfSerializer when there is no discriminator }}
+    final targetType = const FullType(OneOf, [{{#composedSchemas}}{{#oneOf}}{{>serialization/built_value/variable_serializer_type}}, {{/oneOf}}{{/composedSchemas}}]);
+    {{#vendorExtensions.x-has-self-and-ancestor-only-props}}
+    {{! has props, assign them to result, and extract unhandled }}
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    {{! only deserialize unhandled props }}
+    oneOfDataSrc = unhandled;
+    {{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+    {{^vendorExtensions.x-has-self-and-ancestor-only-props}}
+    {{! has no probs at all, pass the serialized as is }}
+    oneOfDataSrc = serialized;
+    {{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+    result.oneOf = serializers.deserialize(oneOfDataSrc, specifiedType: targetType) as OneOf;
+    {{/hasDiscriminatorWithNonEmptyMapping}}
+    return result.build();
+    {{/-first}}
+    {{/oneOf}}
+    {{! anyOf }}
+    {{#anyOf}}
+    {{#-first}}
+    final result = {{#vendorExtensions.x-is-parent}}${{/vendorExtensions.x-is-parent}}{{classname}}Builder();
+    Object? anyOfDataSrc;
+    {{#hasDiscriminatorWithNonEmptyMapping}}
+    {{#discriminator}}
+    {{! has props, assign them to result, and extract unhandled }}
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final discIndex = serializedList.indexOf({{classname}}.discriminatorFieldName) + 1;
+    final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String;
+    {{#vendorExtensions.x-has-self-and-ancestor-only-props}}
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    {{! only deserialize unhandled props }}
+    anyOfDataSrc = unhandled;
+    {{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+    {{^vendorExtensions.x-has-self-and-ancestor-only-props}}
+    anyOfDataSrc = serialized;
+    {{! has no probs at all, pass the serialized as is }}
+    {{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+    final anyOfTypes = [{{#mappedModels}}{{modelName}}, {{/mappedModels}}{{#vendorExtensions.x-is-parent}}${{classname}}{{/vendorExtensions.x-is-parent}}];
+    Object anyOfResult;
+    Type anyOfType;
+    switch (discValue) {
+      {{#mappedModels}}
+      case '{{mappingName}}':
+        anyOfResult = serializers.deserialize(anyOfDataSrc, specifiedType: FullType({{modelName}})) as {{modelName}};
+        anyOfType = {{modelName}};
+        break;
+      {{/mappedModels}}
+      default:
+        {{#vendorExtensions.x-is-parent}}
+        anyOfResult = serializers.deserialize(anyOfDataSrc, specifiedType: FullType(${{classname}})) as ${{classname}};
+        anyOfType = ${{classname}};
+        {{/vendorExtensions.x-is-parent}}
+        {{^vendorExtensions.x-is-parent}}
+        throw UnsupportedError("Couldn't deserialize anyOf for the discriminator value: ${discValue}");
+        {{/vendorExtensions.x-is-parent}}
+    }
+    result.anyOf = AnyOfDynamic(values: {anyOfTypes.indexOf(anyOfType): anyOfResult}, types: anyOfTypes);
+    {{/discriminator}}
+    {{/hasDiscriminatorWithNonEmptyMapping}}
+    {{^hasDiscriminatorWithNonEmptyMapping}}
+    {{! use the OneOfSerializer when there is no discriminator }}
+    final targetType = const FullType(AnyOf, [{{#composedSchemas}}{{#anyOf}}{{>serialization/built_value/variable_serializer_type}}, {{/anyOf}}{{/composedSchemas}}]);
+    {{#vendorExtensions.x-has-self-and-ancestor-only-props}}
+    {{! has props, assign them to result, and extract unhandled }}
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    {{! only deserialize unhandled props }}
+    anyOfDataSrc = unhandled;
+    {{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+    {{^vendorExtensions.x-has-self-and-ancestor-only-props}}
+    {{! has no probs at all, pass the serialized as is }}
+    anyOfDataSrc = serialized;
+    {{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+    result.anyOf = serializers.deserialize(anyOfDataSrc, specifiedType: targetType) as AnyOf;
+    {{/hasDiscriminatorWithNonEmptyMapping}}
+    return result.build();
+    {{/-first}}
+    {{/anyOf}}
+    {{! no anyOf nor oneOf, handles allOf trees }}
+    {{^oneOf}}
+    {{^anyOf}}
+    {{#vendorExtensions.x-is-parent}}
+    {{!
+        parent classes don't have builder
+        so they must delegate to another serializer using
+        1) discriminator + mapping
+        2) concrete implmentation ($classname)
+    }}
+    {{#hasDiscriminatorWithNonEmptyMapping}}
+    {{#discriminator}}
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final discIndex = serializedList.indexOf({{classname}}.discriminatorFieldName) + 1;
+    final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String;
+    switch (discValue) {
+      {{#mappedModels}}
+      case '{{mappingName}}':
+        return serializers.deserialize(serialized, specifiedType: FullType({{modelName}})) as {{modelName}};
+      {{/mappedModels}}
+      default:
+        return serializers.deserialize(serialized, specifiedType: FullType(${{classname}})) as ${{classname}};
+    }
+    {{/discriminator}}
+    {{/hasDiscriminatorWithNonEmptyMapping}}
+    {{^hasDiscriminatorWithNonEmptyMapping}}
+    return serializers.deserialize(serialized, specifiedType: FullType(${{classname}})) as ${{classname}};
+    {{/hasDiscriminatorWithNonEmptyMapping}}
+    {{/vendorExtensions.x-is-parent}}
+    {{^vendorExtensions.x-is-parent}}
+    final result = {{classname}}Builder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    {{#vendorExtensions.x-has-self-and-ancestor-only-props}}
+    {{! has props, assign them to result, and extract unhandled }}
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    {{/vendorExtensions.x-has-self-and-ancestor-only-props}}
+    return result.build();
+    {{/vendorExtensions.x-is-parent}}
+    {{/anyOf}}
+    {{/oneOf}}
+  }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/deserialize_properties.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/deserialize_properties.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..d64ec8086c34a4f1685073759e4d9fd95892c0a3
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/deserialize_properties.mustache
@@ -0,0 +1,57 @@
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required {{classname}}Builder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        {{#vendorExtensions.x-self-and-ancestor-only-props}}
+        case r'{{baseName}}':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const {{>serialization/built_value/variable_serializer_type}},
+          ) as {{>serialization/built_value/variable_type}};
+          {{#isNullable}}
+          if (valueDes == null) continue;
+          {{/isNullable}}
+          {{#isContainer}}
+          result.{{{name}}}.replace(valueDes);
+          {{/isContainer}}
+          {{^isContainer}}
+          {{#isEnum}}
+          result.{{{name}}} = valueDes;
+          {{/isEnum}}
+          {{^isEnum}}
+          {{#isModel}}
+          {{#isPrimitiveType}}
+          {{! These are models that have been manually marked as primitive via generator param. }}
+          result.{{{name}}} = valueDes;
+          {{/isPrimitiveType}}
+          {{^isPrimitiveType}}
+          {{#vendorExtensions.x-is-parent}}
+          result.{{{name}}} = valueDes;
+          {{/vendorExtensions.x-is-parent}}
+          {{^vendorExtensions.x-is-parent}}
+          result.{{{name}}}.replace(valueDes);
+          {{/vendorExtensions.x-is-parent}}
+          {{/isPrimitiveType}}
+          {{/isModel}}
+          {{^isModel}}
+          result.{{{name}}} = valueDes;
+          {{/isModel}}
+          {{/isEnum}}
+          {{/isContainer}}
+          break;
+        {{/vendorExtensions.x-self-and-ancestor-only-props}}
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serializers.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serializers.mustache
index 7ef191808eb298e1789a22eb4a898f2803e085f6..aa49d9aef9e42752a03d3478d5169e76778ddc4a 100644
--- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serializers.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serializers.mustache
@@ -1,6 +1,8 @@
 {{>header}}
 // ignore_for_file: unused_import
 
+import 'package:one_of_serializer/any_of_serializer.dart';
+import 'package:one_of_serializer/one_of_serializer.dart';
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/json_object.dart';
 import 'package:built_value/serializer.dart';
@@ -17,7 +19,7 @@ import 'package:{{pubName}}/{{sourceFolder}}/offset_date_serializer.dart';{{/use
 part 'serializers.g.dart';
 
 @SerializersFor([{{#models}}{{#model}}
-  {{classname}},{{/model}}{{/models}}
+  {{classname}},{{#vendorExtensions.x-is-parent}}${{classname}},{{/vendorExtensions.x-is-parent}}{{/model}}{{/models}}
 ])
 Serializers serializers = (_$serializers.toBuilder(){{#builtValueSerializers}}
       ..addBuilderFactory(
@@ -29,7 +31,10 @@ Serializers serializers = (_$serializers.toBuilder(){{#builtValueSerializers}}
         const FullType(BuiltMap, [FullType(String), FullType{{#isNullable}}.nullable{{/isNullable}}({{dataType}})]),
         () => MapBuilder<String, {{dataType}}>(),
 {{/isMap}}
-      ){{/builtValueSerializers}}{{#useDateLibTimeMachine}}
+      ){{/builtValueSerializers}}
+      {{#models}}{{#model}}{{#vendorExtensions.x-is-parent}}..add({{classname}}.serializer)
+      {{/vendorExtensions.x-is-parent}}{{/model}}{{/models}}..add(const OneOfSerializer())
+      ..add(const AnyOfSerializer()){{#useDateLibTimeMachine}}      
       ..add(const OffsetDateSerializer())
       ..add(const OffsetDateTimeSerializer()){{/useDateLibTimeMachine}}{{#useDateLibCore}}
       ..add(const DateSerializer())
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/test_instance.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/test_instance.mustache
index 4ee29fff3cc08aa79f7f41bdf414b594b27ff092..2d92c472df31640dbe5aee897f07bdb108d62cec 100644
--- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/test_instance.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/test_instance.mustache
@@ -1,2 +1,2 @@
-  final instance = {{{classname}}}Builder();
+  {{#vendorExtensions.x-is-parent}}//{{/vendorExtensions.x-is-parent}}final instance = {{{classname}}}Builder();
   // TODO add properties to the builder and call build()
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index df0a4a8f97ce072ed5fa59b3ae3485141debfbe4..666e811ffaa9938f1f85ead7e60c2e49ab555ead 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1325,6 +1325,9 @@
             </activation>
             <modules>
                 <module>samples/openapi3/client/petstore/dart2/petstore_client_lib</module>
+                <module>samples/openapi3/client/petstore/dart-dio/oneof</module>
+                <module>samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance</module>
+                <module>samples/openapi3/client/petstore/dart-dio/oneof_primitive</module>
                 <module>samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake</module>
                 <module>samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable</module>
             </modules>
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/.gitignore b/samples/openapi3/client/petstore/dart-dio/oneof/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..4298cdcbd1a24268bccd159b376ff8a9c4722868
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/.gitignore
@@ -0,0 +1,41 @@
+# See https://dart.dev/guides/libraries/private-files
+
+# Files and directories created by pub
+.dart_tool/
+.buildlog
+.packages
+.project
+.pub/
+build/
+**/packages/
+
+# Files created by dart2js
+# (Most Dart developers will use pub build to compile Dart, use/modify these
+#  rules if you intend to use dart2js directly
+#  Convention is to use extension '.dart.js' for Dart compiled to Javascript to
+#  differentiate from explicit Javascript files)
+*.dart.js
+*.part.js
+*.js.deps
+*.js.map
+*.info.json
+
+# Directory created by dartdoc
+doc/api/
+
+# Don't commit pubspec lock file
+# (Library packages only! Remove pattern if developing an application package)
+pubspec.lock
+
+# Don’t commit files and directories created by other development environments.
+# For example, if your development environment creates any of the following files,
+# consider putting them in a global ignore file:
+
+# IntelliJ
+*.iml
+*.ipr
+*.iws
+.idea/
+
+# Mac
+.DS_Store
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/.openapi-generator-ignore b/samples/openapi3/client/petstore/dart-dio/oneof/.openapi-generator-ignore
new file mode 100644
index 0000000000000000000000000000000000000000..7484ee590a3894506cf063799b885428f95a71be
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/.openapi-generator-ignore
@@ -0,0 +1,23 @@
+# OpenAPI Generator Ignore
+# Generated by openapi-generator https://github.com/openapitools/openapi-generator
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/oneof/.openapi-generator/FILES
new file mode 100644
index 0000000000000000000000000000000000000000..f1ab7b5540a359cc5667f80ed6aa34d8c062bde5
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/.openapi-generator/FILES
@@ -0,0 +1,23 @@
+.gitignore
+README.md
+analysis_options.yaml
+doc/Apple.md
+doc/Banana.md
+doc/DefaultApi.md
+doc/Fruit.md
+lib/openapi.dart
+lib/src/api.dart
+lib/src/api/default_api.dart
+lib/src/api_util.dart
+lib/src/auth/api_key_auth.dart
+lib/src/auth/auth.dart
+lib/src/auth/basic_auth.dart
+lib/src/auth/bearer_auth.dart
+lib/src/auth/oauth.dart
+lib/src/date_serializer.dart
+lib/src/model/apple.dart
+lib/src/model/banana.dart
+lib/src/model/date.dart
+lib/src/model/fruit.dart
+lib/src/serializers.dart
+pubspec.yaml
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/.openapi-generator/VERSION b/samples/openapi3/client/petstore/dart-dio/oneof/.openapi-generator/VERSION
new file mode 100644
index 0000000000000000000000000000000000000000..66672d4e9d31378b298e49f1b38a028b2afe48ac
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/.openapi-generator/VERSION
@@ -0,0 +1 @@
+6.1.0-SNAPSHOT
\ No newline at end of file
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/README.md b/samples/openapi3/client/petstore/dart-dio/oneof/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..53bfd08fec436ee928996df190c33b7036d3b3e3
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/README.md
@@ -0,0 +1,84 @@
+# openapi (EXPERIMENTAL)
+No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+
+This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
+
+- API version: 0.0.1
+- Build package: org.openapitools.codegen.languages.DartDioClientCodegen
+
+## Requirements
+
+* Dart 2.12.0 or later OR Flutter 1.26.0 or later
+* Dio 4.0.0+
+
+## Installation & Usage
+
+### pub.dev
+To use the package from [pub.dev](https://pub.dev), please include the following in pubspec.yaml
+```yaml
+dependencies:
+  openapi: 1.0.0
+```
+
+### Github
+If this Dart package is published to Github, please include the following in pubspec.yaml
+```yaml
+dependencies:
+  openapi:
+    git:
+      url: https://github.com/GIT_USER_ID/GIT_REPO_ID.git
+      #ref: main
+```
+
+### Local development
+To use the package from your local drive, please include the following in pubspec.yaml
+```yaml
+dependencies:
+  openapi:
+    path: /path/to/openapi
+```
+
+## Getting Started
+
+Please follow the [installation procedure](#installation--usage) and then run the following:
+
+```dart
+import 'package:openapi/openapi.dart';
+
+
+final api = Openapi().getDefaultApi();
+
+try {
+    final response = await api.rootGet();
+    print(response);
+} catch on DioError (e) {
+    print("Exception when calling DefaultApi->rootGet: $e\n");
+}
+
+```
+
+## Documentation for API Endpoints
+
+All URIs are relative to *http://localhost*
+
+Class | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+[*DefaultApi*](doc/DefaultApi.md) | [**rootGet**](doc/DefaultApi.md#rootget) | **GET** / | 
+
+
+## Documentation For Models
+
+ - [Apple](doc/Apple.md)
+ - [Banana](doc/Banana.md)
+ - [Fruit](doc/Fruit.md)
+
+
+## Documentation For Authorization
+
+ All endpoints do not require authorization.
+
+
+## Author
+
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/analysis_options.yaml b/samples/openapi3/client/petstore/dart-dio/oneof/analysis_options.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..a611887d3acfe1fdfd0ad16005f9e675d3583ff0
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/analysis_options.yaml
@@ -0,0 +1,9 @@
+analyzer:
+  language:
+    strict-inference: true
+    strict-raw-types: true
+  strong-mode:
+    implicit-dynamic: false
+    implicit-casts: false
+  exclude:
+    - test/*.dart
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/doc/Apple.md b/samples/openapi3/client/petstore/dart-dio/oneof/doc/Apple.md
new file mode 100644
index 0000000000000000000000000000000000000000..c7f711b87cef8536e1127a2c454d6525d259c827
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/doc/Apple.md
@@ -0,0 +1,15 @@
+# openapi.model.Apple
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**kind** | **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/openapi3/client/petstore/dart-dio/oneof/doc/Banana.md b/samples/openapi3/client/petstore/dart-dio/oneof/doc/Banana.md
new file mode 100644
index 0000000000000000000000000000000000000000..bef8a58a427607fcdba1cc6c768bee684b4cab84
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/doc/Banana.md
@@ -0,0 +1,15 @@
+# openapi.model.Banana
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**count** | **num** |  | [optional] 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/doc/DefaultApi.md b/samples/openapi3/client/petstore/dart-dio/oneof/doc/DefaultApi.md
new file mode 100644
index 0000000000000000000000000000000000000000..41c9b6f9411652e01ab556c058a13b5b14fa688e
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/doc/DefaultApi.md
@@ -0,0 +1,51 @@
+# openapi.api.DefaultApi
+
+## Load the API package
+```dart
+import 'package:openapi/api.dart';
+```
+
+All URIs are relative to *http://localhost*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**rootGet**](DefaultApi.md#rootget) | **GET** / | 
+
+
+# **rootGet**
+> Fruit rootGet()
+
+
+
+### Example
+```dart
+import 'package:openapi/api.dart';
+
+final api = Openapi().getDefaultApi();
+
+try {
+    final response = api.rootGet();
+    print(response);
+} catch on DioError (e) {
+    print('Exception when calling DefaultApi->rootGet: $e\n');
+}
+```
+
+### Parameters
+This endpoint does not need any parameter.
+
+### Return type
+
+[**Fruit**](Fruit.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/doc/Fruit.md b/samples/openapi3/client/petstore/dart-dio/oneof/doc/Fruit.md
new file mode 100644
index 0000000000000000000000000000000000000000..5d48cc6e6d38322c32dfff7fc5e7f4ba64bece60
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/doc/Fruit.md
@@ -0,0 +1,17 @@
+# openapi.model.Fruit
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**color** | **String** |  | [optional] 
+**kind** | **String** |  | [optional] 
+**count** | **num** |  | [optional] 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/openapi.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/openapi.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d85a16fc6ad981d7276f360fa656a9a6a25c69f5
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/openapi.dart
@@ -0,0 +1,16 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+export 'package:openapi/src/api.dart';
+export 'package:openapi/src/auth/api_key_auth.dart';
+export 'package:openapi/src/auth/basic_auth.dart';
+export 'package:openapi/src/auth/oauth.dart';
+export 'package:openapi/src/serializers.dart';
+export 'package:openapi/src/model/date.dart';
+
+export 'package:openapi/src/api/default_api.dart';
+
+export 'package:openapi/src/model/apple.dart';
+export 'package:openapi/src/model/banana.dart';
+export 'package:openapi/src/model/fruit.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ba9424a2d2a1de02648222077cff74041bfd4744
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api.dart
@@ -0,0 +1,73 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+import 'package:built_value/serializer.dart';
+import 'package:openapi/src/serializers.dart';
+import 'package:openapi/src/auth/api_key_auth.dart';
+import 'package:openapi/src/auth/basic_auth.dart';
+import 'package:openapi/src/auth/bearer_auth.dart';
+import 'package:openapi/src/auth/oauth.dart';
+import 'package:openapi/src/api/default_api.dart';
+
+class Openapi {
+  static const String basePath = r'http://localhost';
+
+  final Dio dio;
+  final Serializers serializers;
+
+  Openapi({
+    Dio? dio,
+    Serializers? serializers,
+    String? basePathOverride,
+    List<Interceptor>? interceptors,
+  })  : this.serializers = serializers ?? standardSerializers,
+        this.dio = dio ??
+            Dio(BaseOptions(
+              baseUrl: basePathOverride ?? basePath,
+              connectTimeout: 5000,
+              receiveTimeout: 3000,
+            )) {
+    if (interceptors == null) {
+      this.dio.interceptors.addAll([
+        OAuthInterceptor(),
+        BasicAuthInterceptor(),
+        BearerAuthInterceptor(),
+        ApiKeyAuthInterceptor(),
+      ]);
+    } else {
+      this.dio.interceptors.addAll(interceptors);
+    }
+  }
+
+  void setOAuthToken(String name, String token) {
+    if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens[name] = token;
+    }
+  }
+
+  void setBearerAuth(String name, String token) {
+    if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token;
+    }
+  }
+
+  void setBasicAuth(String name, String username, String password) {
+    if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password);
+    }
+  }
+
+  void setApiKey(String name, String apiKey) {
+    if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
+    }
+  }
+
+  /// Get DefaultApi instance, base route and serializer can be overridden by a given but be careful,
+  /// by doing that all interceptors will not be executed
+  DefaultApi getDefaultApi() {
+    return DefaultApi(dio, serializers);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api/default_api.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api/default_api.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e98b7ae9cae4f64088f472c92173420514530ef5
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api/default_api.dart
@@ -0,0 +1,92 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'dart:async';
+
+import 'package:built_value/serializer.dart';
+import 'package:dio/dio.dart';
+
+import 'package:openapi/src/model/fruit.dart';
+
+class DefaultApi {
+
+  final Dio _dio;
+
+  final Serializers _serializers;
+
+  const DefaultApi(this._dio, this._serializers);
+
+  /// rootGet
+  /// 
+  ///
+  /// Parameters:
+  /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
+  /// * [headers] - Can be used to add additional headers to the request
+  /// * [extras] - Can be used to add flags to the request
+  /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
+  /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
+  /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
+  ///
+  /// Returns a [Future] containing a [Response] with a [Fruit] as data
+  /// Throws [DioError] if API call or serialization fails
+  Future<Response<Fruit>> rootGet({ 
+    CancelToken? cancelToken,
+    Map<String, dynamic>? headers,
+    Map<String, dynamic>? extra,
+    ValidateStatus? validateStatus,
+    ProgressCallback? onSendProgress,
+    ProgressCallback? onReceiveProgress,
+  }) async {
+    final _path = r'/';
+    final _options = Options(
+      method: r'GET',
+      headers: <String, dynamic>{
+        ...?headers,
+      },
+      extra: <String, dynamic>{
+        'secure': <Map<String, String>>[],
+        ...?extra,
+      },
+      validateStatus: validateStatus,
+    );
+
+    final _response = await _dio.request<Object>(
+      _path,
+      options: _options,
+      cancelToken: cancelToken,
+      onSendProgress: onSendProgress,
+      onReceiveProgress: onReceiveProgress,
+    );
+
+    Fruit _responseData;
+
+    try {
+      const _responseType = FullType(Fruit);
+      _responseData = _serializers.deserialize(
+        _response.data!,
+        specifiedType: _responseType,
+      ) as Fruit;
+
+    } catch (error, stackTrace) {
+      throw DioError(
+        requestOptions: _response.requestOptions,
+        response: _response,
+        type: DioErrorType.other,
+        error: error,
+      )..stackTrace = stackTrace;
+    }
+
+    return Response<Fruit>(
+      data: _responseData,
+      headers: _response.headers,
+      isRedirect: _response.isRedirect,
+      requestOptions: _response.requestOptions,
+      redirects: _response.redirects,
+      statusCode: _response.statusCode,
+      statusMessage: _response.statusMessage,
+      extra: _response.extra,
+    );
+  }
+
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api_util.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api_util.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ed3bb12f25b81a6d266b1a4c0070f52d8d67ef25
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/api_util.dart
@@ -0,0 +1,77 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'dart:convert';
+import 'dart:typed_data';
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/serializer.dart';
+import 'package:dio/dio.dart';
+
+/// Format the given form parameter object into something that Dio can handle.
+/// Returns primitive or String.
+/// Returns List/Map if the value is BuildList/BuiltMap.
+dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) {
+  if (value == null) {
+    return '';
+  }
+  if (value is String || value is num || value is bool) {
+    return value;
+  }
+  final serialized = serializers.serialize(
+    value as Object,
+    specifiedType: type,
+  );
+  if (serialized is String) {
+    return serialized;
+  }
+  if (value is BuiltList || value is BuiltSet || value is BuiltMap) {
+    return serialized;
+  }
+  return json.encode(serialized);
+}
+
+dynamic encodeQueryParameter(
+  Serializers serializers,
+  dynamic value,
+  FullType type,
+) {
+  if (value == null) {
+    return '';
+  }
+  if (value is String || value is num || value is bool) {
+    return value;
+  }
+  if (value is Uint8List) {
+    // Currently not sure how to serialize this
+    return value;
+  }
+  final serialized = serializers.serialize(
+    value as Object,
+    specifiedType: type,
+  );
+  if (serialized == null) {
+    return '';
+  }
+  if (serialized is String) {
+    return serialized;
+  }
+  return serialized;
+}
+
+ListParam<Object?> encodeCollectionQueryParameter<T>(
+  Serializers serializers,
+  dynamic value,
+  FullType type, {
+  ListFormat format = ListFormat.multi,
+}) {
+  final serialized = serializers.serialize(
+    value as Object,
+    specifiedType: type,
+  );
+  if (value is BuiltList<T> || value is BuiltSet<T>) {
+    return ListParam(List.of((serialized as Iterable<Object?>).cast()), format);
+  }
+  throw ArgumentError('Invalid value passed to encodeCollectionQueryParameter');
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/api_key_auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/api_key_auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ee16e3f0f92fd4e87d97ec6e5dc9ad3b0519fae6
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/api_key_auth.dart
@@ -0,0 +1,30 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class ApiKeyAuthInterceptor extends AuthInterceptor {
+  final Map<String, String> apiKeys = {};
+
+  @override
+  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
+    final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'apiKey');
+    for (final info in authInfo) {
+      final authName = info['name'] as String;
+      final authKeyName = info['keyName'] as String;
+      final authWhere = info['where'] as String;
+      final apiKey = apiKeys[authName];
+      if (apiKey != null) {
+        if (authWhere == 'query') {
+          options.queryParameters[authKeyName] = apiKey;
+        } else {
+          options.headers[authKeyName] = apiKey;
+        }
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f7ae9bf3f11eb909e6d00b2087f2c17a6a260478
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/auth.dart
@@ -0,0 +1,18 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+
+abstract class AuthInterceptor extends Interceptor {
+  /// Get auth information on given route for the given type.
+  /// Can return an empty list if type is not present on auth data or
+  /// if route doesn't need authentication.
+  List<Map<String, String>> getAuthInfo(RequestOptions route, bool Function(Map<String, String> secure) handles) {
+    if (route.extra.containsKey('secure')) {
+      final auth = route.extra['secure'] as List<Map<String, String>>;
+      return auth.where((secure) => handles(secure)).toList();
+    }
+    return [];
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/basic_auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/basic_auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b6e6dce04f9c4ff33478271ba7994f0e22af35a7
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/basic_auth.dart
@@ -0,0 +1,37 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'dart:convert';
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class BasicAuthInfo {
+  final String username;
+  final String password;
+
+  const BasicAuthInfo(this.username, this.password);
+}
+
+class BasicAuthInterceptor extends AuthInterceptor {
+  final Map<String, BasicAuthInfo> authInfo = {};
+
+  @override
+  void onRequest(
+    RequestOptions options,
+    RequestInterceptorHandler handler,
+  ) {
+    final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
+    for (final info in metadataAuthInfo) {
+      final authName = info['name'] as String;
+      final basicAuthInfo = authInfo[authName];
+      if (basicAuthInfo != null) {
+        final basicAuth = 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}';
+        options.headers['Authorization'] = basicAuth;
+        break;
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/bearer_auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/bearer_auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1d4402b376c0a794ada1b4756ed08cd247fb6564
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/bearer_auth.dart
@@ -0,0 +1,26 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class BearerAuthInterceptor extends AuthInterceptor {
+  final Map<String, String> tokens = {};
+
+  @override
+  void onRequest(
+    RequestOptions options,
+    RequestInterceptorHandler handler,
+  ) {
+    final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
+    for (final info in authInfo) {
+      final token = tokens[info['name']];
+      if (token != null) {
+        options.headers['Authorization'] = 'Bearer ${token}';
+        break;
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/oauth.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/oauth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..337cf762b0ce77ccb2ed30882ea66e5abe84d354
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/auth/oauth.dart
@@ -0,0 +1,26 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class OAuthInterceptor extends AuthInterceptor {
+  final Map<String, String> tokens = {};
+
+  @override
+  void onRequest(
+    RequestOptions options,
+    RequestInterceptorHandler handler,
+  ) {
+    final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'oauth' || secure['type'] == 'oauth2');
+    for (final info in authInfo) {
+      final token = tokens[info['name']];
+      if (token != null) {
+        options.headers['Authorization'] = 'Bearer ${token}';
+        break;
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/date_serializer.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/date_serializer.dart
new file mode 100644
index 0000000000000000000000000000000000000000..db3c5c437db10d074eb892e190d01f1874c3ce7c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/date_serializer.dart
@@ -0,0 +1,31 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/serializer.dart';
+import 'package:openapi/src/model/date.dart';
+
+class DateSerializer implements PrimitiveSerializer<Date> {
+
+  const DateSerializer();
+
+  @override
+  Iterable<Type> get types => BuiltList.of([Date]);
+
+  @override
+  String get wireName => 'Date';
+
+  @override
+  Date deserialize(Serializers serializers, Object serialized,
+      {FullType specifiedType = FullType.unspecified}) {
+    final parsed = DateTime.parse(serialized as String);
+    return Date(parsed.year, parsed.month, parsed.day);
+  }
+
+  @override
+  Object serialize(Serializers serializers, Date date,
+      {FullType specifiedType = FullType.unspecified}) {
+    return date.toString();
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/apple.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/apple.dart
new file mode 100644
index 0000000000000000000000000000000000000000..02ca94190b969a3b59418b4e19589222d0056121
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/apple.dart
@@ -0,0 +1,108 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'apple.g.dart';
+
+/// Apple
+///
+/// Properties:
+/// * [kind] 
+@BuiltValue()
+abstract class Apple implements Built<Apple, AppleBuilder> {
+  @BuiltValueField(wireName: r'kind')
+  String? get kind;
+
+  Apple._();
+
+  factory Apple([void updates(AppleBuilder b)]) = _$Apple;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(AppleBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Apple> get serializer => _$AppleSerializer();
+}
+
+class _$AppleSerializer implements PrimitiveSerializer<Apple> {
+  @override
+  final Iterable<Type> types = const [Apple, _$Apple];
+
+  @override
+  final String wireName = r'Apple';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Apple object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.kind != null) {
+      yield r'kind';
+      yield serializers.serialize(
+        object.kind,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Apple object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required AppleBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'kind':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.kind = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  Apple deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = AppleBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/banana.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/banana.dart
new file mode 100644
index 0000000000000000000000000000000000000000..bf2d632ee11436df950d4abfba21a553b292408a
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/banana.dart
@@ -0,0 +1,108 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'banana.g.dart';
+
+/// Banana
+///
+/// Properties:
+/// * [count] 
+@BuiltValue()
+abstract class Banana implements Built<Banana, BananaBuilder> {
+  @BuiltValueField(wireName: r'count')
+  num? get count;
+
+  Banana._();
+
+  factory Banana([void updates(BananaBuilder b)]) = _$Banana;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(BananaBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Banana> get serializer => _$BananaSerializer();
+}
+
+class _$BananaSerializer implements PrimitiveSerializer<Banana> {
+  @override
+  final Iterable<Type> types = const [Banana, _$Banana];
+
+  @override
+  final String wireName = r'Banana';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Banana object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.count != null) {
+      yield r'count';
+      yield serializers.serialize(
+        object.count,
+        specifiedType: const FullType(num),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Banana object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required BananaBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'count':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(num),
+          ) as num;
+          result.count = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  Banana deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = BananaBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/date.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/date.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b21c7f544beefb379c4b64b464f02d42c8355cbe
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/date.dart
@@ -0,0 +1,70 @@
+/// A gregorian calendar date generated by
+/// OpenAPI generator to differentiate
+/// between [DateTime] and [Date] formats.
+class Date implements Comparable<Date> {
+  final int year;
+
+  /// January is 1.
+  final int month;
+
+  /// First day is 1.
+  final int day;
+
+  Date(this.year, this.month, this.day);
+
+  /// The current date
+  static Date now({bool utc = false}) {
+    var now = DateTime.now();
+    if (utc) {
+      now = now.toUtc();
+    }
+    return now.toDate();
+  }
+
+  /// Convert to a [DateTime].
+  DateTime toDateTime({bool utc = false}) {
+    if (utc) {
+      return DateTime.utc(year, month, day);
+    } else {
+      return DateTime(year, month, day);
+    }
+  }
+
+  @override
+  int compareTo(Date other) {
+    int d = year.compareTo(other.year);
+    if (d != 0) {
+      return d;
+    }
+    d = month.compareTo(other.month);
+    if (d != 0) {
+      return d;
+    }
+    return day.compareTo(other.day);
+  }
+
+  @override
+  bool operator ==(Object other) =>
+      identical(this, other) ||
+      other is Date &&
+          runtimeType == other.runtimeType &&
+          year == other.year &&
+          month == other.month &&
+          day == other.day;
+
+  @override
+  int get hashCode => year.hashCode ^ month.hashCode ^ day.hashCode;
+
+  @override
+  String toString() {
+    final yyyy = year.toString();
+    final mm = month.toString().padLeft(2, '0');
+    final dd = day.toString().padLeft(2, '0');
+
+    return '$yyyy-$mm-$dd';
+  }
+}
+
+extension DateTimeToDate on DateTime {
+  Date toDate() => Date(year, month, day);
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/fruit.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/fruit.dart
new file mode 100644
index 0000000000000000000000000000000000000000..11f8cfa70501b278e42b7a3cfee8f480287e9511
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/model/fruit.dart
@@ -0,0 +1,123 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/apple.dart';
+import 'package:openapi/src/model/banana.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+import 'package:one_of/one_of.dart';
+
+part 'fruit.g.dart';
+
+/// Fruit
+///
+/// Properties:
+/// * [color] 
+/// * [kind] 
+/// * [count] 
+@BuiltValue()
+abstract class Fruit implements Built<Fruit, FruitBuilder> {
+  @BuiltValueField(wireName: r'color')
+  String? get color;
+
+  /// One Of [Apple], [Banana]
+  OneOf get oneOf;
+
+  Fruit._();
+
+  factory Fruit([void updates(FruitBuilder b)]) = _$Fruit;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(FruitBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Fruit> get serializer => _$FruitSerializer();
+}
+
+class _$FruitSerializer implements PrimitiveSerializer<Fruit> {
+  @override
+  final Iterable<Type> types = const [Fruit, _$Fruit];
+
+  @override
+  final String wireName = r'Fruit';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Fruit object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.color != null) {
+      yield r'color';
+      yield serializers.serialize(
+        object.color,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Fruit object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final oneOf = object.oneOf;
+    final result = _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+    result.addAll(serializers.serialize(oneOf.value, specifiedType: FullType(oneOf.valueType)) as Iterable<Object?>);
+    return result;
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required FruitBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'color':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.color = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  Fruit deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = FruitBuilder();
+    Object? oneOfDataSrc;
+    final targetType = const FullType(OneOf, [FullType(Apple), FullType(Banana), ]);
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    oneOfDataSrc = unhandled;
+    result.oneOf = serializers.deserialize(oneOfDataSrc, specifiedType: targetType) as OneOf;
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/serializers.dart b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/serializers.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ddb1d66a1f5e5bbd68e08c995b09f913addbb972
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/lib/src/serializers.dart
@@ -0,0 +1,36 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_import
+
+import 'package:one_of_serializer/any_of_serializer.dart';
+import 'package:one_of_serializer/one_of_serializer.dart';
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/json_object.dart';
+import 'package:built_value/serializer.dart';
+import 'package:built_value/standard_json_plugin.dart';
+import 'package:built_value/iso_8601_date_time_serializer.dart';
+import 'package:openapi/src/date_serializer.dart';
+import 'package:openapi/src/model/date.dart';
+
+import 'package:openapi/src/model/apple.dart';
+import 'package:openapi/src/model/banana.dart';
+import 'package:openapi/src/model/fruit.dart';
+
+part 'serializers.g.dart';
+
+@SerializersFor([
+  Apple,
+  Banana,
+  Fruit,
+])
+Serializers serializers = (_$serializers.toBuilder()
+      ..add(const OneOfSerializer())
+      ..add(const AnyOfSerializer())
+      ..add(const DateSerializer())
+      ..add(Iso8601DateTimeSerializer()))
+    .build();
+
+Serializers standardSerializers =
+    (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/pom.xml b/samples/openapi3/client/petstore/dart-dio/oneof/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..810c7d48d77f04eb3586ec0bcfa137e1d2f7a266
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/pom.xml
@@ -0,0 +1,88 @@
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.openapitools</groupId>
+    <artifactId>DartDioOneOf</artifactId>
+    <packaging>pom</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>DartDio OneOf</name>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.2.1</version>
+                <executions>
+                    <execution>
+                        <id>pub-get</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>pub</executable>
+                            <arguments>
+                                <argument>get</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>pub-run-build-runner</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>pub</executable>
+                            <arguments>
+                                <argument>run</argument>
+                                <argument>build_runner</argument>
+                                <argument>build</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>dart-analyze</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>dart</executable>
+                            <arguments>
+                                <argument>analyze</argument>
+                                <argument>--fatal-infos</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>dart-test</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>dart</executable>
+                            <arguments>
+                                <argument>test</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/oneof/pubspec.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..fb676f65c393c216466d443ec4060097085cd922
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/pubspec.yaml
@@ -0,0 +1,19 @@
+name: openapi
+version: 1.0.0
+description: OpenAPI API client
+homepage: homepage
+
+environment:
+  sdk: '>=2.12.0 <3.0.0'
+
+dependencies:
+  dio: '>=4.0.1 <5.0.0'
+  one_of: '>=1.5.0 <2.0.0'
+  one_of_serializer: '>=1.5.0 <2.0.0'
+  built_value: '>=8.4.0 <9.0.0'
+  built_collection: '>=5.1.1 <6.0.0'
+
+dev_dependencies:
+  built_value_generator: '>=8.4.0 <9.0.0'
+  build_runner: any
+  test: ^1.16.0
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/test/apple_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof/test/apple_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1d542169550d8dbf69a7cc65f0a4640f7a2a78c2
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/test/apple_test.dart
@@ -0,0 +1,16 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Apple
+void main() {
+  final instance = AppleBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Apple, () {
+    // String kind
+    test('to test the property `kind`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/test/banana_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof/test/banana_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a883acc0a9e840cad9c92f56aa2e77871e87aef6
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/test/banana_test.dart
@@ -0,0 +1,16 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Banana
+void main() {
+  final instance = BananaBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Banana, () {
+    // num count
+    test('to test the property `count`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/test/default_api_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof/test/default_api_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..07d256d2e55457f61511a68cef563c59a193545c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/test/default_api_test.dart
@@ -0,0 +1,16 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+
+/// tests for DefaultApi
+void main() {
+  final instance = Openapi().getDefaultApi();
+
+  group(DefaultApi, () {
+    //Future<Fruit> rootGet() async
+    test('test rootGet', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/test/fruit_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof/test/fruit_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c18790ae9566a954fba010a9ec7f40421156ca73
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof/test/fruit_test.dart
@@ -0,0 +1,26 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Fruit
+void main() {
+  final instance = FruitBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Fruit, () {
+    // String color
+    test('to test the property `color`', () async {
+      // TODO
+    });
+
+    // String kind
+    test('to test the property `kind`', () async {
+      // TODO
+    });
+
+    // num count
+    test('to test the property `count`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.gitignore b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..4298cdcbd1a24268bccd159b376ff8a9c4722868
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.gitignore
@@ -0,0 +1,41 @@
+# See https://dart.dev/guides/libraries/private-files
+
+# Files and directories created by pub
+.dart_tool/
+.buildlog
+.packages
+.project
+.pub/
+build/
+**/packages/
+
+# Files created by dart2js
+# (Most Dart developers will use pub build to compile Dart, use/modify these
+#  rules if you intend to use dart2js directly
+#  Convention is to use extension '.dart.js' for Dart compiled to Javascript to
+#  differentiate from explicit Javascript files)
+*.dart.js
+*.part.js
+*.js.deps
+*.js.map
+*.info.json
+
+# Directory created by dartdoc
+doc/api/
+
+# Don't commit pubspec lock file
+# (Library packages only! Remove pattern if developing an application package)
+pubspec.lock
+
+# Don’t commit files and directories created by other development environments.
+# For example, if your development environment creates any of the following files,
+# consider putting them in a global ignore file:
+
+# IntelliJ
+*.iml
+*.ipr
+*.iws
+.idea/
+
+# Mac
+.DS_Store
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator-ignore b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator-ignore
new file mode 100644
index 0000000000000000000000000000000000000000..7484ee590a3894506cf063799b885428f95a71be
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator-ignore
@@ -0,0 +1,23 @@
+# OpenAPI Generator Ignore
+# Generated by openapi-generator https://github.com/openapitools/openapi-generator
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator/FILES
new file mode 100644
index 0000000000000000000000000000000000000000..52a900a196239615215a85d7a2137865322ea66f
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator/FILES
@@ -0,0 +1,47 @@
+.gitignore
+README.md
+analysis_options.yaml
+doc/Addressable.md
+doc/Bar.md
+doc/BarApi.md
+doc/BarCreate.md
+doc/BarRef.md
+doc/BarRefOrValue.md
+doc/Entity.md
+doc/EntityRef.md
+doc/Extensible.md
+doc/Foo.md
+doc/FooApi.md
+doc/FooRef.md
+doc/FooRefOrValue.md
+doc/Pasta.md
+doc/Pizza.md
+doc/PizzaSpeziale.md
+lib/openapi.dart
+lib/src/api.dart
+lib/src/api/bar_api.dart
+lib/src/api/foo_api.dart
+lib/src/api_util.dart
+lib/src/auth/api_key_auth.dart
+lib/src/auth/auth.dart
+lib/src/auth/basic_auth.dart
+lib/src/auth/bearer_auth.dart
+lib/src/auth/oauth.dart
+lib/src/date_serializer.dart
+lib/src/model/addressable.dart
+lib/src/model/bar.dart
+lib/src/model/bar_create.dart
+lib/src/model/bar_ref.dart
+lib/src/model/bar_ref_or_value.dart
+lib/src/model/date.dart
+lib/src/model/entity.dart
+lib/src/model/entity_ref.dart
+lib/src/model/extensible.dart
+lib/src/model/foo.dart
+lib/src/model/foo_ref.dart
+lib/src/model/foo_ref_or_value.dart
+lib/src/model/pasta.dart
+lib/src/model/pizza.dart
+lib/src/model/pizza_speziale.dart
+lib/src/serializers.dart
+pubspec.yaml
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator/VERSION b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator/VERSION
new file mode 100644
index 0000000000000000000000000000000000000000..66672d4e9d31378b298e49f1b38a028b2afe48ac
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/.openapi-generator/VERSION
@@ -0,0 +1 @@
+6.1.0-SNAPSHOT
\ No newline at end of file
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/README.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..6a3fea771a123509088413e45eda4c94799b0020
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/README.md
@@ -0,0 +1,99 @@
+# openapi (EXPERIMENTAL)
+This tests for a oneOf interface representation
+
+
+This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
+
+- API version: 0.0.1
+- Build package: org.openapitools.codegen.languages.DartDioClientCodegen
+
+## Requirements
+
+* Dart 2.12.0 or later OR Flutter 1.26.0 or later
+* Dio 4.0.0+
+
+## Installation & Usage
+
+### pub.dev
+To use the package from [pub.dev](https://pub.dev), please include the following in pubspec.yaml
+```yaml
+dependencies:
+  openapi: 1.0.0
+```
+
+### Github
+If this Dart package is published to Github, please include the following in pubspec.yaml
+```yaml
+dependencies:
+  openapi:
+    git:
+      url: https://github.com/GIT_USER_ID/GIT_REPO_ID.git
+      #ref: main
+```
+
+### Local development
+To use the package from your local drive, please include the following in pubspec.yaml
+```yaml
+dependencies:
+  openapi:
+    path: /path/to/openapi
+```
+
+## Getting Started
+
+Please follow the [installation procedure](#installation--usage) and then run the following:
+
+```dart
+import 'package:openapi/openapi.dart';
+
+
+final api = Openapi().getBarApi();
+final BarCreate barCreate = ; // BarCreate | 
+
+try {
+    final response = await api.createBar(barCreate);
+    print(response);
+} catch on DioError (e) {
+    print("Exception when calling BarApi->createBar: $e\n");
+}
+
+```
+
+## Documentation for API Endpoints
+
+All URIs are relative to *http://localhost:8080*
+
+Class | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+[*BarApi*](doc/BarApi.md) | [**createBar**](doc/BarApi.md#createbar) | **POST** /bar | Create a Bar
+[*FooApi*](doc/FooApi.md) | [**createFoo**](doc/FooApi.md#createfoo) | **POST** /foo | Create a Foo
+[*FooApi*](doc/FooApi.md) | [**getAllFoos**](doc/FooApi.md#getallfoos) | **GET** /foo | GET all Foos
+
+
+## Documentation For Models
+
+ - [Addressable](doc/Addressable.md)
+ - [Bar](doc/Bar.md)
+ - [BarCreate](doc/BarCreate.md)
+ - [BarRef](doc/BarRef.md)
+ - [BarRefOrValue](doc/BarRefOrValue.md)
+ - [Entity](doc/Entity.md)
+ - [EntityRef](doc/EntityRef.md)
+ - [Extensible](doc/Extensible.md)
+ - [Foo](doc/Foo.md)
+ - [FooRef](doc/FooRef.md)
+ - [FooRefOrValue](doc/FooRefOrValue.md)
+ - [Pasta](doc/Pasta.md)
+ - [Pizza](doc/Pizza.md)
+ - [PizzaSpeziale](doc/PizzaSpeziale.md)
+
+
+## Documentation For Authorization
+
+ All endpoints do not require authorization.
+
+
+## Author
+
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/analysis_options.yaml b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/analysis_options.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..a611887d3acfe1fdfd0ad16005f9e675d3583ff0
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/analysis_options.yaml
@@ -0,0 +1,9 @@
+analyzer:
+  language:
+    strict-inference: true
+    strict-raw-types: true
+  strong-mode:
+    implicit-dynamic: false
+    implicit-casts: false
+  exclude:
+    - test/*.dart
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Addressable.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Addressable.md
new file mode 100644
index 0000000000000000000000000000000000000000..0fcd81b80382aadb637141c763ca3d1ab3c3d309
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Addressable.md
@@ -0,0 +1,16 @@
+# openapi.model.Addressable
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Bar.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Bar.md
new file mode 100644
index 0000000000000000000000000000000000000000..4cccc863a4893fd56fb934090875fa57707ed09f
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Bar.md
@@ -0,0 +1,22 @@
+# openapi.model.Bar
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**id** | **String** |  | 
+**barPropA** | **String** |  | [optional] 
+**fooPropB** | **String** |  | [optional] 
+**foo** | [**FooRefOrValue**](FooRefOrValue.md) |  | [optional] 
+**href** | **String** | Hyperlink reference | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarApi.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarApi.md
new file mode 100644
index 0000000000000000000000000000000000000000..3ef168ecf34b313d86f5db0a9b7682877fba270e
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarApi.md
@@ -0,0 +1,55 @@
+# openapi.api.BarApi
+
+## Load the API package
+```dart
+import 'package:openapi/api.dart';
+```
+
+All URIs are relative to *http://localhost:8080*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**createBar**](BarApi.md#createbar) | **POST** /bar | Create a Bar
+
+
+# **createBar**
+> Bar createBar(barCreate)
+
+Create a Bar
+
+### Example
+```dart
+import 'package:openapi/api.dart';
+
+final api = Openapi().getBarApi();
+final BarCreate barCreate = ; // BarCreate | 
+
+try {
+    final response = api.createBar(barCreate);
+    print(response);
+} catch on DioError (e) {
+    print('Exception when calling BarApi->createBar: $e\n');
+}
+```
+
+### Parameters
+
+Name | Type | Description  | Notes
+------------- | ------------- | ------------- | -------------
+ **barCreate** | [**BarCreate**](BarCreate.md)|  | 
+
+### Return type
+
+[**Bar**](Bar.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarCreate.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarCreate.md
new file mode 100644
index 0000000000000000000000000000000000000000..c0b4ba6edc9a15a3076b47543e10394d7ffaf26e
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarCreate.md
@@ -0,0 +1,22 @@
+# openapi.model.BarCreate
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**barPropA** | **String** |  | [optional] 
+**fooPropB** | **String** |  | [optional] 
+**foo** | [**FooRefOrValue**](FooRefOrValue.md) |  | [optional] 
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarRef.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarRef.md
new file mode 100644
index 0000000000000000000000000000000000000000..949695f4d36fe91808817e6c879f5c35f3e2c379
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarRef.md
@@ -0,0 +1,19 @@
+# openapi.model.BarRef
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarRefOrValue.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarRefOrValue.md
new file mode 100644
index 0000000000000000000000000000000000000000..9dafa2d6b220275818607a693ecd9d50f5329054
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/BarRefOrValue.md
@@ -0,0 +1,19 @@
+# openapi.model.BarRefOrValue
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Entity.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Entity.md
new file mode 100644
index 0000000000000000000000000000000000000000..5ba2144b44fe51d0055b07a0e697f95d4e96988c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Entity.md
@@ -0,0 +1,19 @@
+# openapi.model.Entity
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/EntityRef.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/EntityRef.md
new file mode 100644
index 0000000000000000000000000000000000000000..80eae55f4145573bd8b9494a4b28cdbcae789837
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/EntityRef.md
@@ -0,0 +1,21 @@
+# openapi.model.EntityRef
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**name** | **String** | Name of the related entity. | [optional] 
+**atReferredType** | **String** | The actual type of the target instance when needed for disambiguation. | [optional] 
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Extensible.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Extensible.md
new file mode 100644
index 0000000000000000000000000000000000000000..7a781e578ea49b0a989964c24b6347bde3ab1621
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Extensible.md
@@ -0,0 +1,17 @@
+# openapi.model.Extensible
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Foo.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Foo.md
new file mode 100644
index 0000000000000000000000000000000000000000..2627691fefe5cd6f8b60c3312fc2103fd03974dd
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Foo.md
@@ -0,0 +1,21 @@
+# openapi.model.Foo
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**fooPropA** | **String** |  | [optional] 
+**fooPropB** | **String** |  | [optional] 
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooApi.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooApi.md
new file mode 100644
index 0000000000000000000000000000000000000000..9e8990ebb8b3b264064dba8f30b75ca84604ab09
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooApi.md
@@ -0,0 +1,93 @@
+# openapi.api.FooApi
+
+## Load the API package
+```dart
+import 'package:openapi/api.dart';
+```
+
+All URIs are relative to *http://localhost:8080*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**createFoo**](FooApi.md#createfoo) | **POST** /foo | Create a Foo
+[**getAllFoos**](FooApi.md#getallfoos) | **GET** /foo | GET all Foos
+
+
+# **createFoo**
+> FooRefOrValue createFoo(foo)
+
+Create a Foo
+
+### Example
+```dart
+import 'package:openapi/api.dart';
+
+final api = Openapi().getFooApi();
+final Foo foo = ; // Foo | The Foo to be created
+
+try {
+    final response = api.createFoo(foo);
+    print(response);
+} catch on DioError (e) {
+    print('Exception when calling FooApi->createFoo: $e\n');
+}
+```
+
+### Parameters
+
+Name | Type | Description  | Notes
+------------- | ------------- | ------------- | -------------
+ **foo** | [**Foo**](Foo.md)| The Foo to be created | [optional] 
+
+### Return type
+
+[**FooRefOrValue**](FooRefOrValue.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: application/json;charset=utf-8
+ - **Accept**: application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **getAllFoos**
+> BuiltList<FooRefOrValue> getAllFoos()
+
+GET all Foos
+
+### Example
+```dart
+import 'package:openapi/api.dart';
+
+final api = Openapi().getFooApi();
+
+try {
+    final response = api.getAllFoos();
+    print(response);
+} catch on DioError (e) {
+    print('Exception when calling FooApi->getAllFoos: $e\n');
+}
+```
+
+### Parameters
+This endpoint does not need any parameter.
+
+### Return type
+
+[**BuiltList&lt;FooRefOrValue&gt;**](FooRefOrValue.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json;charset=utf-8
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooRef.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooRef.md
new file mode 100644
index 0000000000000000000000000000000000000000..68104b22729220a40c34a9d195ba35ce2e1f1bb0
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooRef.md
@@ -0,0 +1,20 @@
+# openapi.model.FooRef
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**foorefPropA** | **String** |  | [optional] 
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooRefOrValue.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooRefOrValue.md
new file mode 100644
index 0000000000000000000000000000000000000000..35e9fd114e1dad1b35c639f0224108c22e77855c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooRefOrValue.md
@@ -0,0 +1,19 @@
+# openapi.model.FooRefOrValue
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooRefOrValueWithProperties.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooRefOrValueWithProperties.md
new file mode 100644
index 0000000000000000000000000000000000000000..05aa2b0bbc1cdd8bcf43ea3fe18582f3fea67c77
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/FooRefOrValueWithProperties.md
@@ -0,0 +1,19 @@
+# openapi.model.FooRefOrValueWithProperties
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Pasta.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Pasta.md
new file mode 100644
index 0000000000000000000000000000000000000000..034ff420d323f5a68d074a3dbfbc2c68796952d3
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Pasta.md
@@ -0,0 +1,20 @@
+# openapi.model.Pasta
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**vendor** | **String** |  | [optional] 
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Pizza.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Pizza.md
new file mode 100644
index 0000000000000000000000000000000000000000..e4b040a6a79c20dfd9cadbace87bf546af56e3d0
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/Pizza.md
@@ -0,0 +1,20 @@
+# openapi.model.Pizza
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**pizzaSize** | **num** |  | [optional] 
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/PizzaSpeziale.md b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/PizzaSpeziale.md
new file mode 100644
index 0000000000000000000000000000000000000000..e1d8434c077d381c60f5c3f9f6e91eaf17c340b0
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/doc/PizzaSpeziale.md
@@ -0,0 +1,20 @@
+# openapi.model.PizzaSpeziale
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**toppings** | **String** |  | [optional] 
+**href** | **String** | Hyperlink reference | [optional] 
+**id** | **String** | unique identifier | [optional] 
+**atSchemaLocation** | **String** | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional] 
+**atBaseType** | **String** | When sub-classing, this defines the super-class | [optional] 
+**atType** | **String** | When sub-classing, this defines the sub-class Extensible name | 
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/openapi.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/openapi.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ea87a7cb4761acd0c70ac915b957477d56d42994
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/openapi.dart
@@ -0,0 +1,28 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+export 'package:openapi/src/api.dart';
+export 'package:openapi/src/auth/api_key_auth.dart';
+export 'package:openapi/src/auth/basic_auth.dart';
+export 'package:openapi/src/auth/oauth.dart';
+export 'package:openapi/src/serializers.dart';
+export 'package:openapi/src/model/date.dart';
+
+export 'package:openapi/src/api/bar_api.dart';
+export 'package:openapi/src/api/foo_api.dart';
+
+export 'package:openapi/src/model/addressable.dart';
+export 'package:openapi/src/model/bar.dart';
+export 'package:openapi/src/model/bar_create.dart';
+export 'package:openapi/src/model/bar_ref.dart';
+export 'package:openapi/src/model/bar_ref_or_value.dart';
+export 'package:openapi/src/model/entity.dart';
+export 'package:openapi/src/model/entity_ref.dart';
+export 'package:openapi/src/model/extensible.dart';
+export 'package:openapi/src/model/foo.dart';
+export 'package:openapi/src/model/foo_ref.dart';
+export 'package:openapi/src/model/foo_ref_or_value.dart';
+export 'package:openapi/src/model/pasta.dart';
+export 'package:openapi/src/model/pizza.dart';
+export 'package:openapi/src/model/pizza_speziale.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0bb368eace083faa8a5362dcb0e9eb5da94118cb
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api.dart
@@ -0,0 +1,80 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+import 'package:built_value/serializer.dart';
+import 'package:openapi/src/serializers.dart';
+import 'package:openapi/src/auth/api_key_auth.dart';
+import 'package:openapi/src/auth/basic_auth.dart';
+import 'package:openapi/src/auth/bearer_auth.dart';
+import 'package:openapi/src/auth/oauth.dart';
+import 'package:openapi/src/api/bar_api.dart';
+import 'package:openapi/src/api/foo_api.dart';
+
+class Openapi {
+  static const String basePath = r'http://localhost:8080';
+
+  final Dio dio;
+  final Serializers serializers;
+
+  Openapi({
+    Dio? dio,
+    Serializers? serializers,
+    String? basePathOverride,
+    List<Interceptor>? interceptors,
+  })  : this.serializers = serializers ?? standardSerializers,
+        this.dio = dio ??
+            Dio(BaseOptions(
+              baseUrl: basePathOverride ?? basePath,
+              connectTimeout: 5000,
+              receiveTimeout: 3000,
+            )) {
+    if (interceptors == null) {
+      this.dio.interceptors.addAll([
+        OAuthInterceptor(),
+        BasicAuthInterceptor(),
+        BearerAuthInterceptor(),
+        ApiKeyAuthInterceptor(),
+      ]);
+    } else {
+      this.dio.interceptors.addAll(interceptors);
+    }
+  }
+
+  void setOAuthToken(String name, String token) {
+    if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens[name] = token;
+    }
+  }
+
+  void setBearerAuth(String name, String token) {
+    if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token;
+    }
+  }
+
+  void setBasicAuth(String name, String username, String password) {
+    if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password);
+    }
+  }
+
+  void setApiKey(String name, String apiKey) {
+    if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
+    }
+  }
+
+  /// Get BarApi instance, base route and serializer can be overridden by a given but be careful,
+  /// by doing that all interceptors will not be executed
+  BarApi getBarApi() {
+    return BarApi(dio, serializers);
+  }
+
+  /// Get FooApi instance, base route and serializer can be overridden by a given but be careful,
+  /// by doing that all interceptors will not be executed
+  FooApi getFooApi() {
+    return FooApi(dio, serializers);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api/bar_api.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api/bar_api.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4afe604a557834ce6388d5ee5c6b036507cb91cb
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api/bar_api.dart
@@ -0,0 +1,114 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'dart:async';
+
+import 'package:built_value/serializer.dart';
+import 'package:dio/dio.dart';
+
+import 'package:openapi/src/model/bar.dart';
+import 'package:openapi/src/model/bar_create.dart';
+
+class BarApi {
+
+  final Dio _dio;
+
+  final Serializers _serializers;
+
+  const BarApi(this._dio, this._serializers);
+
+  /// Create a Bar
+  /// 
+  ///
+  /// Parameters:
+  /// * [barCreate] 
+  /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
+  /// * [headers] - Can be used to add additional headers to the request
+  /// * [extras] - Can be used to add flags to the request
+  /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
+  /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
+  /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
+  ///
+  /// Returns a [Future] containing a [Response] with a [Bar] as data
+  /// Throws [DioError] if API call or serialization fails
+  Future<Response<Bar>> createBar({ 
+    required BarCreate barCreate,
+    CancelToken? cancelToken,
+    Map<String, dynamic>? headers,
+    Map<String, dynamic>? extra,
+    ValidateStatus? validateStatus,
+    ProgressCallback? onSendProgress,
+    ProgressCallback? onReceiveProgress,
+  }) async {
+    final _path = r'/bar';
+    final _options = Options(
+      method: r'POST',
+      headers: <String, dynamic>{
+        ...?headers,
+      },
+      extra: <String, dynamic>{
+        'secure': <Map<String, String>>[],
+        ...?extra,
+      },
+      contentType: 'application/json',
+      validateStatus: validateStatus,
+    );
+
+    dynamic _bodyData;
+
+    try {
+      const _type = FullType(BarCreate);
+      _bodyData = _serializers.serialize(barCreate, specifiedType: _type);
+
+    } catch(error, stackTrace) {
+      throw DioError(
+         requestOptions: _options.compose(
+          _dio.options,
+          _path,
+        ),
+        type: DioErrorType.other,
+        error: error,
+      )..stackTrace = stackTrace;
+    }
+
+    final _response = await _dio.request<Object>(
+      _path,
+      data: _bodyData,
+      options: _options,
+      cancelToken: cancelToken,
+      onSendProgress: onSendProgress,
+      onReceiveProgress: onReceiveProgress,
+    );
+
+    Bar _responseData;
+
+    try {
+      const _responseType = FullType(Bar);
+      _responseData = _serializers.deserialize(
+        _response.data!,
+        specifiedType: _responseType,
+      ) as Bar;
+
+    } catch (error, stackTrace) {
+      throw DioError(
+        requestOptions: _response.requestOptions,
+        response: _response,
+        type: DioErrorType.other,
+        error: error,
+      )..stackTrace = stackTrace;
+    }
+
+    return Response<Bar>(
+      data: _responseData,
+      headers: _response.headers,
+      isRedirect: _response.isRedirect,
+      requestOptions: _response.requestOptions,
+      redirects: _response.redirects,
+      statusCode: _response.statusCode,
+      statusMessage: _response.statusMessage,
+      extra: _response.extra,
+    );
+  }
+
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api/foo_api.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api/foo_api.dart
new file mode 100644
index 0000000000000000000000000000000000000000..232392c76a70704f36c5fa0c73c3cf6ec97dcb08
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api/foo_api.dart
@@ -0,0 +1,187 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'dart:async';
+
+import 'package:built_value/serializer.dart';
+import 'package:dio/dio.dart';
+
+import 'package:built_collection/built_collection.dart';
+import 'package:openapi/src/model/foo.dart';
+import 'package:openapi/src/model/foo_ref_or_value.dart';
+
+class FooApi {
+
+  final Dio _dio;
+
+  final Serializers _serializers;
+
+  const FooApi(this._dio, this._serializers);
+
+  /// Create a Foo
+  /// 
+  ///
+  /// Parameters:
+  /// * [foo] - The Foo to be created
+  /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
+  /// * [headers] - Can be used to add additional headers to the request
+  /// * [extras] - Can be used to add flags to the request
+  /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
+  /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
+  /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
+  ///
+  /// Returns a [Future] containing a [Response] with a [FooRefOrValue] as data
+  /// Throws [DioError] if API call or serialization fails
+  Future<Response<FooRefOrValue>> createFoo({ 
+    Foo? foo,
+    CancelToken? cancelToken,
+    Map<String, dynamic>? headers,
+    Map<String, dynamic>? extra,
+    ValidateStatus? validateStatus,
+    ProgressCallback? onSendProgress,
+    ProgressCallback? onReceiveProgress,
+  }) async {
+    final _path = r'/foo';
+    final _options = Options(
+      method: r'POST',
+      headers: <String, dynamic>{
+        ...?headers,
+      },
+      extra: <String, dynamic>{
+        'secure': <Map<String, String>>[],
+        ...?extra,
+      },
+      contentType: 'application/json;charset=utf-8',
+      validateStatus: validateStatus,
+    );
+
+    dynamic _bodyData;
+
+    try {
+      const _type = FullType(Foo);
+      _bodyData = foo == null ? null : _serializers.serialize(foo, specifiedType: _type);
+
+    } catch(error, stackTrace) {
+      throw DioError(
+         requestOptions: _options.compose(
+          _dio.options,
+          _path,
+        ),
+        type: DioErrorType.other,
+        error: error,
+      )..stackTrace = stackTrace;
+    }
+
+    final _response = await _dio.request<Object>(
+      _path,
+      data: _bodyData,
+      options: _options,
+      cancelToken: cancelToken,
+      onSendProgress: onSendProgress,
+      onReceiveProgress: onReceiveProgress,
+    );
+
+    FooRefOrValue _responseData;
+
+    try {
+      const _responseType = FullType(FooRefOrValue);
+      _responseData = _serializers.deserialize(
+        _response.data!,
+        specifiedType: _responseType,
+      ) as FooRefOrValue;
+
+    } catch (error, stackTrace) {
+      throw DioError(
+        requestOptions: _response.requestOptions,
+        response: _response,
+        type: DioErrorType.other,
+        error: error,
+      )..stackTrace = stackTrace;
+    }
+
+    return Response<FooRefOrValue>(
+      data: _responseData,
+      headers: _response.headers,
+      isRedirect: _response.isRedirect,
+      requestOptions: _response.requestOptions,
+      redirects: _response.redirects,
+      statusCode: _response.statusCode,
+      statusMessage: _response.statusMessage,
+      extra: _response.extra,
+    );
+  }
+
+  /// GET all Foos
+  /// 
+  ///
+  /// Parameters:
+  /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
+  /// * [headers] - Can be used to add additional headers to the request
+  /// * [extras] - Can be used to add flags to the request
+  /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
+  /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
+  /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
+  ///
+  /// Returns a [Future] containing a [Response] with a [BuiltList<FooRefOrValue>] as data
+  /// Throws [DioError] if API call or serialization fails
+  Future<Response<BuiltList<FooRefOrValue>>> getAllFoos({ 
+    CancelToken? cancelToken,
+    Map<String, dynamic>? headers,
+    Map<String, dynamic>? extra,
+    ValidateStatus? validateStatus,
+    ProgressCallback? onSendProgress,
+    ProgressCallback? onReceiveProgress,
+  }) async {
+    final _path = r'/foo';
+    final _options = Options(
+      method: r'GET',
+      headers: <String, dynamic>{
+        ...?headers,
+      },
+      extra: <String, dynamic>{
+        'secure': <Map<String, String>>[],
+        ...?extra,
+      },
+      validateStatus: validateStatus,
+    );
+
+    final _response = await _dio.request<Object>(
+      _path,
+      options: _options,
+      cancelToken: cancelToken,
+      onSendProgress: onSendProgress,
+      onReceiveProgress: onReceiveProgress,
+    );
+
+    BuiltList<FooRefOrValue> _responseData;
+
+    try {
+      const _responseType = FullType(BuiltList, [FullType(FooRefOrValue)]);
+      _responseData = _serializers.deserialize(
+        _response.data!,
+        specifiedType: _responseType,
+      ) as BuiltList<FooRefOrValue>;
+
+    } catch (error, stackTrace) {
+      throw DioError(
+        requestOptions: _response.requestOptions,
+        response: _response,
+        type: DioErrorType.other,
+        error: error,
+      )..stackTrace = stackTrace;
+    }
+
+    return Response<BuiltList<FooRefOrValue>>(
+      data: _responseData,
+      headers: _response.headers,
+      isRedirect: _response.isRedirect,
+      requestOptions: _response.requestOptions,
+      redirects: _response.redirects,
+      statusCode: _response.statusCode,
+      statusMessage: _response.statusMessage,
+      extra: _response.extra,
+    );
+  }
+
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api_util.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api_util.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ed3bb12f25b81a6d266b1a4c0070f52d8d67ef25
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/api_util.dart
@@ -0,0 +1,77 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'dart:convert';
+import 'dart:typed_data';
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/serializer.dart';
+import 'package:dio/dio.dart';
+
+/// Format the given form parameter object into something that Dio can handle.
+/// Returns primitive or String.
+/// Returns List/Map if the value is BuildList/BuiltMap.
+dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) {
+  if (value == null) {
+    return '';
+  }
+  if (value is String || value is num || value is bool) {
+    return value;
+  }
+  final serialized = serializers.serialize(
+    value as Object,
+    specifiedType: type,
+  );
+  if (serialized is String) {
+    return serialized;
+  }
+  if (value is BuiltList || value is BuiltSet || value is BuiltMap) {
+    return serialized;
+  }
+  return json.encode(serialized);
+}
+
+dynamic encodeQueryParameter(
+  Serializers serializers,
+  dynamic value,
+  FullType type,
+) {
+  if (value == null) {
+    return '';
+  }
+  if (value is String || value is num || value is bool) {
+    return value;
+  }
+  if (value is Uint8List) {
+    // Currently not sure how to serialize this
+    return value;
+  }
+  final serialized = serializers.serialize(
+    value as Object,
+    specifiedType: type,
+  );
+  if (serialized == null) {
+    return '';
+  }
+  if (serialized is String) {
+    return serialized;
+  }
+  return serialized;
+}
+
+ListParam<Object?> encodeCollectionQueryParameter<T>(
+  Serializers serializers,
+  dynamic value,
+  FullType type, {
+  ListFormat format = ListFormat.multi,
+}) {
+  final serialized = serializers.serialize(
+    value as Object,
+    specifiedType: type,
+  );
+  if (value is BuiltList<T> || value is BuiltSet<T>) {
+    return ListParam(List.of((serialized as Iterable<Object?>).cast()), format);
+  }
+  throw ArgumentError('Invalid value passed to encodeCollectionQueryParameter');
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/api_key_auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/api_key_auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ee16e3f0f92fd4e87d97ec6e5dc9ad3b0519fae6
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/api_key_auth.dart
@@ -0,0 +1,30 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class ApiKeyAuthInterceptor extends AuthInterceptor {
+  final Map<String, String> apiKeys = {};
+
+  @override
+  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
+    final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'apiKey');
+    for (final info in authInfo) {
+      final authName = info['name'] as String;
+      final authKeyName = info['keyName'] as String;
+      final authWhere = info['where'] as String;
+      final apiKey = apiKeys[authName];
+      if (apiKey != null) {
+        if (authWhere == 'query') {
+          options.queryParameters[authKeyName] = apiKey;
+        } else {
+          options.headers[authKeyName] = apiKey;
+        }
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f7ae9bf3f11eb909e6d00b2087f2c17a6a260478
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/auth.dart
@@ -0,0 +1,18 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+
+abstract class AuthInterceptor extends Interceptor {
+  /// Get auth information on given route for the given type.
+  /// Can return an empty list if type is not present on auth data or
+  /// if route doesn't need authentication.
+  List<Map<String, String>> getAuthInfo(RequestOptions route, bool Function(Map<String, String> secure) handles) {
+    if (route.extra.containsKey('secure')) {
+      final auth = route.extra['secure'] as List<Map<String, String>>;
+      return auth.where((secure) => handles(secure)).toList();
+    }
+    return [];
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/basic_auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/basic_auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b6e6dce04f9c4ff33478271ba7994f0e22af35a7
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/basic_auth.dart
@@ -0,0 +1,37 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'dart:convert';
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class BasicAuthInfo {
+  final String username;
+  final String password;
+
+  const BasicAuthInfo(this.username, this.password);
+}
+
+class BasicAuthInterceptor extends AuthInterceptor {
+  final Map<String, BasicAuthInfo> authInfo = {};
+
+  @override
+  void onRequest(
+    RequestOptions options,
+    RequestInterceptorHandler handler,
+  ) {
+    final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
+    for (final info in metadataAuthInfo) {
+      final authName = info['name'] as String;
+      final basicAuthInfo = authInfo[authName];
+      if (basicAuthInfo != null) {
+        final basicAuth = 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}';
+        options.headers['Authorization'] = basicAuth;
+        break;
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/bearer_auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/bearer_auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1d4402b376c0a794ada1b4756ed08cd247fb6564
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/bearer_auth.dart
@@ -0,0 +1,26 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class BearerAuthInterceptor extends AuthInterceptor {
+  final Map<String, String> tokens = {};
+
+  @override
+  void onRequest(
+    RequestOptions options,
+    RequestInterceptorHandler handler,
+  ) {
+    final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
+    for (final info in authInfo) {
+      final token = tokens[info['name']];
+      if (token != null) {
+        options.headers['Authorization'] = 'Bearer ${token}';
+        break;
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/oauth.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/oauth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..337cf762b0ce77ccb2ed30882ea66e5abe84d354
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/auth/oauth.dart
@@ -0,0 +1,26 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class OAuthInterceptor extends AuthInterceptor {
+  final Map<String, String> tokens = {};
+
+  @override
+  void onRequest(
+    RequestOptions options,
+    RequestInterceptorHandler handler,
+  ) {
+    final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'oauth' || secure['type'] == 'oauth2');
+    for (final info in authInfo) {
+      final token = tokens[info['name']];
+      if (token != null) {
+        options.headers['Authorization'] = 'Bearer ${token}';
+        break;
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/date_serializer.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/date_serializer.dart
new file mode 100644
index 0000000000000000000000000000000000000000..db3c5c437db10d074eb892e190d01f1874c3ce7c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/date_serializer.dart
@@ -0,0 +1,31 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/serializer.dart';
+import 'package:openapi/src/model/date.dart';
+
+class DateSerializer implements PrimitiveSerializer<Date> {
+
+  const DateSerializer();
+
+  @override
+  Iterable<Type> get types => BuiltList.of([Date]);
+
+  @override
+  String get wireName => 'Date';
+
+  @override
+  Date deserialize(Serializers serializers, Object serialized,
+      {FullType specifiedType = FullType.unspecified}) {
+    final parsed = DateTime.parse(serialized as String);
+    return Date(parsed.year, parsed.month, parsed.day);
+  }
+
+  @override
+  Object serialize(Serializers serializers, Date date,
+      {FullType specifiedType = FullType.unspecified}) {
+    return date.toString();
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/addressable.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/addressable.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e0311b6595b1cb6084f38d2310c26b7fd88e3978
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/addressable.dart
@@ -0,0 +1,161 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'addressable.g.dart';
+
+/// Base schema for adressable entities
+///
+/// Properties:
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+@BuiltValue(instantiable: false)
+abstract class Addressable  {
+  /// Hyperlink reference
+  @BuiltValueField(wireName: r'href')
+  String? get href;
+
+  /// unique identifier
+  @BuiltValueField(wireName: r'id')
+  String? get id;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Addressable> get serializer => _$AddressableSerializer();
+}
+
+class _$AddressableSerializer implements PrimitiveSerializer<Addressable> {
+  @override
+  final Iterable<Type> types = const [Addressable];
+
+  @override
+  final String wireName = r'Addressable';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Addressable object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Addressable object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  @override
+  Addressable deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.deserialize(serialized, specifiedType: FullType($Addressable)) as $Addressable;
+  }
+}
+
+/// a concrete implementation of [Addressable], since [Addressable] is not instantiable
+@BuiltValue(instantiable: true)
+abstract class $Addressable implements Addressable, Built<$Addressable, $AddressableBuilder> {
+  $Addressable._();
+
+  factory $Addressable([void Function($AddressableBuilder)? updates]) = _$$Addressable;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults($AddressableBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<$Addressable> get serializer => _$$AddressableSerializer();
+}
+
+class _$$AddressableSerializer implements PrimitiveSerializer<$Addressable> {
+  @override
+  final Iterable<Type> types = const [$Addressable, _$$Addressable];
+
+  @override
+  final String wireName = r'$Addressable';
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    $Addressable object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.serialize(object, specifiedType: FullType(Addressable))!;
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required AddressableBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  $Addressable deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = $AddressableBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9c52802b84aa2c0b116fbd65c50f897b9cc9c3cc
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar.dart
@@ -0,0 +1,221 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/foo_ref_or_value.dart';
+import 'package:openapi/src/model/entity.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'bar.g.dart';
+
+/// Bar
+///
+/// Properties:
+/// * [id] 
+/// * [barPropA] 
+/// * [fooPropB] 
+/// * [foo] 
+/// * [href] - Hyperlink reference
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue()
+abstract class Bar implements Entity, Built<Bar, BarBuilder> {
+  @BuiltValueField(wireName: r'foo')
+  FooRefOrValue? get foo;
+
+  @BuiltValueField(wireName: r'fooPropB')
+  String? get fooPropB;
+
+  @BuiltValueField(wireName: r'barPropA')
+  String? get barPropA;
+
+  static const String discriminatorFieldName = r'atType';
+
+  Bar._();
+
+  factory Bar([void updates(BarBuilder b)]) = _$Bar;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(BarBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Bar> get serializer => _$BarSerializer();
+}
+
+class _$BarSerializer implements PrimitiveSerializer<Bar> {
+  @override
+  final Iterable<Type> types = const [Bar, _$Bar];
+
+  @override
+  final String wireName = r'Bar';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Bar object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.foo != null) {
+      yield r'foo';
+      yield serializers.serialize(
+        object.foo,
+        specifiedType: const FullType(FooRefOrValue),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.fooPropB != null) {
+      yield r'fooPropB';
+      yield serializers.serialize(
+        object.fooPropB,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+    if (object.barPropA != null) {
+      yield r'barPropA';
+      yield serializers.serialize(
+        object.barPropA,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Bar object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required BarBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'foo':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(FooRefOrValue),
+          ) as FooRefOrValue;
+          result.foo.replace(valueDes);
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'fooPropB':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.fooPropB = valueDes;
+          break;
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        case r'barPropA':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.barPropA = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  Bar deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = BarBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar_create.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar_create.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ebbce3577828e7e5c2d21f474f591dc0052f3bc1
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar_create.dart
@@ -0,0 +1,221 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/foo_ref_or_value.dart';
+import 'package:openapi/src/model/entity.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'bar_create.g.dart';
+
+/// BarCreate
+///
+/// Properties:
+/// * [barPropA] 
+/// * [fooPropB] 
+/// * [foo] 
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue()
+abstract class BarCreate implements Entity, Built<BarCreate, BarCreateBuilder> {
+  @BuiltValueField(wireName: r'foo')
+  FooRefOrValue? get foo;
+
+  @BuiltValueField(wireName: r'fooPropB')
+  String? get fooPropB;
+
+  @BuiltValueField(wireName: r'barPropA')
+  String? get barPropA;
+
+  static const String discriminatorFieldName = r'atType';
+
+  BarCreate._();
+
+  factory BarCreate([void updates(BarCreateBuilder b)]) = _$BarCreate;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(BarCreateBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<BarCreate> get serializer => _$BarCreateSerializer();
+}
+
+class _$BarCreateSerializer implements PrimitiveSerializer<BarCreate> {
+  @override
+  final Iterable<Type> types = const [BarCreate, _$BarCreate];
+
+  @override
+  final String wireName = r'BarCreate';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    BarCreate object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.foo != null) {
+      yield r'foo';
+      yield serializers.serialize(
+        object.foo,
+        specifiedType: const FullType(FooRefOrValue),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.fooPropB != null) {
+      yield r'fooPropB';
+      yield serializers.serialize(
+        object.fooPropB,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+    if (object.barPropA != null) {
+      yield r'barPropA';
+      yield serializers.serialize(
+        object.barPropA,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    BarCreate object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required BarCreateBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'foo':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(FooRefOrValue),
+          ) as FooRefOrValue;
+          result.foo.replace(valueDes);
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'fooPropB':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.fooPropB = valueDes;
+          break;
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        case r'barPropA':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.barPropA = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  BarCreate deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = BarCreateBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar_ref.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar_ref.dart
new file mode 100644
index 0000000000000000000000000000000000000000..bb4965bea821ff23f5a2ec9636d0760e1ba7c0d2
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar_ref.dart
@@ -0,0 +1,194 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/entity_ref.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'bar_ref.g.dart';
+
+/// BarRef
+///
+/// Properties:
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue()
+abstract class BarRef implements EntityRef, Built<BarRef, BarRefBuilder> {
+  static const String discriminatorFieldName = r'atType';
+
+  BarRef._();
+
+  factory BarRef([void updates(BarRefBuilder b)]) = _$BarRef;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(BarRefBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<BarRef> get serializer => _$BarRefSerializer();
+}
+
+class _$BarRefSerializer implements PrimitiveSerializer<BarRef> {
+  @override
+  final Iterable<Type> types = const [BarRef, _$BarRef];
+
+  @override
+  final String wireName = r'BarRef';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    BarRef object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atReferredType != null) {
+      yield r'@referredType';
+      yield serializers.serialize(
+        object.atReferredType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.name != null) {
+      yield r'name';
+      yield serializers.serialize(
+        object.name,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    BarRef object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required BarRefBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'@referredType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atReferredType = valueDes;
+          break;
+        case r'name':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.name = valueDes;
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  BarRef deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = BarRefBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar_ref_or_value.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar_ref_or_value.dart
new file mode 100644
index 0000000000000000000000000000000000000000..09d7b0b99c6e5a7b03205aae4c049509af36538c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/bar_ref_or_value.dart
@@ -0,0 +1,106 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/bar_ref.dart';
+import 'package:openapi/src/model/bar.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+import 'package:one_of/one_of.dart';
+
+part 'bar_ref_or_value.g.dart';
+
+/// BarRefOrValue
+///
+/// Properties:
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue()
+abstract class BarRefOrValue implements Built<BarRefOrValue, BarRefOrValueBuilder> {
+  /// One Of [Bar], [BarRef]
+  OneOf get oneOf;
+
+  static const String discriminatorFieldName = r'atType';
+
+  static const Map<String, Type> discriminatorMapping = {
+    r'Bar': Bar,
+    r'BarRef': BarRef,
+  };
+
+  BarRefOrValue._();
+
+  factory BarRefOrValue([void updates(BarRefOrValueBuilder b)]) = _$BarRefOrValue;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(BarRefOrValueBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<BarRefOrValue> get serializer => _$BarRefOrValueSerializer();
+}
+
+class _$BarRefOrValueSerializer implements PrimitiveSerializer<BarRefOrValue> {
+  @override
+  final Iterable<Type> types = const [BarRefOrValue, _$BarRefOrValue];
+
+  @override
+  final String wireName = r'BarRefOrValue';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    BarRefOrValue object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    BarRefOrValue object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final oneOf = object.oneOf;
+    return serializers.serialize(oneOf.value, specifiedType: FullType(oneOf.valueType))!;
+  }
+
+  @override
+  BarRefOrValue deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = BarRefOrValueBuilder();
+    Object? oneOfDataSrc;
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final discIndex = serializedList.indexOf(BarRefOrValue.discriminatorFieldName) + 1;
+    final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String;
+    oneOfDataSrc = serialized;
+    final oneOfTypes = [Bar, BarRef, ];
+    Object oneOfResult;
+    Type oneOfType;
+    switch (discValue) {
+      case 'Bar':
+        oneOfResult = serializers.deserialize(
+          oneOfDataSrc,
+          specifiedType: FullType(Bar),
+        ) as Bar;
+        oneOfType = Bar;
+        break;
+      case 'BarRef':
+        oneOfResult = serializers.deserialize(
+          oneOfDataSrc,
+          specifiedType: FullType(BarRef),
+        ) as BarRef;
+        oneOfType = BarRef;
+        break;
+      default:
+        throw UnsupportedError("Couldn't deserialize oneOf for the discriminator value: ${discValue}");
+    }
+    result.oneOf = OneOfDynamic(typeIndex: oneOfTypes.indexOf(oneOfType), types: oneOfTypes, value: oneOfResult);
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/date.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/date.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b21c7f544beefb379c4b64b464f02d42c8355cbe
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/date.dart
@@ -0,0 +1,70 @@
+/// A gregorian calendar date generated by
+/// OpenAPI generator to differentiate
+/// between [DateTime] and [Date] formats.
+class Date implements Comparable<Date> {
+  final int year;
+
+  /// January is 1.
+  final int month;
+
+  /// First day is 1.
+  final int day;
+
+  Date(this.year, this.month, this.day);
+
+  /// The current date
+  static Date now({bool utc = false}) {
+    var now = DateTime.now();
+    if (utc) {
+      now = now.toUtc();
+    }
+    return now.toDate();
+  }
+
+  /// Convert to a [DateTime].
+  DateTime toDateTime({bool utc = false}) {
+    if (utc) {
+      return DateTime.utc(year, month, day);
+    } else {
+      return DateTime(year, month, day);
+    }
+  }
+
+  @override
+  int compareTo(Date other) {
+    int d = year.compareTo(other.year);
+    if (d != 0) {
+      return d;
+    }
+    d = month.compareTo(other.month);
+    if (d != 0) {
+      return d;
+    }
+    return day.compareTo(other.day);
+  }
+
+  @override
+  bool operator ==(Object other) =>
+      identical(this, other) ||
+      other is Date &&
+          runtimeType == other.runtimeType &&
+          year == other.year &&
+          month == other.month &&
+          day == other.day;
+
+  @override
+  int get hashCode => year.hashCode ^ month.hashCode ^ day.hashCode;
+
+  @override
+  String toString() {
+    final yyyy = year.toString();
+    final mm = month.toString().padLeft(2, '0');
+    final dd = day.toString().padLeft(2, '0');
+
+    return '$yyyy-$mm-$dd';
+  }
+}
+
+extension DateTimeToDate on DateTime {
+  Date toDate() => Date(year, month, day);
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/entity.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/entity.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1a83a5d6b50a8c3b8b8218bcf1c2391382e5b68f
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/entity.dart
@@ -0,0 +1,251 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/extensible.dart';
+import 'package:openapi/src/model/pizza_speziale.dart';
+import 'package:openapi/src/model/foo.dart';
+import 'package:openapi/src/model/pizza.dart';
+import 'package:openapi/src/model/addressable.dart';
+import 'package:openapi/src/model/pasta.dart';
+import 'package:openapi/src/model/bar_create.dart';
+import 'package:openapi/src/model/bar.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'entity.g.dart';
+
+/// Entity
+///
+/// Properties:
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue(instantiable: false)
+abstract class Entity implements Addressable, Extensible {
+  static const String discriminatorFieldName = r'atType';
+
+  static const Map<String, Type> discriminatorMapping = {
+    r'Bar': Bar,
+    r'Bar_Create': BarCreate,
+    r'Foo': Foo,
+    r'Pasta': Pasta,
+    r'Pizza': Pizza,
+    r'PizzaSpeziale': PizzaSpeziale,
+  };
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Entity> get serializer => _$EntitySerializer();
+}
+
+class _$EntitySerializer implements PrimitiveSerializer<Entity> {
+  @override
+  final Iterable<Type> types = const [Entity];
+
+  @override
+  final String wireName = r'Entity';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Entity object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Entity object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    if (object is Bar) {
+      return serializers.serialize(object, specifiedType: FullType(Bar))!;
+    }
+    if (object is BarCreate) {
+      return serializers.serialize(object, specifiedType: FullType(BarCreate))!;
+    }
+    if (object is Foo) {
+      return serializers.serialize(object, specifiedType: FullType(Foo))!;
+    }
+    if (object is Pasta) {
+      return serializers.serialize(object, specifiedType: FullType(Pasta))!;
+    }
+    if (object is Pizza) {
+      return serializers.serialize(object, specifiedType: FullType(Pizza))!;
+    }
+    if (object is PizzaSpeziale) {
+      return serializers.serialize(object, specifiedType: FullType(PizzaSpeziale))!;
+    }
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  @override
+  Entity deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final discIndex = serializedList.indexOf(Entity.discriminatorFieldName) + 1;
+    final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String;
+    switch (discValue) {
+      case 'Bar':
+        return serializers.deserialize(serialized, specifiedType: FullType(Bar)) as Bar;
+      case 'Bar_Create':
+        return serializers.deserialize(serialized, specifiedType: FullType(BarCreate)) as BarCreate;
+      case 'Foo':
+        return serializers.deserialize(serialized, specifiedType: FullType(Foo)) as Foo;
+      case 'Pasta':
+        return serializers.deserialize(serialized, specifiedType: FullType(Pasta)) as Pasta;
+      case 'Pizza':
+        return serializers.deserialize(serialized, specifiedType: FullType(Pizza)) as Pizza;
+      case 'PizzaSpeziale':
+        return serializers.deserialize(serialized, specifiedType: FullType(PizzaSpeziale)) as PizzaSpeziale;
+      default:
+        return serializers.deserialize(serialized, specifiedType: FullType($Entity)) as $Entity;
+    }
+  }
+}
+
+/// a concrete implementation of [Entity], since [Entity] is not instantiable
+@BuiltValue(instantiable: true)
+abstract class $Entity implements Entity, Built<$Entity, $EntityBuilder> {
+  $Entity._();
+
+  factory $Entity([void Function($EntityBuilder)? updates]) = _$$Entity;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults($EntityBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<$Entity> get serializer => _$$EntitySerializer();
+}
+
+class _$$EntitySerializer implements PrimitiveSerializer<$Entity> {
+  @override
+  final Iterable<Type> types = const [$Entity, _$$Entity];
+
+  @override
+  final String wireName = r'$Entity';
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    $Entity object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.serialize(object, specifiedType: FullType(Entity))!;
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required EntityBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  $Entity deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = $EntityBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/entity_ref.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/entity_ref.dart
new file mode 100644
index 0000000000000000000000000000000000000000..278aa92276c8e0380e99a7a24ef528d3e1ae73c8
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/entity_ref.dart
@@ -0,0 +1,261 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/extensible.dart';
+import 'package:openapi/src/model/bar_ref.dart';
+import 'package:openapi/src/model/addressable.dart';
+import 'package:openapi/src/model/foo_ref.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'entity_ref.g.dart';
+
+/// Entity reference schema to be use for all entityRef class.
+///
+/// Properties:
+/// * [name] - Name of the related entity.
+/// * [atReferredType] - The actual type of the target instance when needed for disambiguation.
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue(instantiable: false)
+abstract class EntityRef implements Addressable, Extensible {
+  /// The actual type of the target instance when needed for disambiguation.
+  @BuiltValueField(wireName: r'@referredType')
+  String? get atReferredType;
+
+  /// Name of the related entity.
+  @BuiltValueField(wireName: r'name')
+  String? get name;
+
+  static const String discriminatorFieldName = r'atType';
+
+  static const Map<String, Type> discriminatorMapping = {
+    r'BarRef': BarRef,
+    r'FooRef': FooRef,
+  };
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<EntityRef> get serializer => _$EntityRefSerializer();
+}
+
+class _$EntityRefSerializer implements PrimitiveSerializer<EntityRef> {
+  @override
+  final Iterable<Type> types = const [EntityRef];
+
+  @override
+  final String wireName = r'EntityRef';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    EntityRef object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atReferredType != null) {
+      yield r'@referredType';
+      yield serializers.serialize(
+        object.atReferredType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.name != null) {
+      yield r'name';
+      yield serializers.serialize(
+        object.name,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    EntityRef object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    if (object is BarRef) {
+      return serializers.serialize(object, specifiedType: FullType(BarRef))!;
+    }
+    if (object is FooRef) {
+      return serializers.serialize(object, specifiedType: FullType(FooRef))!;
+    }
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  @override
+  EntityRef deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final discIndex = serializedList.indexOf(EntityRef.discriminatorFieldName) + 1;
+    final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String;
+    switch (discValue) {
+      case 'BarRef':
+        return serializers.deserialize(serialized, specifiedType: FullType(BarRef)) as BarRef;
+      case 'FooRef':
+        return serializers.deserialize(serialized, specifiedType: FullType(FooRef)) as FooRef;
+      default:
+        return serializers.deserialize(serialized, specifiedType: FullType($EntityRef)) as $EntityRef;
+    }
+  }
+}
+
+/// a concrete implementation of [EntityRef], since [EntityRef] is not instantiable
+@BuiltValue(instantiable: true)
+abstract class $EntityRef implements EntityRef, Built<$EntityRef, $EntityRefBuilder> {
+  $EntityRef._();
+
+  factory $EntityRef([void Function($EntityRefBuilder)? updates]) = _$$EntityRef;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults($EntityRefBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<$EntityRef> get serializer => _$$EntityRefSerializer();
+}
+
+class _$$EntityRefSerializer implements PrimitiveSerializer<$EntityRef> {
+  @override
+  final Iterable<Type> types = const [$EntityRef, _$$EntityRef];
+
+  @override
+  final String wireName = r'$EntityRef';
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    $EntityRef object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.serialize(object, specifiedType: FullType(EntityRef))!;
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required EntityRefBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'@referredType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atReferredType = valueDes;
+          break;
+        case r'name':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.name = valueDes;
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  $EntityRef deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = $EntityRefBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/extensible.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/extensible.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2423fb2764126b53a337212dcb6348ebc122beb9
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/extensible.dart
@@ -0,0 +1,178 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'extensible.g.dart';
+
+/// Extensible
+///
+/// Properties:
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue(instantiable: false)
+abstract class Extensible  {
+  /// A URI to a JSON-Schema file that defines additional attributes and relationships
+  @BuiltValueField(wireName: r'@schemaLocation')
+  String? get atSchemaLocation;
+
+  /// When sub-classing, this defines the super-class
+  @BuiltValueField(wireName: r'@baseType')
+  String? get atBaseType;
+
+  /// When sub-classing, this defines the sub-class Extensible name
+  @BuiltValueField(wireName: r'@type')
+  String get atType;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Extensible> get serializer => _$ExtensibleSerializer();
+}
+
+class _$ExtensibleSerializer implements PrimitiveSerializer<Extensible> {
+  @override
+  final Iterable<Type> types = const [Extensible];
+
+  @override
+  final String wireName = r'Extensible';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Extensible object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Extensible object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  @override
+  Extensible deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.deserialize(serialized, specifiedType: FullType($Extensible)) as $Extensible;
+  }
+}
+
+/// a concrete implementation of [Extensible], since [Extensible] is not instantiable
+@BuiltValue(instantiable: true)
+abstract class $Extensible implements Extensible, Built<$Extensible, $ExtensibleBuilder> {
+  $Extensible._();
+
+  factory $Extensible([void Function($ExtensibleBuilder)? updates]) = _$$Extensible;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults($ExtensibleBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<$Extensible> get serializer => _$$ExtensibleSerializer();
+}
+
+class _$$ExtensibleSerializer implements PrimitiveSerializer<$Extensible> {
+  @override
+  final Iterable<Type> types = const [$Extensible, _$$Extensible];
+
+  @override
+  final String wireName = r'$Extensible';
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    $Extensible object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.serialize(object, specifiedType: FullType(Extensible))!;
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ExtensibleBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  $Extensible deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = $ExtensibleBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/foo.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/foo.dart
new file mode 100644
index 0000000000000000000000000000000000000000..efb327dd664eb728b905250678634780f46fbf9c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/foo.dart
@@ -0,0 +1,202 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/entity.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'foo.g.dart';
+
+/// Foo
+///
+/// Properties:
+/// * [fooPropA] 
+/// * [fooPropB] 
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue()
+abstract class Foo implements Entity, Built<Foo, FooBuilder> {
+  @BuiltValueField(wireName: r'fooPropA')
+  String? get fooPropA;
+
+  @BuiltValueField(wireName: r'fooPropB')
+  String? get fooPropB;
+
+  static const String discriminatorFieldName = r'atType';
+
+  Foo._();
+
+  factory Foo([void updates(FooBuilder b)]) = _$Foo;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(FooBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Foo> get serializer => _$FooSerializer();
+}
+
+class _$FooSerializer implements PrimitiveSerializer<Foo> {
+  @override
+  final Iterable<Type> types = const [Foo, _$Foo];
+
+  @override
+  final String wireName = r'Foo';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Foo object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.fooPropA != null) {
+      yield r'fooPropA';
+      yield serializers.serialize(
+        object.fooPropA,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.fooPropB != null) {
+      yield r'fooPropB';
+      yield serializers.serialize(
+        object.fooPropB,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Foo object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required FooBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'fooPropA':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.fooPropA = valueDes;
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'fooPropB':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.fooPropB = valueDes;
+          break;
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  Foo deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = FooBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/foo_ref.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/foo_ref.dart
new file mode 100644
index 0000000000000000000000000000000000000000..dd05a2d4787f14ac0711353e40a9a2ca20dc5564
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/foo_ref.dart
@@ -0,0 +1,212 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/entity_ref.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'foo_ref.g.dart';
+
+/// FooRef
+///
+/// Properties:
+/// * [foorefPropA] 
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue()
+abstract class FooRef implements EntityRef, Built<FooRef, FooRefBuilder> {
+  @BuiltValueField(wireName: r'foorefPropA')
+  String? get foorefPropA;
+
+  static const String discriminatorFieldName = r'atType';
+
+  FooRef._();
+
+  factory FooRef([void updates(FooRefBuilder b)]) = _$FooRef;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(FooRefBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<FooRef> get serializer => _$FooRefSerializer();
+}
+
+class _$FooRefSerializer implements PrimitiveSerializer<FooRef> {
+  @override
+  final Iterable<Type> types = const [FooRef, _$FooRef];
+
+  @override
+  final String wireName = r'FooRef';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    FooRef object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atReferredType != null) {
+      yield r'@referredType';
+      yield serializers.serialize(
+        object.atReferredType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.foorefPropA != null) {
+      yield r'foorefPropA';
+      yield serializers.serialize(
+        object.foorefPropA,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.name != null) {
+      yield r'name';
+      yield serializers.serialize(
+        object.name,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    FooRef object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required FooRefBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'@referredType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atReferredType = valueDes;
+          break;
+        case r'foorefPropA':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.foorefPropA = valueDes;
+          break;
+        case r'name':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.name = valueDes;
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  FooRef deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = FooRefBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/foo_ref_or_value.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/foo_ref_or_value.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f512292196a27bcfddc6f33dbccd644f99ea1d49
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/foo_ref_or_value.dart
@@ -0,0 +1,106 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/foo.dart';
+import 'package:openapi/src/model/foo_ref.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+import 'package:one_of/one_of.dart';
+
+part 'foo_ref_or_value.g.dart';
+
+/// FooRefOrValue
+///
+/// Properties:
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue()
+abstract class FooRefOrValue implements Built<FooRefOrValue, FooRefOrValueBuilder> {
+  /// One Of [Foo], [FooRef]
+  OneOf get oneOf;
+
+  static const String discriminatorFieldName = r'atType';
+
+  static const Map<String, Type> discriminatorMapping = {
+    r'Foo': Foo,
+    r'FooRef': FooRef,
+  };
+
+  FooRefOrValue._();
+
+  factory FooRefOrValue([void updates(FooRefOrValueBuilder b)]) = _$FooRefOrValue;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(FooRefOrValueBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<FooRefOrValue> get serializer => _$FooRefOrValueSerializer();
+}
+
+class _$FooRefOrValueSerializer implements PrimitiveSerializer<FooRefOrValue> {
+  @override
+  final Iterable<Type> types = const [FooRefOrValue, _$FooRefOrValue];
+
+  @override
+  final String wireName = r'FooRefOrValue';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    FooRefOrValue object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    FooRefOrValue object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final oneOf = object.oneOf;
+    return serializers.serialize(oneOf.value, specifiedType: FullType(oneOf.valueType))!;
+  }
+
+  @override
+  FooRefOrValue deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = FooRefOrValueBuilder();
+    Object? oneOfDataSrc;
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final discIndex = serializedList.indexOf(FooRefOrValue.discriminatorFieldName) + 1;
+    final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String;
+    oneOfDataSrc = serialized;
+    final oneOfTypes = [Foo, FooRef, ];
+    Object oneOfResult;
+    Type oneOfType;
+    switch (discValue) {
+      case 'Foo':
+        oneOfResult = serializers.deserialize(
+          oneOfDataSrc,
+          specifiedType: FullType(Foo),
+        ) as Foo;
+        oneOfType = Foo;
+        break;
+      case 'FooRef':
+        oneOfResult = serializers.deserialize(
+          oneOfDataSrc,
+          specifiedType: FullType(FooRef),
+        ) as FooRef;
+        oneOfType = FooRef;
+        break;
+      default:
+        throw UnsupportedError("Couldn't deserialize oneOf for the discriminator value: ${discValue}");
+    }
+    result.oneOf = OneOfDynamic(typeIndex: oneOfTypes.indexOf(oneOfType), types: oneOfTypes, value: oneOfResult);
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/pasta.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/pasta.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5c5ef72537c2528372c6468b9c905f32638fffa7
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/pasta.dart
@@ -0,0 +1,184 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/entity.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'pasta.g.dart';
+
+/// Pasta
+///
+/// Properties:
+/// * [vendor] 
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue()
+abstract class Pasta implements Entity, Built<Pasta, PastaBuilder> {
+  @BuiltValueField(wireName: r'vendor')
+  String? get vendor;
+
+  static const String discriminatorFieldName = r'atType';
+
+  Pasta._();
+
+  factory Pasta([void updates(PastaBuilder b)]) = _$Pasta;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(PastaBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Pasta> get serializer => _$PastaSerializer();
+}
+
+class _$PastaSerializer implements PrimitiveSerializer<Pasta> {
+  @override
+  final Iterable<Type> types = const [Pasta, _$Pasta];
+
+  @override
+  final String wireName = r'Pasta';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Pasta object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+    if (object.vendor != null) {
+      yield r'vendor';
+      yield serializers.serialize(
+        object.vendor,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Pasta object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required PastaBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        case r'vendor':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.vendor = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  Pasta deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = PastaBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/pizza.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/pizza.dart
new file mode 100644
index 0000000000000000000000000000000000000000..866daab885e18a8231e3c7be4128b459979e9dd9
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/pizza.dart
@@ -0,0 +1,233 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/pizza_speziale.dart';
+import 'package:openapi/src/model/entity.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'pizza.g.dart';
+
+/// Pizza
+///
+/// Properties:
+/// * [pizzaSize] 
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue(instantiable: false)
+abstract class Pizza implements Entity {
+  @BuiltValueField(wireName: r'pizzaSize')
+  num? get pizzaSize;
+
+  static const String discriminatorFieldName = r'atType';
+
+  static const Map<String, Type> discriminatorMapping = {
+    r'PizzaSpeziale': PizzaSpeziale,
+  };
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Pizza> get serializer => _$PizzaSerializer();
+}
+
+class _$PizzaSerializer implements PrimitiveSerializer<Pizza> {
+  @override
+  final Iterable<Type> types = const [Pizza];
+
+  @override
+  final String wireName = r'Pizza';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Pizza object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.pizzaSize != null) {
+      yield r'pizzaSize';
+      yield serializers.serialize(
+        object.pizzaSize,
+        specifiedType: const FullType(num),
+      );
+    }
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Pizza object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    if (object is PizzaSpeziale) {
+      return serializers.serialize(object, specifiedType: FullType(PizzaSpeziale))!;
+    }
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  @override
+  Pizza deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final discIndex = serializedList.indexOf(Pizza.discriminatorFieldName) + 1;
+    final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String;
+    switch (discValue) {
+      case 'PizzaSpeziale':
+        return serializers.deserialize(serialized, specifiedType: FullType(PizzaSpeziale)) as PizzaSpeziale;
+      default:
+        return serializers.deserialize(serialized, specifiedType: FullType($Pizza)) as $Pizza;
+    }
+  }
+}
+
+/// a concrete implementation of [Pizza], since [Pizza] is not instantiable
+@BuiltValue(instantiable: true)
+abstract class $Pizza implements Pizza, Built<$Pizza, $PizzaBuilder> {
+  $Pizza._();
+
+  factory $Pizza([void Function($PizzaBuilder)? updates]) = _$$Pizza;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults($PizzaBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<$Pizza> get serializer => _$$PizzaSerializer();
+}
+
+class _$$PizzaSerializer implements PrimitiveSerializer<$Pizza> {
+  @override
+  final Iterable<Type> types = const [$Pizza, _$$Pizza];
+
+  @override
+  final String wireName = r'$Pizza';
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    $Pizza object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.serialize(object, specifiedType: FullType(Pizza))!;
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required PizzaBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'pizzaSize':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(num),
+          ) as num;
+          result.pizzaSize = valueDes;
+          break;
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  $Pizza deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = $PizzaBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/pizza_speziale.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/pizza_speziale.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7f17257e50337454769d33575c5b4ea539ebdde6
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/model/pizza_speziale.dart
@@ -0,0 +1,198 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/pizza.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'pizza_speziale.g.dart';
+
+/// PizzaSpeziale
+///
+/// Properties:
+/// * [toppings] 
+/// * [href] - Hyperlink reference
+/// * [id] - unique identifier
+/// * [atSchemaLocation] - A URI to a JSON-Schema file that defines additional attributes and relationships
+/// * [atBaseType] - When sub-classing, this defines the super-class
+/// * [atType] - When sub-classing, this defines the sub-class Extensible name
+@BuiltValue()
+abstract class PizzaSpeziale implements Pizza, Built<PizzaSpeziale, PizzaSpezialeBuilder> {
+  @BuiltValueField(wireName: r'toppings')
+  String? get toppings;
+
+  static const String discriminatorFieldName = r'atType';
+
+  PizzaSpeziale._();
+
+  factory PizzaSpeziale([void updates(PizzaSpezialeBuilder b)]) = _$PizzaSpeziale;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(PizzaSpezialeBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<PizzaSpeziale> get serializer => _$PizzaSpezialeSerializer();
+}
+
+class _$PizzaSpezialeSerializer implements PrimitiveSerializer<PizzaSpeziale> {
+  @override
+  final Iterable<Type> types = const [PizzaSpeziale, _$PizzaSpeziale];
+
+  @override
+  final String wireName = r'PizzaSpeziale';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    PizzaSpeziale object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.atSchemaLocation != null) {
+      yield r'@schemaLocation';
+      yield serializers.serialize(
+        object.atSchemaLocation,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.pizzaSize != null) {
+      yield r'pizzaSize';
+      yield serializers.serialize(
+        object.pizzaSize,
+        specifiedType: const FullType(num),
+      );
+    }
+    if (object.toppings != null) {
+      yield r'toppings';
+      yield serializers.serialize(
+        object.toppings,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.atBaseType != null) {
+      yield r'@baseType';
+      yield serializers.serialize(
+        object.atBaseType,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.href != null) {
+      yield r'href';
+      yield serializers.serialize(
+        object.href,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'@type';
+    yield serializers.serialize(
+      object.atType,
+      specifiedType: const FullType(String),
+    );
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    PizzaSpeziale object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required PizzaSpezialeBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'@schemaLocation':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atSchemaLocation = valueDes;
+          break;
+        case r'pizzaSize':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(num),
+          ) as num;
+          result.pizzaSize = valueDes;
+          break;
+        case r'toppings':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.toppings = valueDes;
+          break;
+        case r'@baseType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atBaseType = valueDes;
+          break;
+        case r'href':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.href = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.id = valueDes;
+          break;
+        case r'@type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.atType = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  PizzaSpeziale deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = PizzaSpezialeBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/serializers.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/serializers.dart
new file mode 100644
index 0000000000000000000000000000000000000000..55083251e5e8f4738b57d354d40358fd36924f70
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/lib/src/serializers.dart
@@ -0,0 +1,67 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_import
+
+import 'package:one_of_serializer/any_of_serializer.dart';
+import 'package:one_of_serializer/one_of_serializer.dart';
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/json_object.dart';
+import 'package:built_value/serializer.dart';
+import 'package:built_value/standard_json_plugin.dart';
+import 'package:built_value/iso_8601_date_time_serializer.dart';
+import 'package:openapi/src/date_serializer.dart';
+import 'package:openapi/src/model/date.dart';
+
+import 'package:openapi/src/model/addressable.dart';
+import 'package:openapi/src/model/bar.dart';
+import 'package:openapi/src/model/bar_create.dart';
+import 'package:openapi/src/model/bar_ref.dart';
+import 'package:openapi/src/model/bar_ref_or_value.dart';
+import 'package:openapi/src/model/entity.dart';
+import 'package:openapi/src/model/entity_ref.dart';
+import 'package:openapi/src/model/extensible.dart';
+import 'package:openapi/src/model/foo.dart';
+import 'package:openapi/src/model/foo_ref.dart';
+import 'package:openapi/src/model/foo_ref_or_value.dart';
+import 'package:openapi/src/model/pasta.dart';
+import 'package:openapi/src/model/pizza.dart';
+import 'package:openapi/src/model/pizza_speziale.dart';
+
+part 'serializers.g.dart';
+
+@SerializersFor([
+  Addressable,$Addressable,
+  Bar,
+  BarCreate,
+  BarRef,
+  BarRefOrValue,
+  Entity,$Entity,
+  EntityRef,$EntityRef,
+  Extensible,$Extensible,
+  Foo,
+  FooRef,
+  FooRefOrValue,
+  Pasta,
+  Pizza,$Pizza,
+  PizzaSpeziale,
+])
+Serializers serializers = (_$serializers.toBuilder()
+      ..addBuilderFactory(
+        const FullType(BuiltList, [FullType(FooRefOrValue)]),
+        () => ListBuilder<FooRefOrValue>(),
+      )
+      ..add(Addressable.serializer)
+      ..add(Entity.serializer)
+      ..add(EntityRef.serializer)
+      ..add(Extensible.serializer)
+      ..add(Pizza.serializer)
+      ..add(const OneOfSerializer())
+      ..add(const AnyOfSerializer())
+      ..add(const DateSerializer())
+      ..add(Iso8601DateTimeSerializer()))
+    .build();
+
+Serializers standardSerializers =
+    (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/pom.xml b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..50f62b7f8daefd450e1f335c878c0380644987cc
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/pom.xml
@@ -0,0 +1,88 @@
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.openapitools</groupId>
+    <artifactId>DartDioOneOfPolymorphismAndInheritance</artifactId>
+    <packaging>pom</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>DartDio OneOf Polymorphism and Inheritance</name>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.2.1</version>
+                <executions>
+                    <execution>
+                        <id>pub-get</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>pub</executable>
+                            <arguments>
+                                <argument>get</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>pub-run-build-runner</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>pub</executable>
+                            <arguments>
+                                <argument>run</argument>
+                                <argument>build_runner</argument>
+                                <argument>build</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>dart-analyze</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>dart</executable>
+                            <arguments>
+                                <argument>analyze</argument>
+                                <argument>--fatal-infos</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>dart-test</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>dart</executable>
+                            <arguments>
+                                <argument>test</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/pubspec.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..fb676f65c393c216466d443ec4060097085cd922
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/pubspec.yaml
@@ -0,0 +1,19 @@
+name: openapi
+version: 1.0.0
+description: OpenAPI API client
+homepage: homepage
+
+environment:
+  sdk: '>=2.12.0 <3.0.0'
+
+dependencies:
+  dio: '>=4.0.1 <5.0.0'
+  one_of: '>=1.5.0 <2.0.0'
+  one_of_serializer: '>=1.5.0 <2.0.0'
+  built_value: '>=8.4.0 <9.0.0'
+  built_collection: '>=5.1.1 <6.0.0'
+
+dev_dependencies:
+  built_value_generator: '>=8.4.0 <9.0.0'
+  build_runner: any
+  test: ^1.16.0
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/addressable_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/addressable_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..696e26e8e549489832e62a57d1d0388573218426
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/addressable_test.dart
@@ -0,0 +1,23 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Addressable
+void main() {
+  //final instance = AddressableBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Addressable, () {
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_api_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_api_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..73be91c446e0a70ac15990578701c3071be63f5e
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_api_test.dart
@@ -0,0 +1,18 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+
+/// tests for BarApi
+void main() {
+  final instance = Openapi().getBarApi();
+
+  group(BarApi, () {
+    // Create a Bar
+    //
+    //Future<Bar> createBar(BarCreate barCreate) async
+    test('test createBar', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_create_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_create_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1bf90151be8b6f78c001ddc202f5f4112eba07e4
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_create_test.dart
@@ -0,0 +1,56 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for BarCreate
+void main() {
+  final instance = BarCreateBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(BarCreate, () {
+    // String barPropA
+    test('to test the property `barPropA`', () async {
+      // TODO
+    });
+
+    // String fooPropB
+    test('to test the property `fooPropB`', () async {
+      // TODO
+    });
+
+    // FooRefOrValue foo
+    test('to test the property `foo`', () async {
+      // TODO
+    });
+
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_ref_or_value_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_ref_or_value_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c132ac09943b10b013ba5041b6c00798774d4eb6
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_ref_or_value_test.dart
@@ -0,0 +1,41 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for BarRefOrValue
+void main() {
+  final instance = BarRefOrValueBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(BarRefOrValue, () {
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_ref_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_ref_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9c410b2b5c54b9b6b45246acc6bf1be5666f09e7
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_ref_test.dart
@@ -0,0 +1,41 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for BarRef
+void main() {
+  final instance = BarRefBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(BarRef, () {
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..dc6daaa3400d78b3748672beddcf74e9adcafb16
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/bar_test.dart
@@ -0,0 +1,55 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Bar
+void main() {
+  final instance = BarBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Bar, () {
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // String barPropA
+    test('to test the property `barPropA`', () async {
+      // TODO
+    });
+
+    // String fooPropB
+    test('to test the property `fooPropB`', () async {
+      // TODO
+    });
+
+    // FooRefOrValue foo
+    test('to test the property `foo`', () async {
+      // TODO
+    });
+
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/entity_ref_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/entity_ref_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..836289893fb4044d0ed781d37b2b7fb4db1fc489
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/entity_ref_test.dart
@@ -0,0 +1,53 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for EntityRef
+void main() {
+  //final instance = EntityRefBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(EntityRef, () {
+    // Name of the related entity.
+    // String name
+    test('to test the property `name`', () async {
+      // TODO
+    });
+
+    // The actual type of the target instance when needed for disambiguation.
+    // String atReferredType
+    test('to test the property `atReferredType`', () async {
+      // TODO
+    });
+
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/entity_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/entity_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..30429747562d4f4515f93a1a3a2595c1be681b0c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/entity_test.dart
@@ -0,0 +1,41 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Entity
+void main() {
+  //final instance = EntityBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Entity, () {
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/extensible_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/extensible_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..75e6211e074beb83b192da4e7b03000d4b4f735c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/extensible_test.dart
@@ -0,0 +1,29 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Extensible
+void main() {
+  //final instance = ExtensibleBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Extensible, () {
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_api_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_api_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f33986a08b699535754f55523d9308228257349b
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_api_test.dart
@@ -0,0 +1,25 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+
+/// tests for FooApi
+void main() {
+  final instance = Openapi().getFooApi();
+
+  group(FooApi, () {
+    // Create a Foo
+    //
+    //Future<FooRefOrValue> createFoo({ Foo foo }) async
+    test('test createFoo', () async {
+      // TODO
+    });
+
+    // GET all Foos
+    //
+    //Future<BuiltList<FooRefOrValue>> getAllFoos() async
+    test('test getAllFoos', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_ref_or_value_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_ref_or_value_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..029d030e5e350235fd59cf3ae11fc0ffb751ac12
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_ref_or_value_test.dart
@@ -0,0 +1,41 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for FooRefOrValue
+void main() {
+  final instance = FooRefOrValueBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(FooRefOrValue, () {
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_ref_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_ref_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a1398787bbcbd50947afadbddfb05a6a29c6d54d
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_ref_test.dart
@@ -0,0 +1,46 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for FooRef
+void main() {
+  final instance = FooRefBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(FooRef, () {
+    // String foorefPropA
+    test('to test the property `foorefPropA`', () async {
+      // TODO
+    });
+
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..93a5286e2b4548d5d007ae2d94da9dbb50b366e4
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/foo_test.dart
@@ -0,0 +1,51 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Foo
+void main() {
+  final instance = FooBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Foo, () {
+    // String fooPropA
+    test('to test the property `fooPropA`', () async {
+      // TODO
+    });
+
+    // String fooPropB
+    test('to test the property `fooPropB`', () async {
+      // TODO
+    });
+
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/pasta_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/pasta_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6a3ae338eec25ceefd4a6898a77f622de707340d
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/pasta_test.dart
@@ -0,0 +1,46 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Pasta
+void main() {
+  final instance = PastaBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Pasta, () {
+    // String vendor
+    test('to test the property `vendor`', () async {
+      // TODO
+    });
+
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/pizza_speziale_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/pizza_speziale_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..774320231c9e62792ddba511ce08d12f5b36084a
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/pizza_speziale_test.dart
@@ -0,0 +1,46 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for PizzaSpeziale
+void main() {
+  final instance = PizzaSpezialeBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(PizzaSpeziale, () {
+    // String toppings
+    test('to test the property `toppings`', () async {
+      // TODO
+    });
+
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/pizza_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/pizza_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5c6e1af95a5980ae7fc2174d982275f8f3d1039d
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/test/pizza_test.dart
@@ -0,0 +1,46 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Pizza
+void main() {
+  //final instance = PizzaBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Pizza, () {
+    // num pizzaSize
+    test('to test the property `pizzaSize`', () async {
+      // TODO
+    });
+
+    // Hyperlink reference
+    // String href
+    test('to test the property `href`', () async {
+      // TODO
+    });
+
+    // unique identifier
+    // String id
+    test('to test the property `id`', () async {
+      // TODO
+    });
+
+    // A URI to a JSON-Schema file that defines additional attributes and relationships
+    // String atSchemaLocation
+    test('to test the property `atSchemaLocation`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the super-class
+    // String atBaseType
+    test('to test the property `atBaseType`', () async {
+      // TODO
+    });
+
+    // When sub-classing, this defines the sub-class Extensible name
+    // String atType
+    test('to test the property `atType`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.gitignore b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..4298cdcbd1a24268bccd159b376ff8a9c4722868
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.gitignore
@@ -0,0 +1,41 @@
+# See https://dart.dev/guides/libraries/private-files
+
+# Files and directories created by pub
+.dart_tool/
+.buildlog
+.packages
+.project
+.pub/
+build/
+**/packages/
+
+# Files created by dart2js
+# (Most Dart developers will use pub build to compile Dart, use/modify these
+#  rules if you intend to use dart2js directly
+#  Convention is to use extension '.dart.js' for Dart compiled to Javascript to
+#  differentiate from explicit Javascript files)
+*.dart.js
+*.part.js
+*.js.deps
+*.js.map
+*.info.json
+
+# Directory created by dartdoc
+doc/api/
+
+# Don't commit pubspec lock file
+# (Library packages only! Remove pattern if developing an application package)
+pubspec.lock
+
+# Don’t commit files and directories created by other development environments.
+# For example, if your development environment creates any of the following files,
+# consider putting them in a global ignore file:
+
+# IntelliJ
+*.iml
+*.ipr
+*.iws
+.idea/
+
+# Mac
+.DS_Store
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.openapi-generator-ignore b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.openapi-generator-ignore
new file mode 100644
index 0000000000000000000000000000000000000000..7484ee590a3894506cf063799b885428f95a71be
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.openapi-generator-ignore
@@ -0,0 +1,23 @@
+# OpenAPI Generator Ignore
+# Generated by openapi-generator https://github.com/openapitools/openapi-generator
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.openapi-generator/FILES
new file mode 100644
index 0000000000000000000000000000000000000000..7f2ac59bf645026d90bdb61ef97865d3887bfb1a
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.openapi-generator/FILES
@@ -0,0 +1,21 @@
+.gitignore
+README.md
+analysis_options.yaml
+doc/Child.md
+doc/DefaultApi.md
+doc/Example.md
+lib/openapi.dart
+lib/src/api.dart
+lib/src/api/default_api.dart
+lib/src/api_util.dart
+lib/src/auth/api_key_auth.dart
+lib/src/auth/auth.dart
+lib/src/auth/basic_auth.dart
+lib/src/auth/bearer_auth.dart
+lib/src/auth/oauth.dart
+lib/src/date_serializer.dart
+lib/src/model/child.dart
+lib/src/model/date.dart
+lib/src/model/example.dart
+lib/src/serializers.dart
+pubspec.yaml
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.openapi-generator/VERSION b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.openapi-generator/VERSION
new file mode 100644
index 0000000000000000000000000000000000000000..66672d4e9d31378b298e49f1b38a028b2afe48ac
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/.openapi-generator/VERSION
@@ -0,0 +1 @@
+6.1.0-SNAPSHOT
\ No newline at end of file
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/README.md b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..d73bafd4c64fec56614fe2886b05902df3fbe044
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/README.md
@@ -0,0 +1,83 @@
+# openapi (EXPERIMENTAL)
+No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+
+This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
+
+- API version: 1.0.0
+- Build package: org.openapitools.codegen.languages.DartDioClientCodegen
+
+## Requirements
+
+* Dart 2.12.0 or later OR Flutter 1.26.0 or later
+* Dio 4.0.0+
+
+## Installation & Usage
+
+### pub.dev
+To use the package from [pub.dev](https://pub.dev), please include the following in pubspec.yaml
+```yaml
+dependencies:
+  openapi: 1.0.0
+```
+
+### Github
+If this Dart package is published to Github, please include the following in pubspec.yaml
+```yaml
+dependencies:
+  openapi:
+    git:
+      url: https://github.com/GIT_USER_ID/GIT_REPO_ID.git
+      #ref: main
+```
+
+### Local development
+To use the package from your local drive, please include the following in pubspec.yaml
+```yaml
+dependencies:
+  openapi:
+    path: /path/to/openapi
+```
+
+## Getting Started
+
+Please follow the [installation procedure](#installation--usage) and then run the following:
+
+```dart
+import 'package:openapi/openapi.dart';
+
+
+final api = Openapi().getDefaultApi();
+
+try {
+    final response = await api.list();
+    print(response);
+} catch on DioError (e) {
+    print("Exception when calling DefaultApi->list: $e\n");
+}
+
+```
+
+## Documentation for API Endpoints
+
+All URIs are relative to *http://api.example.xyz/v1*
+
+Class | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+[*DefaultApi*](doc/DefaultApi.md) | [**list**](doc/DefaultApi.md#list) | **GET** /example | 
+
+
+## Documentation For Models
+
+ - [Child](doc/Child.md)
+ - [Example](doc/Example.md)
+
+
+## Documentation For Authorization
+
+ All endpoints do not require authorization.
+
+
+## Author
+
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/analysis_options.yaml b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/analysis_options.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..a611887d3acfe1fdfd0ad16005f9e675d3583ff0
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/analysis_options.yaml
@@ -0,0 +1,9 @@
+analyzer:
+  language:
+    strict-inference: true
+    strict-raw-types: true
+  strong-mode:
+    implicit-dynamic: false
+    implicit-casts: false
+  exclude:
+    - test/*.dart
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/doc/Child.md b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/doc/Child.md
new file mode 100644
index 0000000000000000000000000000000000000000..bed0f2feec1293d76c895eb6a2c211ee27b4d4c7
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/doc/Child.md
@@ -0,0 +1,15 @@
+# openapi.model.Child
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**name** | **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/openapi3/client/petstore/dart-dio/oneof_primitive/doc/DefaultApi.md b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/doc/DefaultApi.md
new file mode 100644
index 0000000000000000000000000000000000000000..abbf5f07f499df0f538bd38de62edecb0e54d92b
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/doc/DefaultApi.md
@@ -0,0 +1,51 @@
+# openapi.api.DefaultApi
+
+## Load the API package
+```dart
+import 'package:openapi/api.dart';
+```
+
+All URIs are relative to *http://api.example.xyz/v1*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**list**](DefaultApi.md#list) | **GET** /example | 
+
+
+# **list**
+> Example list()
+
+
+
+### Example
+```dart
+import 'package:openapi/api.dart';
+
+final api = Openapi().getDefaultApi();
+
+try {
+    final response = api.list();
+    print(response);
+} catch on DioError (e) {
+    print('Exception when calling DefaultApi->list: $e\n');
+}
+```
+
+### Parameters
+This endpoint does not need any parameter.
+
+### Return type
+
+[**Example**](Example.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/doc/Example.md b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/doc/Example.md
new file mode 100644
index 0000000000000000000000000000000000000000..bf49bb137a60d0225eb2a3c9415c51afd28e754a
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/doc/Example.md
@@ -0,0 +1,15 @@
+# openapi.model.Example
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**name** | **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/openapi3/client/petstore/dart-dio/oneof_primitive/lib/openapi.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/openapi.dart
new file mode 100644
index 0000000000000000000000000000000000000000..220621d6961b34824afc3d295110e10de64db651
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/openapi.dart
@@ -0,0 +1,15 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+export 'package:openapi/src/api.dart';
+export 'package:openapi/src/auth/api_key_auth.dart';
+export 'package:openapi/src/auth/basic_auth.dart';
+export 'package:openapi/src/auth/oauth.dart';
+export 'package:openapi/src/serializers.dart';
+export 'package:openapi/src/model/date.dart';
+
+export 'package:openapi/src/api/default_api.dart';
+
+export 'package:openapi/src/model/child.dart';
+export 'package:openapi/src/model/example.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api.dart
new file mode 100644
index 0000000000000000000000000000000000000000..776737680d59ad290cc6807b8c87c55089a26280
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api.dart
@@ -0,0 +1,73 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+import 'package:built_value/serializer.dart';
+import 'package:openapi/src/serializers.dart';
+import 'package:openapi/src/auth/api_key_auth.dart';
+import 'package:openapi/src/auth/basic_auth.dart';
+import 'package:openapi/src/auth/bearer_auth.dart';
+import 'package:openapi/src/auth/oauth.dart';
+import 'package:openapi/src/api/default_api.dart';
+
+class Openapi {
+  static const String basePath = r'http://api.example.xyz/v1';
+
+  final Dio dio;
+  final Serializers serializers;
+
+  Openapi({
+    Dio? dio,
+    Serializers? serializers,
+    String? basePathOverride,
+    List<Interceptor>? interceptors,
+  })  : this.serializers = serializers ?? standardSerializers,
+        this.dio = dio ??
+            Dio(BaseOptions(
+              baseUrl: basePathOverride ?? basePath,
+              connectTimeout: 5000,
+              receiveTimeout: 3000,
+            )) {
+    if (interceptors == null) {
+      this.dio.interceptors.addAll([
+        OAuthInterceptor(),
+        BasicAuthInterceptor(),
+        BearerAuthInterceptor(),
+        ApiKeyAuthInterceptor(),
+      ]);
+    } else {
+      this.dio.interceptors.addAll(interceptors);
+    }
+  }
+
+  void setOAuthToken(String name, String token) {
+    if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens[name] = token;
+    }
+  }
+
+  void setBearerAuth(String name, String token) {
+    if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token;
+    }
+  }
+
+  void setBasicAuth(String name, String username, String password) {
+    if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password);
+    }
+  }
+
+  void setApiKey(String name, String apiKey) {
+    if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) {
+      (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
+    }
+  }
+
+  /// Get DefaultApi instance, base route and serializer can be overridden by a given but be careful,
+  /// by doing that all interceptors will not be executed
+  DefaultApi getDefaultApi() {
+    return DefaultApi(dio, serializers);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api/default_api.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api/default_api.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8d500cb70aadb933ce0526cafb0a916b6c6a58fa
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api/default_api.dart
@@ -0,0 +1,92 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'dart:async';
+
+import 'package:built_value/serializer.dart';
+import 'package:dio/dio.dart';
+
+import 'package:openapi/src/model/example.dart';
+
+class DefaultApi {
+
+  final Dio _dio;
+
+  final Serializers _serializers;
+
+  const DefaultApi(this._dio, this._serializers);
+
+  /// list
+  /// 
+  ///
+  /// Parameters:
+  /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
+  /// * [headers] - Can be used to add additional headers to the request
+  /// * [extras] - Can be used to add flags to the request
+  /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
+  /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
+  /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
+  ///
+  /// Returns a [Future] containing a [Response] with a [Example] as data
+  /// Throws [DioError] if API call or serialization fails
+  Future<Response<Example>> list({ 
+    CancelToken? cancelToken,
+    Map<String, dynamic>? headers,
+    Map<String, dynamic>? extra,
+    ValidateStatus? validateStatus,
+    ProgressCallback? onSendProgress,
+    ProgressCallback? onReceiveProgress,
+  }) async {
+    final _path = r'/example';
+    final _options = Options(
+      method: r'GET',
+      headers: <String, dynamic>{
+        ...?headers,
+      },
+      extra: <String, dynamic>{
+        'secure': <Map<String, String>>[],
+        ...?extra,
+      },
+      validateStatus: validateStatus,
+    );
+
+    final _response = await _dio.request<Object>(
+      _path,
+      options: _options,
+      cancelToken: cancelToken,
+      onSendProgress: onSendProgress,
+      onReceiveProgress: onReceiveProgress,
+    );
+
+    Example _responseData;
+
+    try {
+      const _responseType = FullType(Example);
+      _responseData = _serializers.deserialize(
+        _response.data!,
+        specifiedType: _responseType,
+      ) as Example;
+
+    } catch (error, stackTrace) {
+      throw DioError(
+        requestOptions: _response.requestOptions,
+        response: _response,
+        type: DioErrorType.other,
+        error: error,
+      )..stackTrace = stackTrace;
+    }
+
+    return Response<Example>(
+      data: _responseData,
+      headers: _response.headers,
+      isRedirect: _response.isRedirect,
+      requestOptions: _response.requestOptions,
+      redirects: _response.redirects,
+      statusCode: _response.statusCode,
+      statusMessage: _response.statusMessage,
+      extra: _response.extra,
+    );
+  }
+
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api_util.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api_util.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ed3bb12f25b81a6d266b1a4c0070f52d8d67ef25
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/api_util.dart
@@ -0,0 +1,77 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'dart:convert';
+import 'dart:typed_data';
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/serializer.dart';
+import 'package:dio/dio.dart';
+
+/// Format the given form parameter object into something that Dio can handle.
+/// Returns primitive or String.
+/// Returns List/Map if the value is BuildList/BuiltMap.
+dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) {
+  if (value == null) {
+    return '';
+  }
+  if (value is String || value is num || value is bool) {
+    return value;
+  }
+  final serialized = serializers.serialize(
+    value as Object,
+    specifiedType: type,
+  );
+  if (serialized is String) {
+    return serialized;
+  }
+  if (value is BuiltList || value is BuiltSet || value is BuiltMap) {
+    return serialized;
+  }
+  return json.encode(serialized);
+}
+
+dynamic encodeQueryParameter(
+  Serializers serializers,
+  dynamic value,
+  FullType type,
+) {
+  if (value == null) {
+    return '';
+  }
+  if (value is String || value is num || value is bool) {
+    return value;
+  }
+  if (value is Uint8List) {
+    // Currently not sure how to serialize this
+    return value;
+  }
+  final serialized = serializers.serialize(
+    value as Object,
+    specifiedType: type,
+  );
+  if (serialized == null) {
+    return '';
+  }
+  if (serialized is String) {
+    return serialized;
+  }
+  return serialized;
+}
+
+ListParam<Object?> encodeCollectionQueryParameter<T>(
+  Serializers serializers,
+  dynamic value,
+  FullType type, {
+  ListFormat format = ListFormat.multi,
+}) {
+  final serialized = serializers.serialize(
+    value as Object,
+    specifiedType: type,
+  );
+  if (value is BuiltList<T> || value is BuiltSet<T>) {
+    return ListParam(List.of((serialized as Iterable<Object?>).cast()), format);
+  }
+  throw ArgumentError('Invalid value passed to encodeCollectionQueryParameter');
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/api_key_auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/api_key_auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ee16e3f0f92fd4e87d97ec6e5dc9ad3b0519fae6
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/api_key_auth.dart
@@ -0,0 +1,30 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class ApiKeyAuthInterceptor extends AuthInterceptor {
+  final Map<String, String> apiKeys = {};
+
+  @override
+  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
+    final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'apiKey');
+    for (final info in authInfo) {
+      final authName = info['name'] as String;
+      final authKeyName = info['keyName'] as String;
+      final authWhere = info['where'] as String;
+      final apiKey = apiKeys[authName];
+      if (apiKey != null) {
+        if (authWhere == 'query') {
+          options.queryParameters[authKeyName] = apiKey;
+        } else {
+          options.headers[authKeyName] = apiKey;
+        }
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f7ae9bf3f11eb909e6d00b2087f2c17a6a260478
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/auth.dart
@@ -0,0 +1,18 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+
+abstract class AuthInterceptor extends Interceptor {
+  /// Get auth information on given route for the given type.
+  /// Can return an empty list if type is not present on auth data or
+  /// if route doesn't need authentication.
+  List<Map<String, String>> getAuthInfo(RequestOptions route, bool Function(Map<String, String> secure) handles) {
+    if (route.extra.containsKey('secure')) {
+      final auth = route.extra['secure'] as List<Map<String, String>>;
+      return auth.where((secure) => handles(secure)).toList();
+    }
+    return [];
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/basic_auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/basic_auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b6e6dce04f9c4ff33478271ba7994f0e22af35a7
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/basic_auth.dart
@@ -0,0 +1,37 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'dart:convert';
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class BasicAuthInfo {
+  final String username;
+  final String password;
+
+  const BasicAuthInfo(this.username, this.password);
+}
+
+class BasicAuthInterceptor extends AuthInterceptor {
+  final Map<String, BasicAuthInfo> authInfo = {};
+
+  @override
+  void onRequest(
+    RequestOptions options,
+    RequestInterceptorHandler handler,
+  ) {
+    final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
+    for (final info in metadataAuthInfo) {
+      final authName = info['name'] as String;
+      final basicAuthInfo = authInfo[authName];
+      if (basicAuthInfo != null) {
+        final basicAuth = 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}';
+        options.headers['Authorization'] = basicAuth;
+        break;
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/bearer_auth.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/bearer_auth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1d4402b376c0a794ada1b4756ed08cd247fb6564
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/bearer_auth.dart
@@ -0,0 +1,26 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class BearerAuthInterceptor extends AuthInterceptor {
+  final Map<String, String> tokens = {};
+
+  @override
+  void onRequest(
+    RequestOptions options,
+    RequestInterceptorHandler handler,
+  ) {
+    final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
+    for (final info in authInfo) {
+      final token = tokens[info['name']];
+      if (token != null) {
+        options.headers['Authorization'] = 'Bearer ${token}';
+        break;
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/oauth.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/oauth.dart
new file mode 100644
index 0000000000000000000000000000000000000000..337cf762b0ce77ccb2ed30882ea66e5abe84d354
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/auth/oauth.dart
@@ -0,0 +1,26 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:dio/dio.dart';
+import 'package:openapi/src/auth/auth.dart';
+
+class OAuthInterceptor extends AuthInterceptor {
+  final Map<String, String> tokens = {};
+
+  @override
+  void onRequest(
+    RequestOptions options,
+    RequestInterceptorHandler handler,
+  ) {
+    final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'oauth' || secure['type'] == 'oauth2');
+    for (final info in authInfo) {
+      final token = tokens[info['name']];
+      if (token != null) {
+        options.headers['Authorization'] = 'Bearer ${token}';
+        break;
+      }
+    }
+    super.onRequest(options, handler);
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/date_serializer.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/date_serializer.dart
new file mode 100644
index 0000000000000000000000000000000000000000..db3c5c437db10d074eb892e190d01f1874c3ce7c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/date_serializer.dart
@@ -0,0 +1,31 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/serializer.dart';
+import 'package:openapi/src/model/date.dart';
+
+class DateSerializer implements PrimitiveSerializer<Date> {
+
+  const DateSerializer();
+
+  @override
+  Iterable<Type> get types => BuiltList.of([Date]);
+
+  @override
+  String get wireName => 'Date';
+
+  @override
+  Date deserialize(Serializers serializers, Object serialized,
+      {FullType specifiedType = FullType.unspecified}) {
+    final parsed = DateTime.parse(serialized as String);
+    return Date(parsed.year, parsed.month, parsed.day);
+  }
+
+  @override
+  Object serialize(Serializers serializers, Date date,
+      {FullType specifiedType = FullType.unspecified}) {
+    return date.toString();
+  }
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/model/child.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/model/child.dart
new file mode 100644
index 0000000000000000000000000000000000000000..987b52ca7240fd1f4cc98df5e5bd2e69a56d7abd
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/model/child.dart
@@ -0,0 +1,108 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'child.g.dart';
+
+/// Child
+///
+/// Properties:
+/// * [name] 
+@BuiltValue()
+abstract class Child implements Built<Child, ChildBuilder> {
+  @BuiltValueField(wireName: r'name')
+  String? get name;
+
+  Child._();
+
+  factory Child([void updates(ChildBuilder b)]) = _$Child;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ChildBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Child> get serializer => _$ChildSerializer();
+}
+
+class _$ChildSerializer implements PrimitiveSerializer<Child> {
+  @override
+  final Iterable<Type> types = const [Child, _$Child];
+
+  @override
+  final String wireName = r'Child';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Child object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.name != null) {
+      yield r'name';
+      yield serializers.serialize(
+        object.name,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Child object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ChildBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'name':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.name = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
+    }
+  }
+
+  @override
+  Child deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ChildBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/model/date.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/model/date.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b21c7f544beefb379c4b64b464f02d42c8355cbe
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/model/date.dart
@@ -0,0 +1,70 @@
+/// A gregorian calendar date generated by
+/// OpenAPI generator to differentiate
+/// between [DateTime] and [Date] formats.
+class Date implements Comparable<Date> {
+  final int year;
+
+  /// January is 1.
+  final int month;
+
+  /// First day is 1.
+  final int day;
+
+  Date(this.year, this.month, this.day);
+
+  /// The current date
+  static Date now({bool utc = false}) {
+    var now = DateTime.now();
+    if (utc) {
+      now = now.toUtc();
+    }
+    return now.toDate();
+  }
+
+  /// Convert to a [DateTime].
+  DateTime toDateTime({bool utc = false}) {
+    if (utc) {
+      return DateTime.utc(year, month, day);
+    } else {
+      return DateTime(year, month, day);
+    }
+  }
+
+  @override
+  int compareTo(Date other) {
+    int d = year.compareTo(other.year);
+    if (d != 0) {
+      return d;
+    }
+    d = month.compareTo(other.month);
+    if (d != 0) {
+      return d;
+    }
+    return day.compareTo(other.day);
+  }
+
+  @override
+  bool operator ==(Object other) =>
+      identical(this, other) ||
+      other is Date &&
+          runtimeType == other.runtimeType &&
+          year == other.year &&
+          month == other.month &&
+          day == other.day;
+
+  @override
+  int get hashCode => year.hashCode ^ month.hashCode ^ day.hashCode;
+
+  @override
+  String toString() {
+    final yyyy = year.toString();
+    final mm = month.toString().padLeft(2, '0');
+    final dd = day.toString().padLeft(2, '0');
+
+    return '$yyyy-$mm-$dd';
+  }
+}
+
+extension DateTimeToDate on DateTime {
+  Date toDate() => Date(year, month, day);
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/model/example.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/model/example.dart
new file mode 100644
index 0000000000000000000000000000000000000000..799b77e4e178ac4998c7f7227da6c5478f5dfc01
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/model/example.dart
@@ -0,0 +1,72 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/child.dart';
+import 'dart:core';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+import 'package:one_of/one_of.dart';
+
+part 'example.g.dart';
+
+/// Example
+///
+/// Properties:
+/// * [name] 
+@BuiltValue()
+abstract class Example implements Built<Example, ExampleBuilder> {
+  /// One Of [Child], [int]
+  OneOf get oneOf;
+
+  Example._();
+
+  factory Example([void updates(ExampleBuilder b)]) = _$Example;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ExampleBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Example> get serializer => _$ExampleSerializer();
+}
+
+class _$ExampleSerializer implements PrimitiveSerializer<Example> {
+  @override
+  final Iterable<Type> types = const [Example, _$Example];
+
+  @override
+  final String wireName = r'Example';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Example object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Example object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final oneOf = object.oneOf;
+    return serializers.serialize(oneOf.value, specifiedType: FullType(oneOf.valueType))!;
+  }
+
+  @override
+  Example deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ExampleBuilder();
+    Object? oneOfDataSrc;
+    final targetType = const FullType(OneOf, [FullType(Child), FullType(int), ]);
+    oneOfDataSrc = serialized;
+    result.oneOf = serializers.deserialize(oneOfDataSrc, specifiedType: targetType) as OneOf;
+    return result.build();
+  }
+}
+
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/serializers.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/serializers.dart
new file mode 100644
index 0000000000000000000000000000000000000000..cbd8870dc6767e7c2c261851333f1744e74aad7c
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/lib/src/serializers.dart
@@ -0,0 +1,34 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+// ignore_for_file: unused_import
+
+import 'package:one_of_serializer/any_of_serializer.dart';
+import 'package:one_of_serializer/one_of_serializer.dart';
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/json_object.dart';
+import 'package:built_value/serializer.dart';
+import 'package:built_value/standard_json_plugin.dart';
+import 'package:built_value/iso_8601_date_time_serializer.dart';
+import 'package:openapi/src/date_serializer.dart';
+import 'package:openapi/src/model/date.dart';
+
+import 'package:openapi/src/model/child.dart';
+import 'package:openapi/src/model/example.dart';
+
+part 'serializers.g.dart';
+
+@SerializersFor([
+  Child,
+  Example,
+])
+Serializers serializers = (_$serializers.toBuilder()
+      ..add(const OneOfSerializer())
+      ..add(const AnyOfSerializer())
+      ..add(const DateSerializer())
+      ..add(Iso8601DateTimeSerializer()))
+    .build();
+
+Serializers standardSerializers =
+    (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/pom.xml b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..cceaebd895f673a87e3d5a5971817f16127870ce
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/pom.xml
@@ -0,0 +1,88 @@
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.openapitools</groupId>
+    <artifactId>DartDioOneOfPrimitive</artifactId>
+    <packaging>pom</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>DartDio OneOf Primitive</name>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.2.1</version>
+                <executions>
+                    <execution>
+                        <id>pub-get</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>pub</executable>
+                            <arguments>
+                                <argument>get</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>pub-run-build-runner</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>pub</executable>
+                            <arguments>
+                                <argument>run</argument>
+                                <argument>build_runner</argument>
+                                <argument>build</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>dart-analyze</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>dart</executable>
+                            <arguments>
+                                <argument>analyze</argument>
+                                <argument>--fatal-infos</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>dart-test</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>dart</executable>
+                            <arguments>
+                                <argument>test</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/pubspec.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..fb676f65c393c216466d443ec4060097085cd922
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/pubspec.yaml
@@ -0,0 +1,19 @@
+name: openapi
+version: 1.0.0
+description: OpenAPI API client
+homepage: homepage
+
+environment:
+  sdk: '>=2.12.0 <3.0.0'
+
+dependencies:
+  dio: '>=4.0.1 <5.0.0'
+  one_of: '>=1.5.0 <2.0.0'
+  one_of_serializer: '>=1.5.0 <2.0.0'
+  built_value: '>=8.4.0 <9.0.0'
+  built_collection: '>=5.1.1 <6.0.0'
+
+dev_dependencies:
+  built_value_generator: '>=8.4.0 <9.0.0'
+  build_runner: any
+  test: ^1.16.0
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/test/child_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/test/child_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d40451a84c2c46ffbdd268e01f967467c1ce2ec0
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/test/child_test.dart
@@ -0,0 +1,16 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Child
+void main() {
+  final instance = ChildBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Child, () {
+    // String name
+    test('to test the property `name`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/test/default_api_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/test/default_api_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e4ec5707794652a7823b6e057b966b364f80e260
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/test/default_api_test.dart
@@ -0,0 +1,16 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+
+/// tests for DefaultApi
+void main() {
+  final instance = Openapi().getDefaultApi();
+
+  group(DefaultApi, () {
+    //Future<Example> list() async
+    test('test list', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/test/example_test.dart b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/test/example_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ccb35121143ea7e8ff3bdf5f9f4d40729a0d635e
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/test/example_test.dart
@@ -0,0 +1,16 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for Example
+void main() {
+  final instance = ExampleBuilder();
+  // TODO add properties to the builder and call build()
+
+  group(Example, () {
+    // String name
+    test('to test the property `name`', () async {
+      // TODO
+    });
+
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/additional_properties_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/additional_properties_class.dart
index d45eeef83d992b2967bccb06bc484f29a748b819..a3d4df084be523cb99681ab1adeafaa7ea2b0890 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/additional_properties_class.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/additional_properties_class.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'additional_properties_class.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/all_of_with_single_ref.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/all_of_with_single_ref.dart
index 7ee9944f7f0910bd05ec2781bd86c12e4f875dd1..dd3a19e9d93f42d1f34cfd791a6b5295e254c895 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/all_of_with_single_ref.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/all_of_with_single_ref.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/single_ref_type.dart';
 import 'package:json_annotation/json_annotation.dart';
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/animal.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/animal.dart
index 26090b109208382741dcfb3cbdfd5cfbbc296350..22a196ce7d7fd1da2e35945db5301601db746468 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/animal.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/animal.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'animal.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/api_response.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/api_response.dart
index ac22fd59d69a3409ce3b55e27bdfa539e9b0a53b..c6700e2d39ce6010853b8c7b4cd52eb415ad252c 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/api_response.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/api_response.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'api_response.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_of_array_of_number_only.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_of_array_of_number_only.dart
index dbae180528bd70de709d42d561be7c127975330c..7372be1583f266a974a7b5bfdb0bbb1036867fba 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_of_array_of_number_only.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_of_array_of_number_only.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'array_of_array_of_number_only.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_of_number_only.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_of_number_only.dart
index a203361bcc3d0d5c44fc751df13ceb582a50c4b9..d538bb312fdeec3f36a777faa53e0b546466ee05 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_of_number_only.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_of_number_only.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'array_of_number_only.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_test.dart
index 1f1720b2b667300299a0a15a55d3c1d454929329..30a6ec8a8b724874cb99121e7d20cdc0840f438e 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_test.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/read_only_first.dart';
 import 'package:json_annotation/json_annotation.dart';
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/capitalization.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/capitalization.dart
index d40127b68a980e17acbfd69b67c0beb7e2c3f52f..707cb05a040facce1f23c1dc7be0aff402f4a99c 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/capitalization.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/capitalization.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'capitalization.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/cat.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/cat.dart
index 9d79ad482202cd3aaa1767c6f5df76295e6a2d5b..0b176faf313e563e2e8c15725b6b5257c16fb267 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/cat.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/cat.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/animal.dart';
 import 'package:json_annotation/json_annotation.dart';
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/cat_all_of.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/cat_all_of.dart
index 55e2a10832f88c45037628c72e1639a8d1569f8a..abb9dbc25e5f87430335f44fb470031200f76f66 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/cat_all_of.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/cat_all_of.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'cat_all_of.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/category.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/category.dart
index 6bc66f34418b45ae1631d618a7f38808cd3f4575..b94c61579909c863d6de595512e64b4c27e4f352 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/category.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/category.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'category.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/class_model.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/class_model.dart
index 015d2d0297a02f661bfef528c918c1c1149d561d..01837bfcca962b877faee067567ec8bcf1a89fae 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/class_model.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/class_model.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'class_model.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/deprecated_object.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/deprecated_object.dart
index 9240f1160d0327070a4fb9c139173dc98fdf20d0..b97e0637258e529b852dacfb506d9630681b8ec7 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/deprecated_object.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/deprecated_object.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'deprecated_object.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/dog.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/dog.dart
index 62527c046b38f510451c1bf3f9f704f36f4d031d..a049d0479fb01fa3f8ed40e9a0537b219f63e879 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/dog.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/dog.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/animal.dart';
 import 'package:json_annotation/json_annotation.dart';
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/dog_all_of.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/dog_all_of.dart
index d5ceabdc3a1af85168ec5a44d4dcf8f18dbca170..19bd4c0267bee035305556302e1e794fb79426e9 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/dog_all_of.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/dog_all_of.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'dog_all_of.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_arrays.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_arrays.dart
index 54c9839b9fe179349bac35bc84cb7104f32b5621..a97d069a3d258b8522d71f5cb0401b79ff338b26 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_arrays.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_arrays.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'enum_arrays.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_test.dart
index 17a67de347eb1a781a997c228fd03d92177ac2cc..80555c14d0388fe8af08e66be05b63e337ab9869 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_test.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/outer_enum.dart';
 import 'package:openapi/src/model/outer_enum_default_value.dart';
 import 'package:openapi/src/model/outer_enum_integer.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/file_schema_test_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/file_schema_test_class.dart
index 99d4dd3551c362bac473ec9fdafba45514873c57..bd2a9dc6f2fc1ec1898972ee2a8236e912d78de5 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/file_schema_test_class.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/file_schema_test_class.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/model_file.dart';
 import 'package:json_annotation/json_annotation.dart';
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/foo.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/foo.dart
index b21bae484ea52f6d0fb6a666c31d24cd95bd7410..b43572d222cb5a89ce8809e7ae6a4306bd642bf6 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/foo.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/foo.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'foo.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/foo_get_default_response.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/foo_get_default_response.dart
index 423f93eb7798f45c8ae4543769c2b3a8225ef448..acc1c60e4353abbca85860a31d4eafe2500b3be9 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/foo_get_default_response.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/foo_get_default_response.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/foo.dart';
 import 'package:json_annotation/json_annotation.dart';
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/format_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/format_test.dart
index a83f4721d820af30e7fb07b3f2047b87ad65e843..91b35595a34d322b0936c56faea45989da045bff 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/format_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/format_test.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:dio/dio.dart';
 import 'package:json_annotation/json_annotation.dart';
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/has_only_read_only.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/has_only_read_only.dart
index 25d25ddd06e965cea3fa4d2ab1ee2a988d696514..84c99fbc188cb0fc77ea7b611c48599978c79007 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/has_only_read_only.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/has_only_read_only.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'has_only_read_only.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/health_check_result.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/health_check_result.dart
index 43a07ec7d50cf24f1ed5e1bd7e92cbbff7162139..fcb2973b7514de6df6ffba152f73ca7906dd9be4 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/health_check_result.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/health_check_result.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'health_check_result.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/map_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/map_test.dart
index 5c4c3edb70f9aefe63c4d0ec782d35b44fb7c240..7ab19eabd5cdb37c4cc3f11db6d200c6c1f81bea 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/map_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/map_test.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'map_test.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/mixed_properties_and_additional_properties_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/mixed_properties_and_additional_properties_class.dart
index 649f7955806b39d0ba9141a012956b6bbc51eed3..e2e3cd0b857a3b76570c132e5ec3a4d866512d9b 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/mixed_properties_and_additional_properties_class.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/mixed_properties_and_additional_properties_class.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/animal.dart';
 import 'package:json_annotation/json_annotation.dart';
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model200_response.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model200_response.dart
index f4be2b420f647266e7e074d40f80b1f1ba9e4d1e..346f1257555f9408c96f9e45b3f9913dbf60c042 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model200_response.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model200_response.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'model200_response.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_client.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_client.dart
index 811e277685402477d4dfd2232ca5997affa8788b..14e22005a1618f8cc441391a788abe83c77c2788 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_client.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_client.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'model_client.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_enum_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_enum_class.dart
index e3323e17a181c78f0f690c694daca0021c92f9c2..8abf107d98e68c17b8702e73646c30c07a444070 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_enum_class.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_enum_class.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_file.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_file.dart
index fa38556a545590a303754c8527730b29962ed2f9..fe95e3ff002918ee18881e08a23256f8ffd6ad34 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_file.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_file.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'model_file.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_list.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_list.dart
index f5ae9fdbd76c8e92d08e5489febf647cfa909e7c..543b79ac9f13982d8dd697805731f32086936f06 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_list.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_list.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'model_list.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_return.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_return.dart
index a2b022414fb87223f1680ef33197be3fed97e27f..192b134d8fc6891b37fd0c162f44886d83caabbd 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_return.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/model_return.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'model_return.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/name.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/name.dart
index c361e4397eaf3a7539e40fa49e762a6a3203f687..6613fa3afc8be2825db035674f65024f6ad038c6 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/name.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/name.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'name.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/nullable_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/nullable_class.dart
index 3816bb33839e8c635f6095457c2657a37efae516..897d489ba4503e95c9ef8d50ce42a70ac9c27d6a 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/nullable_class.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/nullable_class.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'nullable_class.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/number_only.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/number_only.dart
index 8efb55ea167b1076e0fd572fea74b5cb498370fb..3ca6bf704b59bdd08fce4f6a3784fdde1a3ef48e 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/number_only.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/number_only.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'number_only.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/object_with_deprecated_fields.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/object_with_deprecated_fields.dart
index 522ee40e2e02227133eb2ea497caa3361aa480c8..17361613609ccd69c789a9feebdf9e22e6e9ef0c 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/object_with_deprecated_fields.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/object_with_deprecated_fields.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/deprecated_object.dart';
 import 'package:json_annotation/json_annotation.dart';
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/order.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/order.dart
index 087980a08e888d0b6f050f29ba26a25cb137c3d1..54134b51131625bbe65c318807f4c39a6187e47e 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/order.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/order.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'order.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_composite.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_composite.dart
index f452e4b233d580ece7878a813e0da65484eb2219..f2509cb99213e9f3307ca2452f555d701bdedf80 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_composite.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_composite.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'outer_composite.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum.dart
index 5b863632d5d9fe94cb10e9a4070d61fda801c607..514507968c66571dd91bb49c0a93d5d8bb3d71c0 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_default_value.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_default_value.dart
index f4585362ec877060176415573ae5fb8a0faa9f44..0c8116edea96e669e3849f05be4c66cf9583842d 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_default_value.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_default_value.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_integer.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_integer.dart
index c3f134455dc93e0139191c46dbd4276bdcd6ca64..34268d0e9c53ef3052663f1331cb562437cf7b98 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_integer.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_integer.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_integer_default_value.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_integer_default_value.dart
index d94f696f81b4e471ac006a06c94db7c22d760117..97b325938828e27e43ac5e90ac7224df311eba44 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_integer_default_value.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_enum_integer_default_value.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_object_with_enum_property.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_object_with_enum_property.dart
index 80331fe4df41b41308379af8021db9078bed2f20..76d18676a110deb8ed9add74cfa41f9aae96964a 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_object_with_enum_property.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/outer_object_with_enum_property.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/outer_enum_integer.dart';
 import 'package:json_annotation/json_annotation.dart';
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/pet.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/pet.dart
index f9cf64883848e2dcf587df56283093ed0f13fe2b..28d6294bae59c1445f190845ab7f364538a2fd74 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/pet.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/pet.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/category.dart';
 import 'package:openapi/src/model/tag.dart';
 import 'package:json_annotation/json_annotation.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/read_only_first.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/read_only_first.dart
index c79e7df9aeafcee7d8db41c6c7f560618f5bdcb2..c71c088f13815053d2d4a825a05da7c5f754491c 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/read_only_first.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/read_only_first.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'read_only_first.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/single_ref_type.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/single_ref_type.dart
index 072d072e0bde23ebb40594bc9934c86f253cdc70..ca56d9841a5a84c5ca7f2cf4f4e1ce26ed4e28a8 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/single_ref_type.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/single_ref_type.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/special_model_name.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/special_model_name.dart
index 84332bb1a13ec71c1714886cbed75773a82e7969..acd3ba099576e1e23ea8801957c66e275cc4b7c9 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/special_model_name.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/special_model_name.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'special_model_name.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/tag.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/tag.dart
index d0372c1742246426d3cbf8b92df81a94699beb66..d8a87eec182008365782fce459d799d2b99185e4 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/tag.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/tag.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'tag.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/user.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/user.dart
index 8bb2ae70ce5e0a2d48071d8fe30eb5f2e3de1353..62f132ce776d8e40fa44576993429fa645c6a047 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/user.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/user.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:json_annotation/json_annotation.dart';
 
 part 'user.g.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart
index 4d45be3abbfbb84ba6de147e7e2e5bbf400f15d2..3fdac6d5a44fce55c69aaf9d3c77cbdcc18b4781 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
@@ -13,75 +14,114 @@ part 'additional_properties_class.g.dart';
 /// Properties:
 /// * [mapProperty] 
 /// * [mapOfMapProperty] 
+@BuiltValue()
 abstract class AdditionalPropertiesClass implements Built<AdditionalPropertiesClass, AdditionalPropertiesClassBuilder> {
-    @BuiltValueField(wireName: r'map_property')
-    BuiltMap<String, String>? get mapProperty;
+  @BuiltValueField(wireName: r'map_property')
+  BuiltMap<String, String>? get mapProperty;
 
-    @BuiltValueField(wireName: r'map_of_map_property')
-    BuiltMap<String, BuiltMap<String, String>>? get mapOfMapProperty;
+  @BuiltValueField(wireName: r'map_of_map_property')
+  BuiltMap<String, BuiltMap<String, String>>? get mapOfMapProperty;
 
-    AdditionalPropertiesClass._();
+  AdditionalPropertiesClass._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(AdditionalPropertiesClassBuilder b) => b;
+  factory AdditionalPropertiesClass([void updates(AdditionalPropertiesClassBuilder b)]) = _$AdditionalPropertiesClass;
 
-    factory AdditionalPropertiesClass([void updates(AdditionalPropertiesClassBuilder b)]) = _$AdditionalPropertiesClass;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(AdditionalPropertiesClassBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<AdditionalPropertiesClass> get serializer => _$AdditionalPropertiesClassSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<AdditionalPropertiesClass> get serializer => _$AdditionalPropertiesClassSerializer();
 }
 
-class _$AdditionalPropertiesClassSerializer implements StructuredSerializer<AdditionalPropertiesClass> {
-    @override
-    final Iterable<Type> types = const [AdditionalPropertiesClass, _$AdditionalPropertiesClass];
+class _$AdditionalPropertiesClassSerializer implements PrimitiveSerializer<AdditionalPropertiesClass> {
+  @override
+  final Iterable<Type> types = const [AdditionalPropertiesClass, _$AdditionalPropertiesClass];
 
-    @override
-    final String wireName = r'AdditionalPropertiesClass';
+  @override
+  final String wireName = r'AdditionalPropertiesClass';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, AdditionalPropertiesClass object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.mapProperty != null) {
-            result
-                ..add(r'map_property')
-                ..add(serializers.serialize(object.mapProperty,
-                    specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)])));
-        }
-        if (object.mapOfMapProperty != null) {
-            result
-                ..add(r'map_of_map_property')
-                ..add(serializers.serialize(object.mapOfMapProperty,
-                    specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])])));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    AdditionalPropertiesClass object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.mapProperty != null) {
+      yield r'map_property';
+      yield serializers.serialize(
+        object.mapProperty,
+        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]),
+      );
     }
+    if (object.mapOfMapProperty != null) {
+      yield r'map_of_map_property';
+      yield serializers.serialize(
+        object.mapOfMapProperty,
+        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])]),
+      );
+    }
+  }
 
-    @override
-    AdditionalPropertiesClass deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = AdditionalPropertiesClassBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    AdditionalPropertiesClass object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'map_property':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)])) as BuiltMap<String, String>;
-                    result.mapProperty.replace(valueDes);
-                    break;
-                case r'map_of_map_property':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])])) as BuiltMap<String, BuiltMap<String, String>>;
-                    result.mapOfMapProperty.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required AdditionalPropertiesClassBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'map_property':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]),
+          ) as BuiltMap<String, String>;
+          result.mapProperty.replace(valueDes);
+          break;
+        case r'map_of_map_property':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])]),
+          ) as BuiltMap<String, BuiltMap<String, String>>;
+          result.mapOfMapProperty.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  AdditionalPropertiesClass deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = AdditionalPropertiesClassBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/all_of_with_single_ref.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/all_of_with_single_ref.dart
index a6955be4a92a0942193950d661dd3c4248ee1c64..04f59d36012889c98d8d1974ffec2b020136b2de 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/all_of_with_single_ref.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/all_of_with_single_ref.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/single_ref_type.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
@@ -13,75 +14,114 @@ part 'all_of_with_single_ref.g.dart';
 /// Properties:
 /// * [username] 
 /// * [singleRefType] 
+@BuiltValue()
 abstract class AllOfWithSingleRef implements Built<AllOfWithSingleRef, AllOfWithSingleRefBuilder> {
-    @BuiltValueField(wireName: r'username')
-    String? get username;
+  @BuiltValueField(wireName: r'username')
+  String? get username;
 
-    @BuiltValueField(wireName: r'SingleRefType')
-    SingleRefType? get singleRefType;
+  @BuiltValueField(wireName: r'SingleRefType')
+  SingleRefType? get singleRefType;
 
-    AllOfWithSingleRef._();
+  AllOfWithSingleRef._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(AllOfWithSingleRefBuilder b) => b;
+  factory AllOfWithSingleRef([void updates(AllOfWithSingleRefBuilder b)]) = _$AllOfWithSingleRef;
 
-    factory AllOfWithSingleRef([void updates(AllOfWithSingleRefBuilder b)]) = _$AllOfWithSingleRef;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(AllOfWithSingleRefBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<AllOfWithSingleRef> get serializer => _$AllOfWithSingleRefSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<AllOfWithSingleRef> get serializer => _$AllOfWithSingleRefSerializer();
 }
 
-class _$AllOfWithSingleRefSerializer implements StructuredSerializer<AllOfWithSingleRef> {
-    @override
-    final Iterable<Type> types = const [AllOfWithSingleRef, _$AllOfWithSingleRef];
+class _$AllOfWithSingleRefSerializer implements PrimitiveSerializer<AllOfWithSingleRef> {
+  @override
+  final Iterable<Type> types = const [AllOfWithSingleRef, _$AllOfWithSingleRef];
 
-    @override
-    final String wireName = r'AllOfWithSingleRef';
+  @override
+  final String wireName = r'AllOfWithSingleRef';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, AllOfWithSingleRef object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.username != null) {
-            result
-                ..add(r'username')
-                ..add(serializers.serialize(object.username,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.singleRefType != null) {
-            result
-                ..add(r'SingleRefType')
-                ..add(serializers.serialize(object.singleRefType,
-                    specifiedType: const FullType(SingleRefType)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    AllOfWithSingleRef object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.username != null) {
+      yield r'username';
+      yield serializers.serialize(
+        object.username,
+        specifiedType: const FullType(String),
+      );
     }
+    if (object.singleRefType != null) {
+      yield r'SingleRefType';
+      yield serializers.serialize(
+        object.singleRefType,
+        specifiedType: const FullType(SingleRefType),
+      );
+    }
+  }
 
-    @override
-    AllOfWithSingleRef deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = AllOfWithSingleRefBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    AllOfWithSingleRef object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'username':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.username = valueDes;
-                    break;
-                case r'SingleRefType':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(SingleRefType)) as SingleRefType;
-                    result.singleRefType = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required AllOfWithSingleRefBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'username':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.username = valueDes;
+          break;
+        case r'SingleRefType':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(SingleRefType),
+          ) as SingleRefType;
+          result.singleRefType = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  AllOfWithSingleRef deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = AllOfWithSingleRefBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/animal.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/animal.dart
index cd9084ceb289960039dace82043d4854aab6e850..a8f8aa9c9027735d952a673bf93626e6270ce506 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/animal.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/animal.dart
@@ -2,6 +2,9 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/dog.dart';
+import 'package:openapi/src/model/cat.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -12,74 +15,168 @@ part 'animal.g.dart';
 /// Properties:
 /// * [className] 
 /// * [color] 
-abstract class Animal implements Built<Animal, AnimalBuilder> {
-    @BuiltValueField(wireName: r'className')
-    String get className;
+@BuiltValue(instantiable: false)
+abstract class Animal  {
+  @BuiltValueField(wireName: r'className')
+  String get className;
 
-    @BuiltValueField(wireName: r'color')
-    String? get color;
+  @BuiltValueField(wireName: r'color')
+  String? get color;
 
-    Animal._();
+  static const String discriminatorFieldName = r'className';
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(AnimalBuilder b) => b
-        ..color = 'red';
+  static const Map<String, Type> discriminatorMapping = {
+    r'Cat': Cat,
+    r'Dog': Dog,
+  };
 
-    factory Animal([void updates(AnimalBuilder b)]) = _$Animal;
-
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Animal> get serializer => _$AnimalSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Animal> get serializer => _$AnimalSerializer();
 }
 
-class _$AnimalSerializer implements StructuredSerializer<Animal> {
-    @override
-    final Iterable<Type> types = const [Animal, _$Animal];
-
-    @override
-    final String wireName = r'Animal';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Animal object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        result
-            ..add(r'className')
-            ..add(serializers.serialize(object.className,
-                specifiedType: const FullType(String)));
-        if (object.color != null) {
-            result
-                ..add(r'color')
-                ..add(serializers.serialize(object.color,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+class _$AnimalSerializer implements PrimitiveSerializer<Animal> {
+  @override
+  final Iterable<Type> types = const [Animal];
+
+  @override
+  final String wireName = r'Animal';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Animal object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    yield r'className';
+    yield serializers.serialize(
+      object.className,
+      specifiedType: const FullType(String),
+    );
+    if (object.color != null) {
+      yield r'color';
+      yield serializers.serialize(
+        object.color,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Animal object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    if (object is Cat) {
+      return serializers.serialize(object, specifiedType: FullType(Cat))!;
     }
+    if (object is Dog) {
+      return serializers.serialize(object, specifiedType: FullType(Dog))!;
+    }
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  @override
+  Animal deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final discIndex = serializedList.indexOf(Animal.discriminatorFieldName) + 1;
+    final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String;
+    switch (discValue) {
+      case 'Cat':
+        return serializers.deserialize(serialized, specifiedType: FullType(Cat)) as Cat;
+      case 'Dog':
+        return serializers.deserialize(serialized, specifiedType: FullType(Dog)) as Dog;
+      default:
+        return serializers.deserialize(serialized, specifiedType: FullType($Animal)) as $Animal;
+    }
+  }
+}
 
-    @override
-    Animal deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = AnimalBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'className':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.className = valueDes;
-                    break;
-                case r'color':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.color = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+/// a concrete implementation of [Animal], since [Animal] is not instantiable
+@BuiltValue(instantiable: true)
+abstract class $Animal implements Animal, Built<$Animal, $AnimalBuilder> {
+  $Animal._();
+
+  factory $Animal([void Function($AnimalBuilder)? updates]) = _$$Animal;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults($AnimalBuilder b) => b;
+
+  @BuiltValueSerializer(custom: true)
+  static Serializer<$Animal> get serializer => _$$AnimalSerializer();
+}
+
+class _$$AnimalSerializer implements PrimitiveSerializer<$Animal> {
+  @override
+  final Iterable<Type> types = const [$Animal, _$$Animal];
+
+  @override
+  final String wireName = r'$Animal';
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    $Animal object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.serialize(object, specifiedType: FullType(Animal))!;
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required AnimalBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'className':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.className = valueDes;
+          break;
+        case r'color':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.color = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  $Animal deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = $AnimalBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/api_response.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/api_response.dart
index c2ebff7ffeabd87f1d54c4150744eb9b2d54773c..aadcd792e2bfd2af2902dd821b459dbcb6c3503f 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/api_response.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/api_response.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -13,89 +14,131 @@ part 'api_response.g.dart';
 /// * [code] 
 /// * [type] 
 /// * [message] 
+@BuiltValue()
 abstract class ApiResponse implements Built<ApiResponse, ApiResponseBuilder> {
-    @BuiltValueField(wireName: r'code')
-    int? get code;
+  @BuiltValueField(wireName: r'code')
+  int? get code;
 
-    @BuiltValueField(wireName: r'type')
-    String? get type;
+  @BuiltValueField(wireName: r'type')
+  String? get type;
 
-    @BuiltValueField(wireName: r'message')
-    String? get message;
+  @BuiltValueField(wireName: r'message')
+  String? get message;
 
-    ApiResponse._();
+  ApiResponse._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ApiResponseBuilder b) => b;
+  factory ApiResponse([void updates(ApiResponseBuilder b)]) = _$ApiResponse;
 
-    factory ApiResponse([void updates(ApiResponseBuilder b)]) = _$ApiResponse;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ApiResponseBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ApiResponse> get serializer => _$ApiResponseSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ApiResponse> get serializer => _$ApiResponseSerializer();
 }
 
-class _$ApiResponseSerializer implements StructuredSerializer<ApiResponse> {
-    @override
-    final Iterable<Type> types = const [ApiResponse, _$ApiResponse];
-
-    @override
-    final String wireName = r'ApiResponse';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ApiResponse object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.code != null) {
-            result
-                ..add(r'code')
-                ..add(serializers.serialize(object.code,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.type != null) {
-            result
-                ..add(r'type')
-                ..add(serializers.serialize(object.type,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.message != null) {
-            result
-                ..add(r'message')
-                ..add(serializers.serialize(object.message,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+class _$ApiResponseSerializer implements PrimitiveSerializer<ApiResponse> {
+  @override
+  final Iterable<Type> types = const [ApiResponse, _$ApiResponse];
+
+  @override
+  final String wireName = r'ApiResponse';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ApiResponse object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.code != null) {
+      yield r'code';
+      yield serializers.serialize(
+        object.code,
+        specifiedType: const FullType(int),
+      );
+    }
+    if (object.type != null) {
+      yield r'type';
+      yield serializers.serialize(
+        object.type,
+        specifiedType: const FullType(String),
+      );
     }
+    if (object.message != null) {
+      yield r'message';
+      yield serializers.serialize(
+        object.message,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    ApiResponse object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-    @override
-    ApiResponse deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ApiResponseBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'code':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.code = valueDes;
-                    break;
-                case r'type':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.type = valueDes;
-                    break;
-                case r'message':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.message = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ApiResponseBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'code':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.code = valueDes;
+          break;
+        case r'type':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.type = valueDes;
+          break;
+        case r'message':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.message = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ApiResponse deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ApiResponseBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_of_array_of_number_only.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_of_array_of_number_only.dart
index 1fa583bccc15cfbd89dbdeb666338cf6d23c1c09..5bc0982b8ab0eed0e0eec274e9c3d2391b37049f 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_of_array_of_number_only.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_of_array_of_number_only.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
@@ -12,61 +13,97 @@ part 'array_of_array_of_number_only.g.dart';
 ///
 /// Properties:
 /// * [arrayArrayNumber] 
+@BuiltValue()
 abstract class ArrayOfArrayOfNumberOnly implements Built<ArrayOfArrayOfNumberOnly, ArrayOfArrayOfNumberOnlyBuilder> {
-    @BuiltValueField(wireName: r'ArrayArrayNumber')
-    BuiltList<BuiltList<num>>? get arrayArrayNumber;
+  @BuiltValueField(wireName: r'ArrayArrayNumber')
+  BuiltList<BuiltList<num>>? get arrayArrayNumber;
 
-    ArrayOfArrayOfNumberOnly._();
+  ArrayOfArrayOfNumberOnly._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ArrayOfArrayOfNumberOnlyBuilder b) => b;
+  factory ArrayOfArrayOfNumberOnly([void updates(ArrayOfArrayOfNumberOnlyBuilder b)]) = _$ArrayOfArrayOfNumberOnly;
 
-    factory ArrayOfArrayOfNumberOnly([void updates(ArrayOfArrayOfNumberOnlyBuilder b)]) = _$ArrayOfArrayOfNumberOnly;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ArrayOfArrayOfNumberOnlyBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ArrayOfArrayOfNumberOnly> get serializer => _$ArrayOfArrayOfNumberOnlySerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ArrayOfArrayOfNumberOnly> get serializer => _$ArrayOfArrayOfNumberOnlySerializer();
 }
 
-class _$ArrayOfArrayOfNumberOnlySerializer implements StructuredSerializer<ArrayOfArrayOfNumberOnly> {
-    @override
-    final Iterable<Type> types = const [ArrayOfArrayOfNumberOnly, _$ArrayOfArrayOfNumberOnly];
+class _$ArrayOfArrayOfNumberOnlySerializer implements PrimitiveSerializer<ArrayOfArrayOfNumberOnly> {
+  @override
+  final Iterable<Type> types = const [ArrayOfArrayOfNumberOnly, _$ArrayOfArrayOfNumberOnly];
 
-    @override
-    final String wireName = r'ArrayOfArrayOfNumberOnly';
+  @override
+  final String wireName = r'ArrayOfArrayOfNumberOnly';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ArrayOfArrayOfNumberOnly object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.arrayArrayNumber != null) {
-            result
-                ..add(r'ArrayArrayNumber')
-                ..add(serializers.serialize(object.arrayArrayNumber,
-                    specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(num)])])));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ArrayOfArrayOfNumberOnly object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.arrayArrayNumber != null) {
+      yield r'ArrayArrayNumber';
+      yield serializers.serialize(
+        object.arrayArrayNumber,
+        specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(num)])]),
+      );
     }
+  }
 
-    @override
-    ArrayOfArrayOfNumberOnly deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ArrayOfArrayOfNumberOnlyBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    ArrayOfArrayOfNumberOnly object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'ArrayArrayNumber':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(num)])])) as BuiltList<BuiltList<num>>;
-                    result.arrayArrayNumber.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ArrayOfArrayOfNumberOnlyBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'ArrayArrayNumber':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(num)])]),
+          ) as BuiltList<BuiltList<num>>;
+          result.arrayArrayNumber.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ArrayOfArrayOfNumberOnly deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ArrayOfArrayOfNumberOnlyBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_of_number_only.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_of_number_only.dart
index fcbd7d393beabaed6ac9afdb6d45cbdf6ee15645..72239924f5ec7ac3ca525944e010b4e1c7821d03 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_of_number_only.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_of_number_only.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
@@ -12,61 +13,97 @@ part 'array_of_number_only.g.dart';
 ///
 /// Properties:
 /// * [arrayNumber] 
+@BuiltValue()
 abstract class ArrayOfNumberOnly implements Built<ArrayOfNumberOnly, ArrayOfNumberOnlyBuilder> {
-    @BuiltValueField(wireName: r'ArrayNumber')
-    BuiltList<num>? get arrayNumber;
+  @BuiltValueField(wireName: r'ArrayNumber')
+  BuiltList<num>? get arrayNumber;
 
-    ArrayOfNumberOnly._();
+  ArrayOfNumberOnly._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ArrayOfNumberOnlyBuilder b) => b;
+  factory ArrayOfNumberOnly([void updates(ArrayOfNumberOnlyBuilder b)]) = _$ArrayOfNumberOnly;
 
-    factory ArrayOfNumberOnly([void updates(ArrayOfNumberOnlyBuilder b)]) = _$ArrayOfNumberOnly;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ArrayOfNumberOnlyBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ArrayOfNumberOnly> get serializer => _$ArrayOfNumberOnlySerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ArrayOfNumberOnly> get serializer => _$ArrayOfNumberOnlySerializer();
 }
 
-class _$ArrayOfNumberOnlySerializer implements StructuredSerializer<ArrayOfNumberOnly> {
-    @override
-    final Iterable<Type> types = const [ArrayOfNumberOnly, _$ArrayOfNumberOnly];
+class _$ArrayOfNumberOnlySerializer implements PrimitiveSerializer<ArrayOfNumberOnly> {
+  @override
+  final Iterable<Type> types = const [ArrayOfNumberOnly, _$ArrayOfNumberOnly];
 
-    @override
-    final String wireName = r'ArrayOfNumberOnly';
+  @override
+  final String wireName = r'ArrayOfNumberOnly';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ArrayOfNumberOnly object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.arrayNumber != null) {
-            result
-                ..add(r'ArrayNumber')
-                ..add(serializers.serialize(object.arrayNumber,
-                    specifiedType: const FullType(BuiltList, [FullType(num)])));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ArrayOfNumberOnly object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.arrayNumber != null) {
+      yield r'ArrayNumber';
+      yield serializers.serialize(
+        object.arrayNumber,
+        specifiedType: const FullType(BuiltList, [FullType(num)]),
+      );
     }
+  }
 
-    @override
-    ArrayOfNumberOnly deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ArrayOfNumberOnlyBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    ArrayOfNumberOnly object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'ArrayNumber':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltList, [FullType(num)])) as BuiltList<num>;
-                    result.arrayNumber.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ArrayOfNumberOnlyBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'ArrayNumber':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltList, [FullType(num)]),
+          ) as BuiltList<num>;
+          result.arrayNumber.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ArrayOfNumberOnly deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ArrayOfNumberOnlyBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_test.dart
index 8025d141c124b26d080b876153c95382f25d3326..21f3a5a4c2d59213cf7e155556c093ba8d60d911 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/array_test.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:openapi/src/model/read_only_first.dart';
 import 'package:built_value/built_value.dart';
@@ -15,89 +16,131 @@ part 'array_test.g.dart';
 /// * [arrayOfString] 
 /// * [arrayArrayOfInteger] 
 /// * [arrayArrayOfModel] 
+@BuiltValue()
 abstract class ArrayTest implements Built<ArrayTest, ArrayTestBuilder> {
-    @BuiltValueField(wireName: r'array_of_string')
-    BuiltList<String>? get arrayOfString;
+  @BuiltValueField(wireName: r'array_of_string')
+  BuiltList<String>? get arrayOfString;
 
-    @BuiltValueField(wireName: r'array_array_of_integer')
-    BuiltList<BuiltList<int>>? get arrayArrayOfInteger;
+  @BuiltValueField(wireName: r'array_array_of_integer')
+  BuiltList<BuiltList<int>>? get arrayArrayOfInteger;
 
-    @BuiltValueField(wireName: r'array_array_of_model')
-    BuiltList<BuiltList<ReadOnlyFirst>>? get arrayArrayOfModel;
+  @BuiltValueField(wireName: r'array_array_of_model')
+  BuiltList<BuiltList<ReadOnlyFirst>>? get arrayArrayOfModel;
 
-    ArrayTest._();
+  ArrayTest._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ArrayTestBuilder b) => b;
+  factory ArrayTest([void updates(ArrayTestBuilder b)]) = _$ArrayTest;
 
-    factory ArrayTest([void updates(ArrayTestBuilder b)]) = _$ArrayTest;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ArrayTestBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ArrayTest> get serializer => _$ArrayTestSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ArrayTest> get serializer => _$ArrayTestSerializer();
 }
 
-class _$ArrayTestSerializer implements StructuredSerializer<ArrayTest> {
-    @override
-    final Iterable<Type> types = const [ArrayTest, _$ArrayTest];
-
-    @override
-    final String wireName = r'ArrayTest';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ArrayTest object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.arrayOfString != null) {
-            result
-                ..add(r'array_of_string')
-                ..add(serializers.serialize(object.arrayOfString,
-                    specifiedType: const FullType(BuiltList, [FullType(String)])));
-        }
-        if (object.arrayArrayOfInteger != null) {
-            result
-                ..add(r'array_array_of_integer')
-                ..add(serializers.serialize(object.arrayArrayOfInteger,
-                    specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(int)])])));
-        }
-        if (object.arrayArrayOfModel != null) {
-            result
-                ..add(r'array_array_of_model')
-                ..add(serializers.serialize(object.arrayArrayOfModel,
-                    specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(ReadOnlyFirst)])])));
-        }
-        return result;
+class _$ArrayTestSerializer implements PrimitiveSerializer<ArrayTest> {
+  @override
+  final Iterable<Type> types = const [ArrayTest, _$ArrayTest];
+
+  @override
+  final String wireName = r'ArrayTest';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ArrayTest object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.arrayOfString != null) {
+      yield r'array_of_string';
+      yield serializers.serialize(
+        object.arrayOfString,
+        specifiedType: const FullType(BuiltList, [FullType(String)]),
+      );
+    }
+    if (object.arrayArrayOfInteger != null) {
+      yield r'array_array_of_integer';
+      yield serializers.serialize(
+        object.arrayArrayOfInteger,
+        specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(int)])]),
+      );
     }
+    if (object.arrayArrayOfModel != null) {
+      yield r'array_array_of_model';
+      yield serializers.serialize(
+        object.arrayArrayOfModel,
+        specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(ReadOnlyFirst)])]),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    ArrayTest object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-    @override
-    ArrayTest deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ArrayTestBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'array_of_string':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltList, [FullType(String)])) as BuiltList<String>;
-                    result.arrayOfString.replace(valueDes);
-                    break;
-                case r'array_array_of_integer':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(int)])])) as BuiltList<BuiltList<int>>;
-                    result.arrayArrayOfInteger.replace(valueDes);
-                    break;
-                case r'array_array_of_model':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(ReadOnlyFirst)])])) as BuiltList<BuiltList<ReadOnlyFirst>>;
-                    result.arrayArrayOfModel.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ArrayTestBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'array_of_string':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltList, [FullType(String)]),
+          ) as BuiltList<String>;
+          result.arrayOfString.replace(valueDes);
+          break;
+        case r'array_array_of_integer':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(int)])]),
+          ) as BuiltList<BuiltList<int>>;
+          result.arrayArrayOfInteger.replace(valueDes);
+          break;
+        case r'array_array_of_model':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(ReadOnlyFirst)])]),
+          ) as BuiltList<BuiltList<ReadOnlyFirst>>;
+          result.arrayArrayOfModel.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ArrayTest deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ArrayTestBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/capitalization.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/capitalization.dart
index 15a8f080e9b1d563ea86938a99f9698346b2f622..75827b9a429e5572764d3117f79006f0ef295771 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/capitalization.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/capitalization.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -16,132 +17,183 @@ part 'capitalization.g.dart';
 /// * [capitalSnake] 
 /// * [sCAETHFlowPoints] 
 /// * [ATT_NAME] - Name of the pet 
+@BuiltValue()
 abstract class Capitalization implements Built<Capitalization, CapitalizationBuilder> {
-    @BuiltValueField(wireName: r'smallCamel')
-    String? get smallCamel;
+  @BuiltValueField(wireName: r'smallCamel')
+  String? get smallCamel;
 
-    @BuiltValueField(wireName: r'CapitalCamel')
-    String? get capitalCamel;
+  @BuiltValueField(wireName: r'CapitalCamel')
+  String? get capitalCamel;
 
-    @BuiltValueField(wireName: r'small_Snake')
-    String? get smallSnake;
+  @BuiltValueField(wireName: r'small_Snake')
+  String? get smallSnake;
 
-    @BuiltValueField(wireName: r'Capital_Snake')
-    String? get capitalSnake;
+  @BuiltValueField(wireName: r'Capital_Snake')
+  String? get capitalSnake;
 
-    @BuiltValueField(wireName: r'SCA_ETH_Flow_Points')
-    String? get sCAETHFlowPoints;
+  @BuiltValueField(wireName: r'SCA_ETH_Flow_Points')
+  String? get sCAETHFlowPoints;
 
-    /// Name of the pet 
-    @BuiltValueField(wireName: r'ATT_NAME')
-    String? get ATT_NAME;
+  /// Name of the pet 
+  @BuiltValueField(wireName: r'ATT_NAME')
+  String? get ATT_NAME;
 
-    Capitalization._();
+  Capitalization._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(CapitalizationBuilder b) => b;
+  factory Capitalization([void updates(CapitalizationBuilder b)]) = _$Capitalization;
 
-    factory Capitalization([void updates(CapitalizationBuilder b)]) = _$Capitalization;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(CapitalizationBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Capitalization> get serializer => _$CapitalizationSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Capitalization> get serializer => _$CapitalizationSerializer();
 }
 
-class _$CapitalizationSerializer implements StructuredSerializer<Capitalization> {
-    @override
-    final Iterable<Type> types = const [Capitalization, _$Capitalization];
-
-    @override
-    final String wireName = r'Capitalization';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Capitalization object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.smallCamel != null) {
-            result
-                ..add(r'smallCamel')
-                ..add(serializers.serialize(object.smallCamel,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.capitalCamel != null) {
-            result
-                ..add(r'CapitalCamel')
-                ..add(serializers.serialize(object.capitalCamel,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.smallSnake != null) {
-            result
-                ..add(r'small_Snake')
-                ..add(serializers.serialize(object.smallSnake,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.capitalSnake != null) {
-            result
-                ..add(r'Capital_Snake')
-                ..add(serializers.serialize(object.capitalSnake,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.sCAETHFlowPoints != null) {
-            result
-                ..add(r'SCA_ETH_Flow_Points')
-                ..add(serializers.serialize(object.sCAETHFlowPoints,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.ATT_NAME != null) {
-            result
-                ..add(r'ATT_NAME')
-                ..add(serializers.serialize(object.ATT_NAME,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+class _$CapitalizationSerializer implements PrimitiveSerializer<Capitalization> {
+  @override
+  final Iterable<Type> types = const [Capitalization, _$Capitalization];
+
+  @override
+  final String wireName = r'Capitalization';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Capitalization object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.smallCamel != null) {
+      yield r'smallCamel';
+      yield serializers.serialize(
+        object.smallCamel,
+        specifiedType: const FullType(String),
+      );
     }
-
-    @override
-    Capitalization deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = CapitalizationBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'smallCamel':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.smallCamel = valueDes;
-                    break;
-                case r'CapitalCamel':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.capitalCamel = valueDes;
-                    break;
-                case r'small_Snake':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.smallSnake = valueDes;
-                    break;
-                case r'Capital_Snake':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.capitalSnake = valueDes;
-                    break;
-                case r'SCA_ETH_Flow_Points':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.sCAETHFlowPoints = valueDes;
-                    break;
-                case r'ATT_NAME':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.ATT_NAME = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+    if (object.capitalCamel != null) {
+      yield r'CapitalCamel';
+      yield serializers.serialize(
+        object.capitalCamel,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.smallSnake != null) {
+      yield r'small_Snake';
+      yield serializers.serialize(
+        object.smallSnake,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.capitalSnake != null) {
+      yield r'Capital_Snake';
+      yield serializers.serialize(
+        object.capitalSnake,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.sCAETHFlowPoints != null) {
+      yield r'SCA_ETH_Flow_Points';
+      yield serializers.serialize(
+        object.sCAETHFlowPoints,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.ATT_NAME != null) {
+      yield r'ATT_NAME';
+      yield serializers.serialize(
+        object.ATT_NAME,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Capitalization object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required CapitalizationBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'smallCamel':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.smallCamel = valueDes;
+          break;
+        case r'CapitalCamel':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.capitalCamel = valueDes;
+          break;
+        case r'small_Snake':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.smallSnake = valueDes;
+          break;
+        case r'Capital_Snake':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.capitalSnake = valueDes;
+          break;
+        case r'SCA_ETH_Flow_Points':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.sCAETHFlowPoints = valueDes;
+          break;
+        case r'ATT_NAME':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.ATT_NAME = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  Capitalization deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = CapitalizationBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/cat.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/cat.dart
index cad5f349dabe5ea673a002f233ee52f3c1adaf3c..31a2b14769c37c84016e940fd7fd9f7b006fb02e 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/cat.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/cat.dart
@@ -2,102 +2,137 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/animal.dart';
+import 'package:openapi/src/model/cat_all_of.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
 part 'cat.g.dart';
 
-// ignore_for_file: unused_import
-
 /// Cat
 ///
 /// Properties:
 /// * [className] 
 /// * [color] 
 /// * [declawed] 
-abstract class Cat implements Built<Cat, CatBuilder> {
-    @BuiltValueField(wireName: r'className')
-    String get className;
-
-    @BuiltValueField(wireName: r'color')
-    String? get color;
+@BuiltValue()
+abstract class Cat implements Animal, CatAllOf, Built<Cat, CatBuilder> {
+  static const String discriminatorFieldName = r'className';
 
-    @BuiltValueField(wireName: r'declawed')
-    bool? get declawed;
+  Cat._();
 
-    Cat._();
+  factory Cat([void updates(CatBuilder b)]) = _$Cat;
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(CatBuilder b) => b
-        ..color = 'red';
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(CatBuilder b) => b
+      ..color = 'red';
 
-    factory Cat([void updates(CatBuilder b)]) = _$Cat;
-
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Cat> get serializer => _$CatSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Cat> get serializer => _$CatSerializer();
 }
 
-class _$CatSerializer implements StructuredSerializer<Cat> {
-    @override
-    final Iterable<Type> types = const [Cat, _$Cat];
-
-    @override
-    final String wireName = r'Cat';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Cat object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        result
-            ..add(r'className')
-            ..add(serializers.serialize(object.className,
-                specifiedType: const FullType(String)));
-        if (object.color != null) {
-            result
-                ..add(r'color')
-                ..add(serializers.serialize(object.color,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.declawed != null) {
-            result
-                ..add(r'declawed')
-                ..add(serializers.serialize(object.declawed,
-                    specifiedType: const FullType(bool)));
-        }
-        return result;
+class _$CatSerializer implements PrimitiveSerializer<Cat> {
+  @override
+  final Iterable<Type> types = const [Cat, _$Cat];
+
+  @override
+  final String wireName = r'Cat';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Cat object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    yield r'className';
+    yield serializers.serialize(
+      object.className,
+      specifiedType: const FullType(String),
+    );
+    if (object.color != null) {
+      yield r'color';
+      yield serializers.serialize(
+        object.color,
+        specifiedType: const FullType(String),
+      );
     }
-
-    @override
-    Cat deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = CatBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'className':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.className = valueDes;
-                    break;
-                case r'color':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.color = valueDes;
-                    break;
-                case r'declawed':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(bool)) as bool;
-                    result.declawed = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+    if (object.declawed != null) {
+      yield r'declawed';
+      yield serializers.serialize(
+        object.declawed,
+        specifiedType: const FullType(bool),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Cat object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required CatBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'className':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.className = valueDes;
+          break;
+        case r'color':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.color = valueDes;
+          break;
+        case r'declawed':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(bool),
+          ) as bool;
+          result.declawed = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  Cat deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = CatBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/cat_all_of.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/cat_all_of.dart
index 1734098fe2248050c35bef9e253f9a63a73ea0a7..02d9cce0cae171d02c2316623bf5c4dd60b58070 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/cat_all_of.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/cat_all_of.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,61 +12,130 @@ part 'cat_all_of.g.dart';
 ///
 /// Properties:
 /// * [declawed] 
-abstract class CatAllOf implements Built<CatAllOf, CatAllOfBuilder> {
-    @BuiltValueField(wireName: r'declawed')
-    bool? get declawed;
+@BuiltValue(instantiable: false)
+abstract class CatAllOf  {
+  @BuiltValueField(wireName: r'declawed')
+  bool? get declawed;
 
-    CatAllOf._();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<CatAllOf> get serializer => _$CatAllOfSerializer();
+}
+
+class _$CatAllOfSerializer implements PrimitiveSerializer<CatAllOf> {
+  @override
+  final Iterable<Type> types = const [CatAllOf];
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(CatAllOfBuilder b) => b;
+  @override
+  final String wireName = r'CatAllOf';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    CatAllOf object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.declawed != null) {
+      yield r'declawed';
+      yield serializers.serialize(
+        object.declawed,
+        specifiedType: const FullType(bool),
+      );
+    }
+  }
 
-    factory CatAllOf([void updates(CatAllOfBuilder b)]) = _$CatAllOf;
+  @override
+  Object serialize(
+    Serializers serializers,
+    CatAllOf object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<CatAllOf> get serializer => _$CatAllOfSerializer();
+  @override
+  CatAllOf deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.deserialize(serialized, specifiedType: FullType($CatAllOf)) as $CatAllOf;
+  }
 }
 
-class _$CatAllOfSerializer implements StructuredSerializer<CatAllOf> {
-    @override
-    final Iterable<Type> types = const [CatAllOf, _$CatAllOf];
-
-    @override
-    final String wireName = r'CatAllOf';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, CatAllOf object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.declawed != null) {
-            result
-                ..add(r'declawed')
-                ..add(serializers.serialize(object.declawed,
-                    specifiedType: const FullType(bool)));
-        }
-        return result;
-    }
+/// a concrete implementation of [CatAllOf], since [CatAllOf] is not instantiable
+@BuiltValue(instantiable: true)
+abstract class $CatAllOf implements CatAllOf, Built<$CatAllOf, $CatAllOfBuilder> {
+  $CatAllOf._();
+
+  factory $CatAllOf([void Function($CatAllOfBuilder)? updates]) = _$$CatAllOf;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults($CatAllOfBuilder b) => b;
 
-    @override
-    CatAllOf deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = CatAllOfBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'declawed':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(bool)) as bool;
-                    result.declawed = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<$CatAllOf> get serializer => _$$CatAllOfSerializer();
+}
+
+class _$$CatAllOfSerializer implements PrimitiveSerializer<$CatAllOf> {
+  @override
+  final Iterable<Type> types = const [$CatAllOf, _$$CatAllOf];
+
+  @override
+  final String wireName = r'$CatAllOf';
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    $CatAllOf object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.serialize(object, specifiedType: FullType(CatAllOf))!;
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required CatAllOfBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'declawed':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(bool),
+          ) as bool;
+          result.declawed = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  $CatAllOf deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = $CatAllOfBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/category.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/category.dart
index 9ee9a94a3e7c23e88df99045860a3cbeee86c28b..3a541dd1fa921daef385094807c6c5077d9f35bf 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/category.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/category.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -12,74 +13,113 @@ part 'category.g.dart';
 /// Properties:
 /// * [id] 
 /// * [name] 
+@BuiltValue()
 abstract class Category implements Built<Category, CategoryBuilder> {
-    @BuiltValueField(wireName: r'id')
-    int? get id;
+  @BuiltValueField(wireName: r'id')
+  int? get id;
 
-    @BuiltValueField(wireName: r'name')
-    String get name;
+  @BuiltValueField(wireName: r'name')
+  String get name;
 
-    Category._();
+  Category._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(CategoryBuilder b) => b
-        ..name = 'default-name';
+  factory Category([void updates(CategoryBuilder b)]) = _$Category;
 
-    factory Category([void updates(CategoryBuilder b)]) = _$Category;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(CategoryBuilder b) => b
+      ..name = 'default-name';
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Category> get serializer => _$CategorySerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Category> get serializer => _$CategorySerializer();
 }
 
-class _$CategorySerializer implements StructuredSerializer<Category> {
-    @override
-    final Iterable<Type> types = const [Category, _$Category];
+class _$CategorySerializer implements PrimitiveSerializer<Category> {
+  @override
+  final Iterable<Type> types = const [Category, _$Category];
 
-    @override
-    final String wireName = r'Category';
+  @override
+  final String wireName = r'Category';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Category object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.id != null) {
-            result
-                ..add(r'id')
-                ..add(serializers.serialize(object.id,
-                    specifiedType: const FullType(int)));
-        }
-        result
-            ..add(r'name')
-            ..add(serializers.serialize(object.name,
-                specifiedType: const FullType(String)));
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Category object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(int),
+      );
     }
+    yield r'name';
+    yield serializers.serialize(
+      object.name,
+      specifiedType: const FullType(String),
+    );
+  }
 
-    @override
-    Category deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = CategoryBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    Category object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'id':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.id = valueDes;
-                    break;
-                case r'name':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.name = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required CategoryBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.id = valueDes;
+          break;
+        case r'name':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.name = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  Category deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = CategoryBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/class_model.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/class_model.dart
index 3a000f56cb27ca1e17af26a30bf19c03d5f68197..51166943c6cdfb6084749cf33152dffa53f7226e 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/class_model.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/class_model.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,61 +12,97 @@ part 'class_model.g.dart';
 ///
 /// Properties:
 /// * [classField] 
+@BuiltValue()
 abstract class ClassModel implements Built<ClassModel, ClassModelBuilder> {
-    @BuiltValueField(wireName: r'_class')
-    String? get classField;
+  @BuiltValueField(wireName: r'_class')
+  String? get classField;
 
-    ClassModel._();
+  ClassModel._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ClassModelBuilder b) => b;
+  factory ClassModel([void updates(ClassModelBuilder b)]) = _$ClassModel;
 
-    factory ClassModel([void updates(ClassModelBuilder b)]) = _$ClassModel;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ClassModelBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ClassModel> get serializer => _$ClassModelSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ClassModel> get serializer => _$ClassModelSerializer();
 }
 
-class _$ClassModelSerializer implements StructuredSerializer<ClassModel> {
-    @override
-    final Iterable<Type> types = const [ClassModel, _$ClassModel];
+class _$ClassModelSerializer implements PrimitiveSerializer<ClassModel> {
+  @override
+  final Iterable<Type> types = const [ClassModel, _$ClassModel];
 
-    @override
-    final String wireName = r'ClassModel';
+  @override
+  final String wireName = r'ClassModel';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ClassModel object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.classField != null) {
-            result
-                ..add(r'_class')
-                ..add(serializers.serialize(object.classField,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ClassModel object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.classField != null) {
+      yield r'_class';
+      yield serializers.serialize(
+        object.classField,
+        specifiedType: const FullType(String),
+      );
     }
+  }
 
-    @override
-    ClassModel deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ClassModelBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    ClassModel object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'_class':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.classField = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ClassModelBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'_class':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.classField = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ClassModel deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ClassModelBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/deprecated_object.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/deprecated_object.dart
index 98db39b4f44d14bd77732f016f60c63b169f29f3..91d0b428e9bb2d4f9f112baff2e6023b9925e3ce 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/deprecated_object.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/deprecated_object.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,61 +12,97 @@ part 'deprecated_object.g.dart';
 ///
 /// Properties:
 /// * [name] 
+@BuiltValue()
 abstract class DeprecatedObject implements Built<DeprecatedObject, DeprecatedObjectBuilder> {
-    @BuiltValueField(wireName: r'name')
-    String? get name;
+  @BuiltValueField(wireName: r'name')
+  String? get name;
 
-    DeprecatedObject._();
+  DeprecatedObject._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(DeprecatedObjectBuilder b) => b;
+  factory DeprecatedObject([void updates(DeprecatedObjectBuilder b)]) = _$DeprecatedObject;
 
-    factory DeprecatedObject([void updates(DeprecatedObjectBuilder b)]) = _$DeprecatedObject;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(DeprecatedObjectBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<DeprecatedObject> get serializer => _$DeprecatedObjectSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<DeprecatedObject> get serializer => _$DeprecatedObjectSerializer();
 }
 
-class _$DeprecatedObjectSerializer implements StructuredSerializer<DeprecatedObject> {
-    @override
-    final Iterable<Type> types = const [DeprecatedObject, _$DeprecatedObject];
+class _$DeprecatedObjectSerializer implements PrimitiveSerializer<DeprecatedObject> {
+  @override
+  final Iterable<Type> types = const [DeprecatedObject, _$DeprecatedObject];
 
-    @override
-    final String wireName = r'DeprecatedObject';
+  @override
+  final String wireName = r'DeprecatedObject';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, DeprecatedObject object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.name != null) {
-            result
-                ..add(r'name')
-                ..add(serializers.serialize(object.name,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    DeprecatedObject object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.name != null) {
+      yield r'name';
+      yield serializers.serialize(
+        object.name,
+        specifiedType: const FullType(String),
+      );
     }
+  }
 
-    @override
-    DeprecatedObject deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = DeprecatedObjectBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    DeprecatedObject object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'name':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.name = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required DeprecatedObjectBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'name':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.name = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  DeprecatedObject deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = DeprecatedObjectBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/dog.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/dog.dart
index 2ca3df38636a840fff580d39a60b9a77fb8f62b3..b7cb6bf731fd1abd6da0ec57bf6eeaa566ddd44b 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/dog.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/dog.dart
@@ -2,102 +2,137 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
+import 'package:openapi/src/model/dog_all_of.dart';
 import 'package:openapi/src/model/animal.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
 part 'dog.g.dart';
 
-// ignore_for_file: unused_import
-
 /// Dog
 ///
 /// Properties:
 /// * [className] 
 /// * [color] 
 /// * [breed] 
-abstract class Dog implements Built<Dog, DogBuilder> {
-    @BuiltValueField(wireName: r'className')
-    String get className;
-
-    @BuiltValueField(wireName: r'color')
-    String? get color;
+@BuiltValue()
+abstract class Dog implements Animal, DogAllOf, Built<Dog, DogBuilder> {
+  static const String discriminatorFieldName = r'className';
 
-    @BuiltValueField(wireName: r'breed')
-    String? get breed;
+  Dog._();
 
-    Dog._();
+  factory Dog([void updates(DogBuilder b)]) = _$Dog;
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(DogBuilder b) => b
-        ..color = 'red';
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(DogBuilder b) => b
+      ..color = 'red';
 
-    factory Dog([void updates(DogBuilder b)]) = _$Dog;
-
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Dog> get serializer => _$DogSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Dog> get serializer => _$DogSerializer();
 }
 
-class _$DogSerializer implements StructuredSerializer<Dog> {
-    @override
-    final Iterable<Type> types = const [Dog, _$Dog];
-
-    @override
-    final String wireName = r'Dog';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Dog object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        result
-            ..add(r'className')
-            ..add(serializers.serialize(object.className,
-                specifiedType: const FullType(String)));
-        if (object.color != null) {
-            result
-                ..add(r'color')
-                ..add(serializers.serialize(object.color,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.breed != null) {
-            result
-                ..add(r'breed')
-                ..add(serializers.serialize(object.breed,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+class _$DogSerializer implements PrimitiveSerializer<Dog> {
+  @override
+  final Iterable<Type> types = const [Dog, _$Dog];
+
+  @override
+  final String wireName = r'Dog';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Dog object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    yield r'className';
+    yield serializers.serialize(
+      object.className,
+      specifiedType: const FullType(String),
+    );
+    if (object.color != null) {
+      yield r'color';
+      yield serializers.serialize(
+        object.color,
+        specifiedType: const FullType(String),
+      );
     }
-
-    @override
-    Dog deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = DogBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'className':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.className = valueDes;
-                    break;
-                case r'color':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.color = valueDes;
-                    break;
-                case r'breed':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.breed = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+    if (object.breed != null) {
+      yield r'breed';
+      yield serializers.serialize(
+        object.breed,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Dog object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required DogBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'className':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.className = valueDes;
+          break;
+        case r'color':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.color = valueDes;
+          break;
+        case r'breed':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.breed = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  Dog deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = DogBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/dog_all_of.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/dog_all_of.dart
index 23387e4da75a1a9e991c86a4573f445774dca3d1..bd52567fa60a3d8622da860f7323d97bf9328523 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/dog_all_of.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/dog_all_of.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,61 +12,130 @@ part 'dog_all_of.g.dart';
 ///
 /// Properties:
 /// * [breed] 
-abstract class DogAllOf implements Built<DogAllOf, DogAllOfBuilder> {
-    @BuiltValueField(wireName: r'breed')
-    String? get breed;
+@BuiltValue(instantiable: false)
+abstract class DogAllOf  {
+  @BuiltValueField(wireName: r'breed')
+  String? get breed;
 
-    DogAllOf._();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<DogAllOf> get serializer => _$DogAllOfSerializer();
+}
+
+class _$DogAllOfSerializer implements PrimitiveSerializer<DogAllOf> {
+  @override
+  final Iterable<Type> types = const [DogAllOf];
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(DogAllOfBuilder b) => b;
+  @override
+  final String wireName = r'DogAllOf';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    DogAllOf object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.breed != null) {
+      yield r'breed';
+      yield serializers.serialize(
+        object.breed,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
 
-    factory DogAllOf([void updates(DogAllOfBuilder b)]) = _$DogAllOf;
+  @override
+  Object serialize(
+    Serializers serializers,
+    DogAllOf object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<DogAllOf> get serializer => _$DogAllOfSerializer();
+  @override
+  DogAllOf deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.deserialize(serialized, specifiedType: FullType($DogAllOf)) as $DogAllOf;
+  }
 }
 
-class _$DogAllOfSerializer implements StructuredSerializer<DogAllOf> {
-    @override
-    final Iterable<Type> types = const [DogAllOf, _$DogAllOf];
-
-    @override
-    final String wireName = r'DogAllOf';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, DogAllOf object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.breed != null) {
-            result
-                ..add(r'breed')
-                ..add(serializers.serialize(object.breed,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
-    }
+/// a concrete implementation of [DogAllOf], since [DogAllOf] is not instantiable
+@BuiltValue(instantiable: true)
+abstract class $DogAllOf implements DogAllOf, Built<$DogAllOf, $DogAllOfBuilder> {
+  $DogAllOf._();
+
+  factory $DogAllOf([void Function($DogAllOfBuilder)? updates]) = _$$DogAllOf;
+
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults($DogAllOfBuilder b) => b;
 
-    @override
-    DogAllOf deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = DogAllOfBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'breed':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.breed = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<$DogAllOf> get serializer => _$$DogAllOfSerializer();
+}
+
+class _$$DogAllOfSerializer implements PrimitiveSerializer<$DogAllOf> {
+  @override
+  final Iterable<Type> types = const [$DogAllOf, _$$DogAllOf];
+
+  @override
+  final String wireName = r'$DogAllOf';
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    $DogAllOf object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return serializers.serialize(object, specifiedType: FullType(DogAllOf))!;
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required DogAllOfBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'breed':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.breed = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  $DogAllOf deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = $DogAllOfBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/enum_arrays.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/enum_arrays.dart
index 2626b354264e0ee9647e3a53208cd567e157a057..b79a175e833c0cd10e0937eadbeb69a09858cab5 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/enum_arrays.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/enum_arrays.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
@@ -13,78 +14,117 @@ part 'enum_arrays.g.dart';
 /// Properties:
 /// * [justSymbol] 
 /// * [arrayEnum] 
+@BuiltValue()
 abstract class EnumArrays implements Built<EnumArrays, EnumArraysBuilder> {
-    @BuiltValueField(wireName: r'just_symbol')
-    EnumArraysJustSymbolEnum? get justSymbol;
-    // enum justSymbolEnum {  >=,  $,  };
+  @BuiltValueField(wireName: r'just_symbol')
+  EnumArraysJustSymbolEnum? get justSymbol;
+  // enum justSymbolEnum {  >=,  $,  };
 
-    @BuiltValueField(wireName: r'array_enum')
-    BuiltList<EnumArraysArrayEnumEnum>? get arrayEnum;
-    // enum arrayEnumEnum {  fish,  crab,  };
+  @BuiltValueField(wireName: r'array_enum')
+  BuiltList<EnumArraysArrayEnumEnum>? get arrayEnum;
+  // enum arrayEnumEnum {  fish,  crab,  };
 
-    EnumArrays._();
+  EnumArrays._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(EnumArraysBuilder b) => b;
+  factory EnumArrays([void updates(EnumArraysBuilder b)]) = _$EnumArrays;
 
-    factory EnumArrays([void updates(EnumArraysBuilder b)]) = _$EnumArrays;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(EnumArraysBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<EnumArrays> get serializer => _$EnumArraysSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<EnumArrays> get serializer => _$EnumArraysSerializer();
 }
 
-class _$EnumArraysSerializer implements StructuredSerializer<EnumArrays> {
-    @override
-    final Iterable<Type> types = const [EnumArrays, _$EnumArrays];
-
-    @override
-    final String wireName = r'EnumArrays';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, EnumArrays object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.justSymbol != null) {
-            result
-                ..add(r'just_symbol')
-                ..add(serializers.serialize(object.justSymbol,
-                    specifiedType: const FullType(EnumArraysJustSymbolEnum)));
-        }
-        if (object.arrayEnum != null) {
-            result
-                ..add(r'array_enum')
-                ..add(serializers.serialize(object.arrayEnum,
-                    specifiedType: const FullType(BuiltList, [FullType(EnumArraysArrayEnumEnum)])));
-        }
-        return result;
+class _$EnumArraysSerializer implements PrimitiveSerializer<EnumArrays> {
+  @override
+  final Iterable<Type> types = const [EnumArrays, _$EnumArrays];
+
+  @override
+  final String wireName = r'EnumArrays';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    EnumArrays object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.justSymbol != null) {
+      yield r'just_symbol';
+      yield serializers.serialize(
+        object.justSymbol,
+        specifiedType: const FullType(EnumArraysJustSymbolEnum),
+      );
     }
-
-    @override
-    EnumArrays deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = EnumArraysBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'just_symbol':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(EnumArraysJustSymbolEnum)) as EnumArraysJustSymbolEnum;
-                    result.justSymbol = valueDes;
-                    break;
-                case r'array_enum':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltList, [FullType(EnumArraysArrayEnumEnum)])) as BuiltList<EnumArraysArrayEnumEnum>;
-                    result.arrayEnum.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+    if (object.arrayEnum != null) {
+      yield r'array_enum';
+      yield serializers.serialize(
+        object.arrayEnum,
+        specifiedType: const FullType(BuiltList, [FullType(EnumArraysArrayEnumEnum)]),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    EnumArrays object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required EnumArraysBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'just_symbol':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(EnumArraysJustSymbolEnum),
+          ) as EnumArraysJustSymbolEnum;
+          result.justSymbol = valueDes;
+          break;
+        case r'array_enum':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltList, [FullType(EnumArraysArrayEnumEnum)]),
+          ) as BuiltList<EnumArraysArrayEnumEnum>;
+          result.arrayEnum.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  EnumArrays deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = EnumArraysBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
 class EnumArraysJustSymbolEnum extends EnumClass {
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/enum_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/enum_test.dart
index ff022e646e8619baf1b2b7cb7f814aade08cd91b..831f5b9d6d2df89e6f5460375574e46270d3bec5 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/enum_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/enum_test.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/outer_enum.dart';
 import 'package:openapi/src/model/outer_enum_default_value.dart';
 import 'package:built_collection/built_collection.dart';
@@ -23,167 +24,224 @@ part 'enum_test.g.dart';
 /// * [outerEnumInteger] 
 /// * [outerEnumDefaultValue] 
 /// * [outerEnumIntegerDefaultValue] 
+@BuiltValue()
 abstract class EnumTest implements Built<EnumTest, EnumTestBuilder> {
-    @BuiltValueField(wireName: r'enum_string')
-    EnumTestEnumStringEnum? get enumString;
-    // enum enumStringEnum {  UPPER,  lower,  ,  };
+  @BuiltValueField(wireName: r'enum_string')
+  EnumTestEnumStringEnum? get enumString;
+  // enum enumStringEnum {  UPPER,  lower,  ,  };
 
-    @BuiltValueField(wireName: r'enum_string_required')
-    EnumTestEnumStringRequiredEnum get enumStringRequired;
-    // enum enumStringRequiredEnum {  UPPER,  lower,  ,  };
+  @BuiltValueField(wireName: r'enum_string_required')
+  EnumTestEnumStringRequiredEnum get enumStringRequired;
+  // enum enumStringRequiredEnum {  UPPER,  lower,  ,  };
 
-    @BuiltValueField(wireName: r'enum_integer')
-    EnumTestEnumIntegerEnum? get enumInteger;
-    // enum enumIntegerEnum {  1,  -1,  };
+  @BuiltValueField(wireName: r'enum_integer')
+  EnumTestEnumIntegerEnum? get enumInteger;
+  // enum enumIntegerEnum {  1,  -1,  };
 
-    @BuiltValueField(wireName: r'enum_number')
-    EnumTestEnumNumberEnum? get enumNumber;
-    // enum enumNumberEnum {  1.1,  -1.2,  };
+  @BuiltValueField(wireName: r'enum_number')
+  EnumTestEnumNumberEnum? get enumNumber;
+  // enum enumNumberEnum {  1.1,  -1.2,  };
 
-    @BuiltValueField(wireName: r'outerEnum')
-    OuterEnum? get outerEnum;
-    // enum outerEnumEnum {  placed,  approved,  delivered,  };
+  @BuiltValueField(wireName: r'outerEnum')
+  OuterEnum? get outerEnum;
+  // enum outerEnumEnum {  placed,  approved,  delivered,  };
 
-    @BuiltValueField(wireName: r'outerEnumInteger')
-    OuterEnumInteger? get outerEnumInteger;
-    // enum outerEnumIntegerEnum {  0,  1,  2,  };
+  @BuiltValueField(wireName: r'outerEnumInteger')
+  OuterEnumInteger? get outerEnumInteger;
+  // enum outerEnumIntegerEnum {  0,  1,  2,  };
 
-    @BuiltValueField(wireName: r'outerEnumDefaultValue')
-    OuterEnumDefaultValue? get outerEnumDefaultValue;
-    // enum outerEnumDefaultValueEnum {  placed,  approved,  delivered,  };
+  @BuiltValueField(wireName: r'outerEnumDefaultValue')
+  OuterEnumDefaultValue? get outerEnumDefaultValue;
+  // enum outerEnumDefaultValueEnum {  placed,  approved,  delivered,  };
 
-    @BuiltValueField(wireName: r'outerEnumIntegerDefaultValue')
-    OuterEnumIntegerDefaultValue? get outerEnumIntegerDefaultValue;
-    // enum outerEnumIntegerDefaultValueEnum {  0,  1,  2,  };
+  @BuiltValueField(wireName: r'outerEnumIntegerDefaultValue')
+  OuterEnumIntegerDefaultValue? get outerEnumIntegerDefaultValue;
+  // enum outerEnumIntegerDefaultValueEnum {  0,  1,  2,  };
 
-    EnumTest._();
+  EnumTest._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(EnumTestBuilder b) => b;
+  factory EnumTest([void updates(EnumTestBuilder b)]) = _$EnumTest;
 
-    factory EnumTest([void updates(EnumTestBuilder b)]) = _$EnumTest;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(EnumTestBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<EnumTest> get serializer => _$EnumTestSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<EnumTest> get serializer => _$EnumTestSerializer();
 }
 
-class _$EnumTestSerializer implements StructuredSerializer<EnumTest> {
-    @override
-    final Iterable<Type> types = const [EnumTest, _$EnumTest];
-
-    @override
-    final String wireName = r'EnumTest';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, EnumTest object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.enumString != null) {
-            result
-                ..add(r'enum_string')
-                ..add(serializers.serialize(object.enumString,
-                    specifiedType: const FullType(EnumTestEnumStringEnum)));
-        }
-        result
-            ..add(r'enum_string_required')
-            ..add(serializers.serialize(object.enumStringRequired,
-                specifiedType: const FullType(EnumTestEnumStringRequiredEnum)));
-        if (object.enumInteger != null) {
-            result
-                ..add(r'enum_integer')
-                ..add(serializers.serialize(object.enumInteger,
-                    specifiedType: const FullType(EnumTestEnumIntegerEnum)));
-        }
-        if (object.enumNumber != null) {
-            result
-                ..add(r'enum_number')
-                ..add(serializers.serialize(object.enumNumber,
-                    specifiedType: const FullType(EnumTestEnumNumberEnum)));
-        }
-        if (object.outerEnum != null) {
-            result
-                ..add(r'outerEnum')
-                ..add(serializers.serialize(object.outerEnum,
-                    specifiedType: const FullType.nullable(OuterEnum)));
-        }
-        if (object.outerEnumInteger != null) {
-            result
-                ..add(r'outerEnumInteger')
-                ..add(serializers.serialize(object.outerEnumInteger,
-                    specifiedType: const FullType(OuterEnumInteger)));
-        }
-        if (object.outerEnumDefaultValue != null) {
-            result
-                ..add(r'outerEnumDefaultValue')
-                ..add(serializers.serialize(object.outerEnumDefaultValue,
-                    specifiedType: const FullType(OuterEnumDefaultValue)));
-        }
-        if (object.outerEnumIntegerDefaultValue != null) {
-            result
-                ..add(r'outerEnumIntegerDefaultValue')
-                ..add(serializers.serialize(object.outerEnumIntegerDefaultValue,
-                    specifiedType: const FullType(OuterEnumIntegerDefaultValue)));
-        }
-        return result;
+class _$EnumTestSerializer implements PrimitiveSerializer<EnumTest> {
+  @override
+  final Iterable<Type> types = const [EnumTest, _$EnumTest];
+
+  @override
+  final String wireName = r'EnumTest';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    EnumTest object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.enumString != null) {
+      yield r'enum_string';
+      yield serializers.serialize(
+        object.enumString,
+        specifiedType: const FullType(EnumTestEnumStringEnum),
+      );
     }
-
-    @override
-    EnumTest deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = EnumTestBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'enum_string':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(EnumTestEnumStringEnum)) as EnumTestEnumStringEnum;
-                    result.enumString = valueDes;
-                    break;
-                case r'enum_string_required':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(EnumTestEnumStringRequiredEnum)) as EnumTestEnumStringRequiredEnum;
-                    result.enumStringRequired = valueDes;
-                    break;
-                case r'enum_integer':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(EnumTestEnumIntegerEnum)) as EnumTestEnumIntegerEnum;
-                    result.enumInteger = valueDes;
-                    break;
-                case r'enum_number':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(EnumTestEnumNumberEnum)) as EnumTestEnumNumberEnum;
-                    result.enumNumber = valueDes;
-                    break;
-                case r'outerEnum':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(OuterEnum)) as OuterEnum?;
-                    if (valueDes == null) continue;
-                    result.outerEnum = valueDes;
-                    break;
-                case r'outerEnumInteger':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(OuterEnumInteger)) as OuterEnumInteger;
-                    result.outerEnumInteger = valueDes;
-                    break;
-                case r'outerEnumDefaultValue':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(OuterEnumDefaultValue)) as OuterEnumDefaultValue;
-                    result.outerEnumDefaultValue = valueDes;
-                    break;
-                case r'outerEnumIntegerDefaultValue':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(OuterEnumIntegerDefaultValue)) as OuterEnumIntegerDefaultValue;
-                    result.outerEnumIntegerDefaultValue = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+    yield r'enum_string_required';
+    yield serializers.serialize(
+      object.enumStringRequired,
+      specifiedType: const FullType(EnumTestEnumStringRequiredEnum),
+    );
+    if (object.enumInteger != null) {
+      yield r'enum_integer';
+      yield serializers.serialize(
+        object.enumInteger,
+        specifiedType: const FullType(EnumTestEnumIntegerEnum),
+      );
+    }
+    if (object.enumNumber != null) {
+      yield r'enum_number';
+      yield serializers.serialize(
+        object.enumNumber,
+        specifiedType: const FullType(EnumTestEnumNumberEnum),
+      );
+    }
+    if (object.outerEnum != null) {
+      yield r'outerEnum';
+      yield serializers.serialize(
+        object.outerEnum,
+        specifiedType: const FullType.nullable(OuterEnum),
+      );
+    }
+    if (object.outerEnumInteger != null) {
+      yield r'outerEnumInteger';
+      yield serializers.serialize(
+        object.outerEnumInteger,
+        specifiedType: const FullType(OuterEnumInteger),
+      );
+    }
+    if (object.outerEnumDefaultValue != null) {
+      yield r'outerEnumDefaultValue';
+      yield serializers.serialize(
+        object.outerEnumDefaultValue,
+        specifiedType: const FullType(OuterEnumDefaultValue),
+      );
+    }
+    if (object.outerEnumIntegerDefaultValue != null) {
+      yield r'outerEnumIntegerDefaultValue';
+      yield serializers.serialize(
+        object.outerEnumIntegerDefaultValue,
+        specifiedType: const FullType(OuterEnumIntegerDefaultValue),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    EnumTest object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required EnumTestBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'enum_string':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(EnumTestEnumStringEnum),
+          ) as EnumTestEnumStringEnum;
+          result.enumString = valueDes;
+          break;
+        case r'enum_string_required':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(EnumTestEnumStringRequiredEnum),
+          ) as EnumTestEnumStringRequiredEnum;
+          result.enumStringRequired = valueDes;
+          break;
+        case r'enum_integer':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(EnumTestEnumIntegerEnum),
+          ) as EnumTestEnumIntegerEnum;
+          result.enumInteger = valueDes;
+          break;
+        case r'enum_number':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(EnumTestEnumNumberEnum),
+          ) as EnumTestEnumNumberEnum;
+          result.enumNumber = valueDes;
+          break;
+        case r'outerEnum':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(OuterEnum),
+          ) as OuterEnum?;
+          if (valueDes == null) continue;
+          result.outerEnum = valueDes;
+          break;
+        case r'outerEnumInteger':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(OuterEnumInteger),
+          ) as OuterEnumInteger;
+          result.outerEnumInteger = valueDes;
+          break;
+        case r'outerEnumDefaultValue':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(OuterEnumDefaultValue),
+          ) as OuterEnumDefaultValue;
+          result.outerEnumDefaultValue = valueDes;
+          break;
+        case r'outerEnumIntegerDefaultValue':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(OuterEnumIntegerDefaultValue),
+          ) as OuterEnumIntegerDefaultValue;
+          result.outerEnumIntegerDefaultValue = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  EnumTest deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = EnumTestBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
 class EnumTestEnumStringEnum extends EnumClass {
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/file_schema_test_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/file_schema_test_class.dart
index 7a2090e87dad2b79d9e5bb0ff8466fcf4bc2b17d..5ab41d14f43742274a03772d63636b4b1fc7e73f 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/file_schema_test_class.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/file_schema_test_class.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:openapi/src/model/model_file.dart';
 import 'package:built_value/built_value.dart';
@@ -14,75 +15,114 @@ part 'file_schema_test_class.g.dart';
 /// Properties:
 /// * [file] 
 /// * [files] 
+@BuiltValue()
 abstract class FileSchemaTestClass implements Built<FileSchemaTestClass, FileSchemaTestClassBuilder> {
-    @BuiltValueField(wireName: r'file')
-    ModelFile? get file;
+  @BuiltValueField(wireName: r'file')
+  ModelFile? get file;
 
-    @BuiltValueField(wireName: r'files')
-    BuiltList<ModelFile>? get files;
+  @BuiltValueField(wireName: r'files')
+  BuiltList<ModelFile>? get files;
 
-    FileSchemaTestClass._();
+  FileSchemaTestClass._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(FileSchemaTestClassBuilder b) => b;
+  factory FileSchemaTestClass([void updates(FileSchemaTestClassBuilder b)]) = _$FileSchemaTestClass;
 
-    factory FileSchemaTestClass([void updates(FileSchemaTestClassBuilder b)]) = _$FileSchemaTestClass;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(FileSchemaTestClassBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<FileSchemaTestClass> get serializer => _$FileSchemaTestClassSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<FileSchemaTestClass> get serializer => _$FileSchemaTestClassSerializer();
 }
 
-class _$FileSchemaTestClassSerializer implements StructuredSerializer<FileSchemaTestClass> {
-    @override
-    final Iterable<Type> types = const [FileSchemaTestClass, _$FileSchemaTestClass];
+class _$FileSchemaTestClassSerializer implements PrimitiveSerializer<FileSchemaTestClass> {
+  @override
+  final Iterable<Type> types = const [FileSchemaTestClass, _$FileSchemaTestClass];
 
-    @override
-    final String wireName = r'FileSchemaTestClass';
+  @override
+  final String wireName = r'FileSchemaTestClass';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, FileSchemaTestClass object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.file != null) {
-            result
-                ..add(r'file')
-                ..add(serializers.serialize(object.file,
-                    specifiedType: const FullType(ModelFile)));
-        }
-        if (object.files != null) {
-            result
-                ..add(r'files')
-                ..add(serializers.serialize(object.files,
-                    specifiedType: const FullType(BuiltList, [FullType(ModelFile)])));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    FileSchemaTestClass object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.file != null) {
+      yield r'file';
+      yield serializers.serialize(
+        object.file,
+        specifiedType: const FullType(ModelFile),
+      );
     }
+    if (object.files != null) {
+      yield r'files';
+      yield serializers.serialize(
+        object.files,
+        specifiedType: const FullType(BuiltList, [FullType(ModelFile)]),
+      );
+    }
+  }
 
-    @override
-    FileSchemaTestClass deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = FileSchemaTestClassBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    FileSchemaTestClass object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'file':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(ModelFile)) as ModelFile;
-                    result.file.replace(valueDes);
-                    break;
-                case r'files':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltList, [FullType(ModelFile)])) as BuiltList<ModelFile>;
-                    result.files.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required FileSchemaTestClassBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'file':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(ModelFile),
+          ) as ModelFile;
+          result.file.replace(valueDes);
+          break;
+        case r'files':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltList, [FullType(ModelFile)]),
+          ) as BuiltList<ModelFile>;
+          result.files.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  FileSchemaTestClass deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = FileSchemaTestClassBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/foo.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/foo.dart
index dd3691968d4ac2222340213be2b9f94eb39ee510..57e0992c67cdd46e1440a79d0b7e173ee7997dcb 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/foo.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/foo.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,62 +12,98 @@ part 'foo.g.dart';
 ///
 /// Properties:
 /// * [bar] 
+@BuiltValue()
 abstract class Foo implements Built<Foo, FooBuilder> {
-    @BuiltValueField(wireName: r'bar')
-    String? get bar;
+  @BuiltValueField(wireName: r'bar')
+  String? get bar;
 
-    Foo._();
+  Foo._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(FooBuilder b) => b
-        ..bar = 'bar';
+  factory Foo([void updates(FooBuilder b)]) = _$Foo;
 
-    factory Foo([void updates(FooBuilder b)]) = _$Foo;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(FooBuilder b) => b
+      ..bar = 'bar';
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Foo> get serializer => _$FooSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Foo> get serializer => _$FooSerializer();
 }
 
-class _$FooSerializer implements StructuredSerializer<Foo> {
-    @override
-    final Iterable<Type> types = const [Foo, _$Foo];
+class _$FooSerializer implements PrimitiveSerializer<Foo> {
+  @override
+  final Iterable<Type> types = const [Foo, _$Foo];
 
-    @override
-    final String wireName = r'Foo';
+  @override
+  final String wireName = r'Foo';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Foo object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.bar != null) {
-            result
-                ..add(r'bar')
-                ..add(serializers.serialize(object.bar,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Foo object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.bar != null) {
+      yield r'bar';
+      yield serializers.serialize(
+        object.bar,
+        specifiedType: const FullType(String),
+      );
     }
+  }
 
-    @override
-    Foo deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = FooBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    Foo object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'bar':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.bar = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required FooBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'bar':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.bar = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  Foo deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = FooBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/foo_get_default_response.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/foo_get_default_response.dart
index 655b5f480db19f81a4061edab795d07ed4c19c1d..b5903ebd5dbf37dba35059ba6ca03a144d8b7b89 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/foo_get_default_response.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/foo_get_default_response.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/foo.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
@@ -12,61 +13,97 @@ part 'foo_get_default_response.g.dart';
 ///
 /// Properties:
 /// * [string] 
+@BuiltValue()
 abstract class FooGetDefaultResponse implements Built<FooGetDefaultResponse, FooGetDefaultResponseBuilder> {
-    @BuiltValueField(wireName: r'string')
-    Foo? get string;
+  @BuiltValueField(wireName: r'string')
+  Foo? get string;
 
-    FooGetDefaultResponse._();
+  FooGetDefaultResponse._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(FooGetDefaultResponseBuilder b) => b;
+  factory FooGetDefaultResponse([void updates(FooGetDefaultResponseBuilder b)]) = _$FooGetDefaultResponse;
 
-    factory FooGetDefaultResponse([void updates(FooGetDefaultResponseBuilder b)]) = _$FooGetDefaultResponse;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(FooGetDefaultResponseBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<FooGetDefaultResponse> get serializer => _$FooGetDefaultResponseSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<FooGetDefaultResponse> get serializer => _$FooGetDefaultResponseSerializer();
 }
 
-class _$FooGetDefaultResponseSerializer implements StructuredSerializer<FooGetDefaultResponse> {
-    @override
-    final Iterable<Type> types = const [FooGetDefaultResponse, _$FooGetDefaultResponse];
+class _$FooGetDefaultResponseSerializer implements PrimitiveSerializer<FooGetDefaultResponse> {
+  @override
+  final Iterable<Type> types = const [FooGetDefaultResponse, _$FooGetDefaultResponse];
 
-    @override
-    final String wireName = r'FooGetDefaultResponse';
+  @override
+  final String wireName = r'FooGetDefaultResponse';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, FooGetDefaultResponse object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.string != null) {
-            result
-                ..add(r'string')
-                ..add(serializers.serialize(object.string,
-                    specifiedType: const FullType(Foo)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    FooGetDefaultResponse object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.string != null) {
+      yield r'string';
+      yield serializers.serialize(
+        object.string,
+        specifiedType: const FullType(Foo),
+      );
     }
+  }
 
-    @override
-    FooGetDefaultResponse deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = FooGetDefaultResponseBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    FooGetDefaultResponse object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'string':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(Foo)) as Foo;
-                    result.string.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required FooGetDefaultResponseBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'string':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(Foo),
+          ) as Foo;
+          result.string.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  FooGetDefaultResponse deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = FooGetDefaultResponseBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/format_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/format_test.dart
index cf1be44ab5b7dd510b36639d230813a8483e2b32..33775231476ed4ebfc18fbfe469106a8ebab5a19 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/format_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/format_test.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'dart:typed_data';
 import 'package:openapi/src/model/date.dart';
 import 'package:built_value/built_value.dart';
@@ -28,265 +29,346 @@ part 'format_test.g.dart';
 /// * [password] 
 /// * [patternWithDigits] - A string that is a 10 digit number. Can have leading zeros.
 /// * [patternWithDigitsAndDelimiter] - A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
+@BuiltValue()
 abstract class FormatTest implements Built<FormatTest, FormatTestBuilder> {
-    @BuiltValueField(wireName: r'integer')
-    int? get integer;
+  @BuiltValueField(wireName: r'integer')
+  int? get integer;
 
-    @BuiltValueField(wireName: r'int32')
-    int? get int32;
+  @BuiltValueField(wireName: r'int32')
+  int? get int32;
 
-    @BuiltValueField(wireName: r'int64')
-    int? get int64;
+  @BuiltValueField(wireName: r'int64')
+  int? get int64;
 
-    @BuiltValueField(wireName: r'number')
-    num get number;
+  @BuiltValueField(wireName: r'number')
+  num get number;
 
-    @BuiltValueField(wireName: r'float')
-    double? get float;
+  @BuiltValueField(wireName: r'float')
+  double? get float;
 
-    @BuiltValueField(wireName: r'double')
-    double? get double_;
+  @BuiltValueField(wireName: r'double')
+  double? get double_;
 
-    @BuiltValueField(wireName: r'decimal')
-    double? get decimal;
+  @BuiltValueField(wireName: r'decimal')
+  double? get decimal;
 
-    @BuiltValueField(wireName: r'string')
-    String? get string;
+  @BuiltValueField(wireName: r'string')
+  String? get string;
 
-    @BuiltValueField(wireName: r'byte')
-    String get byte;
+  @BuiltValueField(wireName: r'byte')
+  String get byte;
 
-    @BuiltValueField(wireName: r'binary')
-    Uint8List? get binary;
+  @BuiltValueField(wireName: r'binary')
+  Uint8List? get binary;
 
-    @BuiltValueField(wireName: r'date')
-    Date get date;
+  @BuiltValueField(wireName: r'date')
+  Date get date;
 
-    @BuiltValueField(wireName: r'dateTime')
-    DateTime? get dateTime;
+  @BuiltValueField(wireName: r'dateTime')
+  DateTime? get dateTime;
 
-    @BuiltValueField(wireName: r'uuid')
-    String? get uuid;
+  @BuiltValueField(wireName: r'uuid')
+  String? get uuid;
 
-    @BuiltValueField(wireName: r'password')
-    String get password;
+  @BuiltValueField(wireName: r'password')
+  String get password;
 
-    /// A string that is a 10 digit number. Can have leading zeros.
-    @BuiltValueField(wireName: r'pattern_with_digits')
-    String? get patternWithDigits;
+  /// A string that is a 10 digit number. Can have leading zeros.
+  @BuiltValueField(wireName: r'pattern_with_digits')
+  String? get patternWithDigits;
 
-    /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
-    @BuiltValueField(wireName: r'pattern_with_digits_and_delimiter')
-    String? get patternWithDigitsAndDelimiter;
+  /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
+  @BuiltValueField(wireName: r'pattern_with_digits_and_delimiter')
+  String? get patternWithDigitsAndDelimiter;
 
-    FormatTest._();
+  FormatTest._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(FormatTestBuilder b) => b;
+  factory FormatTest([void updates(FormatTestBuilder b)]) = _$FormatTest;
 
-    factory FormatTest([void updates(FormatTestBuilder b)]) = _$FormatTest;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(FormatTestBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<FormatTest> get serializer => _$FormatTestSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<FormatTest> get serializer => _$FormatTestSerializer();
 }
 
-class _$FormatTestSerializer implements StructuredSerializer<FormatTest> {
-    @override
-    final Iterable<Type> types = const [FormatTest, _$FormatTest];
+class _$FormatTestSerializer implements PrimitiveSerializer<FormatTest> {
+  @override
+  final Iterable<Type> types = const [FormatTest, _$FormatTest];
 
-    @override
-    final String wireName = r'FormatTest';
+  @override
+  final String wireName = r'FormatTest';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, FormatTest object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.integer != null) {
-            result
-                ..add(r'integer')
-                ..add(serializers.serialize(object.integer,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.int32 != null) {
-            result
-                ..add(r'int32')
-                ..add(serializers.serialize(object.int32,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.int64 != null) {
-            result
-                ..add(r'int64')
-                ..add(serializers.serialize(object.int64,
-                    specifiedType: const FullType(int)));
-        }
-        result
-            ..add(r'number')
-            ..add(serializers.serialize(object.number,
-                specifiedType: const FullType(num)));
-        if (object.float != null) {
-            result
-                ..add(r'float')
-                ..add(serializers.serialize(object.float,
-                    specifiedType: const FullType(double)));
-        }
-        if (object.double_ != null) {
-            result
-                ..add(r'double')
-                ..add(serializers.serialize(object.double_,
-                    specifiedType: const FullType(double)));
-        }
-        if (object.decimal != null) {
-            result
-                ..add(r'decimal')
-                ..add(serializers.serialize(object.decimal,
-                    specifiedType: const FullType(double)));
-        }
-        if (object.string != null) {
-            result
-                ..add(r'string')
-                ..add(serializers.serialize(object.string,
-                    specifiedType: const FullType(String)));
-        }
-        result
-            ..add(r'byte')
-            ..add(serializers.serialize(object.byte,
-                specifiedType: const FullType(String)));
-        if (object.binary != null) {
-            result
-                ..add(r'binary')
-                ..add(serializers.serialize(object.binary,
-                    specifiedType: const FullType(Uint8List)));
-        }
-        result
-            ..add(r'date')
-            ..add(serializers.serialize(object.date,
-                specifiedType: const FullType(Date)));
-        if (object.dateTime != null) {
-            result
-                ..add(r'dateTime')
-                ..add(serializers.serialize(object.dateTime,
-                    specifiedType: const FullType(DateTime)));
-        }
-        if (object.uuid != null) {
-            result
-                ..add(r'uuid')
-                ..add(serializers.serialize(object.uuid,
-                    specifiedType: const FullType(String)));
-        }
-        result
-            ..add(r'password')
-            ..add(serializers.serialize(object.password,
-                specifiedType: const FullType(String)));
-        if (object.patternWithDigits != null) {
-            result
-                ..add(r'pattern_with_digits')
-                ..add(serializers.serialize(object.patternWithDigits,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.patternWithDigitsAndDelimiter != null) {
-            result
-                ..add(r'pattern_with_digits_and_delimiter')
-                ..add(serializers.serialize(object.patternWithDigitsAndDelimiter,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    FormatTest object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.integer != null) {
+      yield r'integer';
+      yield serializers.serialize(
+        object.integer,
+        specifiedType: const FullType(int),
+      );
     }
+    if (object.int32 != null) {
+      yield r'int32';
+      yield serializers.serialize(
+        object.int32,
+        specifiedType: const FullType(int),
+      );
+    }
+    if (object.int64 != null) {
+      yield r'int64';
+      yield serializers.serialize(
+        object.int64,
+        specifiedType: const FullType(int),
+      );
+    }
+    yield r'number';
+    yield serializers.serialize(
+      object.number,
+      specifiedType: const FullType(num),
+    );
+    if (object.float != null) {
+      yield r'float';
+      yield serializers.serialize(
+        object.float,
+        specifiedType: const FullType(double),
+      );
+    }
+    if (object.double_ != null) {
+      yield r'double';
+      yield serializers.serialize(
+        object.double_,
+        specifiedType: const FullType(double),
+      );
+    }
+    if (object.decimal != null) {
+      yield r'decimal';
+      yield serializers.serialize(
+        object.decimal,
+        specifiedType: const FullType(double),
+      );
+    }
+    if (object.string != null) {
+      yield r'string';
+      yield serializers.serialize(
+        object.string,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'byte';
+    yield serializers.serialize(
+      object.byte,
+      specifiedType: const FullType(String),
+    );
+    if (object.binary != null) {
+      yield r'binary';
+      yield serializers.serialize(
+        object.binary,
+        specifiedType: const FullType(Uint8List),
+      );
+    }
+    yield r'date';
+    yield serializers.serialize(
+      object.date,
+      specifiedType: const FullType(Date),
+    );
+    if (object.dateTime != null) {
+      yield r'dateTime';
+      yield serializers.serialize(
+        object.dateTime,
+        specifiedType: const FullType(DateTime),
+      );
+    }
+    if (object.uuid != null) {
+      yield r'uuid';
+      yield serializers.serialize(
+        object.uuid,
+        specifiedType: const FullType(String),
+      );
+    }
+    yield r'password';
+    yield serializers.serialize(
+      object.password,
+      specifiedType: const FullType(String),
+    );
+    if (object.patternWithDigits != null) {
+      yield r'pattern_with_digits';
+      yield serializers.serialize(
+        object.patternWithDigits,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.patternWithDigitsAndDelimiter != null) {
+      yield r'pattern_with_digits_and_delimiter';
+      yield serializers.serialize(
+        object.patternWithDigitsAndDelimiter,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
 
-    @override
-    FormatTest deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = FormatTestBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    FormatTest object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'integer':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.integer = valueDes;
-                    break;
-                case r'int32':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.int32 = valueDes;
-                    break;
-                case r'int64':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.int64 = valueDes;
-                    break;
-                case r'number':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(num)) as num;
-                    result.number = valueDes;
-                    break;
-                case r'float':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(double)) as double;
-                    result.float = valueDes;
-                    break;
-                case r'double':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(double)) as double;
-                    result.double_ = valueDes;
-                    break;
-                case r'decimal':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(double)) as double;
-                    result.decimal = valueDes;
-                    break;
-                case r'string':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.string = valueDes;
-                    break;
-                case r'byte':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.byte = valueDes;
-                    break;
-                case r'binary':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(Uint8List)) as Uint8List;
-                    result.binary = valueDes;
-                    break;
-                case r'date':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(Date)) as Date;
-                    result.date = valueDes;
-                    break;
-                case r'dateTime':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(DateTime)) as DateTime;
-                    result.dateTime = valueDes;
-                    break;
-                case r'uuid':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.uuid = valueDes;
-                    break;
-                case r'password':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.password = valueDes;
-                    break;
-                case r'pattern_with_digits':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.patternWithDigits = valueDes;
-                    break;
-                case r'pattern_with_digits_and_delimiter':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.patternWithDigitsAndDelimiter = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required FormatTestBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'integer':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.integer = valueDes;
+          break;
+        case r'int32':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.int32 = valueDes;
+          break;
+        case r'int64':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.int64 = valueDes;
+          break;
+        case r'number':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(num),
+          ) as num;
+          result.number = valueDes;
+          break;
+        case r'float':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(double),
+          ) as double;
+          result.float = valueDes;
+          break;
+        case r'double':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(double),
+          ) as double;
+          result.double_ = valueDes;
+          break;
+        case r'decimal':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(double),
+          ) as double;
+          result.decimal = valueDes;
+          break;
+        case r'string':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.string = valueDes;
+          break;
+        case r'byte':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.byte = valueDes;
+          break;
+        case r'binary':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(Uint8List),
+          ) as Uint8List;
+          result.binary = valueDes;
+          break;
+        case r'date':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(Date),
+          ) as Date;
+          result.date = valueDes;
+          break;
+        case r'dateTime':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(DateTime),
+          ) as DateTime;
+          result.dateTime = valueDes;
+          break;
+        case r'uuid':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.uuid = valueDes;
+          break;
+        case r'password':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.password = valueDes;
+          break;
+        case r'pattern_with_digits':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.patternWithDigits = valueDes;
+          break;
+        case r'pattern_with_digits_and_delimiter':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.patternWithDigitsAndDelimiter = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  FormatTest deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = FormatTestBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/has_only_read_only.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/has_only_read_only.dart
index 21b44ece26edfa79c805309724ad9dbd68f800e1..9683985cf198a1fbc205c2800504f14251191b71 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/has_only_read_only.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/has_only_read_only.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -12,75 +13,114 @@ part 'has_only_read_only.g.dart';
 /// Properties:
 /// * [bar] 
 /// * [foo] 
+@BuiltValue()
 abstract class HasOnlyReadOnly implements Built<HasOnlyReadOnly, HasOnlyReadOnlyBuilder> {
-    @BuiltValueField(wireName: r'bar')
-    String? get bar;
+  @BuiltValueField(wireName: r'bar')
+  String? get bar;
 
-    @BuiltValueField(wireName: r'foo')
-    String? get foo;
+  @BuiltValueField(wireName: r'foo')
+  String? get foo;
 
-    HasOnlyReadOnly._();
+  HasOnlyReadOnly._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(HasOnlyReadOnlyBuilder b) => b;
+  factory HasOnlyReadOnly([void updates(HasOnlyReadOnlyBuilder b)]) = _$HasOnlyReadOnly;
 
-    factory HasOnlyReadOnly([void updates(HasOnlyReadOnlyBuilder b)]) = _$HasOnlyReadOnly;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(HasOnlyReadOnlyBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<HasOnlyReadOnly> get serializer => _$HasOnlyReadOnlySerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<HasOnlyReadOnly> get serializer => _$HasOnlyReadOnlySerializer();
 }
 
-class _$HasOnlyReadOnlySerializer implements StructuredSerializer<HasOnlyReadOnly> {
-    @override
-    final Iterable<Type> types = const [HasOnlyReadOnly, _$HasOnlyReadOnly];
+class _$HasOnlyReadOnlySerializer implements PrimitiveSerializer<HasOnlyReadOnly> {
+  @override
+  final Iterable<Type> types = const [HasOnlyReadOnly, _$HasOnlyReadOnly];
 
-    @override
-    final String wireName = r'HasOnlyReadOnly';
+  @override
+  final String wireName = r'HasOnlyReadOnly';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, HasOnlyReadOnly object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.bar != null) {
-            result
-                ..add(r'bar')
-                ..add(serializers.serialize(object.bar,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.foo != null) {
-            result
-                ..add(r'foo')
-                ..add(serializers.serialize(object.foo,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    HasOnlyReadOnly object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.bar != null) {
+      yield r'bar';
+      yield serializers.serialize(
+        object.bar,
+        specifiedType: const FullType(String),
+      );
     }
+    if (object.foo != null) {
+      yield r'foo';
+      yield serializers.serialize(
+        object.foo,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
 
-    @override
-    HasOnlyReadOnly deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = HasOnlyReadOnlyBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    HasOnlyReadOnly object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'bar':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.bar = valueDes;
-                    break;
-                case r'foo':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.foo = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required HasOnlyReadOnlyBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'bar':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.bar = valueDes;
+          break;
+        case r'foo':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.foo = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  HasOnlyReadOnly deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = HasOnlyReadOnlyBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/health_check_result.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/health_check_result.dart
index e589cb7bd35d1ae388605f8d00db57e5987f6181..c092a535f2fcb9eee1296dca68d793d527fa691f 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/health_check_result.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/health_check_result.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,62 +12,98 @@ part 'health_check_result.g.dart';
 ///
 /// Properties:
 /// * [nullableMessage] 
+@BuiltValue()
 abstract class HealthCheckResult implements Built<HealthCheckResult, HealthCheckResultBuilder> {
-    @BuiltValueField(wireName: r'NullableMessage')
-    String? get nullableMessage;
+  @BuiltValueField(wireName: r'NullableMessage')
+  String? get nullableMessage;
 
-    HealthCheckResult._();
+  HealthCheckResult._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(HealthCheckResultBuilder b) => b;
+  factory HealthCheckResult([void updates(HealthCheckResultBuilder b)]) = _$HealthCheckResult;
 
-    factory HealthCheckResult([void updates(HealthCheckResultBuilder b)]) = _$HealthCheckResult;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(HealthCheckResultBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<HealthCheckResult> get serializer => _$HealthCheckResultSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<HealthCheckResult> get serializer => _$HealthCheckResultSerializer();
 }
 
-class _$HealthCheckResultSerializer implements StructuredSerializer<HealthCheckResult> {
-    @override
-    final Iterable<Type> types = const [HealthCheckResult, _$HealthCheckResult];
+class _$HealthCheckResultSerializer implements PrimitiveSerializer<HealthCheckResult> {
+  @override
+  final Iterable<Type> types = const [HealthCheckResult, _$HealthCheckResult];
 
-    @override
-    final String wireName = r'HealthCheckResult';
+  @override
+  final String wireName = r'HealthCheckResult';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, HealthCheckResult object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.nullableMessage != null) {
-            result
-                ..add(r'NullableMessage')
-                ..add(serializers.serialize(object.nullableMessage,
-                    specifiedType: const FullType.nullable(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    HealthCheckResult object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.nullableMessage != null) {
+      yield r'NullableMessage';
+      yield serializers.serialize(
+        object.nullableMessage,
+        specifiedType: const FullType.nullable(String),
+      );
     }
+  }
 
-    @override
-    HealthCheckResult deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = HealthCheckResultBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    HealthCheckResult object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'NullableMessage':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(String)) as String?;
-                    if (valueDes == null) continue;
-                    result.nullableMessage = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required HealthCheckResultBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'NullableMessage':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(String),
+          ) as String?;
+          if (valueDes == null) continue;
+          result.nullableMessage = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  HealthCheckResult deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = HealthCheckResultBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/inline_response_default.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/inline_response_default.dart
index b611f8beb6aa5be9f0e818ab051951f05ac09921..74d5ed70f1e81278887d8114b54f3b20037da488 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/inline_response_default.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/inline_response_default.dart
@@ -5,6 +5,9 @@
 import 'package:openapi/src/model/foo.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
+import 'package:one_of/one_of.dart';
+import 'package:one_of/any_of.dart';
+// ignore_for_file: unused_element, unused_import
 
 part 'inline_response_default.g.dart';
 
@@ -12,61 +15,77 @@ part 'inline_response_default.g.dart';
 ///
 /// Properties:
 /// * [string] 
+@BuiltValue()
 abstract class InlineResponseDefault implements Built<InlineResponseDefault, InlineResponseDefaultBuilder> {
     @BuiltValueField(wireName: r'string')
     Foo? get string;
 
+
     InlineResponseDefault._();
+    
+    factory InlineResponseDefault([void updates(InlineResponseDefaultBuilder b)]) = _$InlineResponseDefault;
 
     @BuiltValueHook(initializeBuilder: true)
     static void _defaults(InlineResponseDefaultBuilder b) => b;
 
-    factory InlineResponseDefault([void updates(InlineResponseDefaultBuilder b)]) = _$InlineResponseDefault;
-
     @BuiltValueSerializer(custom: true)
     static Serializer<InlineResponseDefault> get serializer => _$InlineResponseDefaultSerializer();
+
+
 }
 
-class _$InlineResponseDefaultSerializer implements StructuredSerializer<InlineResponseDefault> {
+class _$InlineResponseDefaultSerializer implements PrimitiveSerializer<InlineResponseDefault> {
     @override
     final Iterable<Type> types = const [InlineResponseDefault, _$InlineResponseDefault];
 
     @override
     final String wireName = r'InlineResponseDefault';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, InlineResponseDefault object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
+    Iterable<Object?> _serializeProperties(Serializers serializers, InlineResponseDefault object,
+        {FullType specifiedType = FullType.unspecified}) sync* {        
         if (object.string != null) {
-            result
-                ..add(r'string')
-                ..add(serializers.serialize(object.string,
-                    specifiedType: const FullType(Foo)));
+            yield r'string';
+            yield serializers.serialize(object.string,
+                    specifiedType: const FullType(Foo));
         }
-        return result;
     }
 
     @override
-    InlineResponseDefault deserialize(Serializers serializers, Iterable<Object?> serialized,
+    Object serialize(Serializers serializers, InlineResponseDefault object,
         {FullType specifiedType = FullType.unspecified}) {
-        final result = InlineResponseDefaultBuilder();
+        return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+    }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
+    void _deserializeProperties(Serializers serializers, Object serialized,
+        {FullType specifiedType = FullType.unspecified, required List<Object?> serializedList,required InlineResponseDefaultBuilder result, required List<Object?> unhandled}) {
+        for (var i = 0; i < serializedList.length; i += 2) {
+            final key = serializedList[i] as String;
+            final value = serializedList[i + 1];
             switch (key) {
-                case r'string':
+                 case r'string':
                     final valueDes = serializers.deserialize(value,
                         specifiedType: const FullType(Foo)) as Foo;
                     result.string.replace(valueDes);
                     break;
+                default:
+                  unhandled.add(key);
+                  unhandled.add(value);
+                  break;
             }
         }
+    }
+    
+    @override
+    InlineResponseDefault deserialize(Serializers serializers, Object serialized,
+        {FullType specifiedType = FullType.unspecified}) {
+        final result = InlineResponseDefaultBuilder();
+        final serializedList = (serialized as Iterable<Object?>).toList();        
+        final unhandled = <Object?>[];
+        _deserializeProperties(serializers, serialized, specifiedType: specifiedType, serializedList: serializedList, unhandled: unhandled, result: result);        
         return result.build();
     }
 }
 
+
+
+
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/map_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/map_test.dart
index 16df0490e16401652c76f436cbf2274d8e890e5a..9fa58677a84a8b650514998f2e415b24c83336d8 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/map_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/map_test.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
@@ -15,105 +16,150 @@ part 'map_test.g.dart';
 /// * [mapOfEnumString] 
 /// * [directMap] 
 /// * [indirectMap] 
+@BuiltValue()
 abstract class MapTest implements Built<MapTest, MapTestBuilder> {
-    @BuiltValueField(wireName: r'map_map_of_string')
-    BuiltMap<String, BuiltMap<String, String>>? get mapMapOfString;
+  @BuiltValueField(wireName: r'map_map_of_string')
+  BuiltMap<String, BuiltMap<String, String>>? get mapMapOfString;
 
-    @BuiltValueField(wireName: r'map_of_enum_string')
-    BuiltMap<String, MapTestMapOfEnumStringEnum>? get mapOfEnumString;
-    // enum mapOfEnumStringEnum {  UPPER,  lower,  };
+  @BuiltValueField(wireName: r'map_of_enum_string')
+  BuiltMap<String, MapTestMapOfEnumStringEnum>? get mapOfEnumString;
+  // enum mapOfEnumStringEnum {  UPPER,  lower,  };
 
-    @BuiltValueField(wireName: r'direct_map')
-    BuiltMap<String, bool>? get directMap;
+  @BuiltValueField(wireName: r'direct_map')
+  BuiltMap<String, bool>? get directMap;
 
-    @BuiltValueField(wireName: r'indirect_map')
-    BuiltMap<String, bool>? get indirectMap;
+  @BuiltValueField(wireName: r'indirect_map')
+  BuiltMap<String, bool>? get indirectMap;
 
-    MapTest._();
+  MapTest._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(MapTestBuilder b) => b;
+  factory MapTest([void updates(MapTestBuilder b)]) = _$MapTest;
 
-    factory MapTest([void updates(MapTestBuilder b)]) = _$MapTest;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(MapTestBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<MapTest> get serializer => _$MapTestSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<MapTest> get serializer => _$MapTestSerializer();
 }
 
-class _$MapTestSerializer implements StructuredSerializer<MapTest> {
-    @override
-    final Iterable<Type> types = const [MapTest, _$MapTest];
-
-    @override
-    final String wireName = r'MapTest';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, MapTest object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.mapMapOfString != null) {
-            result
-                ..add(r'map_map_of_string')
-                ..add(serializers.serialize(object.mapMapOfString,
-                    specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])])));
-        }
-        if (object.mapOfEnumString != null) {
-            result
-                ..add(r'map_of_enum_string')
-                ..add(serializers.serialize(object.mapOfEnumString,
-                    specifiedType: const FullType(BuiltMap, [FullType(String), FullType(MapTestMapOfEnumStringEnum)])));
-        }
-        if (object.directMap != null) {
-            result
-                ..add(r'direct_map')
-                ..add(serializers.serialize(object.directMap,
-                    specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)])));
-        }
-        if (object.indirectMap != null) {
-            result
-                ..add(r'indirect_map')
-                ..add(serializers.serialize(object.indirectMap,
-                    specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)])));
-        }
-        return result;
+class _$MapTestSerializer implements PrimitiveSerializer<MapTest> {
+  @override
+  final Iterable<Type> types = const [MapTest, _$MapTest];
+
+  @override
+  final String wireName = r'MapTest';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    MapTest object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.mapMapOfString != null) {
+      yield r'map_map_of_string';
+      yield serializers.serialize(
+        object.mapMapOfString,
+        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])]),
+      );
     }
-
-    @override
-    MapTest deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = MapTestBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'map_map_of_string':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])])) as BuiltMap<String, BuiltMap<String, String>>;
-                    result.mapMapOfString.replace(valueDes);
-                    break;
-                case r'map_of_enum_string':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(MapTestMapOfEnumStringEnum)])) as BuiltMap<String, MapTestMapOfEnumStringEnum>;
-                    result.mapOfEnumString.replace(valueDes);
-                    break;
-                case r'direct_map':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)])) as BuiltMap<String, bool>;
-                    result.directMap.replace(valueDes);
-                    break;
-                case r'indirect_map':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)])) as BuiltMap<String, bool>;
-                    result.indirectMap.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+    if (object.mapOfEnumString != null) {
+      yield r'map_of_enum_string';
+      yield serializers.serialize(
+        object.mapOfEnumString,
+        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(MapTestMapOfEnumStringEnum)]),
+      );
+    }
+    if (object.directMap != null) {
+      yield r'direct_map';
+      yield serializers.serialize(
+        object.directMap,
+        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)]),
+      );
+    }
+    if (object.indirectMap != null) {
+      yield r'indirect_map';
+      yield serializers.serialize(
+        object.indirectMap,
+        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)]),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    MapTest object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required MapTestBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'map_map_of_string':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])]),
+          ) as BuiltMap<String, BuiltMap<String, String>>;
+          result.mapMapOfString.replace(valueDes);
+          break;
+        case r'map_of_enum_string':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltMap, [FullType(String), FullType(MapTestMapOfEnumStringEnum)]),
+          ) as BuiltMap<String, MapTestMapOfEnumStringEnum>;
+          result.mapOfEnumString.replace(valueDes);
+          break;
+        case r'direct_map':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)]),
+          ) as BuiltMap<String, bool>;
+          result.directMap.replace(valueDes);
+          break;
+        case r'indirect_map':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)]),
+          ) as BuiltMap<String, bool>;
+          result.indirectMap.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  MapTest deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = MapTestBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
 class MapTestMapOfEnumStringEnum extends EnumClass {
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/mixed_properties_and_additional_properties_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/mixed_properties_and_additional_properties_class.dart
index 27c6993cc70faf2a67b69930120b06eada9f7118..76b5933ae5a717e8892fb746d94d9b500d959032 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/mixed_properties_and_additional_properties_class.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/mixed_properties_and_additional_properties_class.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:openapi/src/model/animal.dart';
 import 'package:built_value/built_value.dart';
@@ -15,89 +16,131 @@ part 'mixed_properties_and_additional_properties_class.g.dart';
 /// * [uuid] 
 /// * [dateTime] 
 /// * [map] 
+@BuiltValue()
 abstract class MixedPropertiesAndAdditionalPropertiesClass implements Built<MixedPropertiesAndAdditionalPropertiesClass, MixedPropertiesAndAdditionalPropertiesClassBuilder> {
-    @BuiltValueField(wireName: r'uuid')
-    String? get uuid;
+  @BuiltValueField(wireName: r'uuid')
+  String? get uuid;
 
-    @BuiltValueField(wireName: r'dateTime')
-    DateTime? get dateTime;
+  @BuiltValueField(wireName: r'dateTime')
+  DateTime? get dateTime;
 
-    @BuiltValueField(wireName: r'map')
-    BuiltMap<String, Animal>? get map;
+  @BuiltValueField(wireName: r'map')
+  BuiltMap<String, Animal>? get map;
 
-    MixedPropertiesAndAdditionalPropertiesClass._();
+  MixedPropertiesAndAdditionalPropertiesClass._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(MixedPropertiesAndAdditionalPropertiesClassBuilder b) => b;
+  factory MixedPropertiesAndAdditionalPropertiesClass([void updates(MixedPropertiesAndAdditionalPropertiesClassBuilder b)]) = _$MixedPropertiesAndAdditionalPropertiesClass;
 
-    factory MixedPropertiesAndAdditionalPropertiesClass([void updates(MixedPropertiesAndAdditionalPropertiesClassBuilder b)]) = _$MixedPropertiesAndAdditionalPropertiesClass;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(MixedPropertiesAndAdditionalPropertiesClassBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<MixedPropertiesAndAdditionalPropertiesClass> get serializer => _$MixedPropertiesAndAdditionalPropertiesClassSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<MixedPropertiesAndAdditionalPropertiesClass> get serializer => _$MixedPropertiesAndAdditionalPropertiesClassSerializer();
 }
 
-class _$MixedPropertiesAndAdditionalPropertiesClassSerializer implements StructuredSerializer<MixedPropertiesAndAdditionalPropertiesClass> {
-    @override
-    final Iterable<Type> types = const [MixedPropertiesAndAdditionalPropertiesClass, _$MixedPropertiesAndAdditionalPropertiesClass];
-
-    @override
-    final String wireName = r'MixedPropertiesAndAdditionalPropertiesClass';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, MixedPropertiesAndAdditionalPropertiesClass object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.uuid != null) {
-            result
-                ..add(r'uuid')
-                ..add(serializers.serialize(object.uuid,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.dateTime != null) {
-            result
-                ..add(r'dateTime')
-                ..add(serializers.serialize(object.dateTime,
-                    specifiedType: const FullType(DateTime)));
-        }
-        if (object.map != null) {
-            result
-                ..add(r'map')
-                ..add(serializers.serialize(object.map,
-                    specifiedType: const FullType(BuiltMap, [FullType(String), FullType(Animal)])));
-        }
-        return result;
+class _$MixedPropertiesAndAdditionalPropertiesClassSerializer implements PrimitiveSerializer<MixedPropertiesAndAdditionalPropertiesClass> {
+  @override
+  final Iterable<Type> types = const [MixedPropertiesAndAdditionalPropertiesClass, _$MixedPropertiesAndAdditionalPropertiesClass];
+
+  @override
+  final String wireName = r'MixedPropertiesAndAdditionalPropertiesClass';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    MixedPropertiesAndAdditionalPropertiesClass object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.uuid != null) {
+      yield r'uuid';
+      yield serializers.serialize(
+        object.uuid,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.dateTime != null) {
+      yield r'dateTime';
+      yield serializers.serialize(
+        object.dateTime,
+        specifiedType: const FullType(DateTime),
+      );
     }
+    if (object.map != null) {
+      yield r'map';
+      yield serializers.serialize(
+        object.map,
+        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(Animal)]),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    MixedPropertiesAndAdditionalPropertiesClass object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-    @override
-    MixedPropertiesAndAdditionalPropertiesClass deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = MixedPropertiesAndAdditionalPropertiesClassBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'uuid':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.uuid = valueDes;
-                    break;
-                case r'dateTime':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(DateTime)) as DateTime;
-                    result.dateTime = valueDes;
-                    break;
-                case r'map':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltMap, [FullType(String), FullType(Animal)])) as BuiltMap<String, Animal>;
-                    result.map.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required MixedPropertiesAndAdditionalPropertiesClassBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'uuid':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.uuid = valueDes;
+          break;
+        case r'dateTime':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(DateTime),
+          ) as DateTime;
+          result.dateTime = valueDes;
+          break;
+        case r'map':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltMap, [FullType(String), FullType(Animal)]),
+          ) as BuiltMap<String, Animal>;
+          result.map.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  MixedPropertiesAndAdditionalPropertiesClass deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = MixedPropertiesAndAdditionalPropertiesClassBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model200_response.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model200_response.dart
index 1e7b31e2af61a0c7aaccb76ad7386964dcb903e5..0a2cfb4411aca398a8427502e27cbdeaa34c2bdd 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model200_response.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model200_response.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -12,75 +13,114 @@ part 'model200_response.g.dart';
 /// Properties:
 /// * [name] 
 /// * [classField] 
+@BuiltValue()
 abstract class Model200Response implements Built<Model200Response, Model200ResponseBuilder> {
-    @BuiltValueField(wireName: r'name')
-    int? get name;
+  @BuiltValueField(wireName: r'name')
+  int? get name;
 
-    @BuiltValueField(wireName: r'class')
-    String? get classField;
+  @BuiltValueField(wireName: r'class')
+  String? get classField;
 
-    Model200Response._();
+  Model200Response._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(Model200ResponseBuilder b) => b;
+  factory Model200Response([void updates(Model200ResponseBuilder b)]) = _$Model200Response;
 
-    factory Model200Response([void updates(Model200ResponseBuilder b)]) = _$Model200Response;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(Model200ResponseBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Model200Response> get serializer => _$Model200ResponseSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Model200Response> get serializer => _$Model200ResponseSerializer();
 }
 
-class _$Model200ResponseSerializer implements StructuredSerializer<Model200Response> {
-    @override
-    final Iterable<Type> types = const [Model200Response, _$Model200Response];
+class _$Model200ResponseSerializer implements PrimitiveSerializer<Model200Response> {
+  @override
+  final Iterable<Type> types = const [Model200Response, _$Model200Response];
 
-    @override
-    final String wireName = r'Model200Response';
+  @override
+  final String wireName = r'Model200Response';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Model200Response object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.name != null) {
-            result
-                ..add(r'name')
-                ..add(serializers.serialize(object.name,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.classField != null) {
-            result
-                ..add(r'class')
-                ..add(serializers.serialize(object.classField,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Model200Response object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.name != null) {
+      yield r'name';
+      yield serializers.serialize(
+        object.name,
+        specifiedType: const FullType(int),
+      );
     }
+    if (object.classField != null) {
+      yield r'class';
+      yield serializers.serialize(
+        object.classField,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
 
-    @override
-    Model200Response deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = Model200ResponseBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    Model200Response object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'name':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.name = valueDes;
-                    break;
-                case r'class':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.classField = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required Model200ResponseBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'name':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.name = valueDes;
+          break;
+        case r'class':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.classField = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  Model200Response deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = Model200ResponseBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_client.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_client.dart
index 23c30a77f2b0fe2ab259e87c11df8a1124e0baef..36690977421bdcf05abff26776f1c7bb9b29d121 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_client.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_client.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,61 +12,97 @@ part 'model_client.g.dart';
 ///
 /// Properties:
 /// * [client] 
+@BuiltValue()
 abstract class ModelClient implements Built<ModelClient, ModelClientBuilder> {
-    @BuiltValueField(wireName: r'client')
-    String? get client;
+  @BuiltValueField(wireName: r'client')
+  String? get client;
 
-    ModelClient._();
+  ModelClient._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ModelClientBuilder b) => b;
+  factory ModelClient([void updates(ModelClientBuilder b)]) = _$ModelClient;
 
-    factory ModelClient([void updates(ModelClientBuilder b)]) = _$ModelClient;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ModelClientBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ModelClient> get serializer => _$ModelClientSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ModelClient> get serializer => _$ModelClientSerializer();
 }
 
-class _$ModelClientSerializer implements StructuredSerializer<ModelClient> {
-    @override
-    final Iterable<Type> types = const [ModelClient, _$ModelClient];
+class _$ModelClientSerializer implements PrimitiveSerializer<ModelClient> {
+  @override
+  final Iterable<Type> types = const [ModelClient, _$ModelClient];
 
-    @override
-    final String wireName = r'ModelClient';
+  @override
+  final String wireName = r'ModelClient';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ModelClient object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.client != null) {
-            result
-                ..add(r'client')
-                ..add(serializers.serialize(object.client,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ModelClient object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.client != null) {
+      yield r'client';
+      yield serializers.serialize(
+        object.client,
+        specifiedType: const FullType(String),
+      );
     }
+  }
 
-    @override
-    ModelClient deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ModelClientBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    ModelClient object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'client':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.client = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ModelClientBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'client':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.client = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ModelClient deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ModelClientBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_enum_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_enum_class.dart
index f49be90d2bb3274ab335e9442dceb1b7719fbcbd..ac609bfd15ad1c2ac4aab3c0bf4ead34a6b6d3b6 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_enum_class.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_enum_class.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_file.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_file.dart
index aa7b5ecfeddf39291363d0f3c923bdf5f993554d..2702c21d36f29d0ba1078bd14ba8392f7dfab477 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_file.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_file.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,62 +12,98 @@ part 'model_file.g.dart';
 ///
 /// Properties:
 /// * [sourceURI] - Test capitalization
+@BuiltValue()
 abstract class ModelFile implements Built<ModelFile, ModelFileBuilder> {
-    /// Test capitalization
-    @BuiltValueField(wireName: r'sourceURI')
-    String? get sourceURI;
+  /// Test capitalization
+  @BuiltValueField(wireName: r'sourceURI')
+  String? get sourceURI;
 
-    ModelFile._();
+  ModelFile._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ModelFileBuilder b) => b;
+  factory ModelFile([void updates(ModelFileBuilder b)]) = _$ModelFile;
 
-    factory ModelFile([void updates(ModelFileBuilder b)]) = _$ModelFile;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ModelFileBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ModelFile> get serializer => _$ModelFileSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ModelFile> get serializer => _$ModelFileSerializer();
 }
 
-class _$ModelFileSerializer implements StructuredSerializer<ModelFile> {
-    @override
-    final Iterable<Type> types = const [ModelFile, _$ModelFile];
+class _$ModelFileSerializer implements PrimitiveSerializer<ModelFile> {
+  @override
+  final Iterable<Type> types = const [ModelFile, _$ModelFile];
 
-    @override
-    final String wireName = r'ModelFile';
+  @override
+  final String wireName = r'ModelFile';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ModelFile object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.sourceURI != null) {
-            result
-                ..add(r'sourceURI')
-                ..add(serializers.serialize(object.sourceURI,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ModelFile object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.sourceURI != null) {
+      yield r'sourceURI';
+      yield serializers.serialize(
+        object.sourceURI,
+        specifiedType: const FullType(String),
+      );
     }
+  }
 
-    @override
-    ModelFile deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ModelFileBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    ModelFile object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'sourceURI':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.sourceURI = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ModelFileBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'sourceURI':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.sourceURI = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ModelFile deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ModelFileBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_list.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_list.dart
index 87e10153b1acb340d15a26a34b564f28269f8426..579853258f8e4156d019dee05650bc638aa3cba0 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_list.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_list.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,61 +12,97 @@ part 'model_list.g.dart';
 ///
 /// Properties:
 /// * [n123list] 
+@BuiltValue()
 abstract class ModelList implements Built<ModelList, ModelListBuilder> {
-    @BuiltValueField(wireName: r'123-list')
-    String? get n123list;
+  @BuiltValueField(wireName: r'123-list')
+  String? get n123list;
 
-    ModelList._();
+  ModelList._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ModelListBuilder b) => b;
+  factory ModelList([void updates(ModelListBuilder b)]) = _$ModelList;
 
-    factory ModelList([void updates(ModelListBuilder b)]) = _$ModelList;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ModelListBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ModelList> get serializer => _$ModelListSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ModelList> get serializer => _$ModelListSerializer();
 }
 
-class _$ModelListSerializer implements StructuredSerializer<ModelList> {
-    @override
-    final Iterable<Type> types = const [ModelList, _$ModelList];
+class _$ModelListSerializer implements PrimitiveSerializer<ModelList> {
+  @override
+  final Iterable<Type> types = const [ModelList, _$ModelList];
 
-    @override
-    final String wireName = r'ModelList';
+  @override
+  final String wireName = r'ModelList';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ModelList object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.n123list != null) {
-            result
-                ..add(r'123-list')
-                ..add(serializers.serialize(object.n123list,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ModelList object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.n123list != null) {
+      yield r'123-list';
+      yield serializers.serialize(
+        object.n123list,
+        specifiedType: const FullType(String),
+      );
     }
+  }
 
-    @override
-    ModelList deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ModelListBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    ModelList object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'123-list':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.n123list = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ModelListBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'123-list':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.n123list = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ModelList deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ModelListBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_return.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_return.dart
index c63e0464faaddeb008941d56e2d1555e00051d83..45a2f67f8a40c63ca36ca3f87d1f47b1bd4cb4ac 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_return.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/model_return.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,61 +12,97 @@ part 'model_return.g.dart';
 ///
 /// Properties:
 /// * [return_] 
+@BuiltValue()
 abstract class ModelReturn implements Built<ModelReturn, ModelReturnBuilder> {
-    @BuiltValueField(wireName: r'return')
-    int? get return_;
+  @BuiltValueField(wireName: r'return')
+  int? get return_;
 
-    ModelReturn._();
+  ModelReturn._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ModelReturnBuilder b) => b;
+  factory ModelReturn([void updates(ModelReturnBuilder b)]) = _$ModelReturn;
 
-    factory ModelReturn([void updates(ModelReturnBuilder b)]) = _$ModelReturn;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ModelReturnBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ModelReturn> get serializer => _$ModelReturnSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ModelReturn> get serializer => _$ModelReturnSerializer();
 }
 
-class _$ModelReturnSerializer implements StructuredSerializer<ModelReturn> {
-    @override
-    final Iterable<Type> types = const [ModelReturn, _$ModelReturn];
+class _$ModelReturnSerializer implements PrimitiveSerializer<ModelReturn> {
+  @override
+  final Iterable<Type> types = const [ModelReturn, _$ModelReturn];
 
-    @override
-    final String wireName = r'ModelReturn';
+  @override
+  final String wireName = r'ModelReturn';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ModelReturn object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.return_ != null) {
-            result
-                ..add(r'return')
-                ..add(serializers.serialize(object.return_,
-                    specifiedType: const FullType(int)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ModelReturn object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.return_ != null) {
+      yield r'return';
+      yield serializers.serialize(
+        object.return_,
+        specifiedType: const FullType(int),
+      );
     }
+  }
 
-    @override
-    ModelReturn deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ModelReturnBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    ModelReturn object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'return':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.return_ = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ModelReturnBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'return':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.return_ = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ModelReturn deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ModelReturnBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/name.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/name.dart
index 78f9f8e545eff766ae585da202acf40edc54f52e..10fa99e6a5f77667b1f398e6b0c69f958b79e91f 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/name.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/name.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -14,101 +15,146 @@ part 'name.g.dart';
 /// * [snakeCase] 
 /// * [property] 
 /// * [n123number] 
+@BuiltValue()
 abstract class Name implements Built<Name, NameBuilder> {
-    @BuiltValueField(wireName: r'name')
-    int get name;
+  @BuiltValueField(wireName: r'name')
+  int get name;
 
-    @BuiltValueField(wireName: r'snake_case')
-    int? get snakeCase;
+  @BuiltValueField(wireName: r'snake_case')
+  int? get snakeCase;
 
-    @BuiltValueField(wireName: r'property')
-    String? get property;
+  @BuiltValueField(wireName: r'property')
+  String? get property;
 
-    @BuiltValueField(wireName: r'123Number')
-    int? get n123number;
+  @BuiltValueField(wireName: r'123Number')
+  int? get n123number;
 
-    Name._();
+  Name._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(NameBuilder b) => b;
+  factory Name([void updates(NameBuilder b)]) = _$Name;
 
-    factory Name([void updates(NameBuilder b)]) = _$Name;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(NameBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Name> get serializer => _$NameSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Name> get serializer => _$NameSerializer();
 }
 
-class _$NameSerializer implements StructuredSerializer<Name> {
-    @override
-    final Iterable<Type> types = const [Name, _$Name];
-
-    @override
-    final String wireName = r'Name';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Name object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        result
-            ..add(r'name')
-            ..add(serializers.serialize(object.name,
-                specifiedType: const FullType(int)));
-        if (object.snakeCase != null) {
-            result
-                ..add(r'snake_case')
-                ..add(serializers.serialize(object.snakeCase,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.property != null) {
-            result
-                ..add(r'property')
-                ..add(serializers.serialize(object.property,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.n123number != null) {
-            result
-                ..add(r'123Number')
-                ..add(serializers.serialize(object.n123number,
-                    specifiedType: const FullType(int)));
-        }
-        return result;
+class _$NameSerializer implements PrimitiveSerializer<Name> {
+  @override
+  final Iterable<Type> types = const [Name, _$Name];
+
+  @override
+  final String wireName = r'Name';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Name object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    yield r'name';
+    yield serializers.serialize(
+      object.name,
+      specifiedType: const FullType(int),
+    );
+    if (object.snakeCase != null) {
+      yield r'snake_case';
+      yield serializers.serialize(
+        object.snakeCase,
+        specifiedType: const FullType(int),
+      );
     }
-
-    @override
-    Name deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = NameBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'name':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.name = valueDes;
-                    break;
-                case r'snake_case':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.snakeCase = valueDes;
-                    break;
-                case r'property':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.property = valueDes;
-                    break;
-                case r'123Number':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.n123number = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+    if (object.property != null) {
+      yield r'property';
+      yield serializers.serialize(
+        object.property,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.n123number != null) {
+      yield r'123Number';
+      yield serializers.serialize(
+        object.n123number,
+        specifiedType: const FullType(int),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Name object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required NameBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'name':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.name = valueDes;
+          break;
+        case r'snake_case':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.snakeCase = valueDes;
+          break;
+        case r'property':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.property = valueDes;
+          break;
+        case r'123Number':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.n123number = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  Name deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = NameBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/nullable_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/nullable_class.dart
index efddc42e3072dbfe64659ab8c604957b1fbc0d85..c993a41303f02c74f97bfe9109909eefaf9fd14d 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/nullable_class.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/nullable_class.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:openapi/src/model/date.dart';
 import 'package:built_value/json_object.dart';
@@ -25,225 +26,294 @@ part 'nullable_class.g.dart';
 /// * [objectNullableProp] 
 /// * [objectAndItemsNullableProp] 
 /// * [objectItemsNullable] 
+@BuiltValue()
 abstract class NullableClass implements Built<NullableClass, NullableClassBuilder> {
-    @BuiltValueField(wireName: r'integer_prop')
-    int? get integerProp;
+  @BuiltValueField(wireName: r'integer_prop')
+  int? get integerProp;
 
-    @BuiltValueField(wireName: r'number_prop')
-    num? get numberProp;
+  @BuiltValueField(wireName: r'number_prop')
+  num? get numberProp;
 
-    @BuiltValueField(wireName: r'boolean_prop')
-    bool? get booleanProp;
+  @BuiltValueField(wireName: r'boolean_prop')
+  bool? get booleanProp;
 
-    @BuiltValueField(wireName: r'string_prop')
-    String? get stringProp;
+  @BuiltValueField(wireName: r'string_prop')
+  String? get stringProp;
 
-    @BuiltValueField(wireName: r'date_prop')
-    Date? get dateProp;
+  @BuiltValueField(wireName: r'date_prop')
+  Date? get dateProp;
 
-    @BuiltValueField(wireName: r'datetime_prop')
-    DateTime? get datetimeProp;
+  @BuiltValueField(wireName: r'datetime_prop')
+  DateTime? get datetimeProp;
 
-    @BuiltValueField(wireName: r'array_nullable_prop')
-    BuiltList<JsonObject>? get arrayNullableProp;
+  @BuiltValueField(wireName: r'array_nullable_prop')
+  BuiltList<JsonObject>? get arrayNullableProp;
 
-    @BuiltValueField(wireName: r'array_and_items_nullable_prop')
-    BuiltList<JsonObject?>? get arrayAndItemsNullableProp;
+  @BuiltValueField(wireName: r'array_and_items_nullable_prop')
+  BuiltList<JsonObject?>? get arrayAndItemsNullableProp;
 
-    @BuiltValueField(wireName: r'array_items_nullable')
-    BuiltList<JsonObject?>? get arrayItemsNullable;
+  @BuiltValueField(wireName: r'array_items_nullable')
+  BuiltList<JsonObject?>? get arrayItemsNullable;
 
-    @BuiltValueField(wireName: r'object_nullable_prop')
-    BuiltMap<String, JsonObject>? get objectNullableProp;
+  @BuiltValueField(wireName: r'object_nullable_prop')
+  BuiltMap<String, JsonObject>? get objectNullableProp;
 
-    @BuiltValueField(wireName: r'object_and_items_nullable_prop')
-    BuiltMap<String, JsonObject?>? get objectAndItemsNullableProp;
+  @BuiltValueField(wireName: r'object_and_items_nullable_prop')
+  BuiltMap<String, JsonObject?>? get objectAndItemsNullableProp;
 
-    @BuiltValueField(wireName: r'object_items_nullable')
-    BuiltMap<String, JsonObject?>? get objectItemsNullable;
+  @BuiltValueField(wireName: r'object_items_nullable')
+  BuiltMap<String, JsonObject?>? get objectItemsNullable;
 
-    NullableClass._();
+  NullableClass._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(NullableClassBuilder b) => b;
+  factory NullableClass([void updates(NullableClassBuilder b)]) = _$NullableClass;
 
-    factory NullableClass([void updates(NullableClassBuilder b)]) = _$NullableClass;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(NullableClassBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<NullableClass> get serializer => _$NullableClassSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<NullableClass> get serializer => _$NullableClassSerializer();
 }
 
-class _$NullableClassSerializer implements StructuredSerializer<NullableClass> {
-    @override
-    final Iterable<Type> types = const [NullableClass, _$NullableClass];
-
-    @override
-    final String wireName = r'NullableClass';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, NullableClass object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.integerProp != null) {
-            result
-                ..add(r'integer_prop')
-                ..add(serializers.serialize(object.integerProp,
-                    specifiedType: const FullType.nullable(int)));
-        }
-        if (object.numberProp != null) {
-            result
-                ..add(r'number_prop')
-                ..add(serializers.serialize(object.numberProp,
-                    specifiedType: const FullType.nullable(num)));
-        }
-        if (object.booleanProp != null) {
-            result
-                ..add(r'boolean_prop')
-                ..add(serializers.serialize(object.booleanProp,
-                    specifiedType: const FullType.nullable(bool)));
-        }
-        if (object.stringProp != null) {
-            result
-                ..add(r'string_prop')
-                ..add(serializers.serialize(object.stringProp,
-                    specifiedType: const FullType.nullable(String)));
-        }
-        if (object.dateProp != null) {
-            result
-                ..add(r'date_prop')
-                ..add(serializers.serialize(object.dateProp,
-                    specifiedType: const FullType.nullable(Date)));
-        }
-        if (object.datetimeProp != null) {
-            result
-                ..add(r'datetime_prop')
-                ..add(serializers.serialize(object.datetimeProp,
-                    specifiedType: const FullType.nullable(DateTime)));
-        }
-        if (object.arrayNullableProp != null) {
-            result
-                ..add(r'array_nullable_prop')
-                ..add(serializers.serialize(object.arrayNullableProp,
-                    specifiedType: const FullType.nullable(BuiltList, [FullType(JsonObject)])));
-        }
-        if (object.arrayAndItemsNullableProp != null) {
-            result
-                ..add(r'array_and_items_nullable_prop')
-                ..add(serializers.serialize(object.arrayAndItemsNullableProp,
-                    specifiedType: const FullType.nullable(BuiltList, [FullType.nullable(JsonObject)])));
-        }
-        if (object.arrayItemsNullable != null) {
-            result
-                ..add(r'array_items_nullable')
-                ..add(serializers.serialize(object.arrayItemsNullable,
-                    specifiedType: const FullType(BuiltList, [FullType.nullable(JsonObject)])));
-        }
-        if (object.objectNullableProp != null) {
-            result
-                ..add(r'object_nullable_prop')
-                ..add(serializers.serialize(object.objectNullableProp,
-                    specifiedType: const FullType.nullable(BuiltMap, [FullType(String), FullType(JsonObject)])));
-        }
-        if (object.objectAndItemsNullableProp != null) {
-            result
-                ..add(r'object_and_items_nullable_prop')
-                ..add(serializers.serialize(object.objectAndItemsNullableProp,
-                    specifiedType: const FullType.nullable(BuiltMap, [FullType(String), FullType.nullable(JsonObject)])));
-        }
-        if (object.objectItemsNullable != null) {
-            result
-                ..add(r'object_items_nullable')
-                ..add(serializers.serialize(object.objectItemsNullable,
-                    specifiedType: const FullType(BuiltMap, [FullType(String), FullType.nullable(JsonObject)])));
-        }
-        return result;
+class _$NullableClassSerializer implements PrimitiveSerializer<NullableClass> {
+  @override
+  final Iterable<Type> types = const [NullableClass, _$NullableClass];
+
+  @override
+  final String wireName = r'NullableClass';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    NullableClass object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.integerProp != null) {
+      yield r'integer_prop';
+      yield serializers.serialize(
+        object.integerProp,
+        specifiedType: const FullType.nullable(int),
+      );
+    }
+    if (object.numberProp != null) {
+      yield r'number_prop';
+      yield serializers.serialize(
+        object.numberProp,
+        specifiedType: const FullType.nullable(num),
+      );
+    }
+    if (object.booleanProp != null) {
+      yield r'boolean_prop';
+      yield serializers.serialize(
+        object.booleanProp,
+        specifiedType: const FullType.nullable(bool),
+      );
+    }
+    if (object.stringProp != null) {
+      yield r'string_prop';
+      yield serializers.serialize(
+        object.stringProp,
+        specifiedType: const FullType.nullable(String),
+      );
+    }
+    if (object.dateProp != null) {
+      yield r'date_prop';
+      yield serializers.serialize(
+        object.dateProp,
+        specifiedType: const FullType.nullable(Date),
+      );
+    }
+    if (object.datetimeProp != null) {
+      yield r'datetime_prop';
+      yield serializers.serialize(
+        object.datetimeProp,
+        specifiedType: const FullType.nullable(DateTime),
+      );
+    }
+    if (object.arrayNullableProp != null) {
+      yield r'array_nullable_prop';
+      yield serializers.serialize(
+        object.arrayNullableProp,
+        specifiedType: const FullType.nullable(BuiltList, [FullType(JsonObject)]),
+      );
     }
+    if (object.arrayAndItemsNullableProp != null) {
+      yield r'array_and_items_nullable_prop';
+      yield serializers.serialize(
+        object.arrayAndItemsNullableProp,
+        specifiedType: const FullType.nullable(BuiltList, [FullType.nullable(JsonObject)]),
+      );
+    }
+    if (object.arrayItemsNullable != null) {
+      yield r'array_items_nullable';
+      yield serializers.serialize(
+        object.arrayItemsNullable,
+        specifiedType: const FullType(BuiltList, [FullType.nullable(JsonObject)]),
+      );
+    }
+    if (object.objectNullableProp != null) {
+      yield r'object_nullable_prop';
+      yield serializers.serialize(
+        object.objectNullableProp,
+        specifiedType: const FullType.nullable(BuiltMap, [FullType(String), FullType(JsonObject)]),
+      );
+    }
+    if (object.objectAndItemsNullableProp != null) {
+      yield r'object_and_items_nullable_prop';
+      yield serializers.serialize(
+        object.objectAndItemsNullableProp,
+        specifiedType: const FullType.nullable(BuiltMap, [FullType(String), FullType.nullable(JsonObject)]),
+      );
+    }
+    if (object.objectItemsNullable != null) {
+      yield r'object_items_nullable';
+      yield serializers.serialize(
+        object.objectItemsNullable,
+        specifiedType: const FullType(BuiltMap, [FullType(String), FullType.nullable(JsonObject)]),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    NullableClass object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-    @override
-    NullableClass deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = NullableClassBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'integer_prop':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(int)) as int?;
-                    if (valueDes == null) continue;
-                    result.integerProp = valueDes;
-                    break;
-                case r'number_prop':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(num)) as num?;
-                    if (valueDes == null) continue;
-                    result.numberProp = valueDes;
-                    break;
-                case r'boolean_prop':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(bool)) as bool?;
-                    if (valueDes == null) continue;
-                    result.booleanProp = valueDes;
-                    break;
-                case r'string_prop':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(String)) as String?;
-                    if (valueDes == null) continue;
-                    result.stringProp = valueDes;
-                    break;
-                case r'date_prop':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(Date)) as Date?;
-                    if (valueDes == null) continue;
-                    result.dateProp = valueDes;
-                    break;
-                case r'datetime_prop':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(DateTime)) as DateTime?;
-                    if (valueDes == null) continue;
-                    result.datetimeProp = valueDes;
-                    break;
-                case r'array_nullable_prop':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(BuiltList, [FullType(JsonObject)])) as BuiltList<JsonObject>?;
-                    if (valueDes == null) continue;
-                    result.arrayNullableProp.replace(valueDes);
-                    break;
-                case r'array_and_items_nullable_prop':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(BuiltList, [FullType.nullable(JsonObject)])) as BuiltList<JsonObject?>?;
-                    if (valueDes == null) continue;
-                    result.arrayAndItemsNullableProp.replace(valueDes);
-                    break;
-                case r'array_items_nullable':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltList, [FullType.nullable(JsonObject)])) as BuiltList<JsonObject?>;
-                    result.arrayItemsNullable.replace(valueDes);
-                    break;
-                case r'object_nullable_prop':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(BuiltMap, [FullType(String), FullType(JsonObject)])) as BuiltMap<String, JsonObject>?;
-                    if (valueDes == null) continue;
-                    result.objectNullableProp.replace(valueDes);
-                    break;
-                case r'object_and_items_nullable_prop':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType.nullable(BuiltMap, [FullType(String), FullType.nullable(JsonObject)])) as BuiltMap<String, JsonObject?>?;
-                    if (valueDes == null) continue;
-                    result.objectAndItemsNullableProp.replace(valueDes);
-                    break;
-                case r'object_items_nullable':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltMap, [FullType(String), FullType.nullable(JsonObject)])) as BuiltMap<String, JsonObject?>;
-                    result.objectItemsNullable.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required NullableClassBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'integer_prop':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(int),
+          ) as int?;
+          if (valueDes == null) continue;
+          result.integerProp = valueDes;
+          break;
+        case r'number_prop':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(num),
+          ) as num?;
+          if (valueDes == null) continue;
+          result.numberProp = valueDes;
+          break;
+        case r'boolean_prop':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(bool),
+          ) as bool?;
+          if (valueDes == null) continue;
+          result.booleanProp = valueDes;
+          break;
+        case r'string_prop':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(String),
+          ) as String?;
+          if (valueDes == null) continue;
+          result.stringProp = valueDes;
+          break;
+        case r'date_prop':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(Date),
+          ) as Date?;
+          if (valueDes == null) continue;
+          result.dateProp = valueDes;
+          break;
+        case r'datetime_prop':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(DateTime),
+          ) as DateTime?;
+          if (valueDes == null) continue;
+          result.datetimeProp = valueDes;
+          break;
+        case r'array_nullable_prop':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(BuiltList, [FullType(JsonObject)]),
+          ) as BuiltList<JsonObject>?;
+          if (valueDes == null) continue;
+          result.arrayNullableProp.replace(valueDes);
+          break;
+        case r'array_and_items_nullable_prop':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(BuiltList, [FullType.nullable(JsonObject)]),
+          ) as BuiltList<JsonObject?>?;
+          if (valueDes == null) continue;
+          result.arrayAndItemsNullableProp.replace(valueDes);
+          break;
+        case r'array_items_nullable':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltList, [FullType.nullable(JsonObject)]),
+          ) as BuiltList<JsonObject?>;
+          result.arrayItemsNullable.replace(valueDes);
+          break;
+        case r'object_nullable_prop':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(BuiltMap, [FullType(String), FullType(JsonObject)]),
+          ) as BuiltMap<String, JsonObject>?;
+          if (valueDes == null) continue;
+          result.objectNullableProp.replace(valueDes);
+          break;
+        case r'object_and_items_nullable_prop':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType.nullable(BuiltMap, [FullType(String), FullType.nullable(JsonObject)]),
+          ) as BuiltMap<String, JsonObject?>?;
+          if (valueDes == null) continue;
+          result.objectAndItemsNullableProp.replace(valueDes);
+          break;
+        case r'object_items_nullable':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltMap, [FullType(String), FullType.nullable(JsonObject)]),
+          ) as BuiltMap<String, JsonObject?>;
+          result.objectItemsNullable.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  NullableClass deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = NullableClassBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/number_only.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/number_only.dart
index e90cc9b93408d36ce0482e447063228f6404d495..482a95f3e52131aac1b85c59fa84bba04e7d3c72 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/number_only.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/number_only.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,61 +12,97 @@ part 'number_only.g.dart';
 ///
 /// Properties:
 /// * [justNumber] 
+@BuiltValue()
 abstract class NumberOnly implements Built<NumberOnly, NumberOnlyBuilder> {
-    @BuiltValueField(wireName: r'JustNumber')
-    num? get justNumber;
+  @BuiltValueField(wireName: r'JustNumber')
+  num? get justNumber;
 
-    NumberOnly._();
+  NumberOnly._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(NumberOnlyBuilder b) => b;
+  factory NumberOnly([void updates(NumberOnlyBuilder b)]) = _$NumberOnly;
 
-    factory NumberOnly([void updates(NumberOnlyBuilder b)]) = _$NumberOnly;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(NumberOnlyBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<NumberOnly> get serializer => _$NumberOnlySerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<NumberOnly> get serializer => _$NumberOnlySerializer();
 }
 
-class _$NumberOnlySerializer implements StructuredSerializer<NumberOnly> {
-    @override
-    final Iterable<Type> types = const [NumberOnly, _$NumberOnly];
+class _$NumberOnlySerializer implements PrimitiveSerializer<NumberOnly> {
+  @override
+  final Iterable<Type> types = const [NumberOnly, _$NumberOnly];
 
-    @override
-    final String wireName = r'NumberOnly';
+  @override
+  final String wireName = r'NumberOnly';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, NumberOnly object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.justNumber != null) {
-            result
-                ..add(r'JustNumber')
-                ..add(serializers.serialize(object.justNumber,
-                    specifiedType: const FullType(num)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    NumberOnly object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.justNumber != null) {
+      yield r'JustNumber';
+      yield serializers.serialize(
+        object.justNumber,
+        specifiedType: const FullType(num),
+      );
     }
+  }
 
-    @override
-    NumberOnly deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = NumberOnlyBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    NumberOnly object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'JustNumber':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(num)) as num;
-                    result.justNumber = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required NumberOnlyBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'JustNumber':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(num),
+          ) as num;
+          result.justNumber = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  NumberOnly deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = NumberOnlyBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/object_with_deprecated_fields.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/object_with_deprecated_fields.dart
index 881ede54d0d6416ef92215b4adc4985366295f5d..f59131ea6fbf188f3d1fb8772a9662bc42fce351 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/object_with_deprecated_fields.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/object_with_deprecated_fields.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:openapi/src/model/deprecated_object.dart';
 import 'package:built_value/built_value.dart';
@@ -16,103 +17,148 @@ part 'object_with_deprecated_fields.g.dart';
 /// * [id] 
 /// * [deprecatedRef] 
 /// * [bars] 
+@BuiltValue()
 abstract class ObjectWithDeprecatedFields implements Built<ObjectWithDeprecatedFields, ObjectWithDeprecatedFieldsBuilder> {
-    @BuiltValueField(wireName: r'uuid')
-    String? get uuid;
+  @BuiltValueField(wireName: r'uuid')
+  String? get uuid;
 
-    @BuiltValueField(wireName: r'id')
-    num? get id;
+  @BuiltValueField(wireName: r'id')
+  num? get id;
 
-    @BuiltValueField(wireName: r'deprecatedRef')
-    DeprecatedObject? get deprecatedRef;
+  @BuiltValueField(wireName: r'deprecatedRef')
+  DeprecatedObject? get deprecatedRef;
 
-    @BuiltValueField(wireName: r'bars')
-    BuiltList<String>? get bars;
+  @BuiltValueField(wireName: r'bars')
+  BuiltList<String>? get bars;
 
-    ObjectWithDeprecatedFields._();
+  ObjectWithDeprecatedFields._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ObjectWithDeprecatedFieldsBuilder b) => b;
+  factory ObjectWithDeprecatedFields([void updates(ObjectWithDeprecatedFieldsBuilder b)]) = _$ObjectWithDeprecatedFields;
 
-    factory ObjectWithDeprecatedFields([void updates(ObjectWithDeprecatedFieldsBuilder b)]) = _$ObjectWithDeprecatedFields;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ObjectWithDeprecatedFieldsBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ObjectWithDeprecatedFields> get serializer => _$ObjectWithDeprecatedFieldsSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ObjectWithDeprecatedFields> get serializer => _$ObjectWithDeprecatedFieldsSerializer();
 }
 
-class _$ObjectWithDeprecatedFieldsSerializer implements StructuredSerializer<ObjectWithDeprecatedFields> {
-    @override
-    final Iterable<Type> types = const [ObjectWithDeprecatedFields, _$ObjectWithDeprecatedFields];
-
-    @override
-    final String wireName = r'ObjectWithDeprecatedFields';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ObjectWithDeprecatedFields object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.uuid != null) {
-            result
-                ..add(r'uuid')
-                ..add(serializers.serialize(object.uuid,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.id != null) {
-            result
-                ..add(r'id')
-                ..add(serializers.serialize(object.id,
-                    specifiedType: const FullType(num)));
-        }
-        if (object.deprecatedRef != null) {
-            result
-                ..add(r'deprecatedRef')
-                ..add(serializers.serialize(object.deprecatedRef,
-                    specifiedType: const FullType(DeprecatedObject)));
-        }
-        if (object.bars != null) {
-            result
-                ..add(r'bars')
-                ..add(serializers.serialize(object.bars,
-                    specifiedType: const FullType(BuiltList, [FullType(String)])));
-        }
-        return result;
+class _$ObjectWithDeprecatedFieldsSerializer implements PrimitiveSerializer<ObjectWithDeprecatedFields> {
+  @override
+  final Iterable<Type> types = const [ObjectWithDeprecatedFields, _$ObjectWithDeprecatedFields];
+
+  @override
+  final String wireName = r'ObjectWithDeprecatedFields';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ObjectWithDeprecatedFields object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.uuid != null) {
+      yield r'uuid';
+      yield serializers.serialize(
+        object.uuid,
+        specifiedType: const FullType(String),
+      );
     }
-
-    @override
-    ObjectWithDeprecatedFields deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ObjectWithDeprecatedFieldsBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'uuid':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.uuid = valueDes;
-                    break;
-                case r'id':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(num)) as num;
-                    result.id = valueDes;
-                    break;
-                case r'deprecatedRef':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(DeprecatedObject)) as DeprecatedObject;
-                    result.deprecatedRef.replace(valueDes);
-                    break;
-                case r'bars':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltList, [FullType(String)])) as BuiltList<String>;
-                    result.bars.replace(valueDes);
-                    break;
-            }
-        }
-        return result.build();
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(num),
+      );
+    }
+    if (object.deprecatedRef != null) {
+      yield r'deprecatedRef';
+      yield serializers.serialize(
+        object.deprecatedRef,
+        specifiedType: const FullType(DeprecatedObject),
+      );
+    }
+    if (object.bars != null) {
+      yield r'bars';
+      yield serializers.serialize(
+        object.bars,
+        specifiedType: const FullType(BuiltList, [FullType(String)]),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    ObjectWithDeprecatedFields object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ObjectWithDeprecatedFieldsBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'uuid':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.uuid = valueDes;
+          break;
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(num),
+          ) as num;
+          result.id = valueDes;
+          break;
+        case r'deprecatedRef':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(DeprecatedObject),
+          ) as DeprecatedObject;
+          result.deprecatedRef.replace(valueDes);
+          break;
+        case r'bars':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltList, [FullType(String)]),
+          ) as BuiltList<String>;
+          result.bars.replace(valueDes);
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ObjectWithDeprecatedFields deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ObjectWithDeprecatedFieldsBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/order.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/order.dart
index 507a1e3a98d4dc4e7518d22658f196547699ef18..a44e1b340c1e6057e376d8e524707904b0aef57a 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/order.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/order.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
@@ -17,135 +18,186 @@ part 'order.g.dart';
 /// * [shipDate] 
 /// * [status] - Order Status
 /// * [complete] 
+@BuiltValue()
 abstract class Order implements Built<Order, OrderBuilder> {
-    @BuiltValueField(wireName: r'id')
-    int? get id;
+  @BuiltValueField(wireName: r'id')
+  int? get id;
 
-    @BuiltValueField(wireName: r'petId')
-    int? get petId;
+  @BuiltValueField(wireName: r'petId')
+  int? get petId;
 
-    @BuiltValueField(wireName: r'quantity')
-    int? get quantity;
+  @BuiltValueField(wireName: r'quantity')
+  int? get quantity;
 
-    @BuiltValueField(wireName: r'shipDate')
-    DateTime? get shipDate;
+  @BuiltValueField(wireName: r'shipDate')
+  DateTime? get shipDate;
 
-    /// Order Status
-    @BuiltValueField(wireName: r'status')
-    OrderStatusEnum? get status;
-    // enum statusEnum {  placed,  approved,  delivered,  };
+  /// Order Status
+  @BuiltValueField(wireName: r'status')
+  OrderStatusEnum? get status;
+  // enum statusEnum {  placed,  approved,  delivered,  };
 
-    @BuiltValueField(wireName: r'complete')
-    bool? get complete;
+  @BuiltValueField(wireName: r'complete')
+  bool? get complete;
 
-    Order._();
+  Order._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(OrderBuilder b) => b
-        ..complete = false;
+  factory Order([void updates(OrderBuilder b)]) = _$Order;
 
-    factory Order([void updates(OrderBuilder b)]) = _$Order;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(OrderBuilder b) => b
+      ..complete = false;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Order> get serializer => _$OrderSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Order> get serializer => _$OrderSerializer();
 }
 
-class _$OrderSerializer implements StructuredSerializer<Order> {
-    @override
-    final Iterable<Type> types = const [Order, _$Order];
-
-    @override
-    final String wireName = r'Order';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Order object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.id != null) {
-            result
-                ..add(r'id')
-                ..add(serializers.serialize(object.id,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.petId != null) {
-            result
-                ..add(r'petId')
-                ..add(serializers.serialize(object.petId,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.quantity != null) {
-            result
-                ..add(r'quantity')
-                ..add(serializers.serialize(object.quantity,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.shipDate != null) {
-            result
-                ..add(r'shipDate')
-                ..add(serializers.serialize(object.shipDate,
-                    specifiedType: const FullType(DateTime)));
-        }
-        if (object.status != null) {
-            result
-                ..add(r'status')
-                ..add(serializers.serialize(object.status,
-                    specifiedType: const FullType(OrderStatusEnum)));
-        }
-        if (object.complete != null) {
-            result
-                ..add(r'complete')
-                ..add(serializers.serialize(object.complete,
-                    specifiedType: const FullType(bool)));
-        }
-        return result;
+class _$OrderSerializer implements PrimitiveSerializer<Order> {
+  @override
+  final Iterable<Type> types = const [Order, _$Order];
+
+  @override
+  final String wireName = r'Order';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Order object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(int),
+      );
     }
-
-    @override
-    Order deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = OrderBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'id':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.id = valueDes;
-                    break;
-                case r'petId':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.petId = valueDes;
-                    break;
-                case r'quantity':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.quantity = valueDes;
-                    break;
-                case r'shipDate':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(DateTime)) as DateTime;
-                    result.shipDate = valueDes;
-                    break;
-                case r'status':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(OrderStatusEnum)) as OrderStatusEnum;
-                    result.status = valueDes;
-                    break;
-                case r'complete':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(bool)) as bool;
-                    result.complete = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+    if (object.petId != null) {
+      yield r'petId';
+      yield serializers.serialize(
+        object.petId,
+        specifiedType: const FullType(int),
+      );
+    }
+    if (object.quantity != null) {
+      yield r'quantity';
+      yield serializers.serialize(
+        object.quantity,
+        specifiedType: const FullType(int),
+      );
+    }
+    if (object.shipDate != null) {
+      yield r'shipDate';
+      yield serializers.serialize(
+        object.shipDate,
+        specifiedType: const FullType(DateTime),
+      );
+    }
+    if (object.status != null) {
+      yield r'status';
+      yield serializers.serialize(
+        object.status,
+        specifiedType: const FullType(OrderStatusEnum),
+      );
+    }
+    if (object.complete != null) {
+      yield r'complete';
+      yield serializers.serialize(
+        object.complete,
+        specifiedType: const FullType(bool),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Order object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required OrderBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.id = valueDes;
+          break;
+        case r'petId':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.petId = valueDes;
+          break;
+        case r'quantity':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.quantity = valueDes;
+          break;
+        case r'shipDate':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(DateTime),
+          ) as DateTime;
+          result.shipDate = valueDes;
+          break;
+        case r'status':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(OrderStatusEnum),
+          ) as OrderStatusEnum;
+          result.status = valueDes;
+          break;
+        case r'complete':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(bool),
+          ) as bool;
+          result.complete = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  Order deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = OrderBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
 class OrderStatusEnum extends EnumClass {
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_composite.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_composite.dart
index 0715bdff30567d07f2004a524e48a5608088106d..0d6341cc129982d3f242fcd55fb40d56936114b7 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_composite.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_composite.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -13,89 +14,131 @@ part 'outer_composite.g.dart';
 /// * [myNumber] 
 /// * [myString] 
 /// * [myBoolean] 
+@BuiltValue()
 abstract class OuterComposite implements Built<OuterComposite, OuterCompositeBuilder> {
-    @BuiltValueField(wireName: r'my_number')
-    num? get myNumber;
+  @BuiltValueField(wireName: r'my_number')
+  num? get myNumber;
 
-    @BuiltValueField(wireName: r'my_string')
-    String? get myString;
+  @BuiltValueField(wireName: r'my_string')
+  String? get myString;
 
-    @BuiltValueField(wireName: r'my_boolean')
-    bool? get myBoolean;
+  @BuiltValueField(wireName: r'my_boolean')
+  bool? get myBoolean;
 
-    OuterComposite._();
+  OuterComposite._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(OuterCompositeBuilder b) => b;
+  factory OuterComposite([void updates(OuterCompositeBuilder b)]) = _$OuterComposite;
 
-    factory OuterComposite([void updates(OuterCompositeBuilder b)]) = _$OuterComposite;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(OuterCompositeBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<OuterComposite> get serializer => _$OuterCompositeSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<OuterComposite> get serializer => _$OuterCompositeSerializer();
 }
 
-class _$OuterCompositeSerializer implements StructuredSerializer<OuterComposite> {
-    @override
-    final Iterable<Type> types = const [OuterComposite, _$OuterComposite];
-
-    @override
-    final String wireName = r'OuterComposite';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, OuterComposite object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.myNumber != null) {
-            result
-                ..add(r'my_number')
-                ..add(serializers.serialize(object.myNumber,
-                    specifiedType: const FullType(num)));
-        }
-        if (object.myString != null) {
-            result
-                ..add(r'my_string')
-                ..add(serializers.serialize(object.myString,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.myBoolean != null) {
-            result
-                ..add(r'my_boolean')
-                ..add(serializers.serialize(object.myBoolean,
-                    specifiedType: const FullType(bool)));
-        }
-        return result;
+class _$OuterCompositeSerializer implements PrimitiveSerializer<OuterComposite> {
+  @override
+  final Iterable<Type> types = const [OuterComposite, _$OuterComposite];
+
+  @override
+  final String wireName = r'OuterComposite';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    OuterComposite object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.myNumber != null) {
+      yield r'my_number';
+      yield serializers.serialize(
+        object.myNumber,
+        specifiedType: const FullType(num),
+      );
+    }
+    if (object.myString != null) {
+      yield r'my_string';
+      yield serializers.serialize(
+        object.myString,
+        specifiedType: const FullType(String),
+      );
     }
+    if (object.myBoolean != null) {
+      yield r'my_boolean';
+      yield serializers.serialize(
+        object.myBoolean,
+        specifiedType: const FullType(bool),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    OuterComposite object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-    @override
-    OuterComposite deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = OuterCompositeBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'my_number':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(num)) as num;
-                    result.myNumber = valueDes;
-                    break;
-                case r'my_string':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.myString = valueDes;
-                    break;
-                case r'my_boolean':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(bool)) as bool;
-                    result.myBoolean = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required OuterCompositeBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'my_number':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(num),
+          ) as num;
+          result.myNumber = valueDes;
+          break;
+        case r'my_string':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.myString = valueDes;
+          break;
+        case r'my_boolean':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(bool),
+          ) as bool;
+          result.myBoolean = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  OuterComposite deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = OuterCompositeBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum.dart
index 882219e06cdc9d19651a33be4898c304cc62f058..5ad5d8009bdfdadb70313d4cb155adcaafe6b268 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_default_value.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_default_value.dart
index 77353c07711af43c482ca46e39d33464b75a88a3..62c3cefe845692aba51aa4779418a4857c1e7062 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_default_value.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_default_value.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_integer.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_integer.dart
index 9b179131475c79f126c2fe636e6ff6a725dd6180..988b30785d302b6eaa5455e3fddbcd3127f4cad3 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_integer.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_integer.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_integer_default_value.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_integer_default_value.dart
index ded5b2c72318cd682c048bcc134ad3de27c72adf..3fe792cedbe92c9b40e6d57da9fb13af22737773 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_integer_default_value.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_enum_integer_default_value.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_object_with_enum_property.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_object_with_enum_property.dart
index 91524a285b84c903a63250047322978236f06fdd..1733298564528c1e11752089d7b190e66b11eadd 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_object_with_enum_property.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/outer_object_with_enum_property.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:openapi/src/model/outer_enum_integer.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
@@ -12,60 +13,96 @@ part 'outer_object_with_enum_property.g.dart';
 ///
 /// Properties:
 /// * [value] 
+@BuiltValue()
 abstract class OuterObjectWithEnumProperty implements Built<OuterObjectWithEnumProperty, OuterObjectWithEnumPropertyBuilder> {
-    @BuiltValueField(wireName: r'value')
-    OuterEnumInteger get value;
-    // enum valueEnum {  0,  1,  2,  };
+  @BuiltValueField(wireName: r'value')
+  OuterEnumInteger get value;
+  // enum valueEnum {  0,  1,  2,  };
 
-    OuterObjectWithEnumProperty._();
+  OuterObjectWithEnumProperty._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(OuterObjectWithEnumPropertyBuilder b) => b;
+  factory OuterObjectWithEnumProperty([void updates(OuterObjectWithEnumPropertyBuilder b)]) = _$OuterObjectWithEnumProperty;
 
-    factory OuterObjectWithEnumProperty([void updates(OuterObjectWithEnumPropertyBuilder b)]) = _$OuterObjectWithEnumProperty;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(OuterObjectWithEnumPropertyBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<OuterObjectWithEnumProperty> get serializer => _$OuterObjectWithEnumPropertySerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<OuterObjectWithEnumProperty> get serializer => _$OuterObjectWithEnumPropertySerializer();
 }
 
-class _$OuterObjectWithEnumPropertySerializer implements StructuredSerializer<OuterObjectWithEnumProperty> {
-    @override
-    final Iterable<Type> types = const [OuterObjectWithEnumProperty, _$OuterObjectWithEnumProperty];
+class _$OuterObjectWithEnumPropertySerializer implements PrimitiveSerializer<OuterObjectWithEnumProperty> {
+  @override
+  final Iterable<Type> types = const [OuterObjectWithEnumProperty, _$OuterObjectWithEnumProperty];
 
-    @override
-    final String wireName = r'OuterObjectWithEnumProperty';
+  @override
+  final String wireName = r'OuterObjectWithEnumProperty';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, OuterObjectWithEnumProperty object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        result
-            ..add(r'value')
-            ..add(serializers.serialize(object.value,
-                specifiedType: const FullType(OuterEnumInteger)));
-        return result;
-    }
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    OuterObjectWithEnumProperty object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    yield r'value';
+    yield serializers.serialize(
+      object.value,
+      specifiedType: const FullType(OuterEnumInteger),
+    );
+  }
 
-    @override
-    OuterObjectWithEnumProperty deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = OuterObjectWithEnumPropertyBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    OuterObjectWithEnumProperty object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'value':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(OuterEnumInteger)) as OuterEnumInteger;
-                    result.value = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required OuterObjectWithEnumPropertyBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'value':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(OuterEnumInteger),
+          ) as OuterEnumInteger;
+          result.value = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  OuterObjectWithEnumProperty deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = OuterObjectWithEnumPropertyBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/pet.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/pet.dart
index 8ed90d104aa2bb302e69ad9d9c25d484ddc705d5..4d6358bef27d88c678496ae7646eeb6976dc58f8 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/pet.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/pet.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:openapi/src/model/category.dart';
 import 'package:openapi/src/model/tag.dart';
@@ -19,130 +20,181 @@ part 'pet.g.dart';
 /// * [photoUrls] 
 /// * [tags] 
 /// * [status] - pet status in the store
+@BuiltValue()
 abstract class Pet implements Built<Pet, PetBuilder> {
-    @BuiltValueField(wireName: r'id')
-    int? get id;
+  @BuiltValueField(wireName: r'id')
+  int? get id;
 
-    @BuiltValueField(wireName: r'category')
-    Category? get category;
+  @BuiltValueField(wireName: r'category')
+  Category? get category;
 
-    @BuiltValueField(wireName: r'name')
-    String get name;
+  @BuiltValueField(wireName: r'name')
+  String get name;
 
-    @BuiltValueField(wireName: r'photoUrls')
-    BuiltSet<String> get photoUrls;
+  @BuiltValueField(wireName: r'photoUrls')
+  BuiltSet<String> get photoUrls;
 
-    @BuiltValueField(wireName: r'tags')
-    BuiltList<Tag>? get tags;
+  @BuiltValueField(wireName: r'tags')
+  BuiltList<Tag>? get tags;
 
-    /// pet status in the store
-    @BuiltValueField(wireName: r'status')
-    PetStatusEnum? get status;
-    // enum statusEnum {  available,  pending,  sold,  };
+  /// pet status in the store
+  @BuiltValueField(wireName: r'status')
+  PetStatusEnum? get status;
+  // enum statusEnum {  available,  pending,  sold,  };
 
-    Pet._();
+  Pet._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(PetBuilder b) => b;
+  factory Pet([void updates(PetBuilder b)]) = _$Pet;
 
-    factory Pet([void updates(PetBuilder b)]) = _$Pet;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(PetBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Pet> get serializer => _$PetSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Pet> get serializer => _$PetSerializer();
 }
 
-class _$PetSerializer implements StructuredSerializer<Pet> {
-    @override
-    final Iterable<Type> types = const [Pet, _$Pet];
-
-    @override
-    final String wireName = r'Pet';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Pet object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.id != null) {
-            result
-                ..add(r'id')
-                ..add(serializers.serialize(object.id,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.category != null) {
-            result
-                ..add(r'category')
-                ..add(serializers.serialize(object.category,
-                    specifiedType: const FullType(Category)));
-        }
-        result
-            ..add(r'name')
-            ..add(serializers.serialize(object.name,
-                specifiedType: const FullType(String)));
-        result
-            ..add(r'photoUrls')
-            ..add(serializers.serialize(object.photoUrls,
-                specifiedType: const FullType(BuiltSet, [FullType(String)])));
-        if (object.tags != null) {
-            result
-                ..add(r'tags')
-                ..add(serializers.serialize(object.tags,
-                    specifiedType: const FullType(BuiltList, [FullType(Tag)])));
-        }
-        if (object.status != null) {
-            result
-                ..add(r'status')
-                ..add(serializers.serialize(object.status,
-                    specifiedType: const FullType(PetStatusEnum)));
-        }
-        return result;
+class _$PetSerializer implements PrimitiveSerializer<Pet> {
+  @override
+  final Iterable<Type> types = const [Pet, _$Pet];
+
+  @override
+  final String wireName = r'Pet';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Pet object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(int),
+      );
     }
-
-    @override
-    Pet deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = PetBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'id':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.id = valueDes;
-                    break;
-                case r'category':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(Category)) as Category;
-                    result.category.replace(valueDes);
-                    break;
-                case r'name':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.name = valueDes;
-                    break;
-                case r'photoUrls':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltSet, [FullType(String)])) as BuiltSet<String>;
-                    result.photoUrls.replace(valueDes);
-                    break;
-                case r'tags':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(BuiltList, [FullType(Tag)])) as BuiltList<Tag>;
-                    result.tags.replace(valueDes);
-                    break;
-                case r'status':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(PetStatusEnum)) as PetStatusEnum;
-                    result.status = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+    if (object.category != null) {
+      yield r'category';
+      yield serializers.serialize(
+        object.category,
+        specifiedType: const FullType(Category),
+      );
+    }
+    yield r'name';
+    yield serializers.serialize(
+      object.name,
+      specifiedType: const FullType(String),
+    );
+    yield r'photoUrls';
+    yield serializers.serialize(
+      object.photoUrls,
+      specifiedType: const FullType(BuiltSet, [FullType(String)]),
+    );
+    if (object.tags != null) {
+      yield r'tags';
+      yield serializers.serialize(
+        object.tags,
+        specifiedType: const FullType(BuiltList, [FullType(Tag)]),
+      );
+    }
+    if (object.status != null) {
+      yield r'status';
+      yield serializers.serialize(
+        object.status,
+        specifiedType: const FullType(PetStatusEnum),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    Pet object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required PetBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.id = valueDes;
+          break;
+        case r'category':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(Category),
+          ) as Category;
+          result.category.replace(valueDes);
+          break;
+        case r'name':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.name = valueDes;
+          break;
+        case r'photoUrls':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltSet, [FullType(String)]),
+          ) as BuiltSet<String>;
+          result.photoUrls.replace(valueDes);
+          break;
+        case r'tags':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(BuiltList, [FullType(Tag)]),
+          ) as BuiltList<Tag>;
+          result.tags.replace(valueDes);
+          break;
+        case r'status':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(PetStatusEnum),
+          ) as PetStatusEnum;
+          result.status = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  Pet deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = PetBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
 class PetStatusEnum extends EnumClass {
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/read_only_first.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/read_only_first.dart
index b9f108fb625957f8dc1f03015d07826f501fb4f9..b619217ab3cb0ff88e32b5f70695753bceab40be 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/read_only_first.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/read_only_first.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -12,75 +13,114 @@ part 'read_only_first.g.dart';
 /// Properties:
 /// * [bar] 
 /// * [baz] 
+@BuiltValue()
 abstract class ReadOnlyFirst implements Built<ReadOnlyFirst, ReadOnlyFirstBuilder> {
-    @BuiltValueField(wireName: r'bar')
-    String? get bar;
+  @BuiltValueField(wireName: r'bar')
+  String? get bar;
 
-    @BuiltValueField(wireName: r'baz')
-    String? get baz;
+  @BuiltValueField(wireName: r'baz')
+  String? get baz;
 
-    ReadOnlyFirst._();
+  ReadOnlyFirst._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(ReadOnlyFirstBuilder b) => b;
+  factory ReadOnlyFirst([void updates(ReadOnlyFirstBuilder b)]) = _$ReadOnlyFirst;
 
-    factory ReadOnlyFirst([void updates(ReadOnlyFirstBuilder b)]) = _$ReadOnlyFirst;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(ReadOnlyFirstBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<ReadOnlyFirst> get serializer => _$ReadOnlyFirstSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<ReadOnlyFirst> get serializer => _$ReadOnlyFirstSerializer();
 }
 
-class _$ReadOnlyFirstSerializer implements StructuredSerializer<ReadOnlyFirst> {
-    @override
-    final Iterable<Type> types = const [ReadOnlyFirst, _$ReadOnlyFirst];
+class _$ReadOnlyFirstSerializer implements PrimitiveSerializer<ReadOnlyFirst> {
+  @override
+  final Iterable<Type> types = const [ReadOnlyFirst, _$ReadOnlyFirst];
 
-    @override
-    final String wireName = r'ReadOnlyFirst';
+  @override
+  final String wireName = r'ReadOnlyFirst';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, ReadOnlyFirst object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.bar != null) {
-            result
-                ..add(r'bar')
-                ..add(serializers.serialize(object.bar,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.baz != null) {
-            result
-                ..add(r'baz')
-                ..add(serializers.serialize(object.baz,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    ReadOnlyFirst object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.bar != null) {
+      yield r'bar';
+      yield serializers.serialize(
+        object.bar,
+        specifiedType: const FullType(String),
+      );
     }
+    if (object.baz != null) {
+      yield r'baz';
+      yield serializers.serialize(
+        object.baz,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
 
-    @override
-    ReadOnlyFirst deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = ReadOnlyFirstBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    ReadOnlyFirst object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'bar':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.bar = valueDes;
-                    break;
-                case r'baz':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.baz = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required ReadOnlyFirstBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'bar':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.bar = valueDes;
+          break;
+        case r'baz':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.baz = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  ReadOnlyFirst deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = ReadOnlyFirstBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/single_ref_type.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/single_ref_type.dart
index f1e6aef099e5a57cde1edc5f5c11c247111607b4..b51e77292e8eb1a62e9a86fdfbc31710238bde53 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/single_ref_type.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/single_ref_type.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/special_model_name.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/special_model_name.dart
index dcfe12bb066ae02849e8a6ffa6fab567d444c56a..fa860056b45d7a7d6f5bc87b7943ac66408775f0 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/special_model_name.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/special_model_name.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -11,61 +12,97 @@ part 'special_model_name.g.dart';
 ///
 /// Properties:
 /// * [dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket] 
+@BuiltValue()
 abstract class SpecialModelName implements Built<SpecialModelName, SpecialModelNameBuilder> {
-    @BuiltValueField(wireName: r'$special[property.name]')
-    int? get dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket;
+  @BuiltValueField(wireName: r'$special[property.name]')
+  int? get dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket;
 
-    SpecialModelName._();
+  SpecialModelName._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(SpecialModelNameBuilder b) => b;
+  factory SpecialModelName([void updates(SpecialModelNameBuilder b)]) = _$SpecialModelName;
 
-    factory SpecialModelName([void updates(SpecialModelNameBuilder b)]) = _$SpecialModelName;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(SpecialModelNameBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<SpecialModelName> get serializer => _$SpecialModelNameSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<SpecialModelName> get serializer => _$SpecialModelNameSerializer();
 }
 
-class _$SpecialModelNameSerializer implements StructuredSerializer<SpecialModelName> {
-    @override
-    final Iterable<Type> types = const [SpecialModelName, _$SpecialModelName];
+class _$SpecialModelNameSerializer implements PrimitiveSerializer<SpecialModelName> {
+  @override
+  final Iterable<Type> types = const [SpecialModelName, _$SpecialModelName];
 
-    @override
-    final String wireName = r'SpecialModelName';
+  @override
+  final String wireName = r'SpecialModelName';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, SpecialModelName object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket != null) {
-            result
-                ..add(r'$special[property.name]')
-                ..add(serializers.serialize(object.dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket,
-                    specifiedType: const FullType(int)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    SpecialModelName object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket != null) {
+      yield r'$special[property.name]';
+      yield serializers.serialize(
+        object.dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket,
+        specifiedType: const FullType(int),
+      );
     }
+  }
 
-    @override
-    SpecialModelName deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = SpecialModelNameBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    SpecialModelName object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'$special[property.name]':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required SpecialModelNameBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'$special[property.name]':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  SpecialModelName deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = SpecialModelNameBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/tag.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/tag.dart
index 5a7ed38d94c3dea9567f4b8137f56ac30f66c3f5..3be220d8188e0168c952ba41d0eb773b4b0226da 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/tag.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/tag.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -12,75 +13,114 @@ part 'tag.g.dart';
 /// Properties:
 /// * [id] 
 /// * [name] 
+@BuiltValue()
 abstract class Tag implements Built<Tag, TagBuilder> {
-    @BuiltValueField(wireName: r'id')
-    int? get id;
+  @BuiltValueField(wireName: r'id')
+  int? get id;
 
-    @BuiltValueField(wireName: r'name')
-    String? get name;
+  @BuiltValueField(wireName: r'name')
+  String? get name;
 
-    Tag._();
+  Tag._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(TagBuilder b) => b;
+  factory Tag([void updates(TagBuilder b)]) = _$Tag;
 
-    factory Tag([void updates(TagBuilder b)]) = _$Tag;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(TagBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<Tag> get serializer => _$TagSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<Tag> get serializer => _$TagSerializer();
 }
 
-class _$TagSerializer implements StructuredSerializer<Tag> {
-    @override
-    final Iterable<Type> types = const [Tag, _$Tag];
+class _$TagSerializer implements PrimitiveSerializer<Tag> {
+  @override
+  final Iterable<Type> types = const [Tag, _$Tag];
 
-    @override
-    final String wireName = r'Tag';
+  @override
+  final String wireName = r'Tag';
 
-    @override
-    Iterable<Object?> serialize(Serializers serializers, Tag object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.id != null) {
-            result
-                ..add(r'id')
-                ..add(serializers.serialize(object.id,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.name != null) {
-            result
-                ..add(r'name')
-                ..add(serializers.serialize(object.name,
-                    specifiedType: const FullType(String)));
-        }
-        return result;
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    Tag object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(int),
+      );
     }
+    if (object.name != null) {
+      yield r'name';
+      yield serializers.serialize(
+        object.name,
+        specifiedType: const FullType(String),
+      );
+    }
+  }
 
-    @override
-    Tag deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = TagBuilder();
+  @override
+  Object serialize(
+    Serializers serializers,
+    Tag object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
 
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'id':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.id = valueDes;
-                    break;
-                case r'name':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.name = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required TagBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.id = valueDes;
+          break;
+        case r'name':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.name = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  Tag deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = TagBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/user.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/user.dart
index d590c20bdc7041daf54d2ce216bce6b0e5dee4fe..f7577d7e1ee915a05aa4c29ff596841600d326dd 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/user.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/user.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+// ignore_for_file: unused_element
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -18,160 +19,217 @@ part 'user.g.dart';
 /// * [password] 
 /// * [phone] 
 /// * [userStatus] - User Status
+@BuiltValue()
 abstract class User implements Built<User, UserBuilder> {
-    @BuiltValueField(wireName: r'id')
-    int? get id;
+  @BuiltValueField(wireName: r'id')
+  int? get id;
 
-    @BuiltValueField(wireName: r'username')
-    String? get username;
+  @BuiltValueField(wireName: r'username')
+  String? get username;
 
-    @BuiltValueField(wireName: r'firstName')
-    String? get firstName;
+  @BuiltValueField(wireName: r'firstName')
+  String? get firstName;
 
-    @BuiltValueField(wireName: r'lastName')
-    String? get lastName;
+  @BuiltValueField(wireName: r'lastName')
+  String? get lastName;
 
-    @BuiltValueField(wireName: r'email')
-    String? get email;
+  @BuiltValueField(wireName: r'email')
+  String? get email;
 
-    @BuiltValueField(wireName: r'password')
-    String? get password;
+  @BuiltValueField(wireName: r'password')
+  String? get password;
 
-    @BuiltValueField(wireName: r'phone')
-    String? get phone;
+  @BuiltValueField(wireName: r'phone')
+  String? get phone;
 
-    /// User Status
-    @BuiltValueField(wireName: r'userStatus')
-    int? get userStatus;
+  /// User Status
+  @BuiltValueField(wireName: r'userStatus')
+  int? get userStatus;
 
-    User._();
+  User._();
 
-    @BuiltValueHook(initializeBuilder: true)
-    static void _defaults(UserBuilder b) => b;
+  factory User([void updates(UserBuilder b)]) = _$User;
 
-    factory User([void updates(UserBuilder b)]) = _$User;
+  @BuiltValueHook(initializeBuilder: true)
+  static void _defaults(UserBuilder b) => b;
 
-    @BuiltValueSerializer(custom: true)
-    static Serializer<User> get serializer => _$UserSerializer();
+  @BuiltValueSerializer(custom: true)
+  static Serializer<User> get serializer => _$UserSerializer();
 }
 
-class _$UserSerializer implements StructuredSerializer<User> {
-    @override
-    final Iterable<Type> types = const [User, _$User];
-
-    @override
-    final String wireName = r'User';
-
-    @override
-    Iterable<Object?> serialize(Serializers serializers, User object,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = <Object?>[];
-        if (object.id != null) {
-            result
-                ..add(r'id')
-                ..add(serializers.serialize(object.id,
-                    specifiedType: const FullType(int)));
-        }
-        if (object.username != null) {
-            result
-                ..add(r'username')
-                ..add(serializers.serialize(object.username,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.firstName != null) {
-            result
-                ..add(r'firstName')
-                ..add(serializers.serialize(object.firstName,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.lastName != null) {
-            result
-                ..add(r'lastName')
-                ..add(serializers.serialize(object.lastName,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.email != null) {
-            result
-                ..add(r'email')
-                ..add(serializers.serialize(object.email,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.password != null) {
-            result
-                ..add(r'password')
-                ..add(serializers.serialize(object.password,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.phone != null) {
-            result
-                ..add(r'phone')
-                ..add(serializers.serialize(object.phone,
-                    specifiedType: const FullType(String)));
-        }
-        if (object.userStatus != null) {
-            result
-                ..add(r'userStatus')
-                ..add(serializers.serialize(object.userStatus,
-                    specifiedType: const FullType(int)));
-        }
-        return result;
+class _$UserSerializer implements PrimitiveSerializer<User> {
+  @override
+  final Iterable<Type> types = const [User, _$User];
+
+  @override
+  final String wireName = r'User';
+
+  Iterable<Object?> _serializeProperties(
+    Serializers serializers,
+    User object, {
+    FullType specifiedType = FullType.unspecified,
+  }) sync* {
+    if (object.id != null) {
+      yield r'id';
+      yield serializers.serialize(
+        object.id,
+        specifiedType: const FullType(int),
+      );
     }
-
-    @override
-    User deserialize(Serializers serializers, Iterable<Object?> serialized,
-        {FullType specifiedType = FullType.unspecified}) {
-        final result = UserBuilder();
-
-        final iterator = serialized.iterator;
-        while (iterator.moveNext()) {
-            final key = iterator.current as String;
-            iterator.moveNext();
-            final Object? value = iterator.current;
-            
-            switch (key) {
-                case r'id':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.id = valueDes;
-                    break;
-                case r'username':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.username = valueDes;
-                    break;
-                case r'firstName':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.firstName = valueDes;
-                    break;
-                case r'lastName':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.lastName = valueDes;
-                    break;
-                case r'email':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.email = valueDes;
-                    break;
-                case r'password':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.password = valueDes;
-                    break;
-                case r'phone':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(String)) as String;
-                    result.phone = valueDes;
-                    break;
-                case r'userStatus':
-                    final valueDes = serializers.deserialize(value,
-                        specifiedType: const FullType(int)) as int;
-                    result.userStatus = valueDes;
-                    break;
-            }
-        }
-        return result.build();
+    if (object.username != null) {
+      yield r'username';
+      yield serializers.serialize(
+        object.username,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.firstName != null) {
+      yield r'firstName';
+      yield serializers.serialize(
+        object.firstName,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.lastName != null) {
+      yield r'lastName';
+      yield serializers.serialize(
+        object.lastName,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.email != null) {
+      yield r'email';
+      yield serializers.serialize(
+        object.email,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.password != null) {
+      yield r'password';
+      yield serializers.serialize(
+        object.password,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.phone != null) {
+      yield r'phone';
+      yield serializers.serialize(
+        object.phone,
+        specifiedType: const FullType(String),
+      );
+    }
+    if (object.userStatus != null) {
+      yield r'userStatus';
+      yield serializers.serialize(
+        object.userStatus,
+        specifiedType: const FullType(int),
+      );
+    }
+  }
+
+  @override
+  Object serialize(
+    Serializers serializers,
+    User object, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
+  }
+
+  void _deserializeProperties(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+    required List<Object?> serializedList,
+    required UserBuilder result,
+    required List<Object?> unhandled,
+  }) {
+    for (var i = 0; i < serializedList.length; i += 2) {
+      final key = serializedList[i] as String;
+      final value = serializedList[i + 1];
+      switch (key) {
+        case r'id':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.id = valueDes;
+          break;
+        case r'username':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.username = valueDes;
+          break;
+        case r'firstName':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.firstName = valueDes;
+          break;
+        case r'lastName':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.lastName = valueDes;
+          break;
+        case r'email':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.email = valueDes;
+          break;
+        case r'password':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.password = valueDes;
+          break;
+        case r'phone':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(String),
+          ) as String;
+          result.phone = valueDes;
+          break;
+        case r'userStatus':
+          final valueDes = serializers.deserialize(
+            value,
+            specifiedType: const FullType(int),
+          ) as int;
+          result.userStatus = valueDes;
+          break;
+        default:
+          unhandled.add(key);
+          unhandled.add(value);
+          break;
+      }
     }
+  }
+
+  @override
+  User deserialize(
+    Serializers serializers,
+    Object serialized, {
+    FullType specifiedType = FullType.unspecified,
+  }) {
+    final result = UserBuilder();
+    final serializedList = (serialized as Iterable<Object?>).toList();
+    final unhandled = <Object?>[];
+    _deserializeProperties(
+      serializers,
+      serialized,
+      specifiedType: specifiedType,
+      serializedList: serializedList,
+      unhandled: unhandled,
+      result: result,
+    );
+    return result.build();
+  }
 }
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart
index 8ac0fc258f92d9b06a866ff70a49b4a5735357fd..60f50e5a77f732f12a27b78b9044118e43c9d2e7 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart
@@ -4,6 +4,8 @@
 
 // ignore_for_file: unused_import
 
+import 'package:one_of_serializer/any_of_serializer.dart';
+import 'package:one_of_serializer/one_of_serializer.dart';
 import 'package:built_collection/built_collection.dart';
 import 'package:built_value/json_object.dart';
 import 'package:built_value/serializer.dart';
@@ -66,19 +68,19 @@ part 'serializers.g.dart';
 @SerializersFor([
   AdditionalPropertiesClass,
   AllOfWithSingleRef,
-  Animal,
+  Animal,$Animal,
   ApiResponse,
   ArrayOfArrayOfNumberOnly,
   ArrayOfNumberOnly,
   ArrayTest,
   Capitalization,
   Cat,
-  CatAllOf,
+  CatAllOf,$CatAllOf,
   Category,
   ClassModel,
   DeprecatedObject,
   Dog,
-  DogAllOf,
+  DogAllOf,$DogAllOf,
   EnumArrays,
   EnumTest,
   FileSchemaTestClass,
@@ -146,6 +148,11 @@ Serializers serializers = (_$serializers.toBuilder()
         const FullType(BuiltList, [FullType(String)]),
         () => ListBuilder<String>(),
       )
+      ..add(Animal.serializer)
+      ..add(CatAllOf.serializer)
+      ..add(DogAllOf.serializer)
+      ..add(const OneOfSerializer())
+      ..add(const AnyOfSerializer())
       ..add(const DateSerializer())
       ..add(Iso8601DateTimeSerializer()))
     .build();
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/pubspec.yaml
index 5a3cc4e4df82a280c650796f07555fe48da9ba27..fb676f65c393c216466d443ec4060097085cd922 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/pubspec.yaml
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/pubspec.yaml
@@ -8,10 +8,12 @@ environment:
 
 dependencies:
   dio: '>=4.0.1 <5.0.0'
-  built_value: '>=8.1.0 <9.0.0'
-  built_collection: '>=5.1.0 <6.0.0'
+  one_of: '>=1.5.0 <2.0.0'
+  one_of_serializer: '>=1.5.0 <2.0.0'
+  built_value: '>=8.4.0 <9.0.0'
+  built_collection: '>=5.1.1 <6.0.0'
 
 dev_dependencies:
-  built_value_generator: '>=8.1.0 <9.0.0'
+  built_value_generator: '>=8.4.0 <9.0.0'
   build_runner: any
   test: ^1.16.0
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/all_of_with_single_ref_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/all_of_with_single_ref_test.dart
index 8fdb1603ce35edb36166184a8558f2cf804d6153..64e241a4dce371154ebb65d8f2772ddc77d31406 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/all_of_with_single_ref_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/all_of_with_single_ref_test.dart
@@ -12,7 +12,7 @@ void main() {
       // TODO
     });
 
-    // AllOfWithSingleRefSingleRefType singleRefType
+    // SingleRefType singleRefType
     test('to test the property `singleRefType`', () async {
       // TODO
     });
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/animal_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/animal_test.dart
index 875bb42a106a83f77bc15464a49aca3ddd9b658e..39b8b59cdf51b84c05e559aec37478ae3837b2fd 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/animal_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/animal_test.dart
@@ -3,7 +3,7 @@ import 'package:openapi/openapi.dart';
 
 // tests for Animal
 void main() {
-  final instance = AnimalBuilder();
+  //final instance = AnimalBuilder();
   // TODO add properties to the builder and call build()
 
   group(Animal, () {
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/cat_all_of_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/cat_all_of_test.dart
index afdac82ad1821734f5fe72a0be80991fc5c406ba..fb7e999bf8d1c32608e0fb412c97d3f898f8a571 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/cat_all_of_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/cat_all_of_test.dart
@@ -3,7 +3,7 @@ import 'package:openapi/openapi.dart';
 
 // tests for CatAllOf
 void main() {
-  final instance = CatAllOfBuilder();
+  //final instance = CatAllOfBuilder();
   // TODO add properties to the builder and call build()
 
   group(CatAllOf, () {
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/class_model_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/class_model_test.dart
index 92f95f186c917c75d490af7c614106d430c18d75..89f1d35e556b40c5d8db8d24c68091ec6fcafabc 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/class_model_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/class_model_test.dart
@@ -7,8 +7,8 @@ void main() {
   // TODO add properties to the builder and call build()
 
   group(ClassModel, () {
-    // String class_
-    test('to test the property `class_`', () async {
+    // String classField
+    test('to test the property `classField`', () async {
       // TODO
     });
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/default_api_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/default_api_test.dart
index eef4c41652eb52b66a937967adbe9230be6cd90e..f079565f9785105580f4b3a0008e261ec7a7e1f0 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/default_api_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/default_api_test.dart
@@ -7,7 +7,7 @@ void main() {
   final instance = Openapi().getDefaultApi();
 
   group(DefaultApi, () {
-    //Future<InlineResponseDefault> fooGet() async
+    //Future<FooGetDefaultResponse> fooGet() async
     test('test fooGet', () async {
       // TODO
     });
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/dog_all_of_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/dog_all_of_test.dart
index 7b58b3a27552d3d0566c59c7096732f19aa3e50d..7b4f4095dc9f75ac44b62c66c475528e7b9ef10c 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/dog_all_of_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/dog_all_of_test.dart
@@ -3,7 +3,7 @@ import 'package:openapi/openapi.dart';
 
 // tests for DogAllOf
 void main() {
-  final instance = DogAllOfBuilder();
+  //final instance = DogAllOfBuilder();
   // TODO add properties to the builder and call build()
 
   group(DogAllOf, () {
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model200_response_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model200_response_test.dart
index 39ff6ec59c0b926d5238cf7adaf8198e9f7d96d3..11bac07fafb8b170fb655735313e578746e73da5 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model200_response_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model200_response_test.dart
@@ -12,8 +12,8 @@ void main() {
       // TODO
     });
 
-    // String class_
-    test('to test the property `class_`', () async {
+    // String classField
+    test('to test the property `classField`', () async {
       // TODO
     });
 
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/user_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/user_test.dart
index d4555abccc59c12661242c774b4e0bbbafe4cd89..1e6a1bc23faa9d62cbdce7e90cebff5dc11f3ef0 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/user_test.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/user_test.dart
@@ -48,10 +48,5 @@ void main() {
       // TODO
     });
 
-    // UserType userType
-    test('to test the property `userType`', () async {
-      // TODO
-    });
-
   });
 }
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/pubspec.yaml
index 518f45b62eb0f7d0f14598010479a1888d1e2715..80178cb89a9998eaf07e34eb35a6751b7b7d1af4 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/pubspec.yaml
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/pubspec.yaml
@@ -8,8 +8,8 @@ environment:
   sdk: '>=2.10.0 <3.0.0'
 
 dev_dependencies:
-  built_collection: 5.1.0
-  built_value: 8.1.0
+  built_collection: 5.1.1
+  built_value: 8.4.0
   dio: 4.0.1
   http_mock_adapter: 0.3.2
   mockito: 5.0.11
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/puby.yaml b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/puby.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..64080c7e80a2dd320b5124010a1e9d8747dc1066
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/puby.yaml
@@ -0,0 +1,3 @@
+exclude:
+  - test
+  - pub run build_runner
\ No newline at end of file