From 3c162e2b4651ed570b8e4c768be196678bb71fa3 Mon Sep 17 00:00:00 2001 From: Uladzimir_Paliukhovich Date: Wed, 24 Jan 2024 14:33:06 +0300 Subject: [PATCH] Development (#718) * Fixed some issues * formatted code * updated SDK * Updated SDK and version * Fixed generation of lists of classes * Fixed generation $Items classes * Updated pubspec and changelog * Fixed #524 * Fixed #598 Generation of query enum parameters * Fixed conflicts * Fixed some issues in swaggers * Updated changelog and pubspec * Fix #583, #637, #619 and update readme (#638) * fix #583 and update readme * fix #637 * fix #619 * Fixed generation of some fields * Removed test * Fixed classes named List * Fixed generation of query parameters with ref default type * Fixed generation of DateTime parameters * Fixed generation of responses in some cases * Some fixes * Updated changelog and pubspec * Implemented not nullable fields * Fixed tests * fixed generation of some swaggers * Added ability to return String values * Returned main.dart content * Updated pubspec and changelog * Fixed generation of required and not required fields * Added check for object ref in body * Fixed some things * Fixed tests * Fixed tests * Fixed some things * Updated changelog and pubspec * Removed not needed lines in tests * Fixed generation of nullable responses * Added generation of DateTime * Updated pubspec and changelog * Fixed tests * Fixed #669 Generation models from content schema allof * Fixed #665 generation putIfAbsent for response from content schema * Fixed generation of nullable and required properties * Fixed tests * Fixed some stuff related to nullable properties * Updated changelog and pubspec * Formatted code * Formatted code * Fixed tests * Fixed generation of some enums inside classes * Implemented support of exploded parameters * Pushed constants file * Fixed generation of allOf for request bodies * Implemented overriden_models functionality * Improved overriden models logic * Fixed tests * Updated pubspec and changelog * Removed support of exploded parameters * Fixed generation of patameters contains keywords * Updated pubspec and changelog * Fixed generation of nullable and not nullable fields * Fixed generation of list parameters with specific names * Fixed formurlencoded requests * Revert "Fixed formurlencoded requests" This reverts commit d103118975e7f66ec2cbf10a1f9d28ef935be6eb. * Updated changelog and pubspec * formatted code * Fixed version in changelog * Added generation of writeOnly and readOnly fields as nullable and no required (Issue 487) * Fixed generatino of DateTime query parameters (Issue 536) * Updated pubspec and changelog * Fixed generation in some cases * Added ability to rename downloaded files * Updated example * Implemented support of deprecated fields annotations * Added support of deprecated requests annotations * Fixed tests, updated pubspec and changelog * Fixed putIfAbsent for allOf schemas #700 * Fixed tests * Implemented new build option * Some fixes * Implemented new generator option * Updated changelog, readme and pubspec * Fixed conflicts * Fixed generation of requestBody when one oneOf provided * Added override keyword to exceptionWords --------- Co-authored-by: Uladzimir Paliukhovich Co-authored-by: Romain --- example/input_folder/some_file_name.json | 2 +- lib/src/code_generators/swagger_requests_generator.dart | 5 ++++- lib/src/exception_words.dart | 3 ++- lib/src/models/generator_options.g.dart | 1 + pubspec.yaml | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/example/input_folder/some_file_name.json b/example/input_folder/some_file_name.json index 1c5db9ab..e9a3b569 100644 --- a/example/input_folder/some_file_name.json +++ b/example/input_folder/some_file_name.json @@ -1033,4 +1033,4 @@ "description": "Find out more about Swagger", "url": "http://swagger.io" } -} \ No newline at end of file +} diff --git a/lib/src/code_generators/swagger_requests_generator.dart b/lib/src/code_generators/swagger_requests_generator.dart index 3f125a0d..7139513b 100644 --- a/lib/src/code_generators/swagger_requests_generator.dart +++ b/lib/src/code_generators/swagger_requests_generator.dart @@ -960,7 +960,10 @@ class SwaggerRequestsGenerator extends SwaggerGeneratorBase { final schema = requestBody.content?.schema; if (schema != null) { - if (schema.format == kBinary || schema.oneOf.isNotEmpty) { + if (schema.oneOf.length == 1) { + final oneOfRef = schema.oneOf.first.ref.getUnformattedRef(); + typeName = getValidatedClassName(oneOfRef); + } else if (schema.format == kBinary || schema.oneOf.isNotEmpty) { typeName = kObject.pascalCase; } else if (schema.items?.type.isNotEmpty == true) { typeName = _mapParameterName(schema.items!.type, schema.items!.format, diff --git a/lib/src/exception_words.dart b/lib/src/exception_words.dart index 26facfe1..bca978c6 100644 --- a/lib/src/exception_words.dart +++ b/lib/src/exception_words.dart @@ -55,5 +55,6 @@ List exceptionWords = [ 'try', 'client', 'hashCode', - 'value' + 'value', + 'override', ]; diff --git a/lib/src/models/generator_options.g.dart b/lib/src/models/generator_options.g.dart index 4e3560c2..3f1be435 100644 --- a/lib/src/models/generator_options.g.dart +++ b/lib/src/models/generator_options.g.dart @@ -128,6 +128,7 @@ Map _$GeneratorOptionsToJson(GeneratorOptions instance) => 'import_paths': instance.importPaths, 'custom_return_type': instance.customReturnType, 'exclude_paths': instance.excludePaths, + 'generate_first_succeed_response': instance.generateFirstSucceedResponse, }; DefaultValueMap _$DefaultValueMapFromJson(Map json) => diff --git a/pubspec.yaml b/pubspec.yaml index 843edf1c..ae65b130 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: swagger_dart_code_generator -version: 2.15.0 +version: 2.14.2 homepage: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator repository: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator