From 46b275457ccb65de4e9e2ae9ed0a5daeb10621b6 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sat, 2 Sep 2023 20:32:44 +0200 Subject: [PATCH] refactor(dynamite): improve code readability Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/openapi_builder.dart | 73 +++++++++---------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/dynamite/lib/src/openapi_builder.dart index d4648b2c..6c8f95ed 100644 --- a/packages/dynamite/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/dynamite/lib/src/openapi_builder.dart @@ -1587,52 +1587,47 @@ TypeResult resolveType( } case 'object': if (schema.properties == null) { - if (schema.additionalProperties != null) { - if (schema.additionalProperties is EmptySchema) { - result = TypeResultMap( - 'BuiltMap', - TypeResultBase('JsonObject'), - nullable: nullable, - ); - } else { - final subResult = resolveType( - spec, - variablePrefix, - state, - identifier, - schema.additionalProperties!, - ); - result = TypeResultMap( - 'BuiltMap', - subResult, - nullable: nullable, - ); - } - break; + if (schema.additionalProperties == null) { + result = TypeResultBase( + 'JsonObject', + nullable: nullable, + ); + } else if (schema.additionalProperties is EmptySchema) { + result = TypeResultMap( + 'BuiltMap', + TypeResultBase('JsonObject'), + nullable: nullable, + ); + } else { + final subResult = resolveType( + spec, + variablePrefix, + state, + identifier, + schema.additionalProperties!, + ); + result = TypeResultMap( + 'BuiltMap', + subResult, + nullable: nullable, + ); } - result = TypeResultBase( - 'JsonObject', - nullable: nullable, - ); - break; - } - if (schema.properties!.isEmpty) { + } else if (schema.properties!.isEmpty) { result = TypeResultMap( 'BuiltMap', TypeResultBase('JsonObject'), nullable: nullable, ); - break; + } else { + result = resolveObject( + spec, + variablePrefix, + state, + identifier, + schema, + nullable: nullable, + ); } - - result = resolveObject( - spec, - variablePrefix, - state, - identifier, - schema, - nullable: nullable, - ); } }