|
|
@ -603,7 +603,7 @@ class OpenAPIBuilder implements Builder { |
|
|
|
if (nullable) { |
|
|
|
if (nullable) { |
|
|
|
code.write('if (${_toDartName(parameter.name)} != null) {'); |
|
|
|
code.write('if (${_toDartName(parameter.name)} != null) {'); |
|
|
|
} |
|
|
|
} |
|
|
|
final isPlainList = result is TypeResultList && !result.fromJsonString; |
|
|
|
final isPlainList = result is TypeResultList && !result.fromContentString; |
|
|
|
final value = result.encode( |
|
|
|
final value = result.encode( |
|
|
|
result.serialize(_toDartName(parameter.name)), |
|
|
|
result.serialize(_toDartName(parameter.name)), |
|
|
|
onlyChildren: isPlainList && parameter.in_ == 'query', |
|
|
|
onlyChildren: isPlainList && parameter.in_ == 'query', |
|
|
@ -1039,7 +1039,7 @@ TypeResult resolveObject( |
|
|
|
final Schema schema, { |
|
|
|
final Schema schema, { |
|
|
|
required final Map<String, String>? extraJsonSerializableValues, |
|
|
|
required final Map<String, String>? extraJsonSerializableValues, |
|
|
|
required final Map<String, Map<String, String>>? extraJsonKeyValues, |
|
|
|
required final Map<String, Map<String, String>>? extraJsonKeyValues, |
|
|
|
final bool fromJsonString = false, |
|
|
|
final bool fromContentString = false, |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
if (!state.resolvedTypes.contains('${state.prefix}$identifier')) { |
|
|
|
if (!state.resolvedTypes.contains('${state.prefix}$identifier')) { |
|
|
|
state.resolvedTypes.add('${state.prefix}$identifier'); |
|
|
|
state.resolvedTypes.add('${state.prefix}$identifier'); |
|
|
@ -1181,14 +1181,15 @@ TypeResult resolveObject( |
|
|
|
], |
|
|
|
], |
|
|
|
]); |
|
|
|
]); |
|
|
|
final hasDifferentName = _toDartName(propertyName) != propertyName; |
|
|
|
final hasDifferentName = _toDartName(propertyName) != propertyName; |
|
|
|
final isJsonString = propertySchema.isJsonString; |
|
|
|
final isContentString = propertySchema.isContentString; |
|
|
|
final isJsonStringArray = result is TypeResultList && (propertySchema.items?.isJsonString ?? false); |
|
|
|
final isContentStringArray = |
|
|
|
|
|
|
|
result is TypeResultList && (propertySchema.items?.isContentString ?? false); |
|
|
|
final hasExtraJsonKeyValues = |
|
|
|
final hasExtraJsonKeyValues = |
|
|
|
extraJsonKeyValues != null && extraJsonKeyValues.containsKey(propertyName); |
|
|
|
extraJsonKeyValues != null && extraJsonKeyValues.containsKey(propertyName); |
|
|
|
if (hasDifferentName || isJsonString || isJsonStringArray || hasExtraJsonKeyValues) { |
|
|
|
if (hasDifferentName || isContentString || isContentStringArray || hasExtraJsonKeyValues) { |
|
|
|
var fromJson = '${result.name}.fromJsonString'; |
|
|
|
var fromJson = '${result.name}.fromJsonString'; |
|
|
|
var toJson = '${result.name}.toJsonString'; |
|
|
|
var toJson = '${result.name}.toJsonString'; |
|
|
|
if (isJsonStringArray) { |
|
|
|
if (isContentStringArray) { |
|
|
|
fromJson = '_${_toDartName('${state.prefix}${identifier}FromJsonString')}'; |
|
|
|
fromJson = '_${_toDartName('${state.prefix}${identifier}FromJsonString')}'; |
|
|
|
if (!state.resolvedTypes.contains(fromJson)) { |
|
|
|
if (!state.resolvedTypes.contains(fromJson)) { |
|
|
|
state.resolvedTypes.add(fromJson); |
|
|
|
state.resolvedTypes.add(fromJson); |
|
|
@ -1240,7 +1241,7 @@ TypeResult resolveObject( |
|
|
|
if (hasDifferentName) ...{ |
|
|
|
if (hasDifferentName) ...{ |
|
|
|
'name': refer("'$propertyName'"), |
|
|
|
'name': refer("'$propertyName'"), |
|
|
|
}, |
|
|
|
}, |
|
|
|
if (isJsonString || isJsonStringArray) ...{ |
|
|
|
if (isContentString || isContentStringArray) ...{ |
|
|
|
'fromJson': refer(fromJson), |
|
|
|
'fromJson': refer(fromJson), |
|
|
|
'toJson': refer(toJson), |
|
|
|
'toJson': refer(toJson), |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1263,7 +1264,7 @@ TypeResult resolveObject( |
|
|
|
} |
|
|
|
} |
|
|
|
return TypeResultObject( |
|
|
|
return TypeResultObject( |
|
|
|
'${state.prefix}$identifier', |
|
|
|
'${state.prefix}$identifier', |
|
|
|
fromJsonString: fromJsonString, |
|
|
|
fromContentString: fromContentString, |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1275,7 +1276,7 @@ TypeResult resolveType( |
|
|
|
final Map<String, String>? extraJsonSerializableValues, |
|
|
|
final Map<String, String>? extraJsonSerializableValues, |
|
|
|
final Map<String, Map<String, String>>? extraJsonKeyValues, |
|
|
|
final Map<String, Map<String, String>>? extraJsonKeyValues, |
|
|
|
final bool ignoreEnum = false, |
|
|
|
final bool ignoreEnum = false, |
|
|
|
final bool fromJsonString = false, |
|
|
|
final bool fromContentString = false, |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
TypeResult? result; |
|
|
|
TypeResult? result; |
|
|
|
if (schema.ref != null) { |
|
|
|
if (schema.ref != null) { |
|
|
@ -1286,7 +1287,7 @@ TypeResult resolveType( |
|
|
|
name, |
|
|
|
name, |
|
|
|
spec.components!.schemas![name]!, |
|
|
|
spec.components!.schemas![name]!, |
|
|
|
extraJsonSerializableValues: extraJsonSerializableValues, |
|
|
|
extraJsonSerializableValues: extraJsonSerializableValues, |
|
|
|
fromJsonString: fromJsonString, |
|
|
|
fromContentString: fromContentString, |
|
|
|
); |
|
|
|
); |
|
|
|
} else if (schema.ofs != null) { |
|
|
|
} else if (schema.ofs != null) { |
|
|
|
if (!state.resolvedTypes.contains('${state.prefix}$identifier')) { |
|
|
|
if (!state.resolvedTypes.contains('${state.prefix}$identifier')) { |
|
|
@ -1482,14 +1483,14 @@ TypeResult resolveType( |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (schema.isJsonString) { |
|
|
|
if (schema.isContentString) { |
|
|
|
result = resolveType( |
|
|
|
result = resolveType( |
|
|
|
spec, |
|
|
|
spec, |
|
|
|
state, |
|
|
|
state, |
|
|
|
identifier, |
|
|
|
identifier, |
|
|
|
schema.contentSchema!, |
|
|
|
schema.contentSchema!, |
|
|
|
extraJsonSerializableValues: extraJsonSerializableValues, |
|
|
|
extraJsonSerializableValues: extraJsonSerializableValues, |
|
|
|
fromJsonString: true, |
|
|
|
fromContentString: true, |
|
|
|
); |
|
|
|
); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -1510,7 +1511,7 @@ TypeResult resolveType( |
|
|
|
result = TypeResultList( |
|
|
|
result = TypeResultList( |
|
|
|
'List<${subResult.name}>', |
|
|
|
'List<${subResult.name}>', |
|
|
|
subResult, |
|
|
|
subResult, |
|
|
|
fromJsonString: fromJsonString, |
|
|
|
fromContentString: fromContentString, |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
result = TypeResultList( |
|
|
|
result = TypeResultList( |
|
|
@ -1539,7 +1540,7 @@ TypeResult resolveType( |
|
|
|
schema, |
|
|
|
schema, |
|
|
|
extraJsonSerializableValues: extraJsonSerializableValues, |
|
|
|
extraJsonSerializableValues: extraJsonSerializableValues, |
|
|
|
extraJsonKeyValues: extraJsonKeyValues, |
|
|
|
extraJsonKeyValues: extraJsonKeyValues, |
|
|
|
fromJsonString: fromJsonString, |
|
|
|
fromContentString: fromContentString, |
|
|
|
); |
|
|
|
); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|