diff --git a/docs/generators/dart-dio.md b/docs/generators/dart-dio.md
index 7e62f92f0782..cd1a3a5974d5 100644
--- a/docs/generators/dart-dio.md
+++ b/docs/generators/dart-dio.md
@@ -58,6 +58,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES
+Object
String
bool
double
diff --git a/docs/generators/dart.md b/docs/generators/dart.md
index 79148a7e4791..e5f4d8227077 100644
--- a/docs/generators/dart.md
+++ b/docs/generators/dart.md
@@ -54,6 +54,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES
+Object
String
bool
double
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 f002ee8d8d6a..1c06f6773172 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
@@ -128,7 +128,8 @@ public AbstractDartCodegen() {
"bool",
"int",
"num",
- "double"
+ "double",
+ "Object"
);
typeMapping = new HashMap<>();
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 b4ba0b716a12..c5a5ef541471 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
@@ -119,10 +119,14 @@ class {{{classname}}} {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "{{{classname}}}[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "{{{classname}}}[$key]" has a null value in JSON.');
- });
+ {{#vars}}
+ {{#required}}
+ assert(json.containsKey(r'{{{baseName}}}'), 'Required key "{{{classname}}}[{{{baseName}}}]" is missing from JSON.');
+ {{^isNullable}}
+ assert(json[r'{{{baseName}}}'] != null, 'Required key "{{{classname}}}[{{{baseName}}}]" has a null value in JSON.');
+ {{/isNullable}}
+ {{/required}}
+ {{/vars}}
return true;
}());
@@ -221,7 +225,7 @@ class {{{classname}}} {
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
{{/isEnum}}
{{#isEnum}}
- {{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
+ {{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? const {{{enumName}}}._({{{.}}}){{/defaultValue}}{{/required}},
{{/isEnum}}
{{/isNumber}}
{{/isMap}}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartClientCodegenTest.java
index 4bc51da8d9e9..14348f8854da 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartClientCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartClientCodegenTest.java
@@ -17,15 +17,18 @@
package org.openapitools.codegen.dart;
-import org.openapitools.codegen.CodegenConstants;
+import org.openapitools.codegen.*;
+import org.openapitools.codegen.config.CodegenConfigurator;
import org.openapitools.codegen.languages.DartClientCodegen;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.io.BufferedReader;
+import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -96,4 +99,74 @@ public void testEnumPropertyWithQuotes() {
Assert.assertEquals(codegen.toEnumValue("1.0", "number"), "1.0");
Assert.assertEquals(codegen.toEnumValue("1", "int"), "1");
}
+
+ private List generateDartNativeFromSpec(String specPath) throws Exception {
+ File output = Files.createTempDirectory("dart-native-test").toFile();
+ output.deleteOnExit();
+
+ final CodegenConfigurator configurator = new CodegenConfigurator()
+ .setGeneratorName("dart")
+ .setInputSpec(specPath)
+ .setOutputDir(output.getAbsolutePath().replace("\\", "/"));
+
+ ClientOptInput opts = configurator.toClientOptInput();
+ DefaultGenerator generator = new DefaultGenerator();
+ List files = generator.opts(opts).generate();
+ files.forEach(File::deleteOnExit);
+ return files;
+ }
+
+ @Test(description = "Object-typed arrays should not produce Object.listFromJson()")
+ public void testObjectArrayDoesNotUseListFromJson() throws Exception {
+ List files = generateDartNativeFromSpec(
+ "src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml");
+
+ File modelFile = files.stream()
+ .filter(f -> f.getName().equals("object_array_model.dart"))
+ .findFirst()
+ .orElseThrow(() -> new AssertionError("object_array_model.dart not found in generated files"));
+
+ // Object is a primitive type and has no listFromJson — should use cast() instead
+ TestUtils.assertFileNotContains(modelFile.toPath(), "Object.listFromJson");
+ TestUtils.assertFileContains(modelFile.toPath(), "cast");
+ }
+
+ @Test(description = "Enum properties with defaults should emit enum constructor, not string literal")
+ public void testEnumDefaultUsesEnumConstructor() throws Exception {
+ List files = generateDartNativeFromSpec(
+ "src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml");
+
+ File modelFile = files.stream()
+ .filter(f -> f.getName().equals("enum_default_model.dart"))
+ .findFirst()
+ .orElseThrow(() -> new AssertionError("enum_default_model.dart not found in generated files"));
+
+ // Default should use const EnumType._('value'), not a bare string literal
+ TestUtils.assertFileNotContains(modelFile.toPath(), "?? 'active'");
+ TestUtils.assertFileContains(modelFile.toPath(),
+ "?? const EnumDefaultModelStatusEnum._('active')");
+ }
+
+ @Test(description = "Required+nullable fields should not assert non-null")
+ public void testRequiredNullableFieldsDoNotAssertNonNull() throws Exception {
+ List files = generateDartNativeFromSpec(
+ "src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml");
+
+ File modelFile = files.stream()
+ .filter(f -> f.getName().equals("nullable_required_model.dart"))
+ .findFirst()
+ .orElseThrow(() -> new AssertionError("nullable_required_model.dart not found in generated files"));
+
+ // Required key 'name' (non-nullable) should assert both presence and non-null
+ TestUtils.assertFileContains(modelFile.toPath(),
+ "json.containsKey(r'name')");
+ TestUtils.assertFileContains(modelFile.toPath(),
+ "json[r'name'] != null");
+
+ // Required key 'nickname' (nullable) should assert presence but NOT non-null
+ TestUtils.assertFileContains(modelFile.toPath(),
+ "json.containsKey(r'nickname')");
+ TestUtils.assertFileNotContains(modelFile.toPath(),
+ "json[r'nickname'] != null");
+ }
}
diff --git a/modules/openapi-generator/src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml b/modules/openapi-generator/src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml
new file mode 100644
index 000000000000..bf492a594140
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml
@@ -0,0 +1,34 @@
+openapi: 3.0.0
+info:
+ title: Dart Native Deserialization Bugs
+ description: Test spec for verifying fixes to Dart native serialization codegen bugs.
+ version: 1.0.0
+paths: {}
+components:
+ schemas:
+ ObjectArrayModel:
+ type: object
+ properties:
+ items:
+ type: array
+ items: {}
+ EnumDefaultModel:
+ type: object
+ properties:
+ status:
+ type: string
+ enum:
+ - active
+ - inactive
+ default: active
+ NullableRequiredModel:
+ type: object
+ required:
+ - name
+ - nickname
+ properties:
+ name:
+ type: string
+ nickname:
+ type: string
+ nullable: true
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart
index 5f9ddf484d20..4ae4da84e37b 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart
@@ -89,10 +89,6 @@ class ApiResponse {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ApiResponse[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ApiResponse[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/category.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/category.dart
index 52d343a6659f..84abdf613706 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/category.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/category.dart
@@ -73,10 +73,6 @@ class Category {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Category[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Category[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/order.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/order.dart
index 88a37f9c5fcb..c6597f735d64 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/order.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/order.dart
@@ -122,10 +122,6 @@ class Order {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Order[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Order[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart
index 9b79b4e1c571..c8e0a76ba377 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart
@@ -102,10 +102,10 @@ class Pet {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Pet[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Pet[$key]" has a null value in JSON.');
- });
+ assert(json.containsKey(r'name'), 'Required key "Pet[name]" is missing from JSON.');
+ assert(json[r'name'] != null, 'Required key "Pet[name]" has a null value in JSON.');
+ assert(json.containsKey(r'photoUrls'), 'Required key "Pet[photoUrls]" is missing from JSON.');
+ assert(json[r'photoUrls'] != null, 'Required key "Pet[photoUrls]" has a null value in JSON.');
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart
index b8b5696cf9b5..519cc76dbf17 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart
@@ -73,10 +73,6 @@ class Tag {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Tag[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Tag[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/user.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/user.dart
index 395f9e38e043..1d283f499266 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/user.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/user.dart
@@ -170,10 +170,6 @@ class User {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "User[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "User[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/NullableClass.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/NullableClass.md
index 9b2e46df0a09..0d4f5e68385c 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/NullableClass.md
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/NullableClass.md
@@ -14,12 +14,12 @@ Name | Type | Description | Notes
**stringProp** | **String** | | [optional]
**dateProp** | [**DateTime**](DateTime.md) | | [optional]
**datetimeProp** | [**DateTime**](DateTime.md) | | [optional]
-**arrayNullableProp** | [**List**](Object.md) | | [optional] [default to const []]
-**arrayAndItemsNullableProp** | [**List**](Object.md) | | [optional] [default to const []]
-**arrayItemsNullable** | [**List**](Object.md) | | [optional] [default to const []]
-**objectNullableProp** | [**Map**](Object.md) | | [optional] [default to const {}]
-**objectAndItemsNullableProp** | [**Map**](Object.md) | | [optional] [default to const {}]
-**objectItemsNullable** | [**Map**](Object.md) | | [optional] [default to const {}]
+**arrayNullableProp** | **List** | | [optional] [default to const []]
+**arrayAndItemsNullableProp** | **List** | | [optional] [default to const []]
+**arrayItemsNullable** | **List** | | [optional] [default to const []]
+**objectNullableProp** | **Map** | | [optional] [default to const {}]
+**objectAndItemsNullableProp** | **Map** | | [optional] [default to const {}]
+**objectItemsNullable** | **Map** | | [optional] [default to const {}]
[[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/model/additional_properties_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart
index 1986d67dc9d9..3bf15e55b687 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart
@@ -53,10 +53,6 @@ class AdditionalPropertiesClass {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "AdditionalPropertiesClass[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "AdditionalPropertiesClass[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/all_of_with_single_ref.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/all_of_with_single_ref.dart
index 0411ccc2b7a1..4b9734051976 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/all_of_with_single_ref.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/all_of_with_single_ref.dart
@@ -73,10 +73,6 @@ class AllOfWithSingleRef {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "AllOfWithSingleRef[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "AllOfWithSingleRef[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/animal.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/animal.dart
index a562a11becce..7af5a98e5318 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/animal.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/animal.dart
@@ -53,10 +53,8 @@ class Animal {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Animal[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Animal[$key]" has a null value in JSON.');
- });
+ assert(json.containsKey(r'className'), 'Required key "Animal[className]" is missing from JSON.');
+ assert(json[r'className'] != null, 'Required key "Animal[className]" has a null value in JSON.');
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/api_response.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/api_response.dart
index 5f9ddf484d20..4ae4da84e37b 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/api_response.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/api_response.dart
@@ -89,10 +89,6 @@ class ApiResponse {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ApiResponse[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ApiResponse[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_array_of_number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_array_of_number_only.dart
index 04a9e99e986f..a45ea2f3af1d 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_array_of_number_only.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_array_of_number_only.dart
@@ -47,10 +47,6 @@ class ArrayOfArrayOfNumberOnly {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ArrayOfArrayOfNumberOnly[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ArrayOfArrayOfNumberOnly[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_number_only.dart
index ccf33088a3e1..028b9e86673d 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_number_only.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_number_only.dart
@@ -47,10 +47,6 @@ class ArrayOfNumberOnly {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ArrayOfNumberOnly[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ArrayOfNumberOnly[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_test.dart
index ae7b08dbd3b9..8e73cd62b943 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_test.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_test.dart
@@ -59,10 +59,6 @@ class ArrayTest {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ArrayTest[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ArrayTest[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/capitalization.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/capitalization.dart
index 0f525b45dd87..5ae1a61778a3 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/capitalization.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/capitalization.dart
@@ -138,10 +138,6 @@ class Capitalization {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Capitalization[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Capitalization[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat.dart
index 398fd8525280..c0415c407887 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat.dart
@@ -69,10 +69,8 @@ class Cat {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Cat[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Cat[$key]" has a null value in JSON.');
- });
+ assert(json.containsKey(r'className'), 'Required key "Cat[className]" is missing from JSON.');
+ assert(json[r'className'] != null, 'Required key "Cat[className]" has a null value in JSON.');
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/category.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/category.dart
index 7a2841cd9dcd..ae2ac90a47c0 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/category.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/category.dart
@@ -63,10 +63,8 @@ class Category {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Category[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Category[$key]" has a null value in JSON.');
- });
+ assert(json.containsKey(r'name'), 'Required key "Category[name]" is missing from JSON.');
+ assert(json[r'name'] != null, 'Required key "Category[name]" has a null value in JSON.');
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart
index b50013df7b60..689245e15e9f 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart
@@ -83,10 +83,6 @@ class ChildWithNullable {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ChildWithNullable[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ChildWithNullable[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/class_model.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/class_model.dart
index abf08d64bdfd..9b5ae73f3292 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/class_model.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/class_model.dart
@@ -57,10 +57,6 @@ class ClassModel {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ClassModel[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ClassModel[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/deprecated_object.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/deprecated_object.dart
index 9b5f9d3bb472..d802079e32db 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/deprecated_object.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/deprecated_object.dart
@@ -57,10 +57,6 @@ class DeprecatedObject {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "DeprecatedObject[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "DeprecatedObject[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog.dart
index d7677510b91c..2612b4e50fd3 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog.dart
@@ -69,10 +69,8 @@ class Dog {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Dog[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Dog[$key]" has a null value in JSON.');
- });
+ assert(json.containsKey(r'className'), 'Required key "Dog[className]" is missing from JSON.');
+ assert(json[r'className'] != null, 'Required key "Dog[className]" has a null value in JSON.');
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_arrays.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_arrays.dart
index 74c68b096792..a289585193b0 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_arrays.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_arrays.dart
@@ -57,10 +57,6 @@ class EnumArrays {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "EnumArrays[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "EnumArrays[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_test.dart
index 04ee7808fc0d..b074c3b4b145 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_test.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_test.dart
@@ -135,10 +135,8 @@ class EnumTest {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "EnumTest[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "EnumTest[$key]" has a null value in JSON.');
- });
+ assert(json.containsKey(r'enum_string_required'), 'Required key "EnumTest[enum_string_required]" is missing from JSON.');
+ assert(json[r'enum_string_required'] != null, 'Required key "EnumTest[enum_string_required]" has a null value in JSON.');
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/fake_big_decimal_map200_response.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/fake_big_decimal_map200_response.dart
index 55de1b12e981..86eff453eff9 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/fake_big_decimal_map200_response.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/fake_big_decimal_map200_response.dart
@@ -63,10 +63,6 @@ class FakeBigDecimalMap200Response {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "FakeBigDecimalMap200Response[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "FakeBigDecimalMap200Response[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file_schema_test_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file_schema_test_class.dart
index ff956bc14916..e4bbad1e569f 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file_schema_test_class.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file_schema_test_class.dart
@@ -63,10 +63,6 @@ class FileSchemaTestClass {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "FileSchemaTestClass[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "FileSchemaTestClass[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo.dart
index 6334191a11e8..22a2797c3442 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo.dart
@@ -47,10 +47,6 @@ class Foo {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Foo[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Foo[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo_get_default_response.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo_get_default_response.dart
index 1d562914d307..45dc5c50b812 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo_get_default_response.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo_get_default_response.dart
@@ -57,10 +57,6 @@ class FooGetDefaultResponse {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "FooGetDefaultResponse[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "FooGetDefaultResponse[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart
index b0edc2e38e14..5c22fff27825 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart
@@ -269,10 +269,14 @@ class FormatTest {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "FormatTest[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "FormatTest[$key]" has a null value in JSON.');
- });
+ assert(json.containsKey(r'number'), 'Required key "FormatTest[number]" is missing from JSON.');
+ assert(json[r'number'] != null, 'Required key "FormatTest[number]" has a null value in JSON.');
+ assert(json.containsKey(r'byte'), 'Required key "FormatTest[byte]" is missing from JSON.');
+ assert(json[r'byte'] != null, 'Required key "FormatTest[byte]" has a null value in JSON.');
+ assert(json.containsKey(r'date'), 'Required key "FormatTest[date]" is missing from JSON.');
+ assert(json[r'date'] != null, 'Required key "FormatTest[date]" has a null value in JSON.');
+ assert(json.containsKey(r'password'), 'Required key "FormatTest[password]" is missing from JSON.');
+ assert(json[r'password'] != null, 'Required key "FormatTest[password]" has a null value in JSON.');
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/has_only_read_only.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/has_only_read_only.dart
index 6a753c10fee5..4813166f3c3c 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/has_only_read_only.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/has_only_read_only.dart
@@ -73,10 +73,6 @@ class HasOnlyReadOnly {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "HasOnlyReadOnly[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "HasOnlyReadOnly[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/health_check_result.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/health_check_result.dart
index b3a3f7cb8e0f..fcb439d61024 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/health_check_result.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/health_check_result.dart
@@ -51,10 +51,6 @@ class HealthCheckResult {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "HealthCheckResult[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "HealthCheckResult[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/map_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/map_test.dart
index e55aa93d9056..c403ca02947a 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/map_test.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/map_test.dart
@@ -65,10 +65,6 @@ class MapTest {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "MapTest[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "MapTest[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart
index edc224b79248..1ea2d31cd096 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart
@@ -79,10 +79,6 @@ class MixedPropertiesAndAdditionalPropertiesClass {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "MixedPropertiesAndAdditionalPropertiesClass[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "MixedPropertiesAndAdditionalPropertiesClass[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model200_response.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model200_response.dart
index 2dd008e72e26..8c824ad3f2b4 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model200_response.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model200_response.dart
@@ -73,10 +73,6 @@ class Model200Response {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Model200Response[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Model200Response[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_client.dart
index 15f48a054876..63a2056a38b0 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_client.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_client.dart
@@ -57,10 +57,6 @@ class ModelClient {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ModelClient[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ModelClient[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_file.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_file.dart
index 5183e0f98e49..0e1f8de75674 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_file.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_file.dart
@@ -58,10 +58,6 @@ class ModelFile {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ModelFile[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ModelFile[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_list.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_list.dart
index 40a2767daa8b..805b0087e95f 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_list.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_list.dart
@@ -57,10 +57,6 @@ class ModelList {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ModelList[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ModelList[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_return.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_return.dart
index 610500530533..4c98bece7111 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_return.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_return.dart
@@ -57,10 +57,6 @@ class ModelReturn {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ModelReturn[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ModelReturn[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/name.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/name.dart
index 7d366892b58c..619a0070d398 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/name.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/name.dart
@@ -95,10 +95,8 @@ class Name {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Name[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Name[$key]" has a null value in JSON.');
- });
+ assert(json.containsKey(r'name'), 'Required key "Name[name]" is missing from JSON.');
+ assert(json[r'name'] != null, 'Required key "Name[name]" has a null value in JSON.');
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart
index 25e70c05d92b..650652778f91 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart
@@ -153,10 +153,6 @@ class NullableClass {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "NullableClass[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "NullableClass[$key]" has a null value in JSON.');
- });
return true;
}());
@@ -169,9 +165,15 @@ class NullableClass {
stringProp: mapValueOfType(json, r'string_prop'),
dateProp: mapDateTime(json, r'date_prop', r''),
datetimeProp: mapDateTime(json, r'datetime_prop', r''),
- arrayNullableProp: Object.listFromJson(json[r'array_nullable_prop']),
- arrayAndItemsNullableProp: Object.listFromJson(json[r'array_and_items_nullable_prop']),
- arrayItemsNullable: Object.listFromJson(json[r'array_items_nullable']),
+ arrayNullableProp: json[r'array_nullable_prop'] is Iterable
+ ? (json[r'array_nullable_prop'] as Iterable).cast().toList(growable: false)
+ : const [],
+ arrayAndItemsNullableProp: json[r'array_and_items_nullable_prop'] is Iterable
+ ? (json[r'array_and_items_nullable_prop'] as Iterable).cast().toList(growable: false)
+ : const [],
+ arrayItemsNullable: json[r'array_items_nullable'] is Iterable
+ ? (json[r'array_items_nullable'] as Iterable).cast().toList(growable: false)
+ : const [],
objectNullableProp: mapCastOfType(json, r'object_nullable_prop') ?? const {},
objectAndItemsNullableProp: mapCastOfType(json, r'object_and_items_nullable_prop') ?? const {},
objectItemsNullable: mapCastOfType(json, r'object_items_nullable') ?? const {},
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/number_only.dart
index a27a5682533e..124d620f5834 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/number_only.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/number_only.dart
@@ -57,10 +57,6 @@ class NumberOnly {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "NumberOnly[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "NumberOnly[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_that_references_objects_with_duplicate_inline_enums.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_that_references_objects_with_duplicate_inline_enums.dart
index 2a50a577cd24..9ad96992b33f 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_that_references_objects_with_duplicate_inline_enums.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_that_references_objects_with_duplicate_inline_enums.dart
@@ -73,10 +73,6 @@ class ObjectThatReferencesObjectsWithDuplicateInlineEnums {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ObjectThatReferencesObjectsWithDuplicateInlineEnums[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ObjectThatReferencesObjectsWithDuplicateInlineEnums[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_deprecated_fields.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_deprecated_fields.dart
index 5c7386821aa3..4df1a906d978 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_deprecated_fields.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_deprecated_fields.dart
@@ -95,10 +95,6 @@ class ObjectWithDeprecatedFields {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ObjectWithDeprecatedFields[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ObjectWithDeprecatedFields[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_duplicate_inline_enum.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_duplicate_inline_enum.dart
index 30ba307612ba..d806fd7155dc 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_duplicate_inline_enum.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_duplicate_inline_enum.dart
@@ -48,10 +48,6 @@ class ObjectWithDuplicateInlineEnum {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ObjectWithDuplicateInlineEnum[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ObjectWithDuplicateInlineEnum[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_enum.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_enum.dart
index 8bdfa6bf4d3e..9798caa7b3c4 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_enum.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_enum.dart
@@ -47,10 +47,6 @@ class ObjectWithEnum {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ObjectWithEnum[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ObjectWithEnum[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_inline_enum.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_inline_enum.dart
index b32f6b9337af..858d3d77851e 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_inline_enum.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_inline_enum.dart
@@ -48,10 +48,6 @@ class ObjectWithInlineEnum {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ObjectWithInlineEnum[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ObjectWithInlineEnum[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_inline_enum_default_value.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_inline_enum_default_value.dart
index 022d412c7988..895a0bbdd072 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_inline_enum_default_value.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_inline_enum_default_value.dart
@@ -48,15 +48,11 @@ class ObjectWithInlineEnumDefaultValue {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ObjectWithInlineEnumDefaultValue[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ObjectWithInlineEnumDefaultValue[$key]" has a null value in JSON.');
- });
return true;
}());
return ObjectWithInlineEnumDefaultValue(
- attribute: ObjectWithInlineEnumDefaultValueAttributeEnum.fromJson(json[r'attribute']) ?? 'value_one',
+ attribute: ObjectWithInlineEnumDefaultValueAttributeEnum.fromJson(json[r'attribute']) ?? const ObjectWithInlineEnumDefaultValueAttributeEnum._('value_one'),
);
}
return null;
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/order.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/order.dart
index bc591de9fab9..9d632ff2e90a 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/order.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/order.dart
@@ -122,10 +122,6 @@ class Order {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Order[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Order[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_composite.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_composite.dart
index 5a8757f61984..ee0cb9628b82 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_composite.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_composite.dart
@@ -89,10 +89,6 @@ class OuterComposite {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "OuterComposite[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "OuterComposite[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_object_with_enum_property.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_object_with_enum_property.dart
index 96a121ffc6f5..9d902dcfb1b4 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_object_with_enum_property.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_object_with_enum_property.dart
@@ -47,10 +47,8 @@ class OuterObjectWithEnumProperty {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "OuterObjectWithEnumProperty[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "OuterObjectWithEnumProperty[$key]" has a null value in JSON.');
- });
+ assert(json.containsKey(r'value'), 'Required key "OuterObjectWithEnumProperty[value]" is missing from JSON.');
+ assert(json[r'value'] != null, 'Required key "OuterObjectWithEnumProperty[value]" has a null value in JSON.');
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart
index 6ff6eb1c4f3d..430935179ab7 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart
@@ -67,10 +67,6 @@ class ParentWithNullable {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ParentWithNullable[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ParentWithNullable[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/pet.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/pet.dart
index 806f91e41ace..09d7dd88ca42 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/pet.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/pet.dart
@@ -102,10 +102,10 @@ class Pet {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Pet[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Pet[$key]" has a null value in JSON.');
- });
+ assert(json.containsKey(r'name'), 'Required key "Pet[name]" is missing from JSON.');
+ assert(json[r'name'] != null, 'Required key "Pet[name]" has a null value in JSON.');
+ assert(json.containsKey(r'photoUrls'), 'Required key "Pet[photoUrls]" is missing from JSON.');
+ assert(json[r'photoUrls'] != null, 'Required key "Pet[photoUrls]" has a null value in JSON.');
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/read_only_first.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/read_only_first.dart
index 7088ae4195bf..d0d5820c58a0 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/read_only_first.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/read_only_first.dart
@@ -73,10 +73,6 @@ class ReadOnlyFirst {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "ReadOnlyFirst[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "ReadOnlyFirst[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/special_model_name.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/special_model_name.dart
index aeb25a138f07..35c54b5eaa06 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/special_model_name.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/special_model_name.dart
@@ -57,10 +57,6 @@ class SpecialModelName {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "SpecialModelName[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "SpecialModelName[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/tag.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/tag.dart
index b8b5696cf9b5..519cc76dbf17 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/tag.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/tag.dart
@@ -73,10 +73,6 @@ class Tag {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "Tag[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "Tag[$key]" has a null value in JSON.');
- });
return true;
}());
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/test_inline_freeform_additional_properties_request.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/test_inline_freeform_additional_properties_request.dart
index 8e2316a619dc..b00c9ed668f0 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/test_inline_freeform_additional_properties_request.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/test_inline_freeform_additional_properties_request.dart
@@ -57,10 +57,6 @@ class TestInlineFreeformAdditionalPropertiesRequest {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "TestInlineFreeformAdditionalPropertiesRequest[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "TestInlineFreeformAdditionalPropertiesRequest[$key]" has a null value in JSON.');
- });
return true;
}());
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 395f9e38e043..1d283f499266 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
@@ -170,10 +170,6 @@ class User {
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
- requiredKeys.forEach((key) {
- assert(json.containsKey(key), 'Required key "User[$key]" is missing from JSON.');
- assert(json[key] != null, 'Required key "User[$key]" has a null value in JSON.');
- });
return true;
}());