|
|
@ -779,7 +779,7 @@ class OpenAPIBuilder implements Builder { |
|
|
|
code.write('if (${_toDartName(parameter.name)} != null) {'); |
|
|
|
code.write('if (${_toDartName(parameter.name)} != null) {'); |
|
|
|
} |
|
|
|
} |
|
|
|
final value = result.encode( |
|
|
|
final value = result.encode( |
|
|
|
result.serialize(_toDartName(parameter.name)), |
|
|
|
_toDartName(parameter.name), |
|
|
|
onlyChildren: result is TypeResultList && parameter.in_ == 'query', |
|
|
|
onlyChildren: result is TypeResultList && parameter.in_ == 'query', |
|
|
|
// Objects inside the query always have to be interpreted in some way |
|
|
|
// Objects inside the query always have to be interpreted in some way |
|
|
|
mimeType: 'application/json', |
|
|
|
mimeType: 'application/json', |
|
|
@ -858,7 +858,7 @@ class OpenAPIBuilder implements Builder { |
|
|
|
code.write('if ($parameterName != null) {'); |
|
|
|
code.write('if ($parameterName != null) {'); |
|
|
|
} |
|
|
|
} |
|
|
|
code.write( |
|
|
|
code.write( |
|
|
|
'body = Uint8List.fromList(utf8.encode(${result.encode(result.serialize(parameterName), mimeType: mimeType)}));', |
|
|
|
'body = Uint8List.fromList(utf8.encode(${result.encode(parameterName, mimeType: mimeType)}));', |
|
|
|
); |
|
|
|
); |
|
|
|
if (dartParameterNullable) { |
|
|
|
if (dartParameterNullable) { |
|
|
|
code.write('}'); |
|
|
|
code.write('}'); |
|
|
@ -1493,9 +1493,13 @@ TypeResult resolveObject( |
|
|
|
return [ |
|
|
|
return [ |
|
|
|
Code("case '$propertyName':"), |
|
|
|
Code("case '$propertyName':"), |
|
|
|
if (result.className != 'String') ...[ |
|
|
|
if (result.className != 'String') ...[ |
|
|
|
|
|
|
|
if (result is TypeResultBase || result is TypeResultEnum) ...[ |
|
|
|
|
|
|
|
Code('result.${_toDartName(propertyName)} = ${result.deserialize(result.decode('value!'))};'), |
|
|
|
|
|
|
|
] else ...[ |
|
|
|
Code( |
|
|
|
Code( |
|
|
|
'result.${_toDartName(propertyName)} = ${result.deserialize('jsonDecode(value!)', toBuilder: true)};', |
|
|
|
'result.${_toDartName(propertyName)}.replace(${result.deserialize(result.decode('value!'))});', |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
] else ...[ |
|
|
|
] else ...[ |
|
|
|
Code( |
|
|
|
Code( |
|
|
|
'result.${_toDartName(propertyName)} = value!;', |
|
|
|
'result.${_toDartName(propertyName)} = value!;', |
|
|
@ -1512,7 +1516,7 @@ TypeResult resolveObject( |
|
|
|
const Code('while (iterator.moveNext()) {'), |
|
|
|
const Code('while (iterator.moveNext()) {'), |
|
|
|
const Code('final key = iterator.current! as String;'), |
|
|
|
const Code('final key = iterator.current! as String;'), |
|
|
|
const Code('iterator.moveNext();'), |
|
|
|
const Code('iterator.moveNext();'), |
|
|
|
const Code('final value = iterator.current as String?;'), |
|
|
|
const Code('final value = iterator.current! as String;'), |
|
|
|
const Code('switch (key) {'), |
|
|
|
const Code('switch (key) {'), |
|
|
|
for (final propertyName in schema.properties!.keys) ...[ |
|
|
|
for (final propertyName in schema.properties!.keys) ...[ |
|
|
|
...deserializeProperty(propertyName), |
|
|
|
...deserializeProperty(propertyName), |
|
|
@ -1749,7 +1753,11 @@ TypeResult resolveType( |
|
|
|
'..data = JsonObject(data);', |
|
|
|
'..data = JsonObject(data);', |
|
|
|
if (schema.allOf != null) ...[ |
|
|
|
if (schema.allOf != null) ...[ |
|
|
|
for (final result in results) ...[ |
|
|
|
for (final result in results) ...[ |
|
|
|
'result.${fields[result.name]!} = ${result.deserialize('data', toBuilder: true)};', |
|
|
|
if (result is TypeResultBase || result is TypeResultEnum) ...[ |
|
|
|
|
|
|
|
'result.${fields[result.name]!} = ${result.deserialize('data')};', |
|
|
|
|
|
|
|
] else ...[ |
|
|
|
|
|
|
|
'result.${fields[result.name]!}.replace(${result.deserialize('data')});', |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
] else ...[ |
|
|
|
] else ...[ |
|
|
|
if (schema.discriminator != null) ...[ |
|
|
|
if (schema.discriminator != null) ...[ |
|
|
@ -1786,7 +1794,11 @@ TypeResult resolveType( |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
'try {', |
|
|
|
'try {', |
|
|
|
'result.${fields[result.name]!} = ${result.deserialize('data', toBuilder: true)};', |
|
|
|
if (result is TypeResultBase || result is TypeResultEnum) ...[ |
|
|
|
|
|
|
|
'result._${fields[result.name]!} = ${result.deserialize('data')};', |
|
|
|
|
|
|
|
] else ...[ |
|
|
|
|
|
|
|
'result._${fields[result.name]!} = ${result.deserialize('data')}.toBuilder();', |
|
|
|
|
|
|
|
], |
|
|
|
'} catch (_) {', |
|
|
|
'} catch (_) {', |
|
|
|
if (schema.discriminator != null) ...[ |
|
|
|
if (schema.discriminator != null) ...[ |
|
|
|
'rethrow;', |
|
|
|
'rethrow;', |
|
|
|