|
|
@ -642,7 +642,12 @@ class OpenAPIBuilder implements Builder { |
|
|
|
final parameters = <spec_parameter.Parameter>[ |
|
|
|
final parameters = <spec_parameter.Parameter>[ |
|
|
|
...pathParameters, |
|
|
|
...pathParameters, |
|
|
|
if (operation.parameters != null) ...operation.parameters!, |
|
|
|
if (operation.parameters != null) ...operation.parameters!, |
|
|
|
]; |
|
|
|
]..sort( |
|
|
|
|
|
|
|
(final a, final b) => sortRequiredElements( |
|
|
|
|
|
|
|
a.required ?? false, |
|
|
|
|
|
|
|
b.required ?? false, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
b |
|
|
|
b |
|
|
|
..name = _toDartName(_filterMethodName(operationId, tag ?? '')) |
|
|
|
..name = _toDartName(_filterMethodName(operationId, tag ?? '')) |
|
|
|
..modifier = MethodModifier.async |
|
|
|
..modifier = MethodModifier.async |
|
|
@ -1234,6 +1239,13 @@ TypeResult resolveObject( |
|
|
|
state.output.add( |
|
|
|
state.output.add( |
|
|
|
Class( |
|
|
|
Class( |
|
|
|
(final b) { |
|
|
|
(final b) { |
|
|
|
|
|
|
|
final sortedParameterKeys = schema.properties!.keys.toList() |
|
|
|
|
|
|
|
..sort( |
|
|
|
|
|
|
|
(final a, final b) => sortRequiredElements( |
|
|
|
|
|
|
|
(schema.required ?? []).contains(a), |
|
|
|
|
|
|
|
(schema.required ?? []).contains(b), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
b |
|
|
|
b |
|
|
|
..name = '${state.prefix}$identifier' |
|
|
|
..name = '${state.prefix}$identifier' |
|
|
|
..docs.addAll(_descriptionToDocs(schema.description)) |
|
|
|
..docs.addAll(_descriptionToDocs(schema.description)) |
|
|
@ -1257,7 +1269,7 @@ TypeResult resolveObject( |
|
|
|
Constructor( |
|
|
|
Constructor( |
|
|
|
(final b) => b |
|
|
|
(final b) => b |
|
|
|
..optionalParameters.addAll( |
|
|
|
..optionalParameters.addAll( |
|
|
|
schema.properties!.keys.map( |
|
|
|
sortedParameterKeys.map( |
|
|
|
(final propertyName) => Parameter( |
|
|
|
(final propertyName) => Parameter( |
|
|
|
(final b) { |
|
|
|
(final b) { |
|
|
|
final propertySchema = schema.properties![propertyName]!; |
|
|
|
final propertySchema = schema.properties![propertyName]!; |
|
|
@ -1865,3 +1877,16 @@ TypeResult resolveType( |
|
|
|
|
|
|
|
|
|
|
|
throw Exception('Can not convert OpenAPI type "${schema.toJson()}" to a Dart type'); |
|
|
|
throw Exception('Can not convert OpenAPI type "${schema.toJson()}" to a Dart type'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ignore: avoid_positional_boolean_parameters |
|
|
|
|
|
|
|
int sortRequiredElements(final bool a, final bool b) { |
|
|
|
|
|
|
|
if (a != b) { |
|
|
|
|
|
|
|
if (a && !b) { |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|