|
|
@ -28,7 +28,7 @@ class OpenAPIBuilder implements Builder { |
|
|
|
throw Exception('Only OpenAPI ${supportedVersions.join(', ')} are supported'); |
|
|
|
throw Exception('Only OpenAPI ${supportedVersions.join(', ')} are supported'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final tags = <String?>{ |
|
|
|
var tags = <String?>[ |
|
|
|
null, |
|
|
|
null, |
|
|
|
if (spec.paths != null) ...{ |
|
|
|
if (spec.paths != null) ...{ |
|
|
|
for (final pathItem in spec.paths!.values) ...{ |
|
|
|
for (final pathItem in spec.paths!.values) ...{ |
|
|
@ -39,7 +39,22 @@ class OpenAPIBuilder implements Builder { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
]; |
|
|
|
|
|
|
|
for (final tag in tags.toList()) { |
|
|
|
|
|
|
|
final tagPart = tag?.split('/').first; |
|
|
|
|
|
|
|
if (!tags.contains(tagPart)) { |
|
|
|
|
|
|
|
tags.add(tagPart); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
tags = tags |
|
|
|
|
|
|
|
..sort( |
|
|
|
|
|
|
|
(final a, final b) => a == null |
|
|
|
|
|
|
|
? -1 |
|
|
|
|
|
|
|
: b == null |
|
|
|
|
|
|
|
? 1 |
|
|
|
|
|
|
|
: a.compareTo(b), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
final hasAnySecurity = spec.security?.isNotEmpty ?? false; |
|
|
|
final hasAnySecurity = spec.security?.isNotEmpty ?? false; |
|
|
|
|
|
|
|
|
|
|
|
final state = State(prefix); |
|
|
|
final state = State(prefix); |
|
|
@ -341,10 +356,6 @@ class OpenAPIBuilder implements Builder { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (paths.isEmpty && !isRootClient) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output.add( |
|
|
|
output.add( |
|
|
|
Class( |
|
|
|
Class( |
|
|
|
(final b) { |
|
|
|
(final b) { |
|
|
@ -446,18 +457,6 @@ class OpenAPIBuilder implements Builder { |
|
|
|
), |
|
|
|
), |
|
|
|
) |
|
|
|
) |
|
|
|
..methods.addAll([ |
|
|
|
..methods.addAll([ |
|
|
|
if (isRootClient) ...[ |
|
|
|
|
|
|
|
for (final tag in tags.where((final tag) => tag != null).toList().cast<String>()) ...[ |
|
|
|
|
|
|
|
Method( |
|
|
|
|
|
|
|
(final b) => b |
|
|
|
|
|
|
|
..name = _toDartName(tag) |
|
|
|
|
|
|
|
..lambda = true |
|
|
|
|
|
|
|
..type = MethodType.getter |
|
|
|
|
|
|
|
..returns = refer('$prefix${_clientName(tag)}') |
|
|
|
|
|
|
|
..body = Code('$prefix${_clientName(tag)}(this)'), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
Method( |
|
|
|
Method( |
|
|
|
(final b) => b |
|
|
|
(final b) => b |
|
|
|
..name = 'doRequest' |
|
|
|
..name = 'doRequest' |
|
|
@ -546,6 +545,21 @@ class OpenAPIBuilder implements Builder { |
|
|
|
) |
|
|
|
) |
|
|
|
..methods.addAll( |
|
|
|
..methods.addAll( |
|
|
|
[ |
|
|
|
[ |
|
|
|
|
|
|
|
for (final t in tags |
|
|
|
|
|
|
|
.whereType<String>() |
|
|
|
|
|
|
|
.where( |
|
|
|
|
|
|
|
(final t) => (tag != null && (t.startsWith('$tag/'))) || (tag == null && !t.contains('/')), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.toList()) ...[ |
|
|
|
|
|
|
|
Method( |
|
|
|
|
|
|
|
(final b) => b |
|
|
|
|
|
|
|
..name = _toDartName(tag == null ? t : t.substring('$tag/'.length)) |
|
|
|
|
|
|
|
..lambda = true |
|
|
|
|
|
|
|
..type = MethodType.getter |
|
|
|
|
|
|
|
..returns = refer('$prefix${_clientName(t)}') |
|
|
|
|
|
|
|
..body = Code('$prefix${_clientName(t)}(${isRootClient ? 'this' : 'rootClient'})'), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
for (final path in paths.keys) ...[ |
|
|
|
for (final path in paths.keys) ...[ |
|
|
|
for (final httpMethod in paths[path]!.operations.keys) ...[ |
|
|
|
for (final httpMethod in paths[path]!.operations.keys) ...[ |
|
|
|
Method( |
|
|
|
Method( |
|
|
|