Skip to content

Commit

Permalink
feat: add ComboSecurityScheme
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed May 13, 2023
1 parent a61666b commit f0705d0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
46 changes: 46 additions & 0 deletions lib/src/definitions/security/combo_security_scheme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2023 The NAMIB Project Developers. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// SPDX-License-Identifier: BSD-3-Clause

import 'package:curie/curie.dart';

import '../extensions/json_parser.dart';
import 'security_scheme.dart';

const _schemeName = 'combo';

/// A combination of other security schemes identified by the Vocabulary Term
/// `combo` (i.e., "scheme": "combo").
class ComboSecurityScheme extends SecurityScheme {
/// Constructor.
ComboSecurityScheme({
this.allOf,
this.oneOf,
super.description,
super.descriptions,
super.proxy,
}) : super(_schemeName);

/// Creates a [ComboSecurityScheme] from a [json] object.
ComboSecurityScheme.fromJson(
Map<String, dynamic> json,
PrefixMapping prefixMapping,
Set<String> parsedFields,
) : oneOf = json.parseArrayField<String>('oneOf', parsedFields),
allOf = json.parseArrayField<String>('allOf', parsedFields),
super(_schemeName) {
parseSecurityJson(json, parsedFields, prefixMapping);
}

/// Array of two or more strings identifying other named security scheme
/// definitions, any one of which, when satisfied, will allow access.
///
/// Only one may be chosen for use.
final List<String>? oneOf;

/// Array of two or more strings identifying other named security scheme
/// definitions, all of which must be satisfied for access.
final List<String>? allOf;
}
3 changes: 3 additions & 0 deletions lib/src/definitions/security/security_scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'apikey_security_scheme.dart';
import 'auto_security_scheme.dart';
import 'basic_security_scheme.dart';
import 'bearer_security_scheme.dart';
import 'combo_security_scheme.dart';
import 'digest_security_scheme.dart';
import 'no_security_scheme.dart';
import 'oauth2_security_scheme.dart';
Expand Down Expand Up @@ -84,6 +85,8 @@ abstract class SecurityScheme {
return BasicSecurityScheme.fromJson(json, prefixMapping);
case 'bearer':
return BearerSecurityScheme.fromJson(json, prefixMapping);
case 'combo':
return ComboSecurityScheme.fromJson(json, prefixMapping, {});
case 'nosec':
return NoSecurityScheme.fromJson(json, prefixMapping);
case 'psk':
Expand Down

0 comments on commit f0705d0

Please sign in to comment.