Skip to content

Commit

Permalink
fixup! feat!: improve deserialization logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jun 2, 2024
1 parent c460ee1 commit b1844b1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/src/core/implementation/servient.dart
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,20 @@ class InternalServient implements Servient {

unsupportedSecuritySchemes.forEach(securityDefinitions.remove);

final security = thingDescription["security"] ?? <String>[];
final security = <String>[];

if (security is! List<String>) {
// TODO: Refactor
final tdSecurity = thingDescription["security"] ?? <String>[];

if (tdSecurity is List<String>) {
security.addAll(tdSecurity);
} else if (tdSecurity is String) {
security.add(tdSecurity);
} else {
throw FormatException(
"Incorrect type for security field, "
"expected List<String>, got "
"${security.runtimeType}",
"${tdSecurity.runtimeType}",
);
}

Expand Down

0 comments on commit b1844b1

Please sign in to comment.