Skip to content

Commit

Permalink
Merge pull request #2 from arnac-io/fix/to_json_cycle
Browse files Browse the repository at this point in the history
Fix endless cycle of toJson for objects with a discriminator [DEV-13014]
  • Loading branch information
nadav-fordefi authored Feb 5, 2024
2 parents 1a8ef11 + ae693a9 commit 05d4c6c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/code_generators/swagger_models_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ $copyWithMethod
String generateToJson(SwaggerSchema schema, String validatedClassName) {
final hasMapping = schema.discriminator?.mapping.isNotEmpty ?? false;
if (hasMapping) {
return 'static Map<String, dynamic> _\$${validatedClassName}ToJson($validatedClassName instance) { return instance.toJson();}\n\n'
return 'static Map<String, dynamic> _\$${validatedClassName}ToJson($validatedClassName instance) { return Map<String, dynamic>();}\n\n'
'Map<String, dynamic> toJson() =>'
'_\$${validatedClassName}ToJson(this)'
'\t\t\t${schema.discriminator!.mapping.entries.map(
Expand Down

0 comments on commit 05d4c6c

Please sign in to comment.