Skip to content

Fix crash on multipart body referencing a schema without properties#467

Merged
Carapacik merged 1 commit into
Carapacik:mainfrom
N39r19:fix/multipart-ref-empty-properties
Jun 21, 2026
Merged

Fix crash on multipart body referencing a schema without properties#467
Carapacik merged 1 commit into
Carapacik:mainfrom
N39r19:fix/multipart-ref-empty-properties

Conversation

@N39r19

@N39r19 N39r19 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

What

Fixes #466

swagger_parser crashes (aborting the whole generation) when an endpoint declares a multipart/form-data request body that references (via \$ref) an object schema without a properties field.

type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast at OpenApiParser.parseRestClients.parametersV3.

Root cause

The multipart \$ref branch assumes the referenced schema always has properties, while the inline (non-\$ref) branch already tolerates a missing properties map (properties = {}). This makes the \$ref branch consistent with the inline one.

Reproducer (real-world)

An ASP.NET Core / FastEndpoints file-import endpoint whose request DTO is an empty placeholder while the file is read from the stream emits a multipart body referencing an empty object schema ({ "type": "object" }), e.g. POST /api/admin/team-schedule/importEmptyRequest. Today this wipes the entire generated client because make gen removes lib/src first and swagger_parser exits 0 despite the error.

Changes

  • open_api_parser.dart: null-guard properties in the multipart \$ref branch (treat as empty form, like the inline branch).
  • Added e2e test multipart_request_with_ref_no_properties.
  • CHANGELOG entry.

Checklist

  • dart format .
  • dart analyze — no issues
  • dart test — all tests pass (423 passed, 2 pre-existing skips)

@Carapacik Carapacik merged commit 842e8f8 into Carapacik:main Jun 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash on multipart/form-data body referencing a schema without properties

2 participants