From 6fd43290c44655b38cdc9fa2f1400c4ddf96d44a Mon Sep 17 00:00:00 2001 From: jld3103 Date: Tue, 14 Nov 2023 07:01:35 +0100 Subject: [PATCH] fix(dynamite,dynamite_runtime): Fix security schemes Signed-off-by: jld3103 --- .../dynamite/lib/src/builder/client.dart | 2 +- .../src/models/openapi/security_scheme.dart | 7 +++ .../src/models/openapi/security_scheme.g.dart | 50 +++++++++++++++++-- .../lib/src/dynamite_client.dart | 4 +- 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index f7c6f962a11..2a72388fe43 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -499,7 +499,7 @@ final authentication = $client.authentications.firstWhereOrNull( yield* securityRequirements.map((final requirement) { final securityScheme = spec.components!.securitySchemes![requirement.keys.single]!; final dynamiteAuth = toDartName( - 'Dynamite-${securityScheme.type}-${securityScheme.scheme}-Authentication', + 'Dynamite-${securityScheme.fullName.join('-')}-Authentication', uppercaseFirstCharacter: true, ); return '$dynamiteAuth()'; diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.dart b/packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.dart index 8580e29b550..33ef00d3a37 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.dart +++ b/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/serializer.dart'; +import 'package:collection/collection.dart'; part 'security_scheme.g.dart'; @@ -16,4 +17,10 @@ abstract class SecurityScheme implements Built get fullName => [type, scheme, $in, name].whereNotNull(); } diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.g.dart index 3fe9f1df513..d5796b69a25 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.g.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.g.dart @@ -34,6 +34,18 @@ class _$SecuritySchemeSerializer implements StructuredSerializer ..add('scheme') ..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; } @@ -57,6 +69,12 @@ class _$SecuritySchemeSerializer implements StructuredSerializer case 'scheme': result.scheme = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; 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; @override final String? scheme; + @override + final String? $in; + @override + final String? name; factory _$SecurityScheme([void Function(SecuritySchemeBuilder)? updates]) => (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'); } @@ -88,7 +110,11 @@ class _$SecurityScheme extends SecurityScheme { @override bool operator ==(Object other) { 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 @@ -96,6 +122,8 @@ class _$SecurityScheme extends SecurityScheme { var _$hash = 0; _$hash = $jc(_$hash, type.hashCode); _$hash = $jc(_$hash, scheme.hashCode); + _$hash = $jc(_$hash, $in.hashCode); + _$hash = $jc(_$hash, name.hashCode); _$hash = $jf(_$hash); return _$hash; } @@ -105,7 +133,9 @@ class _$SecurityScheme extends SecurityScheme { return (newBuiltValueToStringHelper(r'SecurityScheme') ..add('type', type) ..add('description', description) - ..add('scheme', scheme)) + ..add('scheme', scheme) + ..add('\$in', $in) + ..add('name', name)) .toString(); } } @@ -125,6 +155,14 @@ class SecuritySchemeBuilder implements Builder _$this._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 get _$this { @@ -133,6 +171,8 @@ class SecuritySchemeBuilder implements Builder get headers;