Browse Source

dynamite: Fix content string arrays

pull/169/head
jld3103 2 years ago
parent
commit
23987704bf
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 7
      packages/dynamite/lib/src/openapi_builder.dart

7
packages/dynamite/lib/src/openapi_builder.dart

@ -1182,8 +1182,7 @@ TypeResult resolveObject(
]); ]);
final hasDifferentName = _toDartName(propertyName) != propertyName; final hasDifferentName = _toDartName(propertyName) != propertyName;
final isContentString = propertySchema.isContentString; final isContentString = propertySchema.isContentString;
final isContentStringArray = final isContentStringArray = isContentString && result is TypeResultList;
result is TypeResultList && (propertySchema.items?.isContentString ?? false);
final hasExtraJsonKeyValues = final hasExtraJsonKeyValues =
extraJsonKeyValues != null && extraJsonKeyValues.containsKey(propertyName); extraJsonKeyValues != null && extraJsonKeyValues.containsKey(propertyName);
if (hasDifferentName || isContentString || isContentStringArray || hasExtraJsonKeyValues) { if (hasDifferentName || isContentString || isContentStringArray || hasExtraJsonKeyValues) {
@ -1217,7 +1216,7 @@ TypeResult resolveObject(
Method( Method(
(final b) => b (final b) => b
..name = toJson ..name = toJson
..returns = refer('List<String>?') ..returns = refer('String?')
..lambda = true ..lambda = true
..requiredParameters.addAll([ ..requiredParameters.addAll([
Parameter( Parameter(
@ -1227,7 +1226,7 @@ TypeResult resolveObject(
), ),
]) ])
..body = Code( ..body = Code(
'data == null ? null : ${result.encode(result.serialize('data'), mimeType: 'application/json', onlyChildren: true)};', 'data == null ? null : ${result.encode(result.serialize('data'), mimeType: 'application/json')};',
), ),
), ),
); );

Loading…
Cancel
Save