Browse Source

refactor(dynamite): cleanup tags handling

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/694/head
Nikolas Rimikis 1 year ago
parent
commit
b171de8c22
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 44
      packages/dynamite/dynamite/lib/src/openapi_builder.dart

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

@ -29,30 +29,30 @@ class OpenAPIBuilder implements Builder {
throw Exception('Only OpenAPI ${supportedVersions.join(', ')} are supported'); throw Exception('Only OpenAPI ${supportedVersions.join(', ')} are supported');
} }
var tags = <String?>[ final 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) {
for (final operation in pathItem.operations.values) ...{ for (final operation in pathItem.operations.values) {
...?operation.tags, if (operation.tags != null) {
}, for (final tag in operation.tags!) {
}, final tagPart = tag.split('/').first;
}, if (!tags.contains(tagPart)) {
]; tags.add(tagPart);
for (final tag in tags.toList()) { }
final tagPart = tag?.split('/').first; }
if (!tags.contains(tagPart)) { }
tags.add(tagPart); }
} }
} }
tags = tags
..sort( tags.sort(
(final a, final b) => a == null (final a, final b) => a == null
? -1 ? -1
: b == null : b == null
? 1 ? 1
: a.compareTo(b), : a.compareTo(b),
); );
final hasAnySecurity = spec.components?.securitySchemes?.isNotEmpty ?? false; final hasAnySecurity = spec.components?.securitySchemes?.isNotEmpty ?? false;

Loading…
Cancel
Save