From 8025cfcbaf0fd4a93b2104eabf2b79f748dcf097 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 16 Apr 2023 11:01:31 +0200 Subject: [PATCH] dynamite: Fix sorting of required parameters and properties with default values --- packages/dynamite/lib/src/openapi_builder.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/lib/src/openapi_builder.dart index 362f85ba..a23019eb 100644 --- a/packages/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/lib/src/openapi_builder.dart @@ -644,8 +644,8 @@ class OpenAPIBuilder implements Builder { if (operation.parameters != null) ...operation.parameters!, ]..sort( (final a, final b) => sortRequiredElements( - a.required ?? false, - b.required ?? false, + (a.required ?? false) && a.schema?.default_ == null, + (b.required ?? false) && b.schema?.default_ == null, ), ); b @@ -1242,8 +1242,8 @@ TypeResult resolveObject( final sortedParameterKeys = schema.properties!.keys.toList() ..sort( (final a, final b) => sortRequiredElements( - (schema.required ?? []).contains(a), - (schema.required ?? []).contains(b), + (schema.required ?? []).contains(a) && schema.properties![a]!.default_ == null, + (schema.required ?? []).contains(b) && schema.properties![b]!.default_ == null, ), ); b