Browse Source

Merge pull request #1138 from nextcloud/fix/dynamite/security-schemes

pull/1139/head
Kate 1 year ago committed by GitHub
parent
commit
4864ced61d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/dynamite/dynamite/lib/src/builder/client.dart
  2. 7
      packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.dart
  3. 50
      packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.g.dart
  4. 4
      packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart

2
packages/dynamite/dynamite/lib/src/builder/client.dart

@ -499,7 +499,7 @@ final authentication = $client.authentications.firstWhereOrNull(
yield* securityRequirements.map((final requirement) { yield* securityRequirements.map((final requirement) {
final securityScheme = spec.components!.securitySchemes![requirement.keys.single]!; final securityScheme = spec.components!.securitySchemes![requirement.keys.single]!;
final dynamiteAuth = toDartName( final dynamiteAuth = toDartName(
'Dynamite-${securityScheme.type}-${securityScheme.scheme}-Authentication', 'Dynamite-${securityScheme.fullName.join('-')}-Authentication',
uppercaseFirstCharacter: true, uppercaseFirstCharacter: true,
); );
return '$dynamiteAuth()'; return '$dynamiteAuth()';

7
packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.dart

@ -1,5 +1,6 @@
import 'package:built_value/built_value.dart'; import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart'; import 'package:built_value/serializer.dart';
import 'package:collection/collection.dart';
part 'security_scheme.g.dart'; part 'security_scheme.g.dart';
@ -16,4 +17,10 @@ abstract class SecurityScheme implements Built<SecurityScheme, SecuritySchemeBui
String? get description; String? get description;
String? get scheme; String? get scheme;
String? get $in;
String? get name;
Iterable<String> get fullName => [type, scheme, $in, name].whereNotNull();
} }

50
packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.g.dart

@ -34,6 +34,18 @@ class _$SecuritySchemeSerializer implements StructuredSerializer<SecurityScheme>
..add('scheme') ..add('scheme')
..add(serializers.serialize(value, specifiedType: const FullType(String))); ..add(serializers.serialize(value, specifiedType: const FullType(String)));
} }
value = object.$in;
if (value != null) {
result
..add('\$in')
..add(serializers.serialize(value, specifiedType: const FullType(String)));
}
value = object.name;
if (value != null) {
result
..add('name')
..add(serializers.serialize(value, specifiedType: const FullType(String)));
}
return result; return result;
} }
@ -57,6 +69,12 @@ class _$SecuritySchemeSerializer implements StructuredSerializer<SecurityScheme>
case 'scheme': case 'scheme':
result.scheme = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; result.scheme = serializers.deserialize(value, specifiedType: const FullType(String)) as String?;
break; break;
case '\$in':
result.$in = serializers.deserialize(value, specifiedType: const FullType(String)) as String?;
break;
case 'name':
result.name = serializers.deserialize(value, specifiedType: const FullType(String)) as String?;
break;
} }
} }
@ -71,11 +89,15 @@ class _$SecurityScheme extends SecurityScheme {
final String? description; final String? description;
@override @override
final String? scheme; final String? scheme;
@override
final String? $in;
@override
final String? name;
factory _$SecurityScheme([void Function(SecuritySchemeBuilder)? updates]) => factory _$SecurityScheme([void Function(SecuritySchemeBuilder)? updates]) =>
(SecuritySchemeBuilder()..update(updates))._build(); (SecuritySchemeBuilder()..update(updates))._build();
_$SecurityScheme._({required this.type, this.description, this.scheme}) : super._() { _$SecurityScheme._({required this.type, this.description, this.scheme, this.$in, this.name}) : super._() {
BuiltValueNullFieldError.checkNotNull(type, r'SecurityScheme', 'type'); BuiltValueNullFieldError.checkNotNull(type, r'SecurityScheme', 'type');
} }
@ -88,7 +110,11 @@ class _$SecurityScheme extends SecurityScheme {
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
if (identical(other, this)) return true; if (identical(other, this)) return true;
return other is SecurityScheme && type == other.type && scheme == other.scheme; return other is SecurityScheme &&
type == other.type &&
scheme == other.scheme &&
$in == other.$in &&
name == other.name;
} }
@override @override
@ -96,6 +122,8 @@ class _$SecurityScheme extends SecurityScheme {
var _$hash = 0; var _$hash = 0;
_$hash = $jc(_$hash, type.hashCode); _$hash = $jc(_$hash, type.hashCode);
_$hash = $jc(_$hash, scheme.hashCode); _$hash = $jc(_$hash, scheme.hashCode);
_$hash = $jc(_$hash, $in.hashCode);
_$hash = $jc(_$hash, name.hashCode);
_$hash = $jf(_$hash); _$hash = $jf(_$hash);
return _$hash; return _$hash;
} }
@ -105,7 +133,9 @@ class _$SecurityScheme extends SecurityScheme {
return (newBuiltValueToStringHelper(r'SecurityScheme') return (newBuiltValueToStringHelper(r'SecurityScheme')
..add('type', type) ..add('type', type)
..add('description', description) ..add('description', description)
..add('scheme', scheme)) ..add('scheme', scheme)
..add('\$in', $in)
..add('name', name))
.toString(); .toString();
} }
} }
@ -125,6 +155,14 @@ class SecuritySchemeBuilder implements Builder<SecurityScheme, SecuritySchemeBui
String? get scheme => _$this._scheme; String? get scheme => _$this._scheme;
set scheme(String? scheme) => _$this._scheme = scheme; set scheme(String? scheme) => _$this._scheme = scheme;
String? _$in;
String? get $in => _$this._$in;
set $in(String? $in) => _$this._$in = $in;
String? _name;
String? get name => _$this._name;
set name(String? name) => _$this._name = name;
SecuritySchemeBuilder(); SecuritySchemeBuilder();
SecuritySchemeBuilder get _$this { SecuritySchemeBuilder get _$this {
@ -133,6 +171,8 @@ class SecuritySchemeBuilder implements Builder<SecurityScheme, SecuritySchemeBui
_type = $v.type; _type = $v.type;
_description = $v.description; _description = $v.description;
_scheme = $v.scheme; _scheme = $v.scheme;
_$in = $v.$in;
_name = $v.name;
_$v = null; _$v = null;
} }
return this; return this;
@ -157,7 +197,9 @@ class SecuritySchemeBuilder implements Builder<SecurityScheme, SecuritySchemeBui
_$SecurityScheme._( _$SecurityScheme._(
type: BuiltValueNullFieldError.checkNotNull(type, r'SecurityScheme', 'type'), type: BuiltValueNullFieldError.checkNotNull(type, r'SecurityScheme', 'type'),
description: description, description: description,
scheme: scheme); scheme: scheme,
$in: $in,
name: name);
replace(_$result); replace(_$result);
return _$result; return _$result;
} }

4
packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart

@ -313,8 +313,8 @@ sealed class DynamiteAuthentication {
/// The base type of the authentication. /// The base type of the authentication.
final String type; final String type;
/// The used authentication scheme. /// The used authentication HTTP scheme.
final String scheme; final String? scheme;
/// The authentication headers added to a request. /// The authentication headers added to a request.
Map<String, String> get headers; Map<String, String> get headers;

Loading…
Cancel
Save