diff --git a/lib/src/core/definitions/security/ace_security_scheme.dart b/lib/src/core/definitions/security/ace_security_scheme.dart index d6dd199e..4457d1ed 100644 --- a/lib/src/core/definitions/security/ace_security_scheme.dart +++ b/lib/src/core/definitions/security/ace_security_scheme.dart @@ -84,7 +84,24 @@ final class AceSecurityScheme extends SecurityScheme { @override Map toJson() { - // TODO: implement toJson - throw UnimplementedError(); + final result = super.toJson(); + + if (as != null) { + result["as"] = as; + } + + if (audience != null) { + result["audience"] = audience; + } + + if (scopes != null) { + result["scopes"] = scopes; + } + + if (cnonce != null) { + result["cnonce"] = cnonce; + } + + return result; } } diff --git a/lib/src/core/definitions/security/apikey_security_scheme.dart b/lib/src/core/definitions/security/apikey_security_scheme.dart index 060e0322..dfc90833 100644 --- a/lib/src/core/definitions/security/apikey_security_scheme.dart +++ b/lib/src/core/definitions/security/apikey_security_scheme.dart @@ -68,7 +68,15 @@ final class ApiKeySecurityScheme extends SecurityScheme { @override Map toJson() { - // TODO: implement toJson - throw UnimplementedError(); + final result = { + "in": in_, + ...super.toJson(), + }; + + if (name != null) { + result["name"] = name; + } + + return result; } } diff --git a/lib/src/core/definitions/security/auto_security_scheme.dart b/lib/src/core/definitions/security/auto_security_scheme.dart index 0e1247d1..dc9b2cd2 100644 --- a/lib/src/core/definitions/security/auto_security_scheme.dart +++ b/lib/src/core/definitions/security/auto_security_scheme.dart @@ -50,30 +50,4 @@ final class AutoSecurityScheme extends SecurityScheme { @override String get scheme => autoSecuritySchemeName; - - @override - Map toJson() { - final result = { - "scheme": autoSecuritySchemeName, - ...additionalFields, - }; - - if (description != null) { - result["description"] = description; - } - - if (descriptions != null) { - result["descriptions"] = descriptions; - } - - if (jsonLdType != null) { - result["@type"] = jsonLdType; - } - - if (proxy != null) { - result["proxy"] = proxy; - } - - return result; - } } diff --git a/lib/src/core/definitions/security/basic_security_scheme.dart b/lib/src/core/definitions/security/basic_security_scheme.dart index 2f87ae2a..fdd0e033 100644 --- a/lib/src/core/definitions/security/basic_security_scheme.dart +++ b/lib/src/core/definitions/security/basic_security_scheme.dart @@ -68,7 +68,15 @@ final class BasicSecurityScheme extends SecurityScheme { @override Map toJson() { - // TODO: implement toJson - throw UnimplementedError(); + final result = { + "in": in_, + ...super.toJson(), + }; + + if (name != null) { + result["name"] = name; + } + + return result; } } diff --git a/lib/src/core/definitions/security/bearer_security_scheme.dart b/lib/src/core/definitions/security/bearer_security_scheme.dart index 161164c8..008f1e41 100644 --- a/lib/src/core/definitions/security/bearer_security_scheme.dart +++ b/lib/src/core/definitions/security/bearer_security_scheme.dart @@ -91,7 +91,21 @@ final class BearerSecurityScheme extends SecurityScheme { @override Map toJson() { - // TODO: implement toJson - throw UnimplementedError(); + final result = { + "in": in_, + "alg": alg, + "format": format, + ...super.toJson(), + }; + + if (name != null) { + result["name"] = name; + } + + if (authorization != null) { + result["authorization"] = authorization; + } + + return result; } } diff --git a/lib/src/core/definitions/security/combo_security_scheme.dart b/lib/src/core/definitions/security/combo_security_scheme.dart index 12dc3cad..4e684f8b 100644 --- a/lib/src/core/definitions/security/combo_security_scheme.dart +++ b/lib/src/core/definitions/security/combo_security_scheme.dart @@ -89,7 +89,16 @@ final class ComboSecurityScheme extends SecurityScheme { @override Map toJson() { - // TODO: implement toJson - throw UnimplementedError(); + final result = super.toJson(); + + if (oneOf != null) { + result["oneOf"] = oneOf; + } + + if (allOf != null) { + result["allOf"] = allOf; + } + + return result; } } diff --git a/lib/src/core/definitions/security/digest_security_scheme.dart b/lib/src/core/definitions/security/digest_security_scheme.dart index 943a9def..8ca10869 100644 --- a/lib/src/core/definitions/security/digest_security_scheme.dart +++ b/lib/src/core/definitions/security/digest_security_scheme.dart @@ -78,28 +78,11 @@ final class DigestSecurityScheme extends SecurityScheme { @override Map toJson() { final result = { - "scheme": digestSecuritySchemeName, "in": in_, "qop": qop, - ...additionalFields, + ...super.toJson(), }; - if (description != null) { - result["description"] = description; - } - - if (descriptions != null) { - result["descriptions"] = descriptions; - } - - if (jsonLdType != null) { - result["@type"] = jsonLdType; - } - - if (proxy != null) { - result["proxy"] = proxy; - } - if (name != null) { result["name"] = name; } diff --git a/lib/src/core/definitions/security/no_security_scheme.dart b/lib/src/core/definitions/security/no_security_scheme.dart index ebb3b8c7..f1aa0456 100644 --- a/lib/src/core/definitions/security/no_security_scheme.dart +++ b/lib/src/core/definitions/security/no_security_scheme.dart @@ -50,30 +50,4 @@ final class NoSecurityScheme extends SecurityScheme { @override String get scheme => nosecSecuritySchemeName; - - @override - Map toJson() { - final result = { - "scheme": nosecSecuritySchemeName, - ...additionalFields, - }; - - if (description != null) { - result["description"] = description; - } - - if (descriptions != null) { - result["descriptions"] = descriptions; - } - - if (jsonLdType != null) { - result["proxy"] = jsonLdType; - } - - if (proxy != null) { - result["@type"] = proxy; - } - - return result; - } } diff --git a/lib/src/core/definitions/security/oauth2_security_scheme.dart b/lib/src/core/definitions/security/oauth2_security_scheme.dart index ee195b91..c92731bc 100644 --- a/lib/src/core/definitions/security/oauth2_security_scheme.dart +++ b/lib/src/core/definitions/security/oauth2_security_scheme.dart @@ -95,7 +95,27 @@ final class OAuth2SecurityScheme extends SecurityScheme { @override Map toJson() { - // TODO: implement toJson - throw UnimplementedError(); + final result = { + "flow": flow, + ...super.toJson(), + }; + + if (authorization != null) { + result["authorization"] = authorization; + } + + if (token != null) { + result["token"] = token; + } + + if (refresh != null) { + result["refresh"] = refresh; + } + + if (scopes != null) { + result["scopes"] = scopes; + } + + return result; } } diff --git a/lib/src/core/definitions/security/psk_security_scheme.dart b/lib/src/core/definitions/security/psk_security_scheme.dart index 633f4f0f..af1bcd00 100644 --- a/lib/src/core/definitions/security/psk_security_scheme.dart +++ b/lib/src/core/definitions/security/psk_security_scheme.dart @@ -60,26 +60,7 @@ final class PskSecurityScheme extends SecurityScheme { @override Map toJson() { - final result = { - "scheme": pskSecuritySchemeName, - ...additionalFields, - }; - - if (description != null) { - result["description"] = description; - } - - if (descriptions != null) { - result["descriptions"] = descriptions; - } - - if (jsonLdType != null) { - result["@type"] = jsonLdType; - } - - if (proxy != null) { - result["proxy"] = proxy; - } + final result = super.toJson(); if (identity != null) { result["identity"] = identity; diff --git a/lib/src/core/definitions/security/security_scheme.dart b/lib/src/core/definitions/security/security_scheme.dart index a132c6e2..9e620b3f 100644 --- a/lib/src/core/definitions/security/security_scheme.dart +++ b/lib/src/core/definitions/security/security_scheme.dart @@ -45,5 +45,29 @@ abstract base class SecurityScheme { /// Converts this [SecurityScheme] instance into a [Map] that can be easily /// converted to JSON. - Map toJson(); + @mustCallSuper + Map toJson() { + final result = { + "scheme": scheme, + ...additionalFields, + }; + + if (description != null) { + result["description"] = description; + } + + if (descriptions != null) { + result["descriptions"] = descriptions; + } + + if (jsonLdType != null) { + result["@type"] = jsonLdType; + } + + if (proxy != null) { + result["proxy"] = proxy; + } + + return result; + } }