Skip to content

Commit

Permalink
fixup! feat!: implement proper serialization logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jun 4, 2024
1 parent 0d11b2d commit 0ce394c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/core/definitions/security/oauth2_security_scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ final class OAuth2SecurityScheme extends SecurityScheme {
final additionalFields =
json.parseAdditionalFields(prefixMapping, parsedFields);

// TODO: Add validation for the different flow-specific assertions
// https://www.w3.org/TR/wot-thing-description11/#oauth2securityscheme
return OAuth2SecurityScheme(
flow,
description: description,
Expand Down
24 changes: 24 additions & 0 deletions test/core/definitions/serialization_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,29 @@ void main() {
dataSchema.toJson(),
);
});

test("OAuth2SecurityScheme", () async {
final oAuth2SecuritySchemeJson = {
"scheme": "oauth2",
"authorization": "https://example.org",
"token": "https://example.org",
"refresh": "https://example.org",
"scopes": ["foo", "bar"],
"flow": "code",
};

final parsedFields = {"scheme"};

final oAuth2SecurityScheme = OAuth2SecurityScheme.fromJson(
oAuth2SecuritySchemeJson,
PrefixMapping(),
parsedFields,
);

expect(
oAuth2SecuritySchemeJson,
oAuth2SecurityScheme.toJson(),
);
});
});
}

0 comments on commit 0ce394c

Please sign in to comment.