From e1c43f135639b9f300350f788fec98bbc375c932 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 16 Dec 2020 10:25:20 +0100 Subject: [PATCH] [dart][dart-dio] Prevent name clashes with existing dart types (#8198) * [dart][dart-dio] Prevent name clashes with existing dart types Can not use dart import aliases for now as this is not supported by built_value. This means we need to add potentially clashing names/classes to an `additionalReservedWords` exclusion list. Starting with a basic list of some http/io classes. Correctly use `importMapping` and `defaultIncludes` this time around. Improve reserved word checking. This now successfully generates `ModelList`, `ModelFile` and `ModelClient` models which previously were not generated at all or were wrong types. * Address review comment * Update generator docs --- docs/generators/dart-dio.md | 12 +--- docs/generators/dart-jaguar.md | 12 +--- docs/generators/dart.md | 12 +--- .../codegen/languages/DartClientCodegen.java | 60 ++++++++++------ .../languages/DartDioClientCodegen.java | 56 +++++++-------- .../codegen/dart/DartModelTest.java | 7 +- .../codegen/dartdio/DartDioModelTest.java | 31 +++++++- .../.openapi-generator/FILES | 10 +-- .../petstore_client_lib_fake/README.md | 9 +-- .../doc/AnotherFakeApi.md | 10 +-- .../petstore_client_lib_fake/doc/FakeApi.md | 10 +-- .../doc/FakeClassnameTags123Api.md | 10 +-- .../doc/FileSchemaTestClass.md | 4 +- .../doc/{Client.md => ModelClient.md} | 2 +- .../doc/{File.md => ModelFile.md} | 2 +- .../petstore_client_lib_fake/doc/ModelList.md | 15 ++++ .../lib/api/another_fake_api.dart | 18 ++--- .../lib/api/fake_api.dart | 18 ++--- .../lib/api/fake_classname_tags123_api.dart | 18 ++--- .../lib/model/client.dart | 18 ----- .../lib/model/file_schema_test_class.dart | 6 +- .../lib/model/model_client.dart | 18 +++++ .../lib/model/{file.dart => model_file.dart} | 10 +-- .../lib/model/model_list.dart | 18 +++++ .../lib/serializers.dart | 25 ++++--- ...lient_test.dart => model_client_test.dart} | 8 +-- .../{file_test.dart => model_file_test.dart} | 8 +-- .../test/model_list_test.dart | 17 +++++ .../petstore_client_lib/doc/InlineObject1.md | 2 +- .../.openapi-generator/FILES | 10 +-- .../dart2/petstore_client_lib_fake/README.md | 9 +-- .../doc/AnotherFakeApi.md | 10 +-- .../petstore_client_lib_fake/doc/FakeApi.md | 10 +-- .../doc/FakeClassnameTags123Api.md | 10 +-- .../doc/FileSchemaTestClass.md | 4 +- .../doc/FormatTest.md | 2 +- .../doc/InlineObject1.md | 2 +- .../doc/InlineObject3.md | 2 +- .../doc/InlineObject5.md | 2 +- .../doc/{Client.md => ModelClient.md} | 2 +- .../doc/{File.md => ModelFile.md} | 2 +- .../petstore_client_lib_fake/doc/ModelList.md | 15 ++++ .../petstore_client_lib_fake/lib/api.dart | 5 +- .../lib/api/another_fake_api.dart | 18 ++--- .../lib/api/fake_api.dart | 18 ++--- .../lib/api/fake_classname_tags123_api.dart | 18 ++--- .../lib/api_client.dart | 10 +-- .../lib/model/client.dart | 71 ------------------ .../lib/model/file.dart | 72 ------------------- .../lib/model/file_schema_test_class.dart | 8 +-- .../lib/model/model_client.dart | 71 ++++++++++++++++++ .../lib/model/model_file.dart | 72 +++++++++++++++++++ .../lib/model/model_list.dart | 71 ++++++++++++++++++ ...lient_test.dart => model_client_test.dart} | 6 +- .../{file_test.dart => model_file_test.dart} | 6 +- .../test/model_list_test.dart | 17 +++++ 56 files changed, 585 insertions(+), 404 deletions(-) rename samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/{Client.md => ModelClient.md} (93%) rename samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/{File.md => ModelFile.md} (94%) create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ModelList.md delete mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/client.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_client.dart rename samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/{file.dart => model_file.dart} (51%) create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_list.dart rename samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/{client_test.dart => model_client_test.dart} (56%) rename samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/{file_test.dart => model_file_test.dart} (62%) create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model_list_test.dart rename samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/{Client.md => ModelClient.md} (93%) rename samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/{File.md => ModelFile.md} (94%) create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ModelList.md delete mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/client.dart delete mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_client.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_file.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_list.dart rename samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/{client_test.dart => model_client_test.dart} (67%) rename samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/{file_test.dart => model_file_test.dart} (72%) create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/model_list_test.dart diff --git a/docs/generators/dart-dio.md b/docs/generators/dart-dio.md index 4d5c3f158e6..755e95f1932 100644 --- a/docs/generators/dart-dio.md +++ b/docs/generators/dart-dio.md @@ -33,19 +33,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl |BuiltList|package:built_collection/built_collection.dart| |BuiltMap|package:built_collection/built_collection.dart| |BuiltSet|package:built_collection/built_collection.dart| -|DateTime|dart:core| |JsonObject|package:built_value/json_object.dart| -|List|dart:core| -|Map|dart:core| -|Object|dart:core| -|Set|dart:core| -|String|dart:core| |Uint8List|dart:typed_data| -|bool|dart:core| -|double|dart:core| -|dynamic|dart:core| -|int|dart:core| -|num|dart:core| ## INSTANTIATION TYPES @@ -62,6 +51,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • String
  • bool
  • double
  • +
  • dynamic
  • int
  • num
  • diff --git a/docs/generators/dart-jaguar.md b/docs/generators/dart-jaguar.md index 39e14688e8c..b2afa28babe 100644 --- a/docs/generators/dart-jaguar.md +++ b/docs/generators/dart-jaguar.md @@ -30,17 +30,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl | Type/Alias | Imports | | ---------- | ------- | -|DateTime|dart:core| -|List|dart:core| -|Map|dart:core| -|Object|dart:core| -|Set|dart:core| -|String|dart:core| -|bool|dart:core| -|double|dart:core| -|dynamic|dart:core| -|int|dart:core| -|num|dart:core| ## INSTANTIATION TYPES @@ -57,6 +46,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • String
  • bool
  • double
  • +
  • dynamic
  • int
  • num
  • diff --git a/docs/generators/dart.md b/docs/generators/dart.md index 1bbd67419e3..395295b07e6 100644 --- a/docs/generators/dart.md +++ b/docs/generators/dart.md @@ -28,17 +28,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl | Type/Alias | Imports | | ---------- | ------- | -|DateTime|dart:core| -|List|dart:core| -|Map|dart:core| -|Object|dart:core| -|Set|dart:core| -|String|dart:core| -|bool|dart:core| -|double|dart:core| -|dynamic|dart:core| -|int|dart:core| -|num|dart:core| ## INSTANTIATION TYPES @@ -55,6 +44,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • String
  • bool
  • double
  • +
  • dynamic
  • int
  • num
  • diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java index dc54e04c0fe..5ebe5d5f5f0 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java @@ -73,6 +73,10 @@ public class DartClientCodegen extends DefaultCodegen { protected String apiTestPath = "test" + File.separator; protected String modelTestPath = "test" + File.separator; + // Names that must not be used as model names because they clash with existing + // default imports (dart:io, dart:async, package:http etc.) but are not basic dataTypes. + protected Set additionalReservedWords; + public DartClientCodegen() { super(); @@ -131,7 +135,8 @@ public class DartClientCodegen extends DefaultCodegen { "bool", "int", "num", - "double" + "double", + "dynamic" ); instantiationTypes.put("array", "List"); instantiationTypes.put("map", "Map"); @@ -155,7 +160,7 @@ public class DartClientCodegen extends DefaultCodegen { typeMapping.put("Date", "DateTime"); typeMapping.put("date", "DateTime"); typeMapping.put("DateTime", "DateTime"); - typeMapping.put("File", "MultipartFile"); + typeMapping.put("file", "MultipartFile"); typeMapping.put("binary", "MultipartFile"); typeMapping.put("UUID", "String"); typeMapping.put("URI", "String"); @@ -163,21 +168,29 @@ public class DartClientCodegen extends DefaultCodegen { typeMapping.put("object", "Object"); typeMapping.put("AnyType", "Object"); - // These are needed as they prevent models from being generated - // which would clash with existing types, e.g. List - importMapping.put("dynamic", "dart:core"); - importMapping.put("Object", "dart:core"); - importMapping.put("String", "dart:core"); - importMapping.put("bool", "dart:core"); - importMapping.put("num", "dart:core"); - importMapping.put("int", "dart:core"); - importMapping.put("double", "dart:core"); - importMapping.put("List", "dart:core"); - importMapping.put("Map", "dart:core"); - importMapping.put("Set", "dart:core"); - importMapping.put("DateTime", "dart:core"); + // DataTypes of the above values which are automatically imported. + // They are also not allowed to be model names. + defaultIncludes = Sets.newHashSet( + "String", + "bool", + "int", + "num", + "double", + "dynamic", + "List", + "Set", + "Map", + "DateTime", + "Object", + "MultipartFile" + ); - defaultIncludes = new HashSet<>(Collections.singletonList("dart:core")); + additionalReservedWords = Sets.newHashSet( + "File", + "Client", + "Future", + "Response" + ); cliOptions.add(new CliOption(PUB_LIBRARY, "Library name in generated code")); cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec")); @@ -306,6 +319,15 @@ public class DartClientCodegen extends DefaultCodegen { supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml")); } + @Override + protected boolean isReservedWord(String word) { + // consider everything as reserved that is either a keyword, + // a default included type, or a type include through some library + return super.isReservedWord(word) || + defaultIncludes().contains(word) || + additionalReservedWords.contains(word); + } + @Override public String escapeReservedWord(String name) { return name + "_"; @@ -370,7 +392,7 @@ public class DartClientCodegen extends DefaultCodegen { name = "n" + name; } - if (isReservedWord(name) || importMapping().containsKey(name)) { + if (isReservedWord(name)) { name = escapeReservedWord(name); } @@ -385,10 +407,6 @@ public class DartClientCodegen extends DefaultCodegen { @Override public String toModelName(final String name) { - if (importMapping().containsKey(name)) { - return name; - } - String nameWithPrefixSuffix = sanitizeName(name); if (!StringUtils.isEmpty(modelNamePrefix)) { // add '_' so that model name can be camelized correctly 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 3f1c04f8d5d..2c49745c294 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 @@ -19,14 +19,9 @@ package org.openapitools.codegen.languages; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; import com.samskivert.mustache.Mustache; +import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.StringUtils; -import org.openapitools.codegen.CliOption; -import org.openapitools.codegen.CodegenConstants; -import org.openapitools.codegen.CodegenModel; -import org.openapitools.codegen.CodegenOperation; -import org.openapitools.codegen.CodegenParameter; -import org.openapitools.codegen.CodegenProperty; -import org.openapitools.codegen.SupportingFile; +import org.openapitools.codegen.*; import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ProcessUtils; import org.slf4j.Logger; @@ -35,8 +30,6 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.util.*; -import io.swagger.v3.oas.models.media.Schema; - import static org.openapitools.codegen.utils.StringUtils.underscore; public class DartDioClientCodegen extends DartClientCodegen { @@ -49,7 +42,6 @@ public class DartDioClientCodegen extends DartClientCodegen { private boolean nullableFields = true; private String dateLibrary = "core"; - private static final Set reservedBuiltValueWords = Sets.newHashSet("EnumClass"); public DartDioClientCodegen() { super(); @@ -75,6 +67,17 @@ public class DartDioClientCodegen extends DartClientCodegen { typeMapping.put("object", "JsonObject"); typeMapping.put("AnyType", "JsonObject"); + additionalReservedWords.addAll(Sets.newHashSet( + "EnumClass", + // The following are reserved dataTypes but can not be added to defaultIncludes + // as this would prevent them from being added to the imports. + "BuiltList", + "BuiltSet", + "BuiltMap", + "Uint8List", + "JsonObject" + )); + importMapping.put("BuiltList", "package:built_collection/built_collection.dart"); importMapping.put("BuiltSet", "package:built_collection/built_collection.dart"); importMapping.put("BuiltMap", "package:built_collection/built_collection.dart"); @@ -108,11 +111,6 @@ public class DartDioClientCodegen extends DartClientCodegen { return "Generates a Dart Dio client library."; } - @Override - protected boolean isReservedWord(String word) { - return super.isReservedWord(word) || reservedBuiltValueWords.contains(word); - } - @Override protected ImmutableMap.Builder addMustacheLambdas() { return super.addMustacheLambdas() @@ -227,19 +225,18 @@ public class DartDioClientCodegen extends DartClientCodegen { supportingFiles.add(new SupportingFile("auth/auth.mustache", authFolder, "auth.dart")); if ("core".equals(dateLibrary)) { + // this option uses the same classes as normal dart generator additionalProperties.put("core", "true"); - typeMapping.put("Date", "DateTime"); - typeMapping.put("date", "DateTime"); } else if ("timemachine".equals(dateLibrary)) { additionalProperties.put("timeMachine", "true"); typeMapping.put("date", "OffsetDate"); typeMapping.put("Date", "OffsetDate"); typeMapping.put("DateTime", "OffsetDateTime"); typeMapping.put("datetime", "OffsetDateTime"); + additionalReservedWords.addAll(Sets.newHashSet("OffsetDate", "OffsetDateTime")); importMapping.put("OffsetDate", "package:time_machine/time_machine.dart"); importMapping.put("OffsetDateTime", "package:time_machine/time_machine.dart"); supportingFiles.add(new SupportingFile("local_date_serializer.mustache", libFolder, "local_date_serializer.dart")); - } } @@ -254,13 +251,12 @@ public class DartDioClientCodegen extends DartClientCodegen { Set modelImports = new HashSet<>(); CodegenModel cm = (CodegenModel) mo.get("model"); for (String modelImport : cm.imports) { - if (importMapping().containsKey(modelImport)) { - final String value = importMapping().get(modelImport); - if (needToImport(value)) { - modelImports.add(value); + if (needToImport(modelImport)) { + if (importMapping().containsKey(modelImport)) { + modelImports.add(importMapping().get(modelImport)); + } else { + modelImports.add("package:" + pubName + "/model/" + underscore(modelImport) + ".dart"); } - } else { - modelImports.add("package:" + pubName + "/model/" + underscore(modelImport) + ".dart"); } } @@ -327,18 +323,16 @@ public class DartDioClientCodegen extends DartClientCodegen { Set imports = new HashSet<>(); for (String item : op.imports) { - if (importMapping().containsKey(item)) { - final String value = importMapping().get(item); - if (needToImport(value)) { - fullImports.add(value); + if (needToImport(item)) { + if (importMapping().containsKey(item) && needToImport(item)) { + fullImports.add(importMapping().get(item)); + } else { + imports.add(underscore(item)); } - } else { - imports.add(underscore(item)); } } modelImports.addAll(imports); op.imports = imports; - } objs.put("modelImports", modelImports); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartModelTest.java index 286acc56a9a..cab086ffaf1 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartModelTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartModelTest.java @@ -295,10 +295,15 @@ public class DartModelTest { {"sample.name", "SampleName"}, {"_sample", "Sample"}, {"sample name", "SampleName"}, + {"List", "ModelList"}, + {"list", "ModelList"}, + {"File", "ModelFile"}, + {"Client", "ModelClient"}, + {"String", "ModelString"}, }; } - @Test(dataProvider = "modelNames", description = "avoid inner class") + @Test(dataProvider = "modelNames", description = "correctly generate model names") public void modelNameTest(String name, String expectedName) { OpenAPI openAPI = TestUtils.createOpenAPI(); final Schema model = new Schema(); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioModelTest.java index 44bf10b3a92..1d7c9532c56 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioModelTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioModelTest.java @@ -350,14 +350,41 @@ public class DartDioModelTest { public static Object[][] modelNames() { return new Object[][] { {"EnumClass", "ModelEnumClass"}, + {"JsonObject", "ModelJsonObject"}, + // OffsetDate is valid without timemachine date library + {"OffsetDate", "OffsetDate"}, }; } - @Test(dataProvider = "modelNames", description = "avoid inner class") + @Test(dataProvider = "modelNames", description = "correctly prefix reserved model names") public void modelNameTest(String name, String expectedName) { OpenAPI openAPI = TestUtils.createOpenAPI(); final Schema model = new Schema(); - final DefaultCodegen codegen = new DartDioClientCodegen(); + final DartDioClientCodegen codegen = new DartDioClientCodegen(); + codegen.setOpenAPI(openAPI); + final CodegenModel cm = codegen.fromModel(name, model); + + Assert.assertEquals(cm.name, name); + Assert.assertEquals(cm.classname, expectedName); + } + + @DataProvider(name = "modelNamesTimemachine") + public static Object[][] modelNamesTimemachine() { + return new Object[][] { + {"EnumClass", "ModelEnumClass"}, + {"JsonObject", "ModelJsonObject"}, + // OffsetDate is not valid with timemachine date library + {"OffsetDate", "ModelOffsetDate"}, + }; + } + + @Test(dataProvider = "modelNamesTimemachine", description = "correctly prefix reserved model names") + public void modelNameTestTimemachine(String name, String expectedName) { + OpenAPI openAPI = TestUtils.createOpenAPI(); + final Schema model = new Schema(); + final DartDioClientCodegen codegen = new DartDioClientCodegen(); + codegen.setDateLibrary("timemachine"); + codegen.processOpts(); codegen.setOpenAPI(openAPI); final CodegenModel cm = codegen.fromModel(name, model); 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 5acd97b9bb8..3e0ed4324bd 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 @@ -13,7 +13,6 @@ doc/Cat.md doc/CatAllOf.md doc/Category.md doc/ClassModel.md -doc/Client.md doc/DefaultApi.md doc/Dog.md doc/DogAllOf.md @@ -21,7 +20,6 @@ doc/EnumArrays.md doc/EnumTest.md doc/FakeApi.md doc/FakeClassnameTags123Api.md -doc/File.md doc/FileSchemaTestClass.md doc/Foo.md doc/FormatTest.md @@ -37,7 +35,10 @@ doc/InlineResponseDefault.md doc/MapTest.md doc/MixedPropertiesAndAdditionalPropertiesClass.md doc/Model200Response.md +doc/ModelClient.md doc/ModelEnumClass.md +doc/ModelFile.md +doc/ModelList.md doc/ModelReturn.md doc/Name.md doc/NullableClass.md @@ -80,12 +81,10 @@ lib/model/cat.dart lib/model/cat_all_of.dart lib/model/category.dart lib/model/class_model.dart -lib/model/client.dart lib/model/dog.dart lib/model/dog_all_of.dart lib/model/enum_arrays.dart lib/model/enum_test.dart -lib/model/file.dart lib/model/file_schema_test_class.dart lib/model/foo.dart lib/model/format_test.dart @@ -101,7 +100,10 @@ lib/model/inline_response_default.dart lib/model/map_test.dart lib/model/mixed_properties_and_additional_properties_class.dart lib/model/model200_response.dart +lib/model/model_client.dart lib/model/model_enum_class.dart +lib/model/model_file.dart +lib/model/model_list.dart lib/model/model_return.dart lib/model/name.dart lib/model/nullable_class.dart 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 67baa9a055f..a9a4c91ee55 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 @@ -41,10 +41,10 @@ import 'package:openapi/api.dart'; var api_instance = new AnotherFakeApi(); -var client = new Client(); // Client | client model +var modelClient = new ModelClient(); // ModelClient | client model try { - var result = api_instance.call123testSpecialTags(client); + var result = api_instance.call123testSpecialTags(modelClient); print(result); } catch (e) { print("Exception when calling AnotherFakeApi->call123testSpecialTags: $e\n"); @@ -112,12 +112,10 @@ Class | Method | HTTP request | Description - [CatAllOf](doc//CatAllOf.md) - [Category](doc//Category.md) - [ClassModel](doc//ClassModel.md) - - [Client](doc//Client.md) - [Dog](doc//Dog.md) - [DogAllOf](doc//DogAllOf.md) - [EnumArrays](doc//EnumArrays.md) - [EnumTest](doc//EnumTest.md) - - [File](doc//File.md) - [FileSchemaTestClass](doc//FileSchemaTestClass.md) - [Foo](doc//Foo.md) - [FormatTest](doc//FormatTest.md) @@ -133,7 +131,10 @@ Class | Method | HTTP request | Description - [MapTest](doc//MapTest.md) - [MixedPropertiesAndAdditionalPropertiesClass](doc//MixedPropertiesAndAdditionalPropertiesClass.md) - [Model200Response](doc//Model200Response.md) + - [ModelClient](doc//ModelClient.md) - [ModelEnumClass](doc//ModelEnumClass.md) + - [ModelFile](doc//ModelFile.md) + - [ModelList](doc//ModelList.md) - [ModelReturn](doc//ModelReturn.md) - [Name](doc//Name.md) - [NullableClass](doc//NullableClass.md) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/AnotherFakeApi.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/AnotherFakeApi.md index 08c8fccc847..525a6b5735b 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/AnotherFakeApi.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/AnotherFakeApi.md @@ -13,7 +13,7 @@ Method | HTTP request | Description # **call123testSpecialTags** -> Client call123testSpecialTags(client) +> ModelClient call123testSpecialTags(modelClient) To test special tags @@ -24,10 +24,10 @@ To test special tags and operation ID starting with number import 'package:openapi/api.dart'; var api_instance = new AnotherFakeApi(); -var client = new Client(); // Client | client model +var modelClient = new ModelClient(); // ModelClient | client model try { - var result = api_instance.call123testSpecialTags(client); + var result = api_instance.call123testSpecialTags(modelClient); print(result); } catch (e) { print('Exception when calling AnotherFakeApi->call123testSpecialTags: $e\n'); @@ -38,11 +38,11 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **client** | [**Client**](Client.md)| client model | + **modelClient** | [**ModelClient**](ModelClient.md)| client model | ### Return type -[**Client**](Client.md) +[**ModelClient**](ModelClient.md) ### Authorization diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md index faac833d21d..c615d0c0bda 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md @@ -367,7 +367,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **testClientModel** -> Client testClientModel(client) +> ModelClient testClientModel(modelClient) To test \"client\" model @@ -378,10 +378,10 @@ To test \"client\" model import 'package:openapi/api.dart'; var api_instance = new FakeApi(); -var client = new Client(); // Client | client model +var modelClient = new ModelClient(); // ModelClient | client model try { - var result = api_instance.testClientModel(client); + var result = api_instance.testClientModel(modelClient); print(result); } catch (e) { print('Exception when calling FakeApi->testClientModel: $e\n'); @@ -392,11 +392,11 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **client** | [**Client**](Client.md)| client model | + **modelClient** | [**ModelClient**](ModelClient.md)| client model | ### Return type -[**Client**](Client.md) +[**ModelClient**](ModelClient.md) ### Authorization diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeClassnameTags123Api.md index b21ef287864..e00f3705bfd 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeClassnameTags123Api.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeClassnameTags123Api.md @@ -13,7 +13,7 @@ Method | HTTP request | Description # **testClassname** -> Client testClassname(client) +> ModelClient testClassname(modelClient) To test class name in snake case @@ -28,10 +28,10 @@ import 'package:openapi/api.dart'; //defaultApiClient.getAuthentication('api_key_query').apiKeyPrefix = 'Bearer'; var api_instance = new FakeClassnameTags123Api(); -var client = new Client(); // Client | client model +var modelClient = new ModelClient(); // ModelClient | client model try { - var result = api_instance.testClassname(client); + var result = api_instance.testClassname(modelClient); print(result); } catch (e) { print('Exception when calling FakeClassnameTags123Api->testClassname: $e\n'); @@ -42,11 +42,11 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **client** | [**Client**](Client.md)| client model | + **modelClient** | [**ModelClient**](ModelClient.md)| client model | ### Return type -[**Client**](Client.md) +[**ModelClient**](ModelClient.md) ### Authorization diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FileSchemaTestClass.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FileSchemaTestClass.md index 935c645cc4e..e0d0fdb7cac 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FileSchemaTestClass.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FileSchemaTestClass.md @@ -8,8 +8,8 @@ import 'package:openapi/api.dart'; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**file** | [**MultipartFile**](MultipartFile.md) | | [optional] [default to null] -**files** | [**BuiltList**](MultipartFile.md) | | [optional] [default to const []] +**file** | [**ModelFile**](ModelFile.md) | | [optional] [default to null] +**files** | [**BuiltList**](ModelFile.md) | | [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/dart-dio/petstore_client_lib_fake/doc/Client.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ModelClient.md similarity index 93% rename from samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/Client.md rename to samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ModelClient.md index ebf8c870463..3d79babf2c8 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/Client.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ModelClient.md @@ -1,4 +1,4 @@ -# openapi.model.Client +# openapi.model.ModelClient ## Load the model package ```dart diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/File.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ModelFile.md similarity index 94% rename from samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/File.md rename to samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ModelFile.md index eaa492c21f5..761c4b125c9 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/File.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ModelFile.md @@ -1,4 +1,4 @@ -# openapi.model.File +# openapi.model.ModelFile ## Load the model package ```dart diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ModelList.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ModelList.md new file mode 100644 index 00000000000..012393143f3 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ModelList.md @@ -0,0 +1,15 @@ +# openapi.model.ModelList + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**n123list** | **String** | | [optional] [default to null] + +[[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/api/another_fake_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/another_fake_api.dart index 5fc9460a253..f7eefe7d7e9 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/another_fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/another_fake_api.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:built_value/serializer.dart'; -import 'package:openapi/model/client.dart'; +import 'package:openapi/model/model_client.dart'; class AnotherFakeApi { final Dio _dio; @@ -14,8 +14,8 @@ class AnotherFakeApi { /// To test special tags /// /// To test special tags and operation ID starting with number - Future> call123testSpecialTags( - Client client, { + Future> call123testSpecialTags( + ModelClient modelClient, { CancelToken cancelToken, Map headers, ProgressCallback onSendProgress, @@ -34,9 +34,9 @@ class AnotherFakeApi { 'application/json', ]; - final serializedBody = _serializers.serialize(client); - final jsonclient = json.encode(serializedBody); - bodyData = jsonclient; + final serializedBody = _serializers.serialize(modelClient); + final jsonmodelClient = json.encode(serializedBody); + bodyData = jsonmodelClient; return _dio.request( _path, @@ -54,10 +54,10 @@ class AnotherFakeApi { onSendProgress: onSendProgress, onReceiveProgress: onReceiveProgress, ).then((response) { - final serializer = _serializers.serializerForType(Client); - final data = _serializers.deserializeWith(serializer, response.data is String ? jsonDecode(response.data) : response.data); + final serializer = _serializers.serializerForType(ModelClient); + final data = _serializers.deserializeWith(serializer, response.data is String ? jsonDecode(response.data) : response.data); - return Response( + return Response( data: data, headers: response.headers, request: response.request, diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart index 1ae970f0e96..71e1aaf2738 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart @@ -3,12 +3,12 @@ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:built_value/serializer.dart'; -import 'package:openapi/model/client.dart'; import 'package:openapi/model/file_schema_test_class.dart'; import 'package:openapi/model/outer_composite.dart'; import 'package:openapi/model/user.dart'; import 'package:openapi/model/health_check_result.dart'; import 'package:openapi/model/pet.dart'; +import 'package:openapi/model/model_client.dart'; import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; import 'package:openapi/api_util.dart'; @@ -449,8 +449,8 @@ class FakeApi { /// To test \"client\" model /// /// To test \"client\" model - Future> testClientModel( - Client client, { + Future> testClientModel( + ModelClient modelClient, { CancelToken cancelToken, Map headers, ProgressCallback onSendProgress, @@ -469,9 +469,9 @@ class FakeApi { 'application/json', ]; - final serializedBody = _serializers.serialize(client); - final jsonclient = json.encode(serializedBody); - bodyData = jsonclient; + final serializedBody = _serializers.serialize(modelClient); + final jsonmodelClient = json.encode(serializedBody); + bodyData = jsonmodelClient; return _dio.request( _path, @@ -489,10 +489,10 @@ class FakeApi { onSendProgress: onSendProgress, onReceiveProgress: onReceiveProgress, ).then((response) { - final serializer = _serializers.serializerForType(Client); - final data = _serializers.deserializeWith(serializer, response.data is String ? jsonDecode(response.data) : response.data); + final serializer = _serializers.serializerForType(ModelClient); + final data = _serializers.deserializeWith(serializer, response.data is String ? jsonDecode(response.data) : response.data); - return Response( + return Response( data: data, headers: response.headers, request: response.request, diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart index d0bb38311f5..fae8bbf33d7 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:built_value/serializer.dart'; -import 'package:openapi/model/client.dart'; +import 'package:openapi/model/model_client.dart'; class FakeClassnameTags123Api { final Dio _dio; @@ -14,8 +14,8 @@ class FakeClassnameTags123Api { /// To test class name in snake case /// /// To test class name in snake case - Future> testClassname( - Client client, { + Future> testClassname( + ModelClient modelClient, { CancelToken cancelToken, Map headers, ProgressCallback onSendProgress, @@ -34,9 +34,9 @@ class FakeClassnameTags123Api { 'application/json', ]; - final serializedBody = _serializers.serialize(client); - final jsonclient = json.encode(serializedBody); - bodyData = jsonclient; + final serializedBody = _serializers.serialize(modelClient); + final jsonmodelClient = json.encode(serializedBody); + bodyData = jsonmodelClient; return _dio.request( _path, @@ -61,10 +61,10 @@ class FakeClassnameTags123Api { onSendProgress: onSendProgress, onReceiveProgress: onReceiveProgress, ).then((response) { - final serializer = _serializers.serializerForType(Client); - final data = _serializers.deserializeWith(serializer, response.data is String ? jsonDecode(response.data) : response.data); + final serializer = _serializers.serializerForType(ModelClient); + final data = _serializers.deserializeWith(serializer, response.data is String ? jsonDecode(response.data) : response.data); - return Response( + return Response( data: data, headers: response.headers, request: response.request, diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/client.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/client.dart deleted file mode 100644 index e8b4facd32e..00000000000 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/client.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'client.g.dart'; - -abstract class Client implements Built { - - @nullable - @BuiltValueField(wireName: r'client') - String get client; - - // Boilerplate code needed to wire-up generated code - Client._(); - - factory Client([updates(ClientBuilder b)]) = _$Client; - static Serializer get serializer => _$clientSerializer; -} - diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/file_schema_test_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/file_schema_test_class.dart index 96894cc0c3f..2e822c5a701 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/file_schema_test_class.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/file_schema_test_class.dart @@ -1,5 +1,5 @@ +import 'package:openapi/model/model_file.dart'; import 'package:built_collection/built_collection.dart'; -import 'package:openapi/model/multipart_file.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; @@ -9,11 +9,11 @@ abstract class FileSchemaTestClass implements Built get files; + BuiltList get files; // Boilerplate code needed to wire-up generated code FileSchemaTestClass._(); diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_client.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_client.dart new file mode 100644 index 00000000000..cd36b77637e --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_client.dart @@ -0,0 +1,18 @@ +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'model_client.g.dart'; + +abstract class ModelClient implements Built { + + @nullable + @BuiltValueField(wireName: r'client') + String get client; + + // Boilerplate code needed to wire-up generated code + ModelClient._(); + + factory ModelClient([updates(ModelClientBuilder b)]) = _$ModelClient; + static Serializer get serializer => _$modelClientSerializer; +} + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/file.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_file.dart similarity index 51% rename from samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/file.dart rename to samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_file.dart index 27b2e69c416..9e10a9b8214 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/file.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_file.dart @@ -1,9 +1,9 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -part 'file.g.dart'; +part 'model_file.g.dart'; -abstract class File implements Built { +abstract class ModelFile implements Built { /// Test capitalization @nullable @@ -11,9 +11,9 @@ abstract class File implements Built { String get sourceURI; // Boilerplate code needed to wire-up generated code - File._(); + ModelFile._(); - factory File([updates(FileBuilder b)]) = _$File; - static Serializer get serializer => _$fileSerializer; + factory ModelFile([updates(ModelFileBuilder b)]) = _$ModelFile; + static Serializer get serializer => _$modelFileSerializer; } diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_list.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_list.dart new file mode 100644 index 00000000000..a925685dbad --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/model/model_list.dart @@ -0,0 +1,18 @@ +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'model_list.g.dart'; + +abstract class ModelList implements Built { + + @nullable + @BuiltValueField(wireName: r'123-list') + String get n123list; + + // Boilerplate code needed to wire-up generated code + ModelList._(); + + factory ModelList([updates(ModelListBuilder b)]) = _$ModelList; + static Serializer get serializer => _$modelListSerializer; +} + 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 654c8be8d67..81e4bbcd3ef 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 @@ -17,12 +17,10 @@ import 'package:openapi/model/cat.dart'; import 'package:openapi/model/cat_all_of.dart'; import 'package:openapi/model/category.dart'; import 'package:openapi/model/class_model.dart'; -import 'package:openapi/model/client.dart'; import 'package:openapi/model/dog.dart'; import 'package:openapi/model/dog_all_of.dart'; import 'package:openapi/model/enum_arrays.dart'; import 'package:openapi/model/enum_test.dart'; -import 'package:openapi/model/file.dart'; import 'package:openapi/model/file_schema_test_class.dart'; import 'package:openapi/model/foo.dart'; import 'package:openapi/model/format_test.dart'; @@ -38,7 +36,10 @@ import 'package:openapi/model/inline_response_default.dart'; import 'package:openapi/model/map_test.dart'; import 'package:openapi/model/mixed_properties_and_additional_properties_class.dart'; import 'package:openapi/model/model200_response.dart'; +import 'package:openapi/model/model_client.dart'; import 'package:openapi/model/model_enum_class.dart'; +import 'package:openapi/model/model_file.dart'; +import 'package:openapi/model/model_list.dart'; import 'package:openapi/model/model_return.dart'; import 'package:openapi/model/name.dart'; import 'package:openapi/model/nullable_class.dart'; @@ -70,12 +71,10 @@ Cat, CatAllOf, Category, ClassModel, -Client, Dog, DogAllOf, EnumArrays, EnumTest, -File, FileSchemaTestClass, Foo, FormatTest, @@ -91,7 +90,10 @@ InlineResponseDefault, MapTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, +ModelClient, ModelEnumClass, +ModelFile, +ModelList, ModelReturn, Name, NullableClass, @@ -146,9 +148,6 @@ const FullType(BuiltList, const [const FullType(Category)]), const FullType(BuiltList, const [const FullType(ClassModel)]), () => new ListBuilder()) ..addBuilderFactory( -const FullType(BuiltList, const [const FullType(Client)]), -() => new ListBuilder()) -..addBuilderFactory( const FullType(BuiltList, const [const FullType(Dog)]), () => new ListBuilder()) ..addBuilderFactory( @@ -161,9 +160,6 @@ const FullType(BuiltList, const [const FullType(EnumArrays)]), const FullType(BuiltList, const [const FullType(EnumTest)]), () => new ListBuilder()) ..addBuilderFactory( -const FullType(BuiltList, const [const FullType(File)]), -() => new ListBuilder()) -..addBuilderFactory( const FullType(BuiltList, const [const FullType(FileSchemaTestClass)]), () => new ListBuilder()) ..addBuilderFactory( @@ -209,9 +205,18 @@ const FullType(BuiltList, const [const FullType(MixedPropertiesAndAdditionalProp const FullType(BuiltList, const [const FullType(Model200Response)]), () => new ListBuilder()) ..addBuilderFactory( +const FullType(BuiltList, const [const FullType(ModelClient)]), +() => new ListBuilder()) +..addBuilderFactory( const FullType(BuiltList, const [const FullType(ModelEnumClass)]), () => new ListBuilder()) ..addBuilderFactory( +const FullType(BuiltList, const [const FullType(ModelFile)]), +() => new ListBuilder()) +..addBuilderFactory( +const FullType(BuiltList, const [const FullType(ModelList)]), +() => new ListBuilder()) +..addBuilderFactory( const FullType(BuiltList, const [const FullType(ModelReturn)]), () => new ListBuilder()) ..addBuilderFactory( diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/client_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model_client_test.dart similarity index 56% rename from samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/client_test.dart rename to samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model_client_test.dart index 135d8cca032..d428e9ccfe7 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/client_test.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model_client_test.dart @@ -1,11 +1,11 @@ -import 'package:openapi/model/client.dart'; +import 'package:openapi/model/model_client.dart'; import 'package:test/test.dart'; -// tests for Client +// tests for ModelClient void main() { - final instance = Client(); + final instance = ModelClient(); - group(Client, () { + group(ModelClient, () { // String client (default value: null) test('to test the property `client`', () async { // TODO diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/file_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model_file_test.dart similarity index 62% rename from samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/file_test.dart rename to samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model_file_test.dart index 77177e13035..1a931e285a0 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/file_test.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model_file_test.dart @@ -1,11 +1,11 @@ -import 'package:openapi/model/file.dart'; +import 'package:openapi/model/model_file.dart'; import 'package:test/test.dart'; -// tests for File +// tests for ModelFile void main() { - final instance = File(); + final instance = ModelFile(); - group(File, () { + group(ModelFile, () { // Test capitalization // String sourceURI (default value: null) test('to test the property `sourceURI`', () async { diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model_list_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model_list_test.dart new file mode 100644 index 00000000000..4d104ab7edc --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/model_list_test.dart @@ -0,0 +1,17 @@ +import 'package:openapi/model/model_list.dart'; +import 'package:test/test.dart'; + +// tests for ModelList +void main() { + final instance = ModelList(); + + group(ModelList, () { + // String n123list (default value: null) + test('to test the property `n123list`', () async { + // TODO + }); + + + }); + +} diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/doc/InlineObject1.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib/doc/InlineObject1.md index 013aa87e9bb..0a92dbfdb95 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/doc/InlineObject1.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/doc/InlineObject1.md @@ -9,7 +9,7 @@ import 'package:openapi/api.dart'; Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **additionalMetadata** | **String** | Additional data to pass to server | [optional] -**file** | [**MultipartFile**](File.md) | file to upload | [optional] +**file** | [**MultipartFile**](MultipartFile.md) | file to upload | [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/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES index 5c0c4382514..f966a261a04 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 @@ -13,7 +13,6 @@ doc/Cat.md doc/CatAllOf.md doc/Category.md doc/ClassModel.md -doc/Client.md doc/DefaultApi.md doc/Dog.md doc/DogAllOf.md @@ -22,7 +21,6 @@ doc/EnumClass.md doc/EnumTest.md doc/FakeApi.md doc/FakeClassnameTags123Api.md -doc/File.md doc/FileSchemaTestClass.md doc/Foo.md doc/FormatTest.md @@ -38,6 +36,9 @@ doc/InlineResponseDefault.md doc/MapTest.md doc/MixedPropertiesAndAdditionalPropertiesClass.md doc/Model200Response.md +doc/ModelClient.md +doc/ModelFile.md +doc/ModelList.md doc/ModelReturn.md doc/Name.md doc/NullableClass.md @@ -84,13 +85,11 @@ lib/model/cat.dart lib/model/cat_all_of.dart lib/model/category.dart lib/model/class_model.dart -lib/model/client.dart lib/model/dog.dart lib/model/dog_all_of.dart lib/model/enum_arrays.dart lib/model/enum_class.dart lib/model/enum_test.dart -lib/model/file.dart lib/model/file_schema_test_class.dart lib/model/foo.dart lib/model/format_test.dart @@ -106,6 +105,9 @@ lib/model/inline_response_default.dart lib/model/map_test.dart lib/model/mixed_properties_and_additional_properties_class.dart lib/model/model200_response.dart +lib/model/model_client.dart +lib/model/model_file.dart +lib/model/model_list.dart lib/model/model_return.dart lib/model/name.dart lib/model/nullable_class.dart 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 95cd1f3db47..c8c4eac75c2 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 @@ -41,10 +41,10 @@ import 'package:openapi/api.dart'; final api_instance = AnotherFakeApi(); -final client = Client(); // Client | client model +final modelClient = ModelClient(); // ModelClient | client model try { - final result = api_instance.call123testSpecialTags(client); + final result = api_instance.call123testSpecialTags(modelClient); print(result); } catch (e) { print('Exception when calling AnotherFakeApi->call123testSpecialTags: $e\n'); @@ -112,13 +112,11 @@ Class | Method | HTTP request | Description - [CatAllOf](doc//CatAllOf.md) - [Category](doc//Category.md) - [ClassModel](doc//ClassModel.md) - - [Client](doc//Client.md) - [Dog](doc//Dog.md) - [DogAllOf](doc//DogAllOf.md) - [EnumArrays](doc//EnumArrays.md) - [EnumClass](doc//EnumClass.md) - [EnumTest](doc//EnumTest.md) - - [File](doc//File.md) - [FileSchemaTestClass](doc//FileSchemaTestClass.md) - [Foo](doc//Foo.md) - [FormatTest](doc//FormatTest.md) @@ -134,6 +132,9 @@ Class | Method | HTTP request | Description - [MapTest](doc//MapTest.md) - [MixedPropertiesAndAdditionalPropertiesClass](doc//MixedPropertiesAndAdditionalPropertiesClass.md) - [Model200Response](doc//Model200Response.md) + - [ModelClient](doc//ModelClient.md) + - [ModelFile](doc//ModelFile.md) + - [ModelList](doc//ModelList.md) - [ModelReturn](doc//ModelReturn.md) - [Name](doc//Name.md) - [NullableClass](doc//NullableClass.md) diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/AnotherFakeApi.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/AnotherFakeApi.md index a0291cd1850..c3781f38137 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/AnotherFakeApi.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/AnotherFakeApi.md @@ -13,7 +13,7 @@ Method | HTTP request | Description # **call123testSpecialTags** -> Client call123testSpecialTags(client) +> ModelClient call123testSpecialTags(modelClient) To test special tags @@ -24,10 +24,10 @@ To test special tags and operation ID starting with number import 'package:openapi/api.dart'; final api_instance = AnotherFakeApi(); -final client = Client(); // Client | client model +final modelClient = ModelClient(); // ModelClient | client model try { - final result = api_instance.call123testSpecialTags(client); + final result = api_instance.call123testSpecialTags(modelClient); print(result); } catch (e) { print('Exception when calling AnotherFakeApi->call123testSpecialTags: $e\n'); @@ -38,11 +38,11 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **client** | [**Client**](Client.md)| client model | + **modelClient** | [**ModelClient**](ModelClient.md)| client model | ### Return type -[**Client**](Client.md) +[**ModelClient**](ModelClient.md) ### Authorization diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md index c1b0cf767e0..d8dfaf9329c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md @@ -364,7 +364,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **testClientModel** -> Client testClientModel(client) +> ModelClient testClientModel(modelClient) To test \"client\" model @@ -375,10 +375,10 @@ To test \"client\" model import 'package:openapi/api.dart'; final api_instance = FakeApi(); -final client = Client(); // Client | client model +final modelClient = ModelClient(); // ModelClient | client model try { - final result = api_instance.testClientModel(client); + final result = api_instance.testClientModel(modelClient); print(result); } catch (e) { print('Exception when calling FakeApi->testClientModel: $e\n'); @@ -389,11 +389,11 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **client** | [**Client**](Client.md)| client model | + **modelClient** | [**ModelClient**](ModelClient.md)| client model | ### Return type -[**Client**](Client.md) +[**ModelClient**](ModelClient.md) ### Authorization diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeClassnameTags123Api.md index 3c0be2a0435..e1045471420 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeClassnameTags123Api.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeClassnameTags123Api.md @@ -13,7 +13,7 @@ Method | HTTP request | Description # **testClassname** -> Client testClassname(client) +> ModelClient testClassname(modelClient) To test class name in snake case @@ -28,10 +28,10 @@ import 'package:openapi/api.dart'; //defaultApiClient.getAuthentication('api_key_query').apiKeyPrefix = 'Bearer'; final api_instance = FakeClassnameTags123Api(); -final client = Client(); // Client | client model +final modelClient = ModelClient(); // ModelClient | client model try { - final result = api_instance.testClassname(client); + final result = api_instance.testClassname(modelClient); print(result); } catch (e) { print('Exception when calling FakeClassnameTags123Api->testClassname: $e\n'); @@ -42,11 +42,11 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **client** | [**Client**](Client.md)| client model | + **modelClient** | [**ModelClient**](ModelClient.md)| client model | ### Return type -[**Client**](Client.md) +[**ModelClient**](ModelClient.md) ### Authorization diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FileSchemaTestClass.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FileSchemaTestClass.md index d5b1765fdc1..eae1dfbe979 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FileSchemaTestClass.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FileSchemaTestClass.md @@ -8,8 +8,8 @@ import 'package:openapi/api.dart'; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**file** | [**MultipartFile**](MultipartFile.md) | | [optional] -**files** | [**List**](MultipartFile.md) | | [optional] [default to const []] +**file** | [**ModelFile**](ModelFile.md) | | [optional] +**files** | [**List**](ModelFile.md) | | [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/doc/FormatTest.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FormatTest.md index a2915ebfc5a..83b60545eb6 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FormatTest.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FormatTest.md @@ -17,7 +17,7 @@ Name | Type | Description | Notes **decimal** | **double** | | [optional] **string** | **String** | | [optional] **byte** | **String** | | -**binary** | [**MultipartFile**](File.md) | | [optional] +**binary** | [**MultipartFile**](MultipartFile.md) | | [optional] **date** | [**DateTime**](DateTime.md) | | **dateTime** | [**DateTime**](DateTime.md) | | [optional] **uuid** | **String** | | [optional] diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject1.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject1.md index 013aa87e9bb..0a92dbfdb95 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject1.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject1.md @@ -9,7 +9,7 @@ import 'package:openapi/api.dart'; Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **additionalMetadata** | **String** | Additional data to pass to server | [optional] -**file** | [**MultipartFile**](File.md) | file to upload | [optional] +**file** | [**MultipartFile**](MultipartFile.md) | file to upload | [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/InlineObject3.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject3.md index 4ea5db6bc72..c9a110e7c8c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject3.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject3.md @@ -17,7 +17,7 @@ Name | Type | Description | Notes **string** | **String** | None | [optional] **patternWithoutDelimiter** | **String** | None | **byte** | **String** | None | -**binary** | [**MultipartFile**](File.md) | None | [optional] +**binary** | [**MultipartFile**](MultipartFile.md) | None | [optional] **date** | [**DateTime**](DateTime.md) | None | [optional] **dateTime** | [**DateTime**](DateTime.md) | None | [optional] **password** | **String** | None | [optional] diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject5.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject5.md index b82544d520a..35879f28bd1 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject5.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/InlineObject5.md @@ -9,7 +9,7 @@ import 'package:openapi/api.dart'; Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **additionalMetadata** | **String** | Additional data to pass to server | [optional] -**requiredFile** | [**MultipartFile**](File.md) | file to upload | +**requiredFile** | [**MultipartFile**](MultipartFile.md) | file to upload | [[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/Client.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ModelClient.md similarity index 93% rename from samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/Client.md rename to samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ModelClient.md index 8e8f3c56b1a..f7b922f4a39 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/Client.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ModelClient.md @@ -1,4 +1,4 @@ -# openapi.model.Client +# openapi.model.ModelClient ## Load the model package ```dart diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/File.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ModelFile.md similarity index 94% rename from samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/File.md rename to samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ModelFile.md index 02f2e417682..4be260e93f6 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/File.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ModelFile.md @@ -1,4 +1,4 @@ -# openapi.model.File +# openapi.model.ModelFile ## Load the model package ```dart diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ModelList.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ModelList.md new file mode 100644 index 00000000000..283aa1f6b71 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ModelList.md @@ -0,0 +1,15 @@ +# openapi.model.ModelList + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**n123list** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart index a7ada3bdb05..36b0ba50ea8 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 @@ -45,13 +45,11 @@ part 'model/cat.dart'; part 'model/cat_all_of.dart'; part 'model/category.dart'; part 'model/class_model.dart'; -part 'model/client.dart'; part 'model/dog.dart'; part 'model/dog_all_of.dart'; part 'model/enum_arrays.dart'; part 'model/enum_class.dart'; part 'model/enum_test.dart'; -part 'model/file.dart'; part 'model/file_schema_test_class.dart'; part 'model/foo.dart'; part 'model/format_test.dart'; @@ -67,6 +65,9 @@ part 'model/inline_response_default.dart'; part 'model/map_test.dart'; part 'model/mixed_properties_and_additional_properties_class.dart'; part 'model/model200_response.dart'; +part 'model/model_client.dart'; +part 'model/model_file.dart'; +part 'model/model_list.dart'; part 'model/model_return.dart'; part 'model/name.dart'; part 'model/nullable_class.dart'; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart index b55bea6d520..4427dbe17da 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart @@ -23,17 +23,17 @@ class AnotherFakeApi { /// /// Parameters: /// - /// * [Client] client (required): + /// * [ModelClient] modelClient (required): /// client model - Future call123testSpecialTagsWithHttpInfo(Client client) async { + Future call123testSpecialTagsWithHttpInfo(ModelClient modelClient) async { // Verify required params are set. - if (client == null) { - throw ApiException(HttpStatus.badRequest, 'Missing required param: client'); + if (modelClient == null) { + throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient'); } final path = '/another-fake/dummy'.replaceAll('{format}', 'json'); - Object postBody = client; + Object postBody = modelClient; final queryParams = []; final headerParams = {}; @@ -73,10 +73,10 @@ class AnotherFakeApi { /// /// Parameters: /// - /// * [Client] client (required): + /// * [ModelClient] modelClient (required): /// client model - Future call123testSpecialTags(Client client) async { - final response = await call123testSpecialTagsWithHttpInfo(client); + Future call123testSpecialTags(ModelClient modelClient) async { + final response = await call123testSpecialTagsWithHttpInfo(modelClient); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, _decodeBodyBytes(response)); } @@ -84,7 +84,7 @@ class AnotherFakeApi { // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Client') as Client; + return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient; } return null; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart index 4ab4555246a..af1425e338b 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart @@ -555,17 +555,17 @@ class FakeApi { /// /// Parameters: /// - /// * [Client] client (required): + /// * [ModelClient] modelClient (required): /// client model - Future testClientModelWithHttpInfo(Client client) async { + Future testClientModelWithHttpInfo(ModelClient modelClient) async { // Verify required params are set. - if (client == null) { - throw ApiException(HttpStatus.badRequest, 'Missing required param: client'); + if (modelClient == null) { + throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient'); } final path = '/fake'.replaceAll('{format}', 'json'); - Object postBody = client; + Object postBody = modelClient; final queryParams = []; final headerParams = {}; @@ -605,10 +605,10 @@ class FakeApi { /// /// Parameters: /// - /// * [Client] client (required): + /// * [ModelClient] modelClient (required): /// client model - Future testClientModel(Client client) async { - final response = await testClientModelWithHttpInfo(client); + Future testClientModel(ModelClient modelClient) async { + final response = await testClientModelWithHttpInfo(modelClient); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, _decodeBodyBytes(response)); } @@ -616,7 +616,7 @@ class FakeApi { // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Client') as Client; + return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient; } return null; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart index 8bc9fc650a6..3743aa85c28 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart @@ -23,17 +23,17 @@ class FakeClassnameTags123Api { /// /// Parameters: /// - /// * [Client] client (required): + /// * [ModelClient] modelClient (required): /// client model - Future testClassnameWithHttpInfo(Client client) async { + Future testClassnameWithHttpInfo(ModelClient modelClient) async { // Verify required params are set. - if (client == null) { - throw ApiException(HttpStatus.badRequest, 'Missing required param: client'); + if (modelClient == null) { + throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient'); } final path = '/fake_classname_test'.replaceAll('{format}', 'json'); - Object postBody = client; + Object postBody = modelClient; final queryParams = []; final headerParams = {}; @@ -73,10 +73,10 @@ class FakeClassnameTags123Api { /// /// Parameters: /// - /// * [Client] client (required): + /// * [ModelClient] modelClient (required): /// client model - Future testClassname(Client client) async { - final response = await testClassnameWithHttpInfo(client); + Future testClassname(ModelClient modelClient) async { + final response = await testClassnameWithHttpInfo(modelClient); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, _decodeBodyBytes(response)); } @@ -84,7 +84,7 @@ class FakeClassnameTags123Api { // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Client') as Client; + return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient; } return null; } 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 1f87ced5ff2..c1fe27914fe 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 @@ -186,8 +186,6 @@ class ApiClient { return Category.fromJson(value); case 'ClassModel': return ClassModel.fromJson(value); - case 'Client': - return Client.fromJson(value); case 'Dog': return Dog.fromJson(value); case 'DogAllOf': @@ -198,8 +196,6 @@ class ApiClient { return EnumClassTypeTransformer().decode(value); case 'EnumTest': return EnumTest.fromJson(value); - case 'File': - return File.fromJson(value); case 'FileSchemaTestClass': return FileSchemaTestClass.fromJson(value); case 'Foo': @@ -230,6 +226,12 @@ class ApiClient { return MixedPropertiesAndAdditionalPropertiesClass.fromJson(value); case 'Model200Response': return Model200Response.fromJson(value); + case 'ModelClient': + return ModelClient.fromJson(value); + case 'ModelFile': + return ModelFile.fromJson(value); + case 'ModelList': + return ModelList.fromJson(value); case 'ModelReturn': return ModelReturn.fromJson(value); case 'Name': diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/client.dart deleted file mode 100644 index 921dd1e66b9..00000000000 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/client.dart +++ /dev/null @@ -1,71 +0,0 @@ -// -// 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: lines_longer_than_80_chars - -part of openapi.api; - -class Client { - /// Returns a new [Client] instance. - Client({ - this.client, - }); - - String client; - - @override - bool operator ==(Object other) => identical(this, other) || other is Client && - other.client == client; - - @override - int get hashCode => - (client == null ? 0 : client.hashCode); - - @override - String toString() => 'Client[client=$client]'; - - Map toJson() { - final json = {}; - if (client != null) { - json[r'client'] = client; - } - return json; - } - - /// Returns a new [Client] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Client fromJson(Map json) => json == null - ? null - : Client( - client: json[r'client'], - ); - - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((v) => Client.fromJson(v)).toList(growable: true == growable); - - static Map mapFromJson(Map json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((String key, dynamic v) => map[key] = Client.fromJson(v)); - } - return map; - } - - // maps a json object with a list of Client-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { - final map = >{}; - if (json != null && json.isNotEmpty) { - json.forEach((String key, dynamic v) { - map[key] = Client.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable); - }); - } - return map; - } -} - diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file.dart deleted file mode 100644 index ce38e5a122a..00000000000 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file.dart +++ /dev/null @@ -1,72 +0,0 @@ -// -// 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: lines_longer_than_80_chars - -part of openapi.api; - -class File { - /// Returns a new [File] instance. - File({ - this.sourceURI, - }); - - /// Test capitalization - String sourceURI; - - @override - bool operator ==(Object other) => identical(this, other) || other is File && - other.sourceURI == sourceURI; - - @override - int get hashCode => - (sourceURI == null ? 0 : sourceURI.hashCode); - - @override - String toString() => 'File[sourceURI=$sourceURI]'; - - Map toJson() { - final json = {}; - if (sourceURI != null) { - json[r'sourceURI'] = sourceURI; - } - return json; - } - - /// Returns a new [File] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static File fromJson(Map json) => json == null - ? null - : File( - sourceURI: json[r'sourceURI'], - ); - - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((v) => File.fromJson(v)).toList(growable: true == growable); - - static Map mapFromJson(Map json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((String key, dynamic v) => map[key] = File.fromJson(v)); - } - return map; - } - - // maps a json object with a list of File-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { - final map = >{}; - if (json != null && json.isNotEmpty) { - json.forEach((String key, dynamic v) { - map[key] = File.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable); - }); - } - return map; - } -} - 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 a6498793ded..fb5f7593554 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 @@ -16,9 +16,9 @@ class FileSchemaTestClass { this.files = const [], }); - MultipartFile file; + ModelFile file; - List files; + List files; @override bool operator ==(Object other) => identical(this, other) || other is FileSchemaTestClass && @@ -49,8 +49,8 @@ class FileSchemaTestClass { static FileSchemaTestClass fromJson(Map json) => json == null ? null : FileSchemaTestClass( - file: MultipartFile.fromJson(json[r'file']), - files: MultipartFile.listFromJson(json[r'files']), + file: ModelFile.fromJson(json[r'file']), + files: ModelFile.listFromJson(json[r'files']), ); static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => 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 new file mode 100644 index 00000000000..08b98859176 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_client.dart @@ -0,0 +1,71 @@ +// +// 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: lines_longer_than_80_chars + +part of openapi.api; + +class ModelClient { + /// Returns a new [ModelClient] instance. + ModelClient({ + this.client, + }); + + String client; + + @override + bool operator ==(Object other) => identical(this, other) || other is ModelClient && + other.client == client; + + @override + int get hashCode => + (client == null ? 0 : client.hashCode); + + @override + String toString() => 'ModelClient[client=$client]'; + + Map toJson() { + final json = {}; + if (client != null) { + json[r'client'] = client; + } + return json; + } + + /// Returns a new [ModelClient] instance and imports its values from + /// [json] if it's non-null, null if [json] is null. + static ModelClient fromJson(Map json) => json == null + ? null + : ModelClient( + client: json[r'client'], + ); + + static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => + json == null || json.isEmpty + ? true == emptyIsNull ? null : [] + : json.map((v) => ModelClient.fromJson(v)).toList(growable: true == growable); + + static Map mapFromJson(Map json) { + final map = {}; + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic v) => map[key] = ModelClient.fromJson(v)); + } + return map; + } + + // maps a json object with a list of ModelClient-objects as value to a dart map + static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + final map = >{}; + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic v) { + map[key] = ModelClient.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable); + }); + } + return map; + } +} + 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 new file mode 100644 index 00000000000..0ca3001c062 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_file.dart @@ -0,0 +1,72 @@ +// +// 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: lines_longer_than_80_chars + +part of openapi.api; + +class ModelFile { + /// Returns a new [ModelFile] instance. + ModelFile({ + this.sourceURI, + }); + + /// Test capitalization + String sourceURI; + + @override + bool operator ==(Object other) => identical(this, other) || other is ModelFile && + other.sourceURI == sourceURI; + + @override + int get hashCode => + (sourceURI == null ? 0 : sourceURI.hashCode); + + @override + String toString() => 'ModelFile[sourceURI=$sourceURI]'; + + Map toJson() { + final json = {}; + if (sourceURI != null) { + json[r'sourceURI'] = sourceURI; + } + return json; + } + + /// Returns a new [ModelFile] instance and imports its values from + /// [json] if it's non-null, null if [json] is null. + static ModelFile fromJson(Map json) => json == null + ? null + : ModelFile( + sourceURI: json[r'sourceURI'], + ); + + static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => + json == null || json.isEmpty + ? true == emptyIsNull ? null : [] + : json.map((v) => ModelFile.fromJson(v)).toList(growable: true == growable); + + static Map mapFromJson(Map json) { + final map = {}; + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic v) => map[key] = ModelFile.fromJson(v)); + } + return map; + } + + // maps a json object with a list of ModelFile-objects as value to a dart map + static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + final map = >{}; + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic v) { + map[key] = ModelFile.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable); + }); + } + return map; + } +} + 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 new file mode 100644 index 00000000000..973198375ad --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_list.dart @@ -0,0 +1,71 @@ +// +// 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: lines_longer_than_80_chars + +part of openapi.api; + +class ModelList { + /// Returns a new [ModelList] instance. + ModelList({ + this.n123list, + }); + + String n123list; + + @override + bool operator ==(Object other) => identical(this, other) || other is ModelList && + other.n123list == n123list; + + @override + int get hashCode => + (n123list == null ? 0 : n123list.hashCode); + + @override + String toString() => 'ModelList[n123list=$n123list]'; + + Map toJson() { + final json = {}; + if (n123list != null) { + json[r'123-list'] = n123list; + } + return json; + } + + /// Returns a new [ModelList] instance and imports its values from + /// [json] if it's non-null, null if [json] is null. + static ModelList fromJson(Map json) => json == null + ? null + : ModelList( + n123list: json[r'123-list'], + ); + + static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => + json == null || json.isEmpty + ? true == emptyIsNull ? null : [] + : json.map((v) => ModelList.fromJson(v)).toList(growable: true == growable); + + static Map mapFromJson(Map json) { + final map = {}; + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic v) => map[key] = ModelList.fromJson(v)); + } + return map; + } + + // maps a json object with a list of ModelList-objects as value to a dart map + static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + final map = >{}; + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic v) { + map[key] = ModelList.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable); + }); + } + return map; + } +} + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/client_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/model_client_test.dart similarity index 67% rename from samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/client_test.dart rename to samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/model_client_test.dart index 27a4ac8b3aa..e4122269ff8 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/client_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/model_client_test.dart @@ -1,11 +1,11 @@ import 'package:openapi/api.dart'; import 'package:test/test.dart'; -// tests for Client +// tests for ModelClient void main() { - final instance = Client(); + final instance = ModelClient(); - group('test Client', () { + group('test ModelClient', () { // String client test('to test the property `client`', () async { // TODO diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/file_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/model_file_test.dart similarity index 72% rename from samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/file_test.dart rename to samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/model_file_test.dart index b838399e08c..54a3bf5e756 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/file_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/model_file_test.dart @@ -1,11 +1,11 @@ import 'package:openapi/api.dart'; import 'package:test/test.dart'; -// tests for File +// tests for ModelFile void main() { - final instance = File(); + final instance = ModelFile(); - group('test File', () { + group('test ModelFile', () { // Test capitalization // String sourceURI test('to test the property `sourceURI`', () async { diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/model_list_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/model_list_test.dart new file mode 100644 index 00000000000..6dccfafbe0a --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/model_list_test.dart @@ -0,0 +1,17 @@ +import 'package:openapi/api.dart'; +import 'package:test/test.dart'; + +// tests for ModelList +void main() { + final instance = ModelList(); + + group('test ModelList', () { + // String n123list + test('to test the property `n123list`', () async { + // TODO + }); + + + }); + +}