From 9a007d9906abe69aa9ef3a9c82ba44d05c225130 Mon Sep 17 00:00:00 2001
From: Peter Leibiger <kuhnroyal@gmail.com>
Date: Wed, 24 Nov 2021 02:06:38 +0100
Subject: [PATCH 1/3] Add example allOf with single ref

* fix dart-dio-next handling of that case
---
 .../languages/AbstractDartCodegen.java        |  48 +++++
 .../main/resources/dart-dio/class.mustache    |   6 +
 .../serialization/built_value/class.mustache  |   7 +-
 ...ith-fake-endpoints-models-for-testing.yaml |   9 +
 .../OpenAPIClient/.openapi-generator/FILES    |   2 +
 .../petstore/csharp/OpenAPIClient/README.md   |   1 +
 .../csharp/OpenAPIClient/docs/User.md         |   1 +
 .../csharp/OpenAPIClient/docs/UserType.md     |  12 ++
 .../Model/UserTypeTests.cs                    |  71 +++++++
 .../src/Org.OpenAPITools/Model/User.cs        |  19 +-
 .../src/Org.OpenAPITools/Model/UserType.cs    |  49 +++++
 .../petstore/elixir/.openapi-generator/FILES  |   1 +
 .../elixir/lib/openapi_petstore/model/user.ex |  10 +-
 .../lib/openapi_petstore/model/user_type.ex   |  25 +++
 .../java/feign/.openapi-generator/FILES       |   1 +
 .../petstore/java/feign/api/openapi.yaml      |  10 +
 .../org/openapitools/client/model/User.java   |  63 ++++++-
 .../openapitools/client/model/UserType.java   |  59 ++++++
 .../client/model/UserTypeTest.java            |  31 +++
 .../java/webclient/.openapi-generator/FILES   |   2 +
 .../client/petstore/java/webclient/README.md  |   1 +
 .../petstore/java/webclient/api/openapi.yaml  |  10 +
 .../petstore/java/webclient/docs/User.md      |   4 +-
 .../petstore/java/webclient/docs/UserType.md  |  13 ++
 .../org/openapitools/client/model/User.java   |  63 ++++++-
 .../openapitools/client/model/UserType.java   |  59 ++++++
 .../client/model/UserTypeTest.java            |  33 ++++
 .../javascript-es6/.openapi-generator/FILES   |   2 +
 .../client/petstore/javascript-es6/README.md  |   1 +
 .../petstore/javascript-es6/docs/User.md      |   1 +
 .../petstore/javascript-es6/docs/UserType.md  |  10 +
 .../petstore/javascript-es6/src/index.js      |   7 +
 .../petstore/javascript-es6/src/model/User.js |   9 +
 .../javascript-es6/src/model/UserType.js      |  46 +++++
 .../test/model/UserType.spec.js               |  58 ++++++
 .../.openapi-generator/FILES                  |   2 +
 .../petstore/javascript-promise-es6/README.md |   1 +
 .../javascript-promise-es6/docs/User.md       |   1 +
 .../javascript-promise-es6/docs/UserType.md   |  10 +
 .../javascript-promise-es6/src/index.js       |   7 +
 .../javascript-promise-es6/src/model/User.js  |   9 +
 .../src/model/UserType.js                     |  46 +++++
 .../test/model/UserType.spec.js               |  58 ++++++
 .../petstore/perl/.openapi-generator/FILES    |   2 +
 samples/client/petstore/perl/README.md        |   3 +
 samples/client/petstore/perl/docs/User.md     |   1 +
 samples/client/petstore/perl/docs/UserType.md |  14 ++
 .../perl/lib/WWW/OpenAPIClient/Object/User.pm |  14 +-
 .../lib/WWW/OpenAPIClient/Object/UserType.pm  | 176 ++++++++++++++++++
 samples/client/petstore/perl/t/UserTypeTest.t |  34 ++++
 .../.openapi-generator/FILES                  |   2 +
 .../petstore/php/OpenAPIClient-php/README.md  |   1 +
 .../php/OpenAPIClient-php/docs/Model/User.md  |   1 +
 .../OpenAPIClient-php/docs/Model/UserType.md  |   8 +
 .../php/OpenAPIClient-php/lib/Model/User.php  |  40 +++-
 .../OpenAPIClient-php/lib/Model/UserType.php  |  62 ++++++
 .../test/Model/UserTypeTest.php               |  81 ++++++++
 .../ruby-faraday/.openapi-generator/FILES     |   2 +
 .../client/petstore/ruby-faraday/README.md    |   1 +
 .../client/petstore/ruby-faraday/docs/User.md |   4 +-
 .../petstore/ruby-faraday/docs/UserType.md    |  15 ++
 .../petstore/ruby-faraday/lib/petstore.rb     |   1 +
 .../ruby-faraday/lib/petstore/models/user.rb  |  18 +-
 .../lib/petstore/models/user_type.rb          |  37 ++++
 .../spec/models/user_type_spec.rb             |  28 +++
 .../petstore/ruby/.openapi-generator/FILES    |   2 +
 samples/client/petstore/ruby/README.md        |   1 +
 samples/client/petstore/ruby/docs/User.md     |   4 +-
 samples/client/petstore/ruby/docs/UserType.md |  15 ++
 samples/client/petstore/ruby/lib/petstore.rb  |   1 +
 .../petstore/ruby/lib/petstore/models/user.rb |  18 +-
 .../ruby/lib/petstore/models/user_type.rb     |  37 ++++
 .../ruby/spec/models/user_type_spec.rb        |  28 +++
 .../default-v3.0/.openapi-generator/FILES     |   1 +
 .../builds/default-v3.0/models/User.ts        |  15 ++
 .../builds/default-v3.0/models/UserType.ts    |  36 ++++
 .../builds/default-v3.0/models/index.ts       |   1 +
 .../doc/UserType.md                           |  14 ++
 .../lib/src/model/user_type.dart              |  33 ++++
 .../test/user_type_test.dart                  |   9 +
 .../.openapi-generator/FILES                  |   2 +
 .../petstore_client_lib_fake/README.md        |   1 +
 .../petstore_client_lib_fake/doc/User.md      |   1 +
 .../petstore_client_lib_fake/doc/UserType.md  |  14 ++
 .../petstore_client_lib_fake/lib/openapi.dart |   1 +
 .../lib/src/model/user.dart                   |  17 ++
 .../lib/src/model/user_type.dart              |  33 ++++
 .../lib/src/serializers.dart                  |   2 +
 .../test/user_type_test.dart                  |   9 +
 .../.openapi-generator/FILES                  |   2 +
 .../petstore_client_lib_fake/README.md        |   1 +
 .../petstore_client_lib_fake/doc/User.md      |   1 +
 .../petstore_client_lib_fake/doc/UserType.md  |  14 ++
 .../lib/model/user.dart                       |  15 ++
 .../lib/model/user_type.dart                  |  36 ++++
 .../lib/serializers.dart                      |   2 +
 .../test/user_type_test.dart                  |  18 ++
 .../.openapi-generator/FILES                  |   2 +
 .../dart2/petstore_client_lib_fake/README.md  |   1 +
 .../petstore_client_lib_fake/doc/User.md      |   1 +
 .../petstore_client_lib_fake/doc/UserType.md  |  14 ++
 .../petstore_client_lib_fake/lib/api.dart     |   1 +
 .../lib/api_client.dart                       |   2 +
 .../lib/api_helper.dart                       |   3 +
 .../lib/model/user.dart                       |  15 +-
 .../lib/model/user_type.dart                  |  78 ++++++++
 .../test/user_type_test.dart                  |  21 +++
 .../python-legacy/.openapi-generator/FILES    |   2 +
 .../client/petstore/python-legacy/README.md   |   1 +
 .../petstore/python-legacy/docs/User.md       |   1 +
 .../petstore/python-legacy/docs/UserType.md   |  10 +
 .../python-legacy/petstore_api/__init__.py    |   1 +
 .../petstore_api/models/__init__.py           |   1 +
 .../python-legacy/petstore_api/models/user.py |  31 ++-
 .../petstore_api/models/user_type.py          | 111 +++++++++++
 .../python-legacy/test/test_user_type.py      |  50 +++++
 .../petstore/mysql/.openapi-generator/FILES   |   1 +
 samples/schema/petstore/mysql/Model/User.sql  |   6 +-
 .../schema/petstore/mysql/Model/UserType.sql  |  26 +++
 .../schema/petstore/mysql/mysql_schema.sql    |   3 +-
 .../jaxrs-jersey/.openapi-generator/FILES     |   1 +
 .../gen/java/org/openapitools/model/User.java |  34 +++-
 .../java/org/openapitools/model/UserType.java |  60 ++++++
 .../php-laravel/.openapi-generator/FILES      |   1 +
 .../php-laravel/lib/app/Models/User.php       |   3 +
 .../php-laravel/lib/app/Models/UserType.php   |  12 ++
 126 files changed, 2256 insertions(+), 44 deletions(-)
 create mode 100644 samples/client/petstore/csharp/OpenAPIClient/docs/UserType.md
 create mode 100644 samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/UserTypeTests.cs
 create mode 100644 samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/UserType.cs
 create mode 100644 samples/client/petstore/elixir/lib/openapi_petstore/model/user_type.ex
 create mode 100644 samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/UserType.java
 create mode 100644 samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/UserTypeTest.java
 create mode 100644 samples/client/petstore/java/webclient/docs/UserType.md
 create mode 100644 samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/UserType.java
 create mode 100644 samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/UserTypeTest.java
 create mode 100644 samples/client/petstore/javascript-es6/docs/UserType.md
 create mode 100644 samples/client/petstore/javascript-es6/src/model/UserType.js
 create mode 100644 samples/client/petstore/javascript-es6/test/model/UserType.spec.js
 create mode 100644 samples/client/petstore/javascript-promise-es6/docs/UserType.md
 create mode 100644 samples/client/petstore/javascript-promise-es6/src/model/UserType.js
 create mode 100644 samples/client/petstore/javascript-promise-es6/test/model/UserType.spec.js
 create mode 100644 samples/client/petstore/perl/docs/UserType.md
 create mode 100644 samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/UserType.pm
 create mode 100644 samples/client/petstore/perl/t/UserTypeTest.t
 create mode 100644 samples/client/petstore/php/OpenAPIClient-php/docs/Model/UserType.md
 create mode 100644 samples/client/petstore/php/OpenAPIClient-php/lib/Model/UserType.php
 create mode 100644 samples/client/petstore/php/OpenAPIClient-php/test/Model/UserTypeTest.php
 create mode 100644 samples/client/petstore/ruby-faraday/docs/UserType.md
 create mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/user_type.rb
 create mode 100644 samples/client/petstore/ruby-faraday/spec/models/user_type_spec.rb
 create mode 100644 samples/client/petstore/ruby/docs/UserType.md
 create mode 100644 samples/client/petstore/ruby/lib/petstore/models/user_type.rb
 create mode 100644 samples/client/petstore/ruby/spec/models/user_type_spec.rb
 create mode 100644 samples/client/petstore/typescript-fetch/builds/default-v3.0/models/UserType.ts
 create mode 100644 samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/doc/UserType.md
 create mode 100644 samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/lib/src/model/user_type.dart
 create mode 100644 samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/test/user_type_test.dart
 create mode 100644 samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/UserType.md
 create mode 100644 samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user_type.dart
 create mode 100644 samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/test/user_type_test.dart
 create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/UserType.md
 create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/user_type.dart
 create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/user_type_test.dart
 create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/UserType.md
 create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user_type.dart
 create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/user_type_test.dart
 create mode 100644 samples/openapi3/client/petstore/python-legacy/docs/UserType.md
 create mode 100644 samples/openapi3/client/petstore/python-legacy/petstore_api/models/user_type.py
 create mode 100644 samples/openapi3/client/petstore/python-legacy/test/test_user_type.py
 create mode 100644 samples/schema/petstore/mysql/Model/UserType.sql
 create mode 100644 samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/UserType.java
 create mode 100644 samples/server/petstore/php-laravel/lib/app/Models/UserType.php

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
index f1156613106..edace2dee8b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
@@ -3,6 +3,7 @@ package org.openapitools.codegen.languages;
 import com.google.common.collect.Sets;
 import io.swagger.v3.oas.models.Operation;
 import io.swagger.v3.oas.models.media.ArraySchema;
+import io.swagger.v3.oas.models.media.ComposedSchema;
 import io.swagger.v3.oas.models.media.Schema;
 import io.swagger.v3.oas.models.media.StringSchema;
 import io.swagger.v3.oas.models.servers.Server;
@@ -24,6 +25,7 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 import java.util.*;
+import java.util.stream.Stream;
 
 import static org.openapitools.codegen.utils.StringUtils.*;
 
@@ -532,6 +534,28 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
         }
     }
 
+    @Override
+    public CodegenProperty fromProperty(String name, Schema p) {
+        final CodegenProperty property = super.fromProperty(name, p);
+        if (ModelUtils.isComposedSchema(p)) {
+            ComposedSchema composed = (ComposedSchema) p;
+
+            Stream.of(composed.getAllOf(), composed.getAnyOf(), composed.getOneOf())
+                    .filter(list -> list != null && !list.isEmpty())
+                    .map(list -> list.get(0).get$ref())
+                    .map(ModelUtils::getSimpleRef)
+                    .filter(Objects::nonNull)
+                    .map(ref -> ModelUtils.getSchemas(this.openAPI).get(ref))
+                    .filter(Objects::nonNull)
+                    .findFirst().ifPresent(schema -> {
+                        property.vendorExtensions.put("x-composed-single-schema", new ComposedSingleSchema(
+                                property, schema.getEnum() != null, ModelUtils.isModel(schema)
+                        ));
+                    });
+        }
+        return property;
+    }
+
     @Override
     public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
         final CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
@@ -779,3 +803,27 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
     @Override
     public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.DART; }
 }
+
+class ComposedSingleSchema {
+    final CodegenProperty property;
+    final boolean isEnum;
+    final boolean isModel;
+
+    ComposedSingleSchema(CodegenProperty property, boolean isEnum, boolean isModel) {
+        this.property = property;
+        this.isEnum = isEnum;
+        this.isModel = isModel;
+    }
+
+    public CodegenProperty getProperty() {
+        return property;
+    }
+
+    public boolean isEnum() {
+        return isEnum;
+    }
+
+    public boolean isModel() {
+        return isModel;
+    }
+}
diff --git a/modules/openapi-generator/src/main/resources/dart-dio/class.mustache b/modules/openapi-generator/src/main/resources/dart-dio/class.mustache
index f4d2c1e4e76..1c1f8fe0543 100644
--- a/modules/openapi-generator/src/main/resources/dart-dio/class.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-dio/class.mustache
@@ -98,8 +98,14 @@ class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
                         specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}});
                     {{/isContainer}}
                     {{#isModel}}
+                    {{#vendorExtensions.x-composed-single-schema.isEnum}}
+                    result.{{{name}}} = serializers.deserialize(value,
+                        specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}};
+                    {{/vendorExtensions.x-composed-single-schema.isEnum}}
+                    {{^vendorExtensions.x-composed-single-schema}}
                     result.{{{name}}}.replace(serializers.deserialize(value,
                         specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}});
+                    {{/vendorExtensions.x-composed-single-schema}}
                     {{/isModel}}
                     {{^isContainer}}
                     {{^isModel}}
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 b144bd50495..303ee3cab87 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
@@ -106,11 +106,16 @@ class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
                     {{/isContainer}}
                     {{#isModel}}
                     {{#isPrimitiveType}}
-                    {{! These are models that have nee manually marked as primitive via generator param. }}
+                    {{! These are models that have been manually marked as primitive via generator param. }}
                     result.{{{name}}} = valueDes;
                     {{/isPrimitiveType}}
                     {{^isPrimitiveType}}
+                    {{#vendorExtensions.x-composed-single-schema.isEnum}}
+                    result.{{{name}}} = valueDes;
+                    {{/vendorExtensions.x-composed-single-schema.isEnum}}
+                    {{^vendorExtensions.x-composed-single-schema}}
                     result.{{{name}}}.replace(valueDes);
+                    {{/vendorExtensions.x-composed-single-schema}}
                     {{/isPrimitiveType}}
                     {{/isModel}}
                     {{^isContainer}}
diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
index cedc9950468..fbc2f4a210f 100644
--- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
@@ -1341,8 +1341,17 @@ components:
           type: integer
           format: int32
           description: User Status
+        userType:
+          allOf:
+            - $ref: '#/components/schemas/UserType'
       xml:
         name: User
+    UserType:
+      type: string
+      title: UserType
+      enum:
+        - admin
+        - user
     Tag:
       type: object
       properties:
diff --git a/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES
index 3ed897cd208..23c6a38779b 100644
--- a/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES
+++ b/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES
@@ -57,6 +57,7 @@ docs/StoreApi.md
 docs/Tag.md
 docs/User.md
 docs/UserApi.md
+docs/UserType.md
 git_push.sh
 mono_nunit_test.sh
 src/Org.OpenAPITools.Test/packages.config
@@ -122,6 +123,7 @@ src/Org.OpenAPITools/Model/Return.cs
 src/Org.OpenAPITools/Model/SpecialModelName.cs
 src/Org.OpenAPITools/Model/Tag.cs
 src/Org.OpenAPITools/Model/User.cs
+src/Org.OpenAPITools/Model/UserType.cs
 src/Org.OpenAPITools/Org.OpenAPITools.csproj
 src/Org.OpenAPITools/Org.OpenAPITools.nuspec
 src/Org.OpenAPITools/Properties/AssemblyInfo.cs
diff --git a/samples/client/petstore/csharp/OpenAPIClient/README.md b/samples/client/petstore/csharp/OpenAPIClient/README.md
index 56990e9348f..209543618c3 100644
--- a/samples/client/petstore/csharp/OpenAPIClient/README.md
+++ b/samples/client/petstore/csharp/OpenAPIClient/README.md
@@ -196,6 +196,7 @@ Class | Method | HTTP request | Description
  - [Model.SpecialModelName](docs/SpecialModelName.md)
  - [Model.Tag](docs/Tag.md)
  - [Model.User](docs/User.md)
+ - [Model.UserType](docs/UserType.md)
 
 
 ## Documentation for Authorization
diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/User.md b/samples/client/petstore/csharp/OpenAPIClient/docs/User.md
index a25c25d1aa0..f8d740c5a22 100644
--- a/samples/client/petstore/csharp/OpenAPIClient/docs/User.md
+++ b/samples/client/petstore/csharp/OpenAPIClient/docs/User.md
@@ -13,6 +13,7 @@ Name | Type | Description | Notes
 **Password** | **string** |  | [optional] 
 **Phone** | **string** |  | [optional] 
 **UserStatus** | **int** | User Status | [optional] 
+**UserType** | **UserType** |  | [optional] 
 
 [[Back to Model list]](../README.md#documentation-for-models)
 [[Back to API list]](../README.md#documentation-for-api-endpoints)
diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/UserType.md b/samples/client/petstore/csharp/OpenAPIClient/docs/UserType.md
new file mode 100644
index 00000000000..e52d5173dd0
--- /dev/null
+++ b/samples/client/petstore/csharp/OpenAPIClient/docs/UserType.md
@@ -0,0 +1,12 @@
+
+# Org.OpenAPITools.Model.UserType
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+[[Back to Model list]](../README.md#documentation-for-models)
+[[Back to API list]](../README.md#documentation-for-api-endpoints)
+[[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/UserTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/UserTypeTests.cs
new file mode 100644
index 00000000000..241b380b977
--- /dev/null
+++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/UserTypeTests.cs
@@ -0,0 +1,71 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using NUnit.Framework;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using Org.OpenAPITools.Api;
+using Org.OpenAPITools.Model;
+using Org.OpenAPITools.Client;
+using System.Reflection;
+using Newtonsoft.Json;
+
+namespace Org.OpenAPITools.Test
+{
+    /// <summary>
+    ///  Class for testing UserType
+    /// </summary>
+    /// <remarks>
+    /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
+    /// Please update the test case below to test the model.
+    /// </remarks>
+    public class UserTypeTests
+    {
+        // TODO uncomment below to declare an instance variable for UserType
+        //private UserType instance;
+
+        /// <summary>
+        /// Setup before each test
+        /// </summary>
+        [SetUp]
+        public void Init()
+        {
+            // TODO uncomment below to create an instance of UserType
+            //instance = new UserType();
+        }
+
+        /// <summary>
+        /// Clean up after each test
+        /// </summary>
+        [TearDown]
+        public void Cleanup()
+        {
+
+        }
+
+        /// <summary>
+        /// Test an instance of UserType
+        /// </summary>
+        [Test]
+        public void UserTypeInstanceTest()
+        {
+            // TODO uncomment below to test "IsInstanceOf" UserType
+            //Assert.IsInstanceOf(typeof(UserType), instance);
+        }
+
+
+
+    }
+
+}
diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/User.cs
index 913098aaab6..9c38bd48869 100644
--- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/User.cs
@@ -30,6 +30,11 @@ namespace Org.OpenAPITools.Model
     [DataContract]
     public partial class User :  IEquatable<User>, IValidatableObject
     {
+        /// <summary>
+        /// Gets or Sets UserType
+        /// </summary>
+        [DataMember(Name="userType", EmitDefaultValue=true)]
+        public UserType? UserType { get; set; }
         /// <summary>
         /// Initializes a new instance of the <see cref="User" /> class.
         /// </summary>
@@ -41,8 +46,10 @@ namespace Org.OpenAPITools.Model
         /// <param name="password">password.</param>
         /// <param name="phone">phone.</param>
         /// <param name="userStatus">User Status.</param>
-        public User(long id = default(long), string username = default(string), string firstName = default(string), string lastName = default(string), string email = default(string), string password = default(string), string phone = default(string), int userStatus = default(int))
+        /// <param name="userType">userType.</param>
+        public User(long id = default(long), string username = default(string), string firstName = default(string), string lastName = default(string), string email = default(string), string password = default(string), string phone = default(string), int userStatus = default(int), UserType? userType = default(UserType?))
         {
+            this.UserType = userType;
             this.Id = id;
             this.Username = username;
             this.FirstName = firstName;
@@ -51,6 +58,7 @@ namespace Org.OpenAPITools.Model
             this.Password = password;
             this.Phone = phone;
             this.UserStatus = userStatus;
+            this.UserType = userType;
         }
 
         /// <summary>
@@ -102,6 +110,7 @@ namespace Org.OpenAPITools.Model
         [DataMember(Name="userStatus", EmitDefaultValue=false)]
         public int UserStatus { get; set; }
 
+
         /// <summary>
         /// Returns the string presentation of the object
         /// </summary>
@@ -118,6 +127,7 @@ namespace Org.OpenAPITools.Model
             sb.Append("  Password: ").Append(Password).Append("\n");
             sb.Append("  Phone: ").Append(Phone).Append("\n");
             sb.Append("  UserStatus: ").Append(UserStatus).Append("\n");
+            sb.Append("  UserType: ").Append(UserType).Append("\n");
             sb.Append("}\n");
             return sb.ToString();
         }
@@ -191,6 +201,11 @@ namespace Org.OpenAPITools.Model
                     this.UserStatus == input.UserStatus ||
                     (this.UserStatus != null &&
                     this.UserStatus.Equals(input.UserStatus))
+                ) && 
+                (
+                    this.UserType == input.UserType ||
+                    (this.UserType != null &&
+                    this.UserType.Equals(input.UserType))
                 );
         }
 
@@ -219,6 +234,8 @@ namespace Org.OpenAPITools.Model
                     hashCode = hashCode * 59 + this.Phone.GetHashCode();
                 if (this.UserStatus != null)
                     hashCode = hashCode * 59 + this.UserStatus.GetHashCode();
+                if (this.UserType != null)
+                    hashCode = hashCode * 59 + this.UserType.GetHashCode();
                 return hashCode;
             }
         }
diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/UserType.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/UserType.cs
new file mode 100644
index 00000000000..1b2e2134a39
--- /dev/null
+++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/UserType.cs
@@ -0,0 +1,49 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System.ComponentModel.DataAnnotations;
+using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter;
+
+namespace Org.OpenAPITools.Model
+{
+    /// <summary>
+    /// Defines UserType
+    /// </summary>
+    
+    [JsonConverter(typeof(StringEnumConverter))]
+    
+    public enum UserType
+    {
+        /// <summary>
+        /// Enum Admin for value: admin
+        /// </summary>
+        [EnumMember(Value = "admin")]
+        Admin = 1,
+
+        /// <summary>
+        /// Enum User for value: user
+        /// </summary>
+        [EnumMember(Value = "user")]
+        User = 2
+
+    }
+
+}
diff --git a/samples/client/petstore/elixir/.openapi-generator/FILES b/samples/client/petstore/elixir/.openapi-generator/FILES
index aa063a4af9e..f9380afb3bd 100644
--- a/samples/client/petstore/elixir/.openapi-generator/FILES
+++ b/samples/client/petstore/elixir/.openapi-generator/FILES
@@ -56,6 +56,7 @@ lib/openapi_petstore/model/read_only_first.ex
 lib/openapi_petstore/model/return.ex
 lib/openapi_petstore/model/tag.ex
 lib/openapi_petstore/model/user.ex
+lib/openapi_petstore/model/user_type.ex
 lib/openapi_petstore/request_builder.ex
 mix.exs
 test/test_helper.exs
diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex
index faaf4ab9a96..99c153ee05c 100644
--- a/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex
+++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex
@@ -16,7 +16,8 @@ defmodule OpenapiPetstore.Model.User do
     :"email",
     :"password",
     :"phone",
-    :"userStatus"
+    :"userStatus",
+    :"userType"
   ]
 
   @type t :: %__MODULE__{
@@ -27,13 +28,16 @@ defmodule OpenapiPetstore.Model.User do
     :"email" => String.t | nil,
     :"password" => String.t | nil,
     :"phone" => String.t | nil,
-    :"userStatus" => integer() | nil
+    :"userStatus" => integer() | nil,
+    :"userType" => UserType | nil
   }
 end
 
 defimpl Poison.Decoder, for: OpenapiPetstore.Model.User do
-  def decode(value, _options) do
+  import OpenapiPetstore.Deserializer
+  def decode(value, options) do
     value
+    |> deserialize(:"userType", :struct, OpenapiPetstore.Model.UserType, options)
   end
 end
 
diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/user_type.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/user_type.ex
new file mode 100644
index 00000000000..77e685e21fc
--- /dev/null
+++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/user_type.ex
@@ -0,0 +1,25 @@
+# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+# https://openapi-generator.tech
+# Do not edit the class manually.
+
+defmodule OpenapiPetstore.Model.UserType do
+  @moduledoc """
+  
+  """
+
+  @derive [Poison.Encoder]
+  defstruct [
+    
+  ]
+
+  @type t :: %__MODULE__{
+    
+  }
+end
+
+defimpl Poison.Decoder, for: OpenapiPetstore.Model.UserType do
+  def decode(value, _options) do
+    value
+  end
+end
+
diff --git a/samples/client/petstore/java/feign/.openapi-generator/FILES b/samples/client/petstore/java/feign/.openapi-generator/FILES
index 72c610ee918..9721c7e7a2f 100644
--- a/samples/client/petstore/java/feign/.openapi-generator/FILES
+++ b/samples/client/petstore/java/feign/.openapi-generator/FILES
@@ -85,3 +85,4 @@ src/main/java/org/openapitools/client/model/ReadOnlyFirst.java
 src/main/java/org/openapitools/client/model/SpecialModelName.java
 src/main/java/org/openapitools/client/model/Tag.java
 src/main/java/org/openapitools/client/model/User.java
+src/main/java/org/openapitools/client/model/UserType.java
diff --git a/samples/client/petstore/java/feign/api/openapi.yaml b/samples/client/petstore/java/feign/api/openapi.yaml
index 9e4b59c52b9..80dd57f768d 100644
--- a/samples/client/petstore/java/feign/api/openapi.yaml
+++ b/samples/client/petstore/java/feign/api/openapi.yaml
@@ -1482,6 +1482,7 @@ components:
         userStatus: 6
         phone: phone
         id: 0
+        userType: ""
         email: email
         username: username
       properties:
@@ -1505,9 +1506,18 @@ components:
           description: User Status
           format: int32
           type: integer
+        userType:
+          allOf:
+          - $ref: '#/components/schemas/UserType'
       type: object
       xml:
         name: User
+    UserType:
+      enum:
+      - admin
+      - user
+      title: UserType
+      type: string
     Tag:
       example:
         name: name
diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/User.java
index a289c89f5e6..31914847dc4 100644
--- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/User.java
+++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/User.java
@@ -22,6 +22,11 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
 import com.fasterxml.jackson.annotation.JsonValue;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import org.openapitools.client.model.UserType;
+import org.openapitools.jackson.nullable.JsonNullable;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openapitools.jackson.nullable.JsonNullable;
+import java.util.NoSuchElementException;
 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
 import com.fasterxml.jackson.annotation.JsonTypeName;
 
@@ -36,7 +41,8 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
   User.JSON_PROPERTY_EMAIL,
   User.JSON_PROPERTY_PASSWORD,
   User.JSON_PROPERTY_PHONE,
-  User.JSON_PROPERTY_USER_STATUS
+  User.JSON_PROPERTY_USER_STATUS,
+  User.JSON_PROPERTY_USER_TYPE
 })
 @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
 public class User {
@@ -64,6 +70,9 @@ public class User {
   public static final String JSON_PROPERTY_USER_STATUS = "userStatus";
   private Integer userStatus;
 
+  public static final String JSON_PROPERTY_USER_TYPE = "userType";
+  private JsonNullable<UserType> userType = JsonNullable.<UserType>undefined();
+
   public User() { 
   }
 
@@ -283,6 +292,41 @@ public class User {
   }
 
 
+  public User userType(UserType userType) {
+    this.userType = JsonNullable.<UserType>of(userType);
+    
+    return this;
+  }
+
+   /**
+   * Get userType
+   * @return userType
+  **/
+  @javax.annotation.Nullable
+  @ApiModelProperty(value = "")
+  @JsonIgnore
+
+  public UserType getUserType() {
+        return userType.orElse(null);
+  }
+
+  @JsonProperty(JSON_PROPERTY_USER_TYPE)
+  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+  public JsonNullable<UserType> getUserType_JsonNullable() {
+    return userType;
+  }
+  
+  @JsonProperty(JSON_PROPERTY_USER_TYPE)
+  public void setUserType_JsonNullable(JsonNullable<UserType> userType) {
+    this.userType = userType;
+  }
+
+  public void setUserType(UserType userType) {
+    this.userType = JsonNullable.<UserType>of(userType);
+  }
+
+
   @Override
   public boolean equals(Object o) {
     if (this == o) {
@@ -299,12 +343,24 @@ public class User {
         Objects.equals(this.email, user.email) &&
         Objects.equals(this.password, user.password) &&
         Objects.equals(this.phone, user.phone) &&
-        Objects.equals(this.userStatus, user.userStatus);
+        Objects.equals(this.userStatus, user.userStatus) &&
+        equalsNullable(this.userType, user.userType);
+  }
+
+  private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
+    return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
   }
 
   @Override
   public int hashCode() {
-    return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
+    return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus, hashCodeNullable(userType));
+  }
+
+  private static <T> int hashCodeNullable(JsonNullable<T> a) {
+    if (a == null) {
+      return 1;
+    }
+    return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
   }
 
   @Override
@@ -319,6 +375,7 @@ public class User {
     sb.append("    password: ").append(toIndentedString(password)).append("\n");
     sb.append("    phone: ").append(toIndentedString(phone)).append("\n");
     sb.append("    userStatus: ").append(toIndentedString(userStatus)).append("\n");
+    sb.append("    userType: ").append(toIndentedString(userType)).append("\n");
     sb.append("}");
     return sb.toString();
   }
diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/UserType.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/UserType.java
new file mode 100644
index 00000000000..cac7287734d
--- /dev/null
+++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/UserType.java
@@ -0,0 +1,59 @@
+/*
+ * OpenAPI Petstore
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import java.util.Objects;
+import java.util.Arrays;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * Gets or Sets UserType
+ */
+public enum UserType {
+  
+  ADMIN("admin"),
+  
+  USER("user");
+
+  private String value;
+
+  UserType(String value) {
+    this.value = value;
+  }
+
+  @JsonValue
+  public String getValue() {
+    return value;
+  }
+
+  @Override
+  public String toString() {
+    return String.valueOf(value);
+  }
+
+  @JsonCreator
+  public static UserType fromValue(String value) {
+    for (UserType b : UserType.values()) {
+      if (b.value.equals(value)) {
+        return b;
+      }
+    }
+    throw new IllegalArgumentException("Unexpected value '" + value + "'");
+  }
+}
+
diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/UserTypeTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/UserTypeTest.java
new file mode 100644
index 00000000000..ceabbca0f7f
--- /dev/null
+++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/UserTypeTest.java
@@ -0,0 +1,31 @@
+/*
+ * OpenAPI Petstore
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import org.junit.jupiter.api.Test;
+
+
+/**
+ * Model tests for UserType
+ */
+class UserTypeTest {
+    /**
+     * Model tests for UserType
+     */
+    @Test
+    void testUserType() {
+        // TODO: test UserType
+    }
+
+}
diff --git a/samples/client/petstore/java/webclient/.openapi-generator/FILES b/samples/client/petstore/java/webclient/.openapi-generator/FILES
index 4e0bb18ff08..991c61333a0 100644
--- a/samples/client/petstore/java/webclient/.openapi-generator/FILES
+++ b/samples/client/petstore/java/webclient/.openapi-generator/FILES
@@ -58,6 +58,7 @@ docs/StoreApi.md
 docs/Tag.md
 docs/User.md
 docs/UserApi.md
+docs/UserType.md
 git_push.sh
 gradle.properties
 gradle/wrapper/gradle-wrapper.jar
@@ -132,3 +133,4 @@ src/main/java/org/openapitools/client/model/ReadOnlyFirst.java
 src/main/java/org/openapitools/client/model/SpecialModelName.java
 src/main/java/org/openapitools/client/model/Tag.java
 src/main/java/org/openapitools/client/model/User.java
+src/main/java/org/openapitools/client/model/UserType.java
diff --git a/samples/client/petstore/java/webclient/README.md b/samples/client/petstore/java/webclient/README.md
index 1204655c39c..735c94ed99d 100644
--- a/samples/client/petstore/java/webclient/README.md
+++ b/samples/client/petstore/java/webclient/README.md
@@ -204,6 +204,7 @@ Class | Method | HTTP request | Description
  - [SpecialModelName](docs/SpecialModelName.md)
  - [Tag](docs/Tag.md)
  - [User](docs/User.md)
+ - [UserType](docs/UserType.md)
 
 
 ## Documentation for Authorization
diff --git a/samples/client/petstore/java/webclient/api/openapi.yaml b/samples/client/petstore/java/webclient/api/openapi.yaml
index 9e4b59c52b9..80dd57f768d 100644
--- a/samples/client/petstore/java/webclient/api/openapi.yaml
+++ b/samples/client/petstore/java/webclient/api/openapi.yaml
@@ -1482,6 +1482,7 @@ components:
         userStatus: 6
         phone: phone
         id: 0
+        userType: ""
         email: email
         username: username
       properties:
@@ -1505,9 +1506,18 @@ components:
           description: User Status
           format: int32
           type: integer
+        userType:
+          allOf:
+          - $ref: '#/components/schemas/UserType'
       type: object
       xml:
         name: User
+    UserType:
+      enum:
+      - admin
+      - user
+      title: UserType
+      type: string
     Tag:
       example:
         name: name
diff --git a/samples/client/petstore/java/webclient/docs/User.md b/samples/client/petstore/java/webclient/docs/User.md
index 08813e4b10b..339c6021330 100644
--- a/samples/client/petstore/java/webclient/docs/User.md
+++ b/samples/client/petstore/java/webclient/docs/User.md
@@ -15,6 +15,4 @@
 |**password** | **String** |  |  [optional] |
 |**phone** | **String** |  |  [optional] |
 |**userStatus** | **Integer** | User Status |  [optional] |
-
-
-
+**userType** | [**UserType**](UserType.md) |  |  [optional] |
diff --git a/samples/client/petstore/java/webclient/docs/UserType.md b/samples/client/petstore/java/webclient/docs/UserType.md
new file mode 100644
index 00000000000..dc9afc65235
--- /dev/null
+++ b/samples/client/petstore/java/webclient/docs/UserType.md
@@ -0,0 +1,13 @@
+
+
+# UserType
+
+## Enum
+
+
+* `ADMIN` (value: `"admin"`)
+
+* `USER` (value: `"user"`)
+
+
+
diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/User.java
index a289c89f5e6..31914847dc4 100644
--- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/User.java
+++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/User.java
@@ -22,6 +22,11 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
 import com.fasterxml.jackson.annotation.JsonValue;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import org.openapitools.client.model.UserType;
+import org.openapitools.jackson.nullable.JsonNullable;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openapitools.jackson.nullable.JsonNullable;
+import java.util.NoSuchElementException;
 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
 import com.fasterxml.jackson.annotation.JsonTypeName;
 
@@ -36,7 +41,8 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
   User.JSON_PROPERTY_EMAIL,
   User.JSON_PROPERTY_PASSWORD,
   User.JSON_PROPERTY_PHONE,
-  User.JSON_PROPERTY_USER_STATUS
+  User.JSON_PROPERTY_USER_STATUS,
+  User.JSON_PROPERTY_USER_TYPE
 })
 @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
 public class User {
@@ -64,6 +70,9 @@ public class User {
   public static final String JSON_PROPERTY_USER_STATUS = "userStatus";
   private Integer userStatus;
 
+  public static final String JSON_PROPERTY_USER_TYPE = "userType";
+  private JsonNullable<UserType> userType = JsonNullable.<UserType>undefined();
+
   public User() { 
   }
 
@@ -283,6 +292,41 @@ public class User {
   }
 
 
+  public User userType(UserType userType) {
+    this.userType = JsonNullable.<UserType>of(userType);
+    
+    return this;
+  }
+
+   /**
+   * Get userType
+   * @return userType
+  **/
+  @javax.annotation.Nullable
+  @ApiModelProperty(value = "")
+  @JsonIgnore
+
+  public UserType getUserType() {
+        return userType.orElse(null);
+  }
+
+  @JsonProperty(JSON_PROPERTY_USER_TYPE)
+  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+  public JsonNullable<UserType> getUserType_JsonNullable() {
+    return userType;
+  }
+  
+  @JsonProperty(JSON_PROPERTY_USER_TYPE)
+  public void setUserType_JsonNullable(JsonNullable<UserType> userType) {
+    this.userType = userType;
+  }
+
+  public void setUserType(UserType userType) {
+    this.userType = JsonNullable.<UserType>of(userType);
+  }
+
+
   @Override
   public boolean equals(Object o) {
     if (this == o) {
@@ -299,12 +343,24 @@ public class User {
         Objects.equals(this.email, user.email) &&
         Objects.equals(this.password, user.password) &&
         Objects.equals(this.phone, user.phone) &&
-        Objects.equals(this.userStatus, user.userStatus);
+        Objects.equals(this.userStatus, user.userStatus) &&
+        equalsNullable(this.userType, user.userType);
+  }
+
+  private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
+    return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
   }
 
   @Override
   public int hashCode() {
-    return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
+    return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus, hashCodeNullable(userType));
+  }
+
+  private static <T> int hashCodeNullable(JsonNullable<T> a) {
+    if (a == null) {
+      return 1;
+    }
+    return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
   }
 
   @Override
@@ -319,6 +375,7 @@ public class User {
     sb.append("    password: ").append(toIndentedString(password)).append("\n");
     sb.append("    phone: ").append(toIndentedString(phone)).append("\n");
     sb.append("    userStatus: ").append(toIndentedString(userStatus)).append("\n");
+    sb.append("    userType: ").append(toIndentedString(userType)).append("\n");
     sb.append("}");
     return sb.toString();
   }
diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/UserType.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/UserType.java
new file mode 100644
index 00000000000..cac7287734d
--- /dev/null
+++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/UserType.java
@@ -0,0 +1,59 @@
+/*
+ * OpenAPI Petstore
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import java.util.Objects;
+import java.util.Arrays;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * Gets or Sets UserType
+ */
+public enum UserType {
+  
+  ADMIN("admin"),
+  
+  USER("user");
+
+  private String value;
+
+  UserType(String value) {
+    this.value = value;
+  }
+
+  @JsonValue
+  public String getValue() {
+    return value;
+  }
+
+  @Override
+  public String toString() {
+    return String.valueOf(value);
+  }
+
+  @JsonCreator
+  public static UserType fromValue(String value) {
+    for (UserType b : UserType.values()) {
+      if (b.value.equals(value)) {
+        return b;
+      }
+    }
+    throw new IllegalArgumentException("Unexpected value '" + value + "'");
+  }
+}
+
diff --git a/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/UserTypeTest.java b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/UserTypeTest.java
new file mode 100644
index 00000000000..ed8242c1b98
--- /dev/null
+++ b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/UserTypeTest.java
@@ -0,0 +1,33 @@
+/*
+ * OpenAPI Petstore
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Model tests for UserType
+ */
+public class UserTypeTest {
+    /**
+     * Model tests for UserType
+     */
+    @Test
+    public void testUserType() {
+        // TODO: test UserType
+    }
+
+}
diff --git a/samples/client/petstore/javascript-es6/.openapi-generator/FILES b/samples/client/petstore/javascript-es6/.openapi-generator/FILES
index 3e7946d76cc..e4b39f7eb90 100644
--- a/samples/client/petstore/javascript-es6/.openapi-generator/FILES
+++ b/samples/client/petstore/javascript-es6/.openapi-generator/FILES
@@ -55,6 +55,7 @@ docs/StoreApi.md
 docs/Tag.md
 docs/User.md
 docs/UserApi.md
+docs/UserType.md
 git_push.sh
 mocha.opts
 package.json
@@ -113,3 +114,4 @@ src/model/Return.js
 src/model/SpecialModelName.js
 src/model/Tag.js
 src/model/User.js
+src/model/UserType.js
diff --git a/samples/client/petstore/javascript-es6/README.md b/samples/client/petstore/javascript-es6/README.md
index 3cf92f17276..ac841e26701 100644
--- a/samples/client/petstore/javascript-es6/README.md
+++ b/samples/client/petstore/javascript-es6/README.md
@@ -211,6 +211,7 @@ Class | Method | HTTP request | Description
  - [OpenApiPetstore.SpecialModelName](docs/SpecialModelName.md)
  - [OpenApiPetstore.Tag](docs/Tag.md)
  - [OpenApiPetstore.User](docs/User.md)
+ - [OpenApiPetstore.UserType](docs/UserType.md)
 
 
 ## Documentation for Authorization
diff --git a/samples/client/petstore/javascript-es6/docs/User.md b/samples/client/petstore/javascript-es6/docs/User.md
index 096f606d0b9..ebcba777dbe 100644
--- a/samples/client/petstore/javascript-es6/docs/User.md
+++ b/samples/client/petstore/javascript-es6/docs/User.md
@@ -12,5 +12,6 @@ Name | Type | Description | Notes
 **password** | **String** |  | [optional] 
 **phone** | **String** |  | [optional] 
 **userStatus** | **Number** | User Status | [optional] 
+**userType** | [**UserType**](UserType.md) |  | [optional] 
 
 
diff --git a/samples/client/petstore/javascript-es6/docs/UserType.md b/samples/client/petstore/javascript-es6/docs/UserType.md
new file mode 100644
index 00000000000..0b8f7d1d65d
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/docs/UserType.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.UserType
+
+## Enum
+
+
+* `admin` (value: `"admin"`)
+
+* `user` (value: `"user"`)
+
+
diff --git a/samples/client/petstore/javascript-es6/src/index.js b/samples/client/petstore/javascript-es6/src/index.js
index 7235863ec1b..243b44e4d0a 100644
--- a/samples/client/petstore/javascript-es6/src/index.js
+++ b/samples/client/petstore/javascript-es6/src/index.js
@@ -59,6 +59,7 @@ import Return from './model/Return';
 import SpecialModelName from './model/SpecialModelName';
 import Tag from './model/Tag';
 import User from './model/User';
+import UserType from './model/UserType';
 import AnotherFakeApi from './api/AnotherFakeApi';
 import DefaultApi from './api/DefaultApi';
 import FakeApi from './api/FakeApi';
@@ -382,6 +383,12 @@ export {
      */
     User,
 
+    /**
+     * The UserType model constructor.
+     * @property {module:model/UserType}
+     */
+    UserType,
+
     /**
     * The AnotherFakeApi service constructor.
     * @property {module:api/AnotherFakeApi}
diff --git a/samples/client/petstore/javascript-es6/src/model/User.js b/samples/client/petstore/javascript-es6/src/model/User.js
index 473bf7c78bc..652a9c2feb2 100644
--- a/samples/client/petstore/javascript-es6/src/model/User.js
+++ b/samples/client/petstore/javascript-es6/src/model/User.js
@@ -12,6 +12,7 @@
  */
 
 import ApiClient from '../ApiClient';
+import UserType from './UserType';
 
 /**
  * The User model module.
@@ -71,6 +72,9 @@ class User {
             if (data.hasOwnProperty('userStatus')) {
                 obj['userStatus'] = ApiClient.convertToType(data['userStatus'], 'Number');
             }
+            if (data.hasOwnProperty('userType')) {
+                obj['userType'] = ApiClient.convertToType(data['userType'], UserType);
+            }
         }
         return obj;
     }
@@ -119,6 +123,11 @@ User.prototype['phone'] = undefined;
  */
 User.prototype['userStatus'] = undefined;
 
+/**
+ * @member {module:model/UserType} userType
+ */
+User.prototype['userType'] = undefined;
+
 
 
 
diff --git a/samples/client/petstore/javascript-es6/src/model/UserType.js b/samples/client/petstore/javascript-es6/src/model/UserType.js
new file mode 100644
index 00000000000..46642aca99f
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/src/model/UserType.js
@@ -0,0 +1,46 @@
+/**
+ * OpenAPI Petstore
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ *
+ */
+
+import ApiClient from '../ApiClient';
+/**
+* Enum class UserType.
+* @enum {}
+* @readonly
+*/
+export default class UserType {
+    
+        /**
+         * value: "admin"
+         * @const
+         */
+        "admin" = "admin";
+
+    
+        /**
+         * value: "user"
+         * @const
+         */
+        "user" = "user";
+
+    
+
+    /**
+    * Returns a <code>UserType</code> enum value from a Javascript object name.
+    * @param {Object} data The plain JavaScript object containing the name of the enum value.
+    * @return {module:model/UserType} The enum <code>UserType</code> value.
+    */
+    static constructFromObject(object) {
+        return object;
+    }
+}
+
diff --git a/samples/client/petstore/javascript-es6/test/model/UserType.spec.js b/samples/client/petstore/javascript-es6/test/model/UserType.spec.js
new file mode 100644
index 00000000000..27eb88fb909
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/test/model/UserType.spec.js
@@ -0,0 +1,58 @@
+/**
+ * OpenAPI Petstore
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ *
+ */
+
+(function(root, factory) {
+  if (typeof define === 'function' && define.amd) {
+    // AMD.
+    define(['expect.js', process.cwd()+'/src/index'], factory);
+  } else if (typeof module === 'object' && module.exports) {
+    // CommonJS-like environments that support module.exports, like Node.
+    factory(require('expect.js'), require(process.cwd()+'/src/index'));
+  } else {
+    // Browser globals (root is window)
+    factory(root.expect, root.OpenApiPetstore);
+  }
+}(this, function(expect, OpenApiPetstore) {
+  'use strict';
+
+  var instance;
+
+  beforeEach(function() {
+  });
+
+  var getProperty = function(object, getter, property) {
+    // Use getter method if present; otherwise, get the property directly.
+    if (typeof object[getter] === 'function')
+      return object[getter]();
+    else
+      return object[property];
+  }
+
+  var setProperty = function(object, setter, property, value) {
+    // Use setter method if present; otherwise, set the property directly.
+    if (typeof object[setter] === 'function')
+      object[setter](value);
+    else
+      object[property] = value;
+  }
+
+  describe('UserType', function() {
+    it('should create an instance of UserType', function() {
+      // uncomment below and update the code to test UserType
+      //var instance = new OpenApiPetstore.UserType();
+      //expect(instance).to.be.a(OpenApiPetstore.UserType);
+    });
+
+  });
+
+}));
diff --git a/samples/client/petstore/javascript-promise-es6/.openapi-generator/FILES b/samples/client/petstore/javascript-promise-es6/.openapi-generator/FILES
index 3e7946d76cc..e4b39f7eb90 100644
--- a/samples/client/petstore/javascript-promise-es6/.openapi-generator/FILES
+++ b/samples/client/petstore/javascript-promise-es6/.openapi-generator/FILES
@@ -55,6 +55,7 @@ docs/StoreApi.md
 docs/Tag.md
 docs/User.md
 docs/UserApi.md
+docs/UserType.md
 git_push.sh
 mocha.opts
 package.json
@@ -113,3 +114,4 @@ src/model/Return.js
 src/model/SpecialModelName.js
 src/model/Tag.js
 src/model/User.js
+src/model/UserType.js
diff --git a/samples/client/petstore/javascript-promise-es6/README.md b/samples/client/petstore/javascript-promise-es6/README.md
index 409d63e9a29..52612b46c52 100644
--- a/samples/client/petstore/javascript-promise-es6/README.md
+++ b/samples/client/petstore/javascript-promise-es6/README.md
@@ -209,6 +209,7 @@ Class | Method | HTTP request | Description
  - [OpenApiPetstore.SpecialModelName](docs/SpecialModelName.md)
  - [OpenApiPetstore.Tag](docs/Tag.md)
  - [OpenApiPetstore.User](docs/User.md)
+ - [OpenApiPetstore.UserType](docs/UserType.md)
 
 
 ## Documentation for Authorization
diff --git a/samples/client/petstore/javascript-promise-es6/docs/User.md b/samples/client/petstore/javascript-promise-es6/docs/User.md
index 096f606d0b9..ebcba777dbe 100644
--- a/samples/client/petstore/javascript-promise-es6/docs/User.md
+++ b/samples/client/petstore/javascript-promise-es6/docs/User.md
@@ -12,5 +12,6 @@ Name | Type | Description | Notes
 **password** | **String** |  | [optional] 
 **phone** | **String** |  | [optional] 
 **userStatus** | **Number** | User Status | [optional] 
+**userType** | [**UserType**](UserType.md) |  | [optional] 
 
 
diff --git a/samples/client/petstore/javascript-promise-es6/docs/UserType.md b/samples/client/petstore/javascript-promise-es6/docs/UserType.md
new file mode 100644
index 00000000000..0b8f7d1d65d
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/docs/UserType.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.UserType
+
+## Enum
+
+
+* `admin` (value: `"admin"`)
+
+* `user` (value: `"user"`)
+
+
diff --git a/samples/client/petstore/javascript-promise-es6/src/index.js b/samples/client/petstore/javascript-promise-es6/src/index.js
index 7235863ec1b..243b44e4d0a 100644
--- a/samples/client/petstore/javascript-promise-es6/src/index.js
+++ b/samples/client/petstore/javascript-promise-es6/src/index.js
@@ -59,6 +59,7 @@ import Return from './model/Return';
 import SpecialModelName from './model/SpecialModelName';
 import Tag from './model/Tag';
 import User from './model/User';
+import UserType from './model/UserType';
 import AnotherFakeApi from './api/AnotherFakeApi';
 import DefaultApi from './api/DefaultApi';
 import FakeApi from './api/FakeApi';
@@ -382,6 +383,12 @@ export {
      */
     User,
 
+    /**
+     * The UserType model constructor.
+     * @property {module:model/UserType}
+     */
+    UserType,
+
     /**
     * The AnotherFakeApi service constructor.
     * @property {module:api/AnotherFakeApi}
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/User.js b/samples/client/petstore/javascript-promise-es6/src/model/User.js
index 473bf7c78bc..652a9c2feb2 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/User.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/User.js
@@ -12,6 +12,7 @@
  */
 
 import ApiClient from '../ApiClient';
+import UserType from './UserType';
 
 /**
  * The User model module.
@@ -71,6 +72,9 @@ class User {
             if (data.hasOwnProperty('userStatus')) {
                 obj['userStatus'] = ApiClient.convertToType(data['userStatus'], 'Number');
             }
+            if (data.hasOwnProperty('userType')) {
+                obj['userType'] = ApiClient.convertToType(data['userType'], UserType);
+            }
         }
         return obj;
     }
@@ -119,6 +123,11 @@ User.prototype['phone'] = undefined;
  */
 User.prototype['userStatus'] = undefined;
 
+/**
+ * @member {module:model/UserType} userType
+ */
+User.prototype['userType'] = undefined;
+
 
 
 
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/UserType.js b/samples/client/petstore/javascript-promise-es6/src/model/UserType.js
new file mode 100644
index 00000000000..46642aca99f
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/src/model/UserType.js
@@ -0,0 +1,46 @@
+/**
+ * OpenAPI Petstore
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ *
+ */
+
+import ApiClient from '../ApiClient';
+/**
+* Enum class UserType.
+* @enum {}
+* @readonly
+*/
+export default class UserType {
+    
+        /**
+         * value: "admin"
+         * @const
+         */
+        "admin" = "admin";
+
+    
+        /**
+         * value: "user"
+         * @const
+         */
+        "user" = "user";
+
+    
+
+    /**
+    * Returns a <code>UserType</code> enum value from a Javascript object name.
+    * @param {Object} data The plain JavaScript object containing the name of the enum value.
+    * @return {module:model/UserType} The enum <code>UserType</code> value.
+    */
+    static constructFromObject(object) {
+        return object;
+    }
+}
+
diff --git a/samples/client/petstore/javascript-promise-es6/test/model/UserType.spec.js b/samples/client/petstore/javascript-promise-es6/test/model/UserType.spec.js
new file mode 100644
index 00000000000..27eb88fb909
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/test/model/UserType.spec.js
@@ -0,0 +1,58 @@
+/**
+ * OpenAPI Petstore
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ *
+ */
+
+(function(root, factory) {
+  if (typeof define === 'function' && define.amd) {
+    // AMD.
+    define(['expect.js', process.cwd()+'/src/index'], factory);
+  } else if (typeof module === 'object' && module.exports) {
+    // CommonJS-like environments that support module.exports, like Node.
+    factory(require('expect.js'), require(process.cwd()+'/src/index'));
+  } else {
+    // Browser globals (root is window)
+    factory(root.expect, root.OpenApiPetstore);
+  }
+}(this, function(expect, OpenApiPetstore) {
+  'use strict';
+
+  var instance;
+
+  beforeEach(function() {
+  });
+
+  var getProperty = function(object, getter, property) {
+    // Use getter method if present; otherwise, get the property directly.
+    if (typeof object[getter] === 'function')
+      return object[getter]();
+    else
+      return object[property];
+  }
+
+  var setProperty = function(object, setter, property, value) {
+    // Use setter method if present; otherwise, set the property directly.
+    if (typeof object[setter] === 'function')
+      object[setter](value);
+    else
+      object[property] = value;
+  }
+
+  describe('UserType', function() {
+    it('should create an instance of UserType', function() {
+      // uncomment below and update the code to test UserType
+      //var instance = new OpenApiPetstore.UserType();
+      //expect(instance).to.be.a(OpenApiPetstore.UserType);
+    });
+
+  });
+
+}));
diff --git a/samples/client/petstore/perl/.openapi-generator/FILES b/samples/client/petstore/perl/.openapi-generator/FILES
index ffe1c03f40e..72f8279c581 100644
--- a/samples/client/petstore/perl/.openapi-generator/FILES
+++ b/samples/client/petstore/perl/.openapi-generator/FILES
@@ -55,6 +55,7 @@ docs/StoreApi.md
 docs/Tag.md
 docs/User.md
 docs/UserApi.md
+docs/UserType.md
 git_push.sh
 lib/WWW/OpenAPIClient/AnotherFakeApi.pm
 lib/WWW/OpenAPIClient/ApiClient.pm
@@ -109,6 +110,7 @@ lib/WWW/OpenAPIClient/Object/ReadOnlyFirst.pm
 lib/WWW/OpenAPIClient/Object/SpecialModelName.pm
 lib/WWW/OpenAPIClient/Object/Tag.pm
 lib/WWW/OpenAPIClient/Object/User.pm
+lib/WWW/OpenAPIClient/Object/UserType.pm
 lib/WWW/OpenAPIClient/PetApi.pm
 lib/WWW/OpenAPIClient/Role.pm
 lib/WWW/OpenAPIClient/Role/AutoDoc.pm
diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md
index 6d20b2459d8..3dcb3e86da1 100644
--- a/samples/client/petstore/perl/README.md
+++ b/samples/client/petstore/perl/README.md
@@ -288,6 +288,7 @@ use WWW::OpenAPIClient::Object::ReadOnlyFirst;
 use WWW::OpenAPIClient::Object::SpecialModelName;
 use WWW::OpenAPIClient::Object::Tag;
 use WWW::OpenAPIClient::Object::User;
+use WWW::OpenAPIClient::Object::UserType;
 
 ````
 
@@ -354,6 +355,7 @@ use WWW::OpenAPIClient::Object::ReadOnlyFirst;
 use WWW::OpenAPIClient::Object::SpecialModelName;
 use WWW::OpenAPIClient::Object::Tag;
 use WWW::OpenAPIClient::Object::User;
+use WWW::OpenAPIClient::Object::UserType;
 
 # for displaying the API response data
 use Data::Dumper;
@@ -470,6 +472,7 @@ Class | Method | HTTP request | Description
  - [WWW::OpenAPIClient::Object::SpecialModelName](docs/SpecialModelName.md)
  - [WWW::OpenAPIClient::Object::Tag](docs/Tag.md)
  - [WWW::OpenAPIClient::Object::User](docs/User.md)
+ - [WWW::OpenAPIClient::Object::UserType](docs/UserType.md)
 
 
 # DOCUMENTATION FOR AUTHORIZATION
diff --git a/samples/client/petstore/perl/docs/User.md b/samples/client/petstore/perl/docs/User.md
index a33c09e22f2..7213bc20857 100644
--- a/samples/client/petstore/perl/docs/User.md
+++ b/samples/client/petstore/perl/docs/User.md
@@ -16,6 +16,7 @@ Name | Type | Description | Notes
 **password** | **string** |  | [optional] 
 **phone** | **string** |  | [optional] 
 **user_status** | **int** | User Status | [optional] 
+**user_type** | [**UserType**](UserType.md) |  | [optional] 
 
 [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
 
diff --git a/samples/client/petstore/perl/docs/UserType.md b/samples/client/petstore/perl/docs/UserType.md
new file mode 100644
index 00000000000..d3f5336192e
--- /dev/null
+++ b/samples/client/petstore/perl/docs/UserType.md
@@ -0,0 +1,14 @@
+# WWW::OpenAPIClient::Object::UserType
+
+## Load the model package
+```perl
+use WWW::OpenAPIClient::Object::UserType;
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/User.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/User.pm
index e301902cc03..9ff2ecf3d9f 100644
--- a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/User.pm
+++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/User.pm
@@ -30,6 +30,7 @@ use Log::Any qw($log);
 use Date::Parse;
 use DateTime;
 
+use WWW::OpenAPIClient::Object::UserType;
 
 use base ("Class::Accessor", "Class::Data::Inheritable");
 
@@ -216,6 +217,13 @@ __PACKAGE__->method_documentation({
         format => '',
         read_only => '',
             },
+    'user_type' => {
+        datatype => 'UserType',
+        base_name => 'userType',
+        description => '',
+        format => '',
+        read_only => '',
+            },
 });
 
 __PACKAGE__->openapi_types( {
@@ -226,7 +234,8 @@ __PACKAGE__->openapi_types( {
     'email' => 'string',
     'password' => 'string',
     'phone' => 'string',
-    'user_status' => 'int'
+    'user_status' => 'int',
+    'user_type' => 'UserType'
 } );
 
 __PACKAGE__->attribute_map( {
@@ -237,7 +246,8 @@ __PACKAGE__->attribute_map( {
     'email' => 'email',
     'password' => 'password',
     'phone' => 'phone',
-    'user_status' => 'userStatus'
+    'user_status' => 'userStatus',
+    'user_type' => 'userType'
 } );
 
 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/UserType.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/UserType.pm
new file mode 100644
index 00000000000..eebe61d6da5
--- /dev/null
+++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/UserType.pm
@@ -0,0 +1,176 @@
+=begin comment
+
+OpenAPI Petstore
+
+This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+
+The version of the OpenAPI document: 1.0.0
+
+Generated by: https://openapi-generator.tech
+
+=end comment
+
+=cut
+
+#
+# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+# Do not edit the class manually.
+# Ref: https://openapi-generator.tech
+#
+package WWW::OpenAPIClient::Object::UserType;
+
+require 5.6.0;
+use strict;
+use warnings;
+use utf8;
+use JSON qw(decode_json);
+use Data::Dumper;
+use Module::Runtime qw(use_module);
+use Log::Any qw($log);
+use Date::Parse;
+use DateTime;
+
+
+use base ("Class::Accessor", "Class::Data::Inheritable");
+
+#
+#
+#
+# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually.
+# REF: https://openapi-generator.tech
+#
+
+=begin comment
+
+OpenAPI Petstore
+
+This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+
+The version of the OpenAPI document: 1.0.0
+
+Generated by: https://openapi-generator.tech
+
+=end comment
+
+=cut
+
+#
+# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+# Do not edit the class manually.
+# Ref: https://openapi-generator.tech
+#
+__PACKAGE__->mk_classdata('attribute_map' => {});
+__PACKAGE__->mk_classdata('openapi_types' => {});
+__PACKAGE__->mk_classdata('method_documentation' => {});
+__PACKAGE__->mk_classdata('class_documentation' => {});
+
+# new plain object
+sub new {
+    my ($class, %args) = @_;
+
+    my $self = bless {}, $class;
+
+    $self->init(%args);
+
+    return $self;
+}
+
+# initialize the object
+sub init
+{
+    my ($self, %args) = @_;
+
+    foreach my $attribute (keys %{$self->attribute_map}) {
+        my $args_key = $self->attribute_map->{$attribute};
+        $self->$attribute( $args{ $args_key } );
+    }
+}
+
+# return perl hash
+sub to_hash {
+    my $self = shift;
+    my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
+
+    return $_hash;
+}
+
+# used by JSON for serialization
+sub TO_JSON {
+    my $self = shift;
+    my $_data = {};
+    foreach my $_key (keys %{$self->attribute_map}) {
+        if (defined $self->{$_key}) {
+            $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
+        }
+    }
+
+    return $_data;
+}
+
+# from Perl hashref
+sub from_hash {
+    my ($self, $hash) = @_;
+
+    # loop through attributes and use openapi_types to deserialize the data
+    while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
+        my $_json_attribute = $self->attribute_map->{$_key};
+        if ($_type =~ /^array\[(.+)\]$/i) { # array
+            my $_subclass = $1;
+            my @_array = ();
+            foreach my $_element (@{$hash->{$_json_attribute}}) {
+                push @_array, $self->_deserialize($_subclass, $_element);
+            }
+            $self->{$_key} = \@_array;
+        } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
+            my $_subclass = $1;
+            my %_hash = ();
+            while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
+                $_hash{$_key} = $self->_deserialize($_subclass, $_element);
+            }
+            $self->{$_key} = \%_hash;
+        } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
+            $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
+        } else {
+            $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
+        }
+    }
+
+    return $self;
+}
+
+# deserialize non-array data
+sub _deserialize {
+    my ($self, $type, $data) = @_;
+    $log->debugf("deserializing %s with %s",Dumper($data), $type);
+
+    if ($type eq 'DateTime') {
+        return DateTime->from_epoch(epoch => str2time($data));
+    } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
+        return $data;
+    } else { # hash(model)
+        my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
+        return $_instance->from_hash($data);
+    }
+}
+
+
+__PACKAGE__->class_documentation({description => '',
+                                  class => 'UserType',
+                                  required => [], # TODO
+}                                 );
+
+__PACKAGE__->method_documentation({
+});
+
+__PACKAGE__->openapi_types( {
+    
+} );
+
+__PACKAGE__->attribute_map( {
+    
+} );
+
+__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
+
+
+1;
diff --git a/samples/client/petstore/perl/t/UserTypeTest.t b/samples/client/petstore/perl/t/UserTypeTest.t
new file mode 100644
index 00000000000..2508bdd5803
--- /dev/null
+++ b/samples/client/petstore/perl/t/UserTypeTest.t
@@ -0,0 +1,34 @@
+=begin comment
+
+OpenAPI Petstore
+
+This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+
+The version of the OpenAPI document: 1.0.0
+
+Generated by: https://openapi-generator.tech
+
+=end comment
+
+=cut
+
+#
+# NOTE: This class is auto generated by the OpenAPI Generator
+# Please update the test cases below to test the model.
+# Ref: https://openapi-generator.tech
+#
+use Test::More tests => 2;
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+
+use_ok('WWW::OpenAPIClient::Object::UserType');
+
+# uncomment below and update the test
+#my $instance = WWW::OpenAPIClient::Object::UserType->new();
+#
+#isa_ok($instance, 'WWW::OpenAPIClient::Object::UserType');
+
diff --git a/samples/client/petstore/php/OpenAPIClient-php/.openapi-generator/FILES b/samples/client/petstore/php/OpenAPIClient-php/.openapi-generator/FILES
index 7d0b2295b61..48ff69c1742 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/.openapi-generator/FILES
+++ b/samples/client/petstore/php/OpenAPIClient-php/.openapi-generator/FILES
@@ -56,6 +56,7 @@ docs/Model/ReadOnlyFirst.md
 docs/Model/SpecialModelName.md
 docs/Model/Tag.md
 docs/Model/User.md
+docs/Model/UserType.md
 git_push.sh
 lib/Api/AnotherFakeApi.php
 lib/Api/DefaultApi.php
@@ -114,5 +115,6 @@ lib/Model/ReadOnlyFirst.php
 lib/Model/SpecialModelName.php
 lib/Model/Tag.php
 lib/Model/User.php
+lib/Model/UserType.php
 lib/ObjectSerializer.php
 phpunit.xml.dist
diff --git a/samples/client/petstore/php/OpenAPIClient-php/README.md b/samples/client/petstore/php/OpenAPIClient-php/README.md
index db6e9e5433f..b076fe82269 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/README.md
+++ b/samples/client/petstore/php/OpenAPIClient-php/README.md
@@ -162,6 +162,7 @@ Class | Method | HTTP request | Description
 - [SpecialModelName](docs/Model/SpecialModelName.md)
 - [Tag](docs/Model/Tag.md)
 - [User](docs/Model/User.md)
+- [UserType](docs/Model/UserType.md)
 
 ## Authorization
 
diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/User.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/User.md
index dde68f38fc0..a1730ca4e05 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/User.md
+++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/User.md
@@ -12,5 +12,6 @@ Name | Type | Description | Notes
 **password** | **string** |  | [optional]
 **phone** | **string** |  | [optional]
 **user_status** | **int** | User Status | [optional]
+**user_type** | [**UserType**](UserType.md) |  | [optional]
 
 [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/UserType.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/UserType.md
new file mode 100644
index 00000000000..128c7650ed3
--- /dev/null
+++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/UserType.md
@@ -0,0 +1,8 @@
+# # UserType
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php
index d1219bf6ab0..156bb3ae952 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php
+++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php
@@ -66,7 +66,8 @@ class User implements ModelInterface, ArrayAccess, \JsonSerializable
         'email' => 'string',
         'password' => 'string',
         'phone' => 'string',
-        'user_status' => 'int'
+        'user_status' => 'int',
+        'user_type' => 'UserType'
     ];
 
     /**
@@ -84,7 +85,8 @@ class User implements ModelInterface, ArrayAccess, \JsonSerializable
         'email' => null,
         'password' => null,
         'phone' => null,
-        'user_status' => 'int32'
+        'user_status' => 'int32',
+        'user_type' => null
     ];
 
     /**
@@ -121,7 +123,8 @@ class User implements ModelInterface, ArrayAccess, \JsonSerializable
         'email' => 'email',
         'password' => 'password',
         'phone' => 'phone',
-        'user_status' => 'userStatus'
+        'user_status' => 'userStatus',
+        'user_type' => 'userType'
     ];
 
     /**
@@ -137,7 +140,8 @@ class User implements ModelInterface, ArrayAccess, \JsonSerializable
         'email' => 'setEmail',
         'password' => 'setPassword',
         'phone' => 'setPhone',
-        'user_status' => 'setUserStatus'
+        'user_status' => 'setUserStatus',
+        'user_type' => 'setUserType'
     ];
 
     /**
@@ -153,7 +157,8 @@ class User implements ModelInterface, ArrayAccess, \JsonSerializable
         'email' => 'getEmail',
         'password' => 'getPassword',
         'phone' => 'getPhone',
-        'user_status' => 'getUserStatus'
+        'user_status' => 'getUserStatus',
+        'user_type' => 'getUserType'
     ];
 
     /**
@@ -221,6 +226,7 @@ class User implements ModelInterface, ArrayAccess, \JsonSerializable
         $this->container['password'] = $data['password'] ?? null;
         $this->container['phone'] = $data['phone'] ?? null;
         $this->container['user_status'] = $data['user_status'] ?? null;
+        $this->container['user_type'] = $data['user_type'] ?? null;
     }
 
     /**
@@ -438,6 +444,30 @@ class User implements ModelInterface, ArrayAccess, \JsonSerializable
 
         return $this;
     }
+
+    /**
+     * Gets user_type
+     *
+     * @return UserType|null
+     */
+    public function getUserType()
+    {
+        return $this->container['user_type'];
+    }
+
+    /**
+     * Sets user_type
+     *
+     * @param UserType|null $user_type user_type
+     *
+     * @return self
+     */
+    public function setUserType($user_type)
+    {
+        $this->container['user_type'] = $user_type;
+
+        return $this;
+    }
     /**
      * Returns true if offset exists. False otherwise.
      *
diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/UserType.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/UserType.php
new file mode 100644
index 00000000000..42a1ff35f5b
--- /dev/null
+++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/UserType.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * UserType
+ *
+ * PHP version 7.3
+ *
+ * @category Class
+ * @package  OpenAPI\Client
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * OpenAPI Generator version: 5.3.1-SNAPSHOT
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace OpenAPI\Client\Model;
+use \OpenAPI\Client\ObjectSerializer;
+
+/**
+ * UserType Class Doc Comment
+ *
+ * @category Class
+ * @package  OpenAPI\Client
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+class UserType
+{
+    /**
+     * Possible values of this enum
+     */
+    const ADMIN = 'admin';
+
+    const USER = 'user';
+
+    /**
+     * Gets allowable values of the enum
+     * @return string[]
+     */
+    public static function getAllowableEnumValues()
+    {
+        return [
+            self::ADMIN,
+            self::USER
+        ];
+    }
+}
+
+
diff --git a/samples/client/petstore/php/OpenAPIClient-php/test/Model/UserTypeTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/UserTypeTest.php
new file mode 100644
index 00000000000..78d5ce2fd85
--- /dev/null
+++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/UserTypeTest.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * UserTypeTest
+ *
+ * PHP version 7.3
+ *
+ * @category Class
+ * @package  OpenAPI\Client
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * OpenAPI Generator version: 5.3.1-SNAPSHOT
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Please update the test case below to test the model.
+ */
+
+namespace OpenAPI\Client\Test\Model;
+
+use PHPUnit\Framework\TestCase;
+
+/**
+ * UserTypeTest Class Doc Comment
+ *
+ * @category    Class
+ * @description UserType
+ * @package     OpenAPI\Client
+ * @author      OpenAPI Generator team
+ * @link        https://openapi-generator.tech
+ */
+class UserTypeTest extends TestCase
+{
+
+    /**
+     * Setup before running any test case
+     */
+    public static function setUpBeforeClass(): void
+    {
+    }
+
+    /**
+     * Setup before running each test case
+     */
+    public function setUp(): void
+    {
+    }
+
+    /**
+     * Clean up after running each test case
+     */
+    public function tearDown(): void
+    {
+    }
+
+    /**
+     * Clean up after running all test cases
+     */
+    public static function tearDownAfterClass(): void
+    {
+    }
+
+    /**
+     * Test "UserType"
+     */
+    public function testUserType()
+    {
+        // TODO: implement
+        $this->markTestIncomplete('Not implemented');
+    }
+}
diff --git a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES
index 8eb7c988140..972f18c3240 100644
--- a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES
+++ b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES
@@ -58,6 +58,7 @@ docs/StoreApi.md
 docs/Tag.md
 docs/User.md
 docs/UserApi.md
+docs/UserType.md
 git_push.sh
 lib/petstore.rb
 lib/petstore/api/another_fake_api.rb
@@ -116,6 +117,7 @@ lib/petstore/models/read_only_first.rb
 lib/petstore/models/special_model_name.rb
 lib/petstore/models/tag.rb
 lib/petstore/models/user.rb
+lib/petstore/models/user_type.rb
 lib/petstore/version.rb
 petstore.gemspec
 spec/api_client_spec.rb
diff --git a/samples/client/petstore/ruby-faraday/README.md b/samples/client/petstore/ruby-faraday/README.md
index 289f8a0833d..3335440ccce 100644
--- a/samples/client/petstore/ruby-faraday/README.md
+++ b/samples/client/petstore/ruby-faraday/README.md
@@ -166,6 +166,7 @@ Class | Method | HTTP request | Description
  - [Petstore::SpecialModelName](docs/SpecialModelName.md)
  - [Petstore::Tag](docs/Tag.md)
  - [Petstore::User](docs/User.md)
+ - [Petstore::UserType](docs/UserType.md)
 
 
 ## Documentation for Authorization
diff --git a/samples/client/petstore/ruby-faraday/docs/User.md b/samples/client/petstore/ruby-faraday/docs/User.md
index 1dab27adba2..9448c781db2 100644
--- a/samples/client/petstore/ruby-faraday/docs/User.md
+++ b/samples/client/petstore/ruby-faraday/docs/User.md
@@ -12,6 +12,7 @@
 | **password** | **String** |  | [optional] |
 | **phone** | **String** |  | [optional] |
 | **user_status** | **Integer** | User Status | [optional] |
+| **user_type** | [**UserType**](UserType.md) |  | [optional] |
 
 ## Example
 
@@ -26,7 +27,8 @@ instance = Petstore::User.new(
   email: null,
   password: null,
   phone: null,
-  user_status: null
+  user_status: null,
+  user_type: null
 )
 ```
 
diff --git a/samples/client/petstore/ruby-faraday/docs/UserType.md b/samples/client/petstore/ruby-faraday/docs/UserType.md
new file mode 100644
index 00000000000..4dd12e908a5
--- /dev/null
+++ b/samples/client/petstore/ruby-faraday/docs/UserType.md
@@ -0,0 +1,15 @@
+# Petstore::UserType
+
+## Properties
+
+| Name | Type | Description | Notes |
+| ---- | ---- | ----------- | ----- |
+
+## Example
+
+```ruby
+require 'petstore'
+
+instance = Petstore::UserType.new()
+```
+
diff --git a/samples/client/petstore/ruby-faraday/lib/petstore.rb b/samples/client/petstore/ruby-faraday/lib/petstore.rb
index bac7b12ce6b..bf80a313e07 100644
--- a/samples/client/petstore/ruby-faraday/lib/petstore.rb
+++ b/samples/client/petstore/ruby-faraday/lib/petstore.rb
@@ -61,6 +61,7 @@ require 'petstore/models/read_only_first'
 require 'petstore/models/special_model_name'
 require 'petstore/models/tag'
 require 'petstore/models/user'
+require 'petstore/models/user_type'
 require 'petstore/models/cat'
 require 'petstore/models/dog'
 
diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb
index 311d608dec3..5f77aa388c7 100644
--- a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb
+++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb
@@ -32,6 +32,8 @@ module Petstore
     # User Status
     attr_accessor :user_status
 
+    attr_accessor :user_type
+
     # Attribute mapping from ruby-style variable name to JSON key.
     def self.attribute_map
       {
@@ -42,7 +44,8 @@ module Petstore
         :'email' => :'email',
         :'password' => :'password',
         :'phone' => :'phone',
-        :'user_status' => :'userStatus'
+        :'user_status' => :'userStatus',
+        :'user_type' => :'userType'
       }
     end
 
@@ -61,13 +64,15 @@ module Petstore
         :'email' => :'String',
         :'password' => :'String',
         :'phone' => :'String',
-        :'user_status' => :'Integer'
+        :'user_status' => :'Integer',
+        :'user_type' => :'UserType'
       }
     end
 
     # List of attributes with nullable: true
     def self.openapi_nullable
       Set.new([
+        :'user_type'
       ])
     end
 
@@ -117,6 +122,10 @@ module Petstore
       if attributes.key?(:'user_status')
         self.user_status = attributes[:'user_status']
       end
+
+      if attributes.key?(:'user_type')
+        self.user_type = attributes[:'user_type']
+      end
     end
 
     # Show invalid properties with the reasons. Usually used together with valid?
@@ -144,7 +153,8 @@ module Petstore
           email == o.email &&
           password == o.password &&
           phone == o.phone &&
-          user_status == o.user_status
+          user_status == o.user_status &&
+          user_type == o.user_type
     end
 
     # @see the `==` method
@@ -156,7 +166,7 @@ module Petstore
     # Calculates hash code according to all attributes.
     # @return [Integer] Hash code
     def hash
-      [id, username, first_name, last_name, email, password, phone, user_status].hash
+      [id, username, first_name, last_name, email, password, phone, user_status, user_type].hash
     end
 
     # Builds the object from hash
diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/user_type.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/user_type.rb
new file mode 100644
index 00000000000..68064a5f33c
--- /dev/null
+++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/user_type.rb
@@ -0,0 +1,37 @@
+=begin
+#OpenAPI Petstore
+
+#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+
+The version of the OpenAPI document: 1.0.0
+
+Generated by: https://openapi-generator.tech
+OpenAPI Generator version: 5.3.1-SNAPSHOT
+
+=end
+
+require 'date'
+require 'time'
+
+module Petstore
+  class UserType
+    ADMIN = "admin".freeze
+    USER = "user".freeze
+
+    # Builds the enum from string
+    # @param [String] The enum value in the form of the string
+    # @return [String] The enum value
+    def self.build_from_hash(value)
+      new.build_from_hash(value)
+    end
+
+    # Builds the enum from string
+    # @param [String] The enum value in the form of the string
+    # @return [String] The enum value
+    def build_from_hash(value)
+      constantValues = UserType.constants.select { |c| UserType::const_get(c) == value }
+      raise "Invalid ENUM value #{value} for class #UserType" if constantValues.empty?
+      value
+    end
+  end
+end
diff --git a/samples/client/petstore/ruby-faraday/spec/models/user_type_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/user_type_spec.rb
new file mode 100644
index 00000000000..137d05d1a81
--- /dev/null
+++ b/samples/client/petstore/ruby-faraday/spec/models/user_type_spec.rb
@@ -0,0 +1,28 @@
+=begin
+#OpenAPI Petstore
+
+#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+
+The version of the OpenAPI document: 1.0.0
+
+Generated by: https://openapi-generator.tech
+OpenAPI Generator version: 5.3.1-SNAPSHOT
+
+=end
+
+require 'spec_helper'
+require 'json'
+require 'date'
+
+# Unit tests for Petstore::UserType
+# Automatically generated by openapi-generator (https://openapi-generator.tech)
+# Please update as you see appropriate
+describe Petstore::UserType do
+  let(:instance) { Petstore::UserType.new }
+
+  describe 'test an instance of UserType' do
+    it 'should create an instance of UserType' do
+      expect(instance).to be_instance_of(Petstore::UserType)
+    end
+  end
+end
diff --git a/samples/client/petstore/ruby/.openapi-generator/FILES b/samples/client/petstore/ruby/.openapi-generator/FILES
index 8eb7c988140..972f18c3240 100644
--- a/samples/client/petstore/ruby/.openapi-generator/FILES
+++ b/samples/client/petstore/ruby/.openapi-generator/FILES
@@ -58,6 +58,7 @@ docs/StoreApi.md
 docs/Tag.md
 docs/User.md
 docs/UserApi.md
+docs/UserType.md
 git_push.sh
 lib/petstore.rb
 lib/petstore/api/another_fake_api.rb
@@ -116,6 +117,7 @@ lib/petstore/models/read_only_first.rb
 lib/petstore/models/special_model_name.rb
 lib/petstore/models/tag.rb
 lib/petstore/models/user.rb
+lib/petstore/models/user_type.rb
 lib/petstore/version.rb
 petstore.gemspec
 spec/api_client_spec.rb
diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md
index 289f8a0833d..3335440ccce 100644
--- a/samples/client/petstore/ruby/README.md
+++ b/samples/client/petstore/ruby/README.md
@@ -166,6 +166,7 @@ Class | Method | HTTP request | Description
  - [Petstore::SpecialModelName](docs/SpecialModelName.md)
  - [Petstore::Tag](docs/Tag.md)
  - [Petstore::User](docs/User.md)
+ - [Petstore::UserType](docs/UserType.md)
 
 
 ## Documentation for Authorization
diff --git a/samples/client/petstore/ruby/docs/User.md b/samples/client/petstore/ruby/docs/User.md
index 1dab27adba2..9448c781db2 100644
--- a/samples/client/petstore/ruby/docs/User.md
+++ b/samples/client/petstore/ruby/docs/User.md
@@ -12,6 +12,7 @@
 | **password** | **String** |  | [optional] |
 | **phone** | **String** |  | [optional] |
 | **user_status** | **Integer** | User Status | [optional] |
+| **user_type** | [**UserType**](UserType.md) |  | [optional] |
 
 ## Example
 
@@ -26,7 +27,8 @@ instance = Petstore::User.new(
   email: null,
   password: null,
   phone: null,
-  user_status: null
+  user_status: null,
+  user_type: null
 )
 ```
 
diff --git a/samples/client/petstore/ruby/docs/UserType.md b/samples/client/petstore/ruby/docs/UserType.md
new file mode 100644
index 00000000000..4dd12e908a5
--- /dev/null
+++ b/samples/client/petstore/ruby/docs/UserType.md
@@ -0,0 +1,15 @@
+# Petstore::UserType
+
+## Properties
+
+| Name | Type | Description | Notes |
+| ---- | ---- | ----------- | ----- |
+
+## Example
+
+```ruby
+require 'petstore'
+
+instance = Petstore::UserType.new()
+```
+
diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb
index bac7b12ce6b..bf80a313e07 100644
--- a/samples/client/petstore/ruby/lib/petstore.rb
+++ b/samples/client/petstore/ruby/lib/petstore.rb
@@ -61,6 +61,7 @@ require 'petstore/models/read_only_first'
 require 'petstore/models/special_model_name'
 require 'petstore/models/tag'
 require 'petstore/models/user'
+require 'petstore/models/user_type'
 require 'petstore/models/cat'
 require 'petstore/models/dog'
 
diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb
index 311d608dec3..5f77aa388c7 100644
--- a/samples/client/petstore/ruby/lib/petstore/models/user.rb
+++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb
@@ -32,6 +32,8 @@ module Petstore
     # User Status
     attr_accessor :user_status
 
+    attr_accessor :user_type
+
     # Attribute mapping from ruby-style variable name to JSON key.
     def self.attribute_map
       {
@@ -42,7 +44,8 @@ module Petstore
         :'email' => :'email',
         :'password' => :'password',
         :'phone' => :'phone',
-        :'user_status' => :'userStatus'
+        :'user_status' => :'userStatus',
+        :'user_type' => :'userType'
       }
     end
 
@@ -61,13 +64,15 @@ module Petstore
         :'email' => :'String',
         :'password' => :'String',
         :'phone' => :'String',
-        :'user_status' => :'Integer'
+        :'user_status' => :'Integer',
+        :'user_type' => :'UserType'
       }
     end
 
     # List of attributes with nullable: true
     def self.openapi_nullable
       Set.new([
+        :'user_type'
       ])
     end
 
@@ -117,6 +122,10 @@ module Petstore
       if attributes.key?(:'user_status')
         self.user_status = attributes[:'user_status']
       end
+
+      if attributes.key?(:'user_type')
+        self.user_type = attributes[:'user_type']
+      end
     end
 
     # Show invalid properties with the reasons. Usually used together with valid?
@@ -144,7 +153,8 @@ module Petstore
           email == o.email &&
           password == o.password &&
           phone == o.phone &&
-          user_status == o.user_status
+          user_status == o.user_status &&
+          user_type == o.user_type
     end
 
     # @see the `==` method
@@ -156,7 +166,7 @@ module Petstore
     # Calculates hash code according to all attributes.
     # @return [Integer] Hash code
     def hash
-      [id, username, first_name, last_name, email, password, phone, user_status].hash
+      [id, username, first_name, last_name, email, password, phone, user_status, user_type].hash
     end
 
     # Builds the object from hash
diff --git a/samples/client/petstore/ruby/lib/petstore/models/user_type.rb b/samples/client/petstore/ruby/lib/petstore/models/user_type.rb
new file mode 100644
index 00000000000..68064a5f33c
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/petstore/models/user_type.rb
@@ -0,0 +1,37 @@
+=begin
+#OpenAPI Petstore
+
+#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+
+The version of the OpenAPI document: 1.0.0
+
+Generated by: https://openapi-generator.tech
+OpenAPI Generator version: 5.3.1-SNAPSHOT
+
+=end
+
+require 'date'
+require 'time'
+
+module Petstore
+  class UserType
+    ADMIN = "admin".freeze
+    USER = "user".freeze
+
+    # Builds the enum from string
+    # @param [String] The enum value in the form of the string
+    # @return [String] The enum value
+    def self.build_from_hash(value)
+      new.build_from_hash(value)
+    end
+
+    # Builds the enum from string
+    # @param [String] The enum value in the form of the string
+    # @return [String] The enum value
+    def build_from_hash(value)
+      constantValues = UserType.constants.select { |c| UserType::const_get(c) == value }
+      raise "Invalid ENUM value #{value} for class #UserType" if constantValues.empty?
+      value
+    end
+  end
+end
diff --git a/samples/client/petstore/ruby/spec/models/user_type_spec.rb b/samples/client/petstore/ruby/spec/models/user_type_spec.rb
new file mode 100644
index 00000000000..137d05d1a81
--- /dev/null
+++ b/samples/client/petstore/ruby/spec/models/user_type_spec.rb
@@ -0,0 +1,28 @@
+=begin
+#OpenAPI Petstore
+
+#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+
+The version of the OpenAPI document: 1.0.0
+
+Generated by: https://openapi-generator.tech
+OpenAPI Generator version: 5.3.1-SNAPSHOT
+
+=end
+
+require 'spec_helper'
+require 'json'
+require 'date'
+
+# Unit tests for Petstore::UserType
+# Automatically generated by openapi-generator (https://openapi-generator.tech)
+# Please update as you see appropriate
+describe Petstore::UserType do
+  let(:instance) { Petstore::UserType.new }
+
+  describe 'test an instance of UserType' do
+    it 'should create an instance of UserType' do
+      expect(instance).to be_instance_of(Petstore::UserType)
+    end
+  end
+end
diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES b/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES
index 4c31a85fd4f..055529d8e51 100644
--- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES
+++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES
@@ -53,5 +53,6 @@ models/Return.ts
 models/SpecialModelName.ts
 models/Tag.ts
 models/User.ts
+models/UserType.ts
 models/index.ts
 runtime.ts
diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/User.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/User.ts
index 05c0ec7b638..75814bca2e3 100644
--- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/User.ts
+++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/User.ts
@@ -13,6 +13,13 @@
  */
 
 import { exists, mapValues } from '../runtime';
+import {
+    UserType,
+    UserTypeFromJSON,
+    UserTypeFromJSONTyped,
+    UserTypeToJSON,
+} from './UserType';
+
 /**
  * 
  * @export
@@ -67,6 +74,12 @@ export interface User {
      * @memberof User
      */
     userStatus?: number;
+    /**
+     * 
+     * @type {UserType}
+     * @memberof User
+     */
+    userType?: UserType | null;
 }
 
 export function UserFromJSON(json: any): User {
@@ -87,6 +100,7 @@ export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User
         'password': !exists(json, 'password') ? undefined : json['password'],
         'phone': !exists(json, 'phone') ? undefined : json['phone'],
         'userStatus': !exists(json, 'userStatus') ? undefined : json['userStatus'],
+        'userType': !exists(json, 'userType') ? undefined : UserTypeFromJSON(json['userType']),
     };
 }
 
@@ -107,6 +121,7 @@ export function UserToJSON(value?: User | null): any {
         'password': value.password,
         'phone': value.phone,
         'userStatus': value.userStatus,
+        'userType': UserTypeToJSON(value.userType),
     };
 }
 
diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/UserType.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/UserType.ts
new file mode 100644
index 00000000000..5ff2e0dff04
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/UserType.ts
@@ -0,0 +1,36 @@
+/* tslint:disable */
+/* eslint-disable */
+/**
+ * OpenAPI Petstore
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+/**
+ * 
+ * @export
+ * @enum {string}
+ */
+export enum UserType {
+    Admin = 'admin',
+    User = 'user'
+}
+
+export function UserTypeFromJSON(json: any): UserType {
+    return UserTypeFromJSONTyped(json, false);
+}
+
+export function UserTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): UserType {
+    return json as UserType;
+}
+
+export function UserTypeToJSON(value?: UserType | null): any {
+    return value as any;
+}
+
diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts
index b2f6e6f9b34..06f259207a0 100644
--- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts
+++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts
@@ -46,3 +46,4 @@ export * from './Return';
 export * from './SpecialModelName';
 export * from './Tag';
 export * from './User';
+export * from './UserType';
diff --git a/samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/doc/UserType.md b/samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/doc/UserType.md
new file mode 100644
index 00000000000..b56ddc66eb7
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/doc/UserType.md
@@ -0,0 +1,14 @@
+# openapi.model.UserType
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+[[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-next/dio_http_petstore_client_lib_fake/lib/src/model/user_type.dart b/samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/lib/src/model/user_type.dart
new file mode 100644
index 00000000000..a90c44f6f4b
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/lib/src/model/user_type.dart
@@ -0,0 +1,33 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'user_type.g.dart';
+
+class UserType extends EnumClass {
+
+  @BuiltValueEnumConst(wireName: r'admin')
+  static const UserType admin = _$admin;
+  @BuiltValueEnumConst(wireName: r'user')
+  static const UserType user = _$user;
+
+  static Serializer<UserType> get serializer => _$userTypeSerializer;
+
+  const UserType._(String name): super(name);
+
+  static BuiltSet<UserType> get values => _$values;
+  static UserType valueOf(String name) => _$valueOf(name);
+}
+
+/// Optionally, enum_class can generate a mixin to go with your enum for use
+/// with Angular. It exposes your enum constants as getters. So, if you mix it
+/// in to your Dart component class, the values become available to the
+/// corresponding Angular template.
+///
+/// Trigger mixin generation by writing a line like this one next to your enum.
+abstract class UserTypeMixin = Object with _$UserTypeMixin;
+
diff --git a/samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/test/user_type_test.dart b/samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/test/user_type_test.dart
new file mode 100644
index 00000000000..0ceb0f20872
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake/test/user_type_test.dart
@@ -0,0 +1,9 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for UserType
+void main() {
+
+  group(UserType, () {
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/.openapi-generator/FILES
index ae28fd24bea..6f14e15b683 100644
--- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/.openapi-generator/FILES
+++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/.openapi-generator/FILES
@@ -54,6 +54,7 @@ doc/StoreApi.md
 doc/Tag.md
 doc/User.md
 doc/UserApi.md
+doc/UserType.md
 lib/openapi.dart
 lib/src/api.dart
 lib/src/api/another_fake_api.dart
@@ -117,5 +118,6 @@ lib/src/model/read_only_first.dart
 lib/src/model/special_model_name.dart
 lib/src/model/tag.dart
 lib/src/model/user.dart
+lib/src/model/user_type.dart
 lib/src/serializers.dart
 pubspec.yaml
diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/README.md
index 52553e236b0..eacb4337d45 100644
--- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/README.md
+++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/README.md
@@ -155,6 +155,7 @@ Class | Method | HTTP request | Description
  - [SpecialModelName](doc/SpecialModelName.md)
  - [Tag](doc/Tag.md)
  - [User](doc/User.md)
+ - [UserType](doc/UserType.md)
 
 
 ## Documentation For Authorization
diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/User.md b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/User.md
index fa87e64d859..0f0490bac19 100644
--- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/User.md
+++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/User.md
@@ -16,6 +16,7 @@ Name | Type | Description | Notes
 **password** | **String** |  | [optional] 
 **phone** | **String** |  | [optional] 
 **userStatus** | **int** | User Status | [optional] 
+**userType** | [**UserType**](UserType.md) |  | [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-next/petstore_client_lib_fake/doc/UserType.md b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/UserType.md
new file mode 100644
index 00000000000..b56ddc66eb7
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/doc/UserType.md
@@ -0,0 +1,14 @@
+# openapi.model.UserType
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+[[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-next/petstore_client_lib_fake/lib/openapi.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/openapi.dart
index 5dbf2a6964d..38d0e8089b8 100644
--- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/openapi.dart
+++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/openapi.dart
@@ -63,3 +63,4 @@ export 'package:openapi/src/model/read_only_first.dart';
 export 'package:openapi/src/model/special_model_name.dart';
 export 'package:openapi/src/model/tag.dart';
 export 'package:openapi/src/model/user.dart';
+export 'package:openapi/src/model/user_type.dart';
diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user.dart
index d590c20bdc7..d5029625a90 100644
--- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user.dart
+++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user.dart
@@ -2,6 +2,7 @@
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
 
+import 'package:openapi/src/model/user_type.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -18,6 +19,7 @@ part 'user.g.dart';
 /// * [password] 
 /// * [phone] 
 /// * [userStatus] - User Status
+/// * [userType] 
 abstract class User implements Built<User, UserBuilder> {
     @BuiltValueField(wireName: r'id')
     int? get id;
@@ -44,6 +46,9 @@ abstract class User implements Built<User, UserBuilder> {
     @BuiltValueField(wireName: r'userStatus')
     int? get userStatus;
 
+    @BuiltValueField(wireName: r'userType')
+    UserType? get userType;
+
     User._();
 
     @BuiltValueHook(initializeBuilder: true)
@@ -114,6 +119,12 @@ class _$UserSerializer implements StructuredSerializer<User> {
                 ..add(serializers.serialize(object.userStatus,
                     specifiedType: const FullType(int)));
         }
+        if (object.userType != null) {
+            result
+                ..add(r'userType')
+                ..add(serializers.serialize(object.userType,
+                    specifiedType: const FullType.nullable(UserType)));
+        }
         return result;
     }
 
@@ -169,6 +180,12 @@ class _$UserSerializer implements StructuredSerializer<User> {
                         specifiedType: const FullType(int)) as int;
                     result.userStatus = valueDes;
                     break;
+                case r'userType':
+                    final valueDes = serializers.deserialize(value,
+                        specifiedType: const FullType.nullable(UserType)) as UserType?;
+                    if (valueDes == null) continue;
+                    result.userType = valueDes;
+                    break;
             }
         }
         return result.build();
diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user_type.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user_type.dart
new file mode 100644
index 00000000000..a90c44f6f4b
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user_type.dart
@@ -0,0 +1,33 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'user_type.g.dart';
+
+class UserType extends EnumClass {
+
+  @BuiltValueEnumConst(wireName: r'admin')
+  static const UserType admin = _$admin;
+  @BuiltValueEnumConst(wireName: r'user')
+  static const UserType user = _$user;
+
+  static Serializer<UserType> get serializer => _$userTypeSerializer;
+
+  const UserType._(String name): super(name);
+
+  static BuiltSet<UserType> get values => _$values;
+  static UserType valueOf(String name) => _$valueOf(name);
+}
+
+/// Optionally, enum_class can generate a mixin to go with your enum for use
+/// with Angular. It exposes your enum constants as getters. So, if you mix it
+/// in to your Dart component class, the values become available to the
+/// corresponding Angular template.
+///
+/// Trigger mixin generation by writing a line like this one next to your enum.
+abstract class UserTypeMixin = Object with _$UserTypeMixin;
+
diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/serializers.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/serializers.dart
index 5ee82d7b501..c89e8051f52 100644
--- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/serializers.dart
+++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/serializers.dart
@@ -58,6 +58,7 @@ import 'package:openapi/src/model/read_only_first.dart';
 import 'package:openapi/src/model/special_model_name.dart';
 import 'package:openapi/src/model/tag.dart';
 import 'package:openapi/src/model/user.dart';
+import 'package:openapi/src/model/user_type.dart';
 
 part 'serializers.g.dart';
 
@@ -108,6 +109,7 @@ part 'serializers.g.dart';
   SpecialModelName,
   Tag,
   User,
+  UserType,
 ])
 Serializers serializers = (_$serializers.toBuilder()
       ..addBuilderFactory(
diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/test/user_type_test.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/test/user_type_test.dart
new file mode 100644
index 00000000000..0ceb0f20872
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/test/user_type_test.dart
@@ -0,0 +1,9 @@
+import 'package:test/test.dart';
+import 'package:openapi/openapi.dart';
+
+// tests for UserType
+void main() {
+
+  group(UserType, () {
+  });
+}
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES
index 0bc4975ff75..864cce2a123 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES
@@ -54,6 +54,7 @@ doc/StoreApi.md
 doc/Tag.md
 doc/User.md
 doc/UserApi.md
+doc/UserType.md
 lib/api.dart
 lib/api/another_fake_api.dart
 lib/api/default_api.dart
@@ -113,5 +114,6 @@ lib/model/read_only_first.dart
 lib/model/special_model_name.dart
 lib/model/tag.dart
 lib/model/user.dart
+lib/model/user_type.dart
 lib/serializers.dart
 pubspec.yaml
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md
index e03bec1228a..459cd81cf2d 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md
@@ -149,6 +149,7 @@ Class | Method | HTTP request | Description
  - [SpecialModelName](doc/SpecialModelName.md)
  - [Tag](doc/Tag.md)
  - [User](doc/User.md)
+ - [UserType](doc/UserType.md)
 
 
 ## Documentation For Authorization
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/User.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/User.md
index fa87e64d859..0f0490bac19 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/User.md
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/User.md
@@ -16,6 +16,7 @@ Name | Type | Description | Notes
 **password** | **String** |  | [optional] 
 **phone** | **String** |  | [optional] 
 **userStatus** | **int** | User Status | [optional] 
+**userType** | [**UserType**](UserType.md) |  | [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/petstore_client_lib_fake/doc/UserType.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/UserType.md
new file mode 100644
index 00000000000..b56ddc66eb7
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/UserType.md
@@ -0,0 +1,14 @@
+# openapi.model.UserType
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+[[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/petstore_client_lib_fake/lib/model/user.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/user.dart
index a13b71072c2..90c029cf819 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/user.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/user.dart
@@ -5,6 +5,7 @@
 
 // ignore_for_file: unused_import
 
+import 'package:openapi/model/user_type.dart';
 import 'package:built_value/built_value.dart';
 import 'package:built_value/serializer.dart';
 
@@ -45,6 +46,10 @@ abstract class User implements Built<User, UserBuilder> {
     @BuiltValueField(wireName: r'userStatus')
     int get userStatus;
 
+    @nullable
+    @BuiltValueField(wireName: r'userType')
+    UserType get userType;
+
     User._();
 
     static void _initializeBuilder(UserBuilder b) => b;
@@ -114,6 +119,12 @@ class _$UserSerializer implements StructuredSerializer<User> {
                 ..add(serializers.serialize(object.userStatus,
                     specifiedType: const FullType(int)));
         }
+        if (object.userType != null) {
+            result
+                ..add(r'userType')
+                ..add(serializers.serialize(object.userType,
+                    specifiedType: const FullType(UserType)));
+        }
         return result;
     }
 
@@ -160,6 +171,10 @@ class _$UserSerializer implements StructuredSerializer<User> {
                     result.userStatus = serializers.deserialize(value,
                         specifiedType: const FullType(int)) as int;
                     break;
+                case r'userType':
+                    result.userType = serializers.deserialize(value,
+                        specifiedType: const FullType(UserType)) as UserType;
+                    break;
             }
         }
         return result.build();
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/user_type.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/user_type.dart
new file mode 100644
index 00000000000..a6c046afac3
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/user_type.dart
@@ -0,0 +1,36 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+// @dart=2.7
+
+// ignore_for_file: unused_import
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part 'user_type.g.dart';
+
+class UserType extends EnumClass {
+
+  @BuiltValueEnumConst(wireName: r'admin')
+  static const UserType admin = _$admin;
+  @BuiltValueEnumConst(wireName: r'user')
+  static const UserType user = _$user;
+
+  static Serializer<UserType> get serializer => _$userTypeSerializer;
+
+  const UserType._(String name): super(name);
+
+  static BuiltSet<UserType> get values => _$values;
+  static UserType valueOf(String name) => _$valueOf(name);
+}
+
+/// Optionally, enum_class can generate a mixin to go with your enum for use
+/// with Angular. It exposes your enum constants as getters. So, if you mix it
+/// in to your Dart component class, the values become available to the
+/// corresponding Angular template.
+///
+/// Trigger mixin generation by writing a line like this one next to your enum.
+abstract class UserTypeMixin = Object with _$UserTypeMixin;
+
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/serializers.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/serializers.dart
index f0dc864e2e2..abea4a1e5d1 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/serializers.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/serializers.dart
@@ -59,6 +59,7 @@ import 'package:openapi/model/read_only_first.dart';
 import 'package:openapi/model/special_model_name.dart';
 import 'package:openapi/model/tag.dart';
 import 'package:openapi/model/user.dart';
+import 'package:openapi/model/user_type.dart';
 
 part 'serializers.g.dart';
 
@@ -109,6 +110,7 @@ part 'serializers.g.dart';
   SpecialModelName,
   Tag,
   User,
+  UserType,
 ])
 Serializers serializers = (_$serializers.toBuilder()
       ..addBuilderFactory(
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/user_type_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/user_type_test.dart
new file mode 100644
index 00000000000..59dd2f6a08b
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/user_type_test.dart
@@ -0,0 +1,18 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+// @dart=2.7
+
+// ignore_for_file: unused_import
+
+import 'package:openapi/model/user_type.dart';
+import 'package:test/test.dart';
+
+// tests for UserType
+void main() {
+
+  group(UserType, () {
+
+  });
+
+}
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES
index 15809529435..2ca18faf070 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES
@@ -55,6 +55,7 @@ doc/StoreApi.md
 doc/Tag.md
 doc/User.md
 doc/UserApi.md
+doc/UserType.md
 git_push.sh
 lib/api.dart
 lib/api/another_fake_api.dart
@@ -118,4 +119,5 @@ lib/model/read_only_first.dart
 lib/model/special_model_name.dart
 lib/model/tag.dart
 lib/model/user.dart
+lib/model/user_type.dart
 pubspec.yaml
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md
index 40871455141..52f3b6fb656 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md
@@ -149,6 +149,7 @@ Class | Method | HTTP request | Description
  - [SpecialModelName](doc//SpecialModelName.md)
  - [Tag](doc//Tag.md)
  - [User](doc//User.md)
+ - [UserType](doc//UserType.md)
 
 
 ## Documentation For Authorization
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/User.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/User.md
index fa87e64d859..0f0490bac19 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/User.md
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/User.md
@@ -16,6 +16,7 @@ Name | Type | Description | Notes
 **password** | **String** |  | [optional] 
 **phone** | **String** |  | [optional] 
 **userStatus** | **int** | User Status | [optional] 
+**userType** | [**UserType**](UserType.md) |  | [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/dart2/petstore_client_lib_fake/doc/UserType.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/UserType.md
new file mode 100644
index 00000000000..b56ddc66eb7
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/UserType.md
@@ -0,0 +1,14 @@
+# openapi.model.UserType
+
+## Load the model package
+```dart
+import 'package:openapi/api.dart';
+```
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+[[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/dart2/petstore_client_lib_fake/lib/api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart
index 48f61a0d5f5..0e46005857c 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart
@@ -81,6 +81,7 @@ part 'model/read_only_first.dart';
 part 'model/special_model_name.dart';
 part 'model/tag.dart';
 part 'model/user.dart';
+part 'model/user_type.dart';
 
 
 const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart
index 8277ac92e7c..96970f6049a 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart
@@ -305,6 +305,8 @@ class ApiClient {
           return Tag.fromJson(value);
         case 'User':
           return User.fromJson(value);
+        case 'UserType':
+          return UserTypeTypeTransformer().decode(value);
         default:
           dynamic match;
           if (value is List && (match = _regList.firstMatch(targetType)?.group(1)) != null) {
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart
index 1aaf1dae8eb..69abe141cb0 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart
@@ -70,6 +70,9 @@ String parameterToString(dynamic value) {
   if (value is OuterEnumIntegerDefaultValue) {
     return OuterEnumIntegerDefaultValueTypeTransformer().encode(value).toString();
   }
+  if (value is UserType) {
+    return UserTypeTypeTransformer().encode(value).toString();
+  }
   return value.toString();
 }
 
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart
index 0b10d4fe7c2..3318f9019f3 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart
@@ -21,6 +21,7 @@ class User {
     this.password,
     this.phone,
     this.userStatus,
+    this.userType,
   });
 
   ///
@@ -88,6 +89,8 @@ class User {
   ///
   int? userStatus;
 
+  UserType userType;
+
   @override
   bool operator ==(Object other) => identical(this, other) || other is User &&
      other.id == id &&
@@ -97,7 +100,8 @@ class User {
      other.email == email &&
      other.password == password &&
      other.phone == phone &&
-     other.userStatus == userStatus;
+     other.userStatus == userStatus &&
+     other.userType == userType;
 
   @override
   int get hashCode =>
@@ -109,10 +113,11 @@ class User {
     (email == null ? 0 : email!.hashCode) +
     (password == null ? 0 : password!.hashCode) +
     (phone == null ? 0 : phone!.hashCode) +
-    (userStatus == null ? 0 : userStatus!.hashCode);
+    (userStatus == null ? 0 : userStatus!.hashCode) +
+    (userType == null ? 0 : userType.hashCode);
 
   @override
-  String toString() => 'User[id=$id, username=$username, firstName=$firstName, lastName=$lastName, email=$email, password=$password, phone=$phone, userStatus=$userStatus]';
+  String toString() => 'User[id=$id, username=$username, firstName=$firstName, lastName=$lastName, email=$email, password=$password, phone=$phone, userStatus=$userStatus, userType=$userType]';
 
   Map<String, dynamic> toJson() {
     final json = <String, dynamic>{};
@@ -140,6 +145,9 @@ class User {
     if (userStatus != null) {
       json[r'userStatus'] = userStatus;
     }
+    if (userType != null) {
+      json[r'userType'] = userType;
+    }
     return json;
   }
 
@@ -170,6 +178,7 @@ class User {
         password: mapValueOfType<String>(json, r'password'),
         phone: mapValueOfType<String>(json, r'phone'),
         userStatus: mapValueOfType<int>(json, r'userStatus'),
+        userType: UserType.fromJson(json[r'userType']),
       );
     }
     return null;
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user_type.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user_type.dart
new file mode 100644
index 00000000000..21b47424805
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user_type.dart
@@ -0,0 +1,78 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+// @dart=2.0
+
+// ignore_for_file: unused_element, unused_import
+// ignore_for_file: always_put_required_named_parameters_first
+// ignore_for_file: constant_identifier_names
+// ignore_for_file: lines_longer_than_80_chars
+
+part of openapi.api;
+
+
+class UserType {
+  /// Instantiate a new enum with the provided [value].
+  const UserType._(this.value);
+
+  /// The underlying value of this enum member.
+  final String value;
+
+  @override
+  String toString() => value ?? '';
+
+  String toJson() => value;
+
+  static const admin = UserType._(r'admin');
+  static const user = UserType._(r'user');
+
+  /// List of all possible values in this [enum][UserType].
+  static const values = <UserType>[
+    admin,
+    user,
+  ];
+
+  static UserType fromJson(dynamic value) =>
+    UserTypeTypeTransformer().decode(value);
+
+  static List<UserType> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
+    json is List && json.isNotEmpty
+      ? json.map(UserType.fromJson).toList(growable: true == growable)
+      : true == emptyIsNull ? null : <UserType>[];
+}
+
+/// Transformation class that can [encode] an instance of [UserType] to String,
+/// and [decode] dynamic data back to [UserType].
+class UserTypeTypeTransformer {
+  factory UserTypeTypeTransformer() => _instance ??= const UserTypeTypeTransformer._();
+
+  const UserTypeTypeTransformer._();
+
+  String encode(UserType data) => data.value;
+
+  /// Decodes a [dynamic value][data] to a UserType.
+  ///
+  /// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
+  /// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
+  /// cannot be decoded successfully, then an [UnimplementedError] is thrown.
+  ///
+  /// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
+  /// and users are still using an old app with the old code.
+  UserType decode(dynamic data, {bool allowNull}) {
+    if (data != null) {
+      switch (data.toString()) {
+        case r'admin': return UserType.admin;
+        case r'user': return UserType.user;
+        default:
+          if (allowNull == false) {
+            throw ArgumentError('Unknown enum value to decode: $data');
+          }
+      }
+    }
+    return null;
+  }
+
+  /// Singleton [UserTypeTypeTransformer] instance.
+  static UserTypeTypeTransformer _instance;
+}
+
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/user_type_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/user_type_test.dart
new file mode 100644
index 00000000000..f9c228b8c5f
--- /dev/null
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/user_type_test.dart
@@ -0,0 +1,21 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
+// @dart=2.0
+
+// ignore_for_file: unused_element, unused_import
+// ignore_for_file: always_put_required_named_parameters_first
+// ignore_for_file: constant_identifier_names
+// ignore_for_file: lines_longer_than_80_chars
+
+import 'package:openapi/api.dart';
+import 'package:test/test.dart';
+
+// tests for UserType
+void main() {
+
+  group('test UserType', () {
+
+  });
+
+}
diff --git a/samples/openapi3/client/petstore/python-legacy/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-legacy/.openapi-generator/FILES
index 4b8573e4117..5c7a2e159a8 100755
--- a/samples/openapi3/client/petstore/python-legacy/.openapi-generator/FILES
+++ b/samples/openapi3/client/petstore/python-legacy/.openapi-generator/FILES
@@ -55,6 +55,7 @@ docs/StoreApi.md
 docs/Tag.md
 docs/User.md
 docs/UserApi.md
+docs/UserType.md
 git_push.sh
 petstore_api/__init__.py
 petstore_api/api/__init__.py
@@ -115,6 +116,7 @@ petstore_api/models/read_only_first.py
 petstore_api/models/special_model_name.py
 petstore_api/models/tag.py
 petstore_api/models/user.py
+petstore_api/models/user_type.py
 petstore_api/rest.py
 requirements.txt
 setup.cfg
diff --git a/samples/openapi3/client/petstore/python-legacy/README.md b/samples/openapi3/client/petstore/python-legacy/README.md
index a508c7e3d21..326fcc294bb 100755
--- a/samples/openapi3/client/petstore/python-legacy/README.md
+++ b/samples/openapi3/client/petstore/python-legacy/README.md
@@ -172,6 +172,7 @@ Class | Method | HTTP request | Description
  - [SpecialModelName](docs/SpecialModelName.md)
  - [Tag](docs/Tag.md)
  - [User](docs/User.md)
+ - [UserType](docs/UserType.md)
 
 
 ## Documentation For Authorization
diff --git a/samples/openapi3/client/petstore/python-legacy/docs/User.md b/samples/openapi3/client/petstore/python-legacy/docs/User.md
index b0079f591b6..7b04655ad48 100755
--- a/samples/openapi3/client/petstore/python-legacy/docs/User.md
+++ b/samples/openapi3/client/petstore/python-legacy/docs/User.md
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
 **password** | **str** |  | [optional] 
 **phone** | **str** |  | [optional] 
 **user_status** | **int** | User Status | [optional] 
+**user_type** | [**UserType**](UserType.md) |  | [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/python-legacy/docs/UserType.md b/samples/openapi3/client/petstore/python-legacy/docs/UserType.md
new file mode 100644
index 00000000000..cb85928a7bc
--- /dev/null
+++ b/samples/openapi3/client/petstore/python-legacy/docs/UserType.md
@@ -0,0 +1,10 @@
+# UserType
+
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+[[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/python-legacy/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/__init__.py
index 420638f9293..56c2dc655df 100755
--- a/samples/openapi3/client/petstore/python-legacy/petstore_api/__init__.py
+++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/__init__.py
@@ -81,4 +81,5 @@ from petstore_api.models.read_only_first import ReadOnlyFirst
 from petstore_api.models.special_model_name import SpecialModelName
 from petstore_api.models.tag import Tag
 from petstore_api.models.user import User
+from petstore_api.models.user_type import UserType
 
diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/__init__.py
index af74db1c258..eab3a22d791 100755
--- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/__init__.py
+++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/__init__.py
@@ -60,3 +60,4 @@ from petstore_api.models.read_only_first import ReadOnlyFirst
 from petstore_api.models.special_model_name import SpecialModelName
 from petstore_api.models.tag import Tag
 from petstore_api.models.user import User
+from petstore_api.models.user_type import UserType
diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user.py
index 7ae2898f6c5..e8881f4287f 100755
--- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user.py
+++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user.py
@@ -43,7 +43,8 @@ class User(object):
         'email': 'str',
         'password': 'str',
         'phone': 'str',
-        'user_status': 'int'
+        'user_status': 'int',
+        'user_type': 'UserType'
     }
 
     attribute_map = {
@@ -54,10 +55,11 @@ class User(object):
         'email': 'email',
         'password': 'password',
         'phone': 'phone',
-        'user_status': 'userStatus'
+        'user_status': 'userStatus',
+        'user_type': 'userType'
     }
 
-    def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None, local_vars_configuration=None):  # noqa: E501
+    def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None, user_type=None, local_vars_configuration=None):  # noqa: E501
         """User - a model defined in OpenAPI"""  # noqa: E501
         if local_vars_configuration is None:
             local_vars_configuration = Configuration.get_default_copy()
@@ -71,6 +73,7 @@ class User(object):
         self._password = None
         self._phone = None
         self._user_status = None
+        self._user_type = None
         self.discriminator = None
 
         if id is not None:
@@ -89,6 +92,7 @@ class User(object):
             self.phone = phone
         if user_status is not None:
             self.user_status = user_status
+        self.user_type = user_type
 
     @property
     def id(self):
@@ -260,6 +264,27 @@ class User(object):
 
         self._user_status = user_status
 
+    @property
+    def user_type(self):
+        """Gets the user_type of this User.  # noqa: E501
+
+
+        :return: The user_type of this User.  # noqa: E501
+        :rtype: UserType
+        """
+        return self._user_type
+
+    @user_type.setter
+    def user_type(self, user_type):
+        """Sets the user_type of this User.
+
+
+        :param user_type: The user_type of this User.  # noqa: E501
+        :type user_type: UserType
+        """
+
+        self._user_type = user_type
+
     def to_dict(self, serialize=False):
         """Returns the model properties as a dict"""
         result = {}
diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user_type.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user_type.py
new file mode 100644
index 00000000000..719694f8995
--- /dev/null
+++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user_type.py
@@ -0,0 +1,111 @@
+# coding: utf-8
+
+"""
+    OpenAPI Petstore
+
+    This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\  # noqa: E501
+
+    The version of the OpenAPI document: 1.0.0
+    Generated by: https://openapi-generator.tech
+"""
+
+
+try:
+    from inspect import getfullargspec
+except ImportError:
+    from inspect import getargspec as getfullargspec
+import pprint
+import re  # noqa: F401
+import six
+
+from petstore_api.configuration import Configuration
+
+
+class UserType(object):
+    """NOTE: This class is auto generated by OpenAPI Generator.
+    Ref: https://openapi-generator.tech
+
+    Do not edit the class manually.
+    """
+
+    """
+    allowed enum values
+    """
+    ADMIN = "admin"
+    USER = "user"
+
+    allowable_values = [ADMIN, USER]  # noqa: E501
+
+    """
+    Attributes:
+      openapi_types (dict): The key is attribute name
+                            and the value is attribute type.
+      attribute_map (dict): The key is attribute name
+                            and the value is json key in definition.
+    """
+    openapi_types = {
+    }
+
+    attribute_map = {
+    }
+
+    def __init__(self, local_vars_configuration=None):  # noqa: E501
+        """UserType - a model defined in OpenAPI"""  # noqa: E501
+        if local_vars_configuration is None:
+            local_vars_configuration = Configuration.get_default_copy()
+        self.local_vars_configuration = local_vars_configuration
+        self.discriminator = None
+
+    def to_dict(self, serialize=False):
+        """Returns the model properties as a dict"""
+        result = {}
+
+        def convert(x):
+            if hasattr(x, "to_dict"):
+                args = getfullargspec(x.to_dict).args
+                if len(args) == 1:
+                    return x.to_dict()
+                else:
+                    return x.to_dict(serialize)
+            else:
+                return x
+
+        for attr, _ in six.iteritems(self.openapi_types):
+            value = getattr(self, attr)
+            attr = self.attribute_map.get(attr, attr) if serialize else attr
+            if isinstance(value, list):
+                result[attr] = list(map(
+                    lambda x: convert(x),
+                    value
+                ))
+            elif isinstance(value, dict):
+                result[attr] = dict(map(
+                    lambda item: (item[0], convert(item[1])),
+                    value.items()
+                ))
+            else:
+                result[attr] = convert(value)
+
+        return result
+
+    def to_str(self):
+        """Returns the string representation of the model"""
+        return pprint.pformat(self.to_dict())
+
+    def __repr__(self):
+        """For `print` and `pprint`"""
+        return self.to_str()
+
+    def __eq__(self, other):
+        """Returns true if both objects are equal"""
+        if not isinstance(other, UserType):
+            return False
+
+        return self.to_dict() == other.to_dict()
+
+    def __ne__(self, other):
+        """Returns true if both objects are not equal"""
+        if not isinstance(other, UserType):
+            return True
+
+        return self.to_dict() != other.to_dict()
diff --git a/samples/openapi3/client/petstore/python-legacy/test/test_user_type.py b/samples/openapi3/client/petstore/python-legacy/test/test_user_type.py
new file mode 100644
index 00000000000..3b776c0cd06
--- /dev/null
+++ b/samples/openapi3/client/petstore/python-legacy/test/test_user_type.py
@@ -0,0 +1,50 @@
+# coding: utf-8
+
+"""
+    OpenAPI Petstore
+
+    This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\  # noqa: E501
+
+    The version of the OpenAPI document: 1.0.0
+    Generated by: https://openapi-generator.tech
+"""
+
+
+from __future__ import absolute_import
+
+import unittest
+import datetime
+
+import petstore_api
+from petstore_api.models.user_type import UserType  # noqa: E501
+from petstore_api.rest import ApiException
+
+class TestUserType(unittest.TestCase):
+    """UserType unit test stubs"""
+
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+    def make_instance(self, include_optional):
+        """Test UserType
+            include_option is a boolean, when False only required
+            params are included, when True both required and
+            optional params are included """
+        # model = petstore_api.models.user_type.UserType()  # noqa: E501
+        if include_optional :
+            return UserType(
+            )
+        else :
+            return UserType(
+        )
+
+    def testUserType(self):
+        """Test UserType"""
+        inst_req_only = self.make_instance(include_optional=False)
+        inst_req_and_optional = self.make_instance(include_optional=True)
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/samples/schema/petstore/mysql/.openapi-generator/FILES b/samples/schema/petstore/mysql/.openapi-generator/FILES
index 59f8ea7241a..321866d6c0b 100644
--- a/samples/schema/petstore/mysql/.openapi-generator/FILES
+++ b/samples/schema/petstore/mysql/.openapi-generator/FILES
@@ -44,5 +44,6 @@ Model/Return.sql
 Model/SpecialModelName.sql
 Model/Tag.sql
 Model/User.sql
+Model/UserType.sql
 README.md
 mysql_schema.sql
diff --git a/samples/schema/petstore/mysql/Model/User.sql b/samples/schema/petstore/mysql/Model/User.sql
index 91afbc9e245..f7ee87c3e92 100644
--- a/samples/schema/petstore/mysql/Model/User.sql
+++ b/samples/schema/petstore/mysql/Model/User.sql
@@ -7,17 +7,17 @@
 --
 -- SELECT template for table `User`
 --
-SELECT `id`, `username`, `firstName`, `lastName`, `email`, `password`, `phone`, `userStatus` FROM `User` WHERE 1;
+SELECT `id`, `username`, `firstName`, `lastName`, `email`, `password`, `phone`, `userStatus`, `userType` FROM `User` WHERE 1;
 
 --
 -- INSERT template for table `User`
 --
-INSERT INTO `User`(`id`, `username`, `firstName`, `lastName`, `email`, `password`, `phone`, `userStatus`) VALUES (?, ?, ?, ?, ?, ?, ?, ?);
+INSERT INTO `User`(`id`, `username`, `firstName`, `lastName`, `email`, `password`, `phone`, `userStatus`, `userType`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
 
 --
 -- UPDATE template for table `User`
 --
-UPDATE `User` SET `id` = ?, `username` = ?, `firstName` = ?, `lastName` = ?, `email` = ?, `password` = ?, `phone` = ?, `userStatus` = ? WHERE 1;
+UPDATE `User` SET `id` = ?, `username` = ?, `firstName` = ?, `lastName` = ?, `email` = ?, `password` = ?, `phone` = ?, `userStatus` = ?, `userType` = ? WHERE 1;
 
 --
 -- DELETE template for table `User`
diff --git a/samples/schema/petstore/mysql/Model/UserType.sql b/samples/schema/petstore/mysql/Model/UserType.sql
new file mode 100644
index 00000000000..43d7b16cb17
--- /dev/null
+++ b/samples/schema/petstore/mysql/Model/UserType.sql
@@ -0,0 +1,26 @@
+--
+-- OpenAPI Petstore.
+-- Prepared SQL queries for 'UserType' definition.
+--
+
+
+--
+-- SELECT template for table `UserType`
+--
+SELECT  FROM `UserType` WHERE 1;
+
+--
+-- INSERT template for table `UserType`
+--
+INSERT INTO `UserType`() VALUES ();
+
+--
+-- UPDATE template for table `UserType`
+--
+UPDATE `UserType` SET  WHERE 1;
+
+--
+-- DELETE template for table `UserType`
+--
+DELETE FROM `UserType` WHERE 0;
+
diff --git a/samples/schema/petstore/mysql/mysql_schema.sql b/samples/schema/petstore/mysql/mysql_schema.sql
index a189b16c3ab..eaf70bf177d 100644
--- a/samples/schema/petstore/mysql/mysql_schema.sql
+++ b/samples/schema/petstore/mysql/mysql_schema.sql
@@ -421,7 +421,8 @@ CREATE TABLE IF NOT EXISTS `User` (
   `email` TEXT DEFAULT NULL,
   `password` TEXT DEFAULT NULL,
   `phone` TEXT DEFAULT NULL,
-  `userStatus` INT DEFAULT NULL COMMENT 'User Status'
+  `userStatus` INT DEFAULT NULL COMMENT 'User Status',
+  `userType` TEXT DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
diff --git a/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES b/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES
index 910d1c2a90b..a1f4987de89 100644
--- a/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES
+++ b/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES
@@ -67,6 +67,7 @@ src/gen/java/org/openapitools/model/ReadOnlyFirst.java
 src/gen/java/org/openapitools/model/SpecialModelName.java
 src/gen/java/org/openapitools/model/Tag.java
 src/gen/java/org/openapitools/model/User.java
+src/gen/java/org/openapitools/model/UserType.java
 src/main/java/org/openapitools/api/Bootstrap.java
 src/main/java/org/openapitools/api/factories/AnotherFakeApiServiceFactory.java
 src/main/java/org/openapitools/api/factories/FakeApiServiceFactory.java
diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/User.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/User.java
index 26261801d0b..d83cbb29d0a 100644
--- a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/User.java
+++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/User.java
@@ -18,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonCreator;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import org.openapitools.model.UserType;
 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
 import javax.validation.constraints.*;
 import javax.validation.Valid;
@@ -33,7 +34,8 @@ import javax.validation.Valid;
   User.JSON_PROPERTY_EMAIL,
   User.JSON_PROPERTY_PASSWORD,
   User.JSON_PROPERTY_PHONE,
-  User.JSON_PROPERTY_USER_STATUS
+  User.JSON_PROPERTY_USER_STATUS,
+  User.JSON_PROPERTY_USER_TYPE
 })
 @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen")
 public class User   {
@@ -69,6 +71,10 @@ public class User   {
   @JsonProperty(JSON_PROPERTY_USER_STATUS)
   private Integer userStatus;
 
+  public static final String JSON_PROPERTY_USER_TYPE = "userType";
+  @JsonProperty(JSON_PROPERTY_USER_TYPE)
+  private UserType userType;
+
   public User id(Long id) {
     this.id = id;
     return this;
@@ -229,6 +235,26 @@ public class User   {
     this.userStatus = userStatus;
   }
 
+  public User userType(UserType userType) {
+    this.userType = userType;
+    return this;
+  }
+
+  /**
+   * Get userType
+   * @return userType
+   **/
+  @JsonProperty(value = "userType")
+  @ApiModelProperty(value = "")
+  @Valid 
+  public UserType getUserType() {
+    return userType;
+  }
+
+  public void setUserType(UserType userType) {
+    this.userType = userType;
+  }
+
 
   @Override
   public boolean equals(Object o) {
@@ -246,12 +272,13 @@ public class User   {
         Objects.equals(this.email, user.email) &&
         Objects.equals(this.password, user.password) &&
         Objects.equals(this.phone, user.phone) &&
-        Objects.equals(this.userStatus, user.userStatus);
+        Objects.equals(this.userStatus, user.userStatus) &&
+        Objects.equals(this.userType, user.userType);
   }
 
   @Override
   public int hashCode() {
-    return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
+    return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus, userType);
   }
 
   @Override
@@ -267,6 +294,7 @@ public class User   {
     sb.append("    password: ").append(toIndentedString(password)).append("\n");
     sb.append("    phone: ").append(toIndentedString(phone)).append("\n");
     sb.append("    userStatus: ").append(toIndentedString(userStatus)).append("\n");
+    sb.append("    userType: ").append(toIndentedString(userType)).append("\n");
     sb.append("}");
     return sb.toString();
   }
diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/UserType.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/UserType.java
new file mode 100644
index 00000000000..b69f52e1704
--- /dev/null
+++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/UserType.java
@@ -0,0 +1,60 @@
+/*
+ * OpenAPI Petstore
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import javax.validation.constraints.*;
+import javax.validation.Valid;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * Gets or Sets UserType
+ */
+public enum UserType {
+  
+  ADMIN("admin"),
+  
+  USER("user");
+
+  private String value;
+
+  UserType(String value) {
+    this.value = value;
+  }
+
+  @JsonValue
+  public String getValue() {
+    return value;
+  }
+
+  @Override
+  public String toString() {
+    return String.valueOf(value);
+  }
+
+  @JsonCreator
+  public static UserType fromValue(String value) {
+    for (UserType b : UserType.values()) {
+      if (b.value.equals(value)) {
+        return b;
+      }
+    }
+    throw new IllegalArgumentException("Unexpected value '" + value + "'");
+  }
+}
+
diff --git a/samples/server/petstore/php-laravel/.openapi-generator/FILES b/samples/server/petstore/php-laravel/.openapi-generator/FILES
index a00cd92d690..0ddc6bbee5f 100644
--- a/samples/server/petstore/php-laravel/.openapi-generator/FILES
+++ b/samples/server/petstore/php-laravel/.openapi-generator/FILES
@@ -68,6 +68,7 @@ lib/app/Models/ReadOnlyFirst.php
 lib/app/Models/SpecialModelName.php
 lib/app/Models/Tag.php
 lib/app/Models/User.php
+lib/app/Models/UserType.php
 lib/app/Providers/AppServiceProvider.php
 lib/app/Providers/AuthServiceProvider.php
 lib/app/Providers/BroadcastServiceProvider.php
diff --git a/samples/server/petstore/php-laravel/lib/app/Models/User.php b/samples/server/petstore/php-laravel/lib/app/Models/User.php
index 3688537ba8c..a68874518f1 100644
--- a/samples/server/petstore/php-laravel/lib/app/Models/User.php
+++ b/samples/server/petstore/php-laravel/lib/app/Models/User.php
@@ -33,4 +33,7 @@ class User {
     /** @var int $userStatus User Status*/
     private $userStatus;
 
+    /** @var UserType $userType */
+    private $userType;
+
 }
diff --git a/samples/server/petstore/php-laravel/lib/app/Models/UserType.php b/samples/server/petstore/php-laravel/lib/app/Models/UserType.php
new file mode 100644
index 00000000000..c94647c8320
--- /dev/null
+++ b/samples/server/petstore/php-laravel/lib/app/Models/UserType.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * UserType
+ */
+namespace app\Models;
+
+/**
+ * UserType
+ */
+class UserType {
+
+}
-- 
GitLab


From 9c2babf1a428e713f742e0aed23ee4be897e1866 Mon Sep 17 00:00:00 2001
From: Peter Leibiger <kuhnroyal@gmail.com>
Date: Wed, 24 Nov 2021 15:19:01 +0100
Subject: [PATCH 2/3] Refactor without vendor extension

---
 .../languages/AbstractDartCodegen.java        | 67 +++++++------------
 .../languages/DartDioClientCodegen.java       |  2 +-
 .../languages/DartDioNextClientCodegen.java   |  2 +-
 .../main/resources/dart-dio/class.mustache    | 19 ++++--
 .../serialization/built_value/class.mustache  | 14 ++--
 .../native/native_class.mustache              |  2 +
 6 files changed, 49 insertions(+), 57 deletions(-)

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
index edace2dee8b..8d121c79c73 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 import java.util.*;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import static org.openapitools.codegen.utils.StringUtils.*;
@@ -512,7 +513,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
     @Override
     public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
         super.postProcessModelProperty(model, property);
-        if (!model.isEnum && property.isEnum) {
+        if (!model.isEnum && property.isEnum && property.getComposedSchemas() == null) {
             // These are inner enums, enums which do not exist as models, just as properties.
             // They are handled via the enum_inline template and are generated in the
             // same file as the containing class. To prevent name clashes the inline enum classes
@@ -537,21 +538,30 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
     @Override
     public CodegenProperty fromProperty(String name, Schema p) {
         final CodegenProperty property = super.fromProperty(name, p);
+
+        // Handle composed properties
         if (ModelUtils.isComposedSchema(p)) {
             ComposedSchema composed = (ComposedSchema) p;
 
-            Stream.of(composed.getAllOf(), composed.getAnyOf(), composed.getOneOf())
-                    .filter(list -> list != null && !list.isEmpty())
-                    .map(list -> list.get(0).get$ref())
-                    .map(ModelUtils::getSimpleRef)
-                    .filter(Objects::nonNull)
-                    .map(ref -> ModelUtils.getSchemas(this.openAPI).get(ref))
-                    .filter(Objects::nonNull)
-                    .findFirst().ifPresent(schema -> {
-                        property.vendorExtensions.put("x-composed-single-schema", new ComposedSingleSchema(
-                                property, schema.getEnum() != null, ModelUtils.isModel(schema)
-                        ));
-                    });
+            // Count the occurrences of allOf/anyOf/oneOf with exactly one child element
+            long count = Stream.of(composed.getAllOf(), composed.getAnyOf(), composed.getOneOf())
+                    .filter(list -> list != null && list.size() == 1).count();
+
+            if (count == 1) {
+                // Continue only if there is one element that matches
+                // and basically treat it as simple property.
+                Stream.of(composed.getAllOf(), composed.getAnyOf(), composed.getOneOf())
+                        .filter(list -> list != null && list.size() == 1)
+                        .findFirst()
+                        .map(list -> list.get(0).get$ref())
+                        .map(ModelUtils::getSimpleRef)
+                        .map(ref -> ModelUtils.getSchemas(this.openAPI).get(ref))
+                        .ifPresent(schema -> {
+                            property.isEnum = schema.getEnum() != null;
+                            property.isModel = true;
+                        });
+
+            }
         }
         return property;
     }
@@ -640,13 +650,6 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
         return prioritizedContentTypes;
     }
 
-    private static boolean isMultipartType(String mediaType) {
-        if (mediaType != null) {
-            return "multipart/form-data".equals(mediaType);
-        }
-        return false;
-    }
-
     @Override
     protected void updateEnumVarsWithExtensions(List<Map<String, Object>> enumVars, Map<String, Object> vendorExtensions, String dataType) {
         if (vendorExtensions != null && useEnumExtension && vendorExtensions.containsKey("x-enum-values")) {
@@ -803,27 +806,3 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
     @Override
     public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.DART; }
 }
-
-class ComposedSingleSchema {
-    final CodegenProperty property;
-    final boolean isEnum;
-    final boolean isModel;
-
-    ComposedSingleSchema(CodegenProperty property, boolean isEnum, boolean isModel) {
-        this.property = property;
-        this.isEnum = isEnum;
-        this.isModel = isModel;
-    }
-
-    public CodegenProperty getProperty() {
-        return property;
-    }
-
-    public boolean isEnum() {
-        return isEnum;
-    }
-
-    public boolean isModel() {
-        return isModel;
-    }
-}
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 c2444fa9348..cbbf4510894 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
@@ -231,7 +231,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
             property.isNullable = true;
         }
 
-        if (property.isEnum) {
+        if (property.isEnum && property.getComposedSchemas() == null) {
             // enums are generated with built_value and make use of BuiltSet
             model.imports.add("BuiltSet");
         }
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java
index e231fc54ccc..bafbfb21188 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java
@@ -305,7 +305,7 @@ public class DartDioNextClientCodegen extends AbstractDartCodegen {
     public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
         super.postProcessModelProperty(model, property);
         if (SERIALIZATION_LIBRARY_BUILT_VALUE.equals(library)) {
-            if (property.isEnum) {
+            if (property.isEnum && property.getComposedSchemas() == null) {
                 // enums are generated with built_value and make use of BuiltSet
                 model.imports.add("BuiltSet");
             }
diff --git a/modules/openapi-generator/src/main/resources/dart-dio/class.mustache b/modules/openapi-generator/src/main/resources/dart-dio/class.mustache
index 1c1f8fe0543..ad801b78b19 100644
--- a/modules/openapi-generator/src/main/resources/dart-dio/class.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-dio/class.mustache
@@ -97,21 +97,28 @@ class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
                     result.{{{name}}}.replace(serializers.deserialize(value,
                         specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}});
                     {{/isContainer}}
+                    {{^isContainer}}
+                    {{#isEnum}}
+                    result.{{{name}}} = serializers.deserialize(value,
+                        specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}};
+                    {{/isEnum}}
+                    {{^isEnum}}
                     {{#isModel}}
-                    {{#vendorExtensions.x-composed-single-schema.isEnum}}
+                    {{#isPrimitiveType}}
+                    {{! These are models that have been manually marked as primitive via generator param. }}    result.{{{name}}} = valueDes;
                     result.{{{name}}} = serializers.deserialize(value,
                         specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}};
-                    {{/vendorExtensions.x-composed-single-schema.isEnum}}
-                    {{^vendorExtensions.x-composed-single-schema}}
+                    {{/isPrimitiveType}}
+                    {{^isPrimitiveType}}
                     result.{{{name}}}.replace(serializers.deserialize(value,
                         specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}});
-                    {{/vendorExtensions.x-composed-single-schema}}
+                    {{/isPrimitiveType}}
                     {{/isModel}}
-                    {{^isContainer}}
                     {{^isModel}}
                     result.{{{name}}} = serializers.deserialize(value,
                         specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}};
                     {{/isModel}}
+                    {{/isEnum}}
                     {{/isContainer}}
                     break;
                 {{/vars}}
@@ -127,6 +134,7 @@ class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
     enum.mustache template.
 }}
 {{#vars}}
+    {{^isModel}}
     {{#isEnum}}
         {{^isContainer}}
 
@@ -139,4 +147,5 @@ class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
             {{/mostInnerItems}}
         {{/isContainer}}
     {{/isEnum}}
+    {{/isModel}}
 {{/vars}}
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 303ee3cab87..66fe59788b0 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
@@ -104,24 +104,24 @@ class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
                     {{#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-composed-single-schema.isEnum}}
-                    result.{{{name}}} = valueDes;
-                    {{/vendorExtensions.x-composed-single-schema.isEnum}}
-                    {{^vendorExtensions.x-composed-single-schema}}
                     result.{{{name}}}.replace(valueDes);
-                    {{/vendorExtensions.x-composed-single-schema}}
                     {{/isPrimitiveType}}
                     {{/isModel}}
-                    {{^isContainer}}
                     {{^isModel}}
                     result.{{{name}}} = valueDes;
                     {{/isModel}}
+                    {{/isEnum}}
                     {{/isContainer}}
                     break;
                 {{/vars}}
@@ -137,6 +137,7 @@ class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
     enum.mustache template.
 }}
 {{#vars}}
+    {{^isModel}}
     {{#isEnum}}
         {{^isContainer}}
 
@@ -149,4 +150,5 @@ class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
             {{/mostInnerItems}}
         {{/isContainer}}
     {{/isEnum}}
+    {{/isModel}}
 {{/vars}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache
index e6a680201fe..a9ec1dc3677 100644
--- a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache
@@ -277,6 +277,7 @@ class {{{classname}}} {
   };
 }
 {{#vars}}
+    {{^isModel}}
     {{#isEnum}}
         {{^isContainer}}
 
@@ -289,4 +290,5 @@ class {{{classname}}} {
             {{/mostInnerItems}}
         {{/isContainer}}
     {{/isEnum}}
+    {{/isModel}}
 {{/vars}}
-- 
GitLab


From 62c109f5efe8bb61935e5d43818b6bcbe2c79568 Mon Sep 17 00:00:00 2001
From: Peter Leibiger <kuhnroyal@gmail.com>
Date: Sun, 10 Apr 2022 19:53:41 +0200
Subject: [PATCH 3/3] Regenerate newer samples

---
 .../petstore/java/webclient/docs/User.md      |  5 +++-
 samples/client/petstore/k6/script.js          |  4 +--
 .../OpenAPIClient-php/lib/Model/UserType.php  |  2 +-
 .../lib/petstore/models/user_type.rb          |  2 +-
 .../ruby/lib/petstore/models/user_type.rb     |  2 +-
 .../builds/default-v3.0/models/UserType.ts    | 12 ++++----
 .../lib/src/model/user_type.dart              |  2 ++
 .../lib/model/user.dart                       |  4 +--
 .../lib/model/user_type.dart                  | 29 ++++++++++++-------
 9 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/samples/client/petstore/java/webclient/docs/User.md b/samples/client/petstore/java/webclient/docs/User.md
index 339c6021330..fe95a82b29f 100644
--- a/samples/client/petstore/java/webclient/docs/User.md
+++ b/samples/client/petstore/java/webclient/docs/User.md
@@ -15,4 +15,7 @@
 |**password** | **String** |  |  [optional] |
 |**phone** | **String** |  |  [optional] |
 |**userStatus** | **Integer** | User Status |  [optional] |
-**userType** | [**UserType**](UserType.md) |  |  [optional] |
+|**userType** | [**UserType**](UserType.md) |  |  [optional] |
+
+
+
diff --git a/samples/client/petstore/k6/script.js b/samples/client/petstore/k6/script.js
index 4febaa387d4..4f336ba1eb6 100644
--- a/samples/client/petstore/k6/script.js
+++ b/samples/client/petstore/k6/script.js
@@ -397,7 +397,7 @@ export default function() {
         {
             let url = BASE_URL + `/fake/body-with-query-params?query=${query}`;
             // TODO: edit the parameters of the request body.
-            let body = {"id": "long", "username": "string", "firstName": "string", "lastName": "string", "email": "string", "password": "string", "phone": "string", "userStatus": "integer"};
+            let body = {"id": "long", "username": "string", "firstName": "string", "lastName": "string", "email": "string", "password": "string", "phone": "string", "userStatus": "integer", "userType": {}};
             let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
             let request = http.put(url, JSON.stringify(body), params);
 
@@ -447,7 +447,7 @@ export default function() {
         {
             let url = BASE_URL + `/user`;
             // TODO: edit the parameters of the request body.
-            let body = {"id": "long", "username": "string", "firstName": "string", "lastName": "string", "email": "string", "password": "string", "phone": "string", "userStatus": "integer"};
+            let body = {"id": "long", "username": "string", "firstName": "string", "lastName": "string", "email": "string", "password": "string", "phone": "string", "userStatus": "integer", "userType": {}};
             let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
             let request = http.post(url, JSON.stringify(body), params);
 
diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/UserType.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/UserType.php
index 42a1ff35f5b..a3f0eccca43 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/UserType.php
+++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/UserType.php
@@ -17,7 +17,7 @@
  *
  * The version of the OpenAPI document: 1.0.0
  * Generated by: https://openapi-generator.tech
- * OpenAPI Generator version: 5.3.1-SNAPSHOT
+ * OpenAPI Generator version: 6.0.0-SNAPSHOT
  */
 
 /**
diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/user_type.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/user_type.rb
index 68064a5f33c..2a6c3cd952a 100644
--- a/samples/client/petstore/ruby-faraday/lib/petstore/models/user_type.rb
+++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/user_type.rb
@@ -6,7 +6,7 @@
 The version of the OpenAPI document: 1.0.0
 
 Generated by: https://openapi-generator.tech
-OpenAPI Generator version: 5.3.1-SNAPSHOT
+OpenAPI Generator version: 6.0.0-SNAPSHOT
 
 =end
 
diff --git a/samples/client/petstore/ruby/lib/petstore/models/user_type.rb b/samples/client/petstore/ruby/lib/petstore/models/user_type.rb
index 68064a5f33c..2a6c3cd952a 100644
--- a/samples/client/petstore/ruby/lib/petstore/models/user_type.rb
+++ b/samples/client/petstore/ruby/lib/petstore/models/user_type.rb
@@ -6,7 +6,7 @@
 The version of the OpenAPI document: 1.0.0
 
 Generated by: https://openapi-generator.tech
-OpenAPI Generator version: 5.3.1-SNAPSHOT
+OpenAPI Generator version: 6.0.0-SNAPSHOT
 
 =end
 
diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/UserType.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/UserType.ts
index 5ff2e0dff04..9704ad24269 100644
--- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/UserType.ts
+++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/UserType.ts
@@ -12,15 +12,17 @@
  * Do not edit the class manually.
  */
 
+
 /**
  * 
  * @export
- * @enum {string}
  */
-export enum UserType {
-    Admin = 'admin',
-    User = 'user'
-}
+export const UserType = {
+    Admin: 'admin' as 'admin',
+    User: 'user' as 'user'
+};
+export type UserType = typeof UserType[keyof typeof UserType];
+
 
 export function UserTypeFromJSON(json: any): UserType {
     return UserTypeFromJSONTyped(json, false);
diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user_type.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user_type.dart
index a90c44f6f4b..2086e33da0d 100644
--- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user_type.dart
+++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user_type.dart
@@ -14,6 +14,8 @@ class UserType extends EnumClass {
   static const UserType admin = _$admin;
   @BuiltValueEnumConst(wireName: r'user')
   static const UserType user = _$user;
+  @BuiltValueEnumConst(wireName: r'unknown_default_open_api', fallback: true)
+  static const UserType unknownDefaultOpenApi = _$unknownDefaultOpenApi;
 
   static Serializer<UserType> get serializer => _$userTypeSerializer;
 
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart
index 3318f9019f3..1f456767779 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart
@@ -89,7 +89,7 @@ class User {
   ///
   int? userStatus;
 
-  UserType userType;
+  UserType? userType;
 
   @override
   bool operator ==(Object other) => identical(this, other) || other is User &&
@@ -114,7 +114,7 @@ class User {
     (password == null ? 0 : password!.hashCode) +
     (phone == null ? 0 : phone!.hashCode) +
     (userStatus == null ? 0 : userStatus!.hashCode) +
-    (userType == null ? 0 : userType.hashCode);
+    (userType == null ? 0 : userType!.hashCode);
 
   @override
   String toString() => 'User[id=$id, username=$username, firstName=$firstName, lastName=$lastName, email=$email, password=$password, phone=$phone, userStatus=$userStatus, userType=$userType]';
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user_type.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user_type.dart
index 21b47424805..1f10b447ca6 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user_type.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user_type.dart
@@ -1,7 +1,7 @@
 //
 // AUTO-GENERATED FILE, DO NOT MODIFY!
 //
-// @dart=2.0
+// @dart=2.12
 
 // ignore_for_file: unused_element, unused_import
 // ignore_for_file: always_put_required_named_parameters_first
@@ -19,7 +19,7 @@ class UserType {
   final String value;
 
   @override
-  String toString() => value ?? '';
+  String toString() => value;
 
   String toJson() => value;
 
@@ -32,13 +32,20 @@ class UserType {
     user,
   ];
 
-  static UserType fromJson(dynamic value) =>
-    UserTypeTypeTransformer().decode(value);
+  static UserType? fromJson(dynamic value) => UserTypeTypeTransformer().decode(value);
 
-  static List<UserType> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
-    json is List && json.isNotEmpty
-      ? json.map(UserType.fromJson).toList(growable: true == growable)
-      : true == emptyIsNull ? null : <UserType>[];
+  static List<UserType>? listFromJson(dynamic json, {bool growable = false,}) {
+    final result = <UserType>[];
+    if (json is List && json.isNotEmpty) {
+      for (final row in json) {
+        final value = UserType.fromJson(row);
+        if (value != null) {
+          result.add(value);
+        }
+      }
+    }
+    return result.toList(growable: growable);
+  }
 }
 
 /// Transformation class that can [encode] an instance of [UserType] to String,
@@ -58,13 +65,13 @@ class UserTypeTypeTransformer {
   ///
   /// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
   /// and users are still using an old app with the old code.
-  UserType decode(dynamic data, {bool allowNull}) {
+  UserType? decode(dynamic data, {bool allowNull = true}) {
     if (data != null) {
       switch (data.toString()) {
         case r'admin': return UserType.admin;
         case r'user': return UserType.user;
         default:
-          if (allowNull == false) {
+          if (!allowNull) {
             throw ArgumentError('Unknown enum value to decode: $data');
           }
       }
@@ -73,6 +80,6 @@ class UserTypeTypeTransformer {
   }
 
   /// Singleton [UserTypeTypeTransformer] instance.
-  static UserTypeTypeTransformer _instance;
+  static UserTypeTypeTransformer? _instance;
 }
 
-- 
GitLab