From ab5dbfa7f90f8d3c48978b9ff16c8c9b2863a0f0 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Thu, 23 Nov 2023 14:20:30 +0100 Subject: [PATCH] feat(dynamite): allow patterns and string lengths in objects Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/builder/client.dart | 24 +-- .../dynamite/lib/src/builder/imports.dart | 2 +- .../lib/src/builder/resolve_object.dart | 11 +- .../dynamite/lib/src/helpers/built_value.dart | 23 ++ .../lib/src/helpers/pattern_check.dart | 21 ++ .../lib/pattern_check.openapi.dart | 79 +++++++ .../lib/pattern_check.openapi.g.dart | 204 ++++++++++++++++++ .../lib/pattern_check.openapi.json | 36 ++++ .../test/pattern_check_test.dart | 50 +++++ .../lib/src/dynamite_client.dart | 2 +- .../lib/src/string_checker.dart | 26 --- .../lib/src/utils/string_checker.dart | 26 +++ .../lib/src/{ => utils}/uri.dart | 0 .../dynamite/dynamite_runtime/lib/utils.dart | 4 +- .../dynamite_runtime/test/uri_test.dart | 2 +- .../nextcloud/lib/src/api/files.openapi.dart | 4 +- .../lib/src/api/files_reminders.openapi.dart | 8 +- .../lib/src/api/provisioning_api.openapi.dart | 20 +- .../nextcloud/lib/src/api/spreed.openapi.dart | 190 ++++++++-------- .../lib/src/api/theming.openapi.dart | 9 +- .../lib/src/api/theming.openapi.g.dart | 1 + 21 files changed, 578 insertions(+), 164 deletions(-) create mode 100644 packages/dynamite/dynamite/lib/src/helpers/pattern_check.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.g.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.json create mode 100644 packages/dynamite/dynamite_end_to_end_test/test/pattern_check_test.dart delete mode 100644 packages/dynamite/dynamite_runtime/lib/src/string_checker.dart create mode 100644 packages/dynamite/dynamite_runtime/lib/src/utils/string_checker.dart rename packages/dynamite/dynamite_runtime/lib/src/{ => utils}/uri.dart (100%) diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index 3d1033f0..2279a172 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -7,6 +7,7 @@ import 'package:dynamite/src/builder/resolve_type.dart'; import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/dynamite.dart'; +import 'package:dynamite/src/helpers/pattern_check.dart'; import 'package:dynamite/src/helpers/type_result.dart'; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; @@ -270,7 +271,7 @@ Iterable buildTags( ), ); - buildPatternCheck(result, parameter).forEach(code.writeln); + buildParameterPatternCheck(parameter).forEach(code.writeln); buildParameterSerialization(result, parameter).forEach(code.writeln); } resolveMimeTypeEncode(operation, spec, state, operationName, operationParameters).forEach(code.writeln); @@ -452,25 +453,16 @@ Iterable buildParameterSerialization( } } -Iterable buildPatternCheck( - final TypeResult result, +Iterable buildParameterPatternCheck( final openapi.Parameter parameter, ) sync* { - final value = toDartName(parameter.name); - final name = "'$value'"; - final schema = parameter.schema; - if (result.name == 'String' && schema != null) { - if (schema.pattern != null) { - yield "checkPattern($value, RegExp(r'${schema.pattern!}'), $name); // coverage:ignore-line"; - } - if (schema.minLength != null) { - yield 'checkMinLength($value, ${schema.minLength}, $name); // coverage:ignore-line'; - } - if (schema.maxLength != null) { - yield 'checkMaxLength($value, ${schema.maxLength}, $name); // coverage:ignore-line'; - } + if (schema == null) { + return; } + + final value = toDartName(parameter.name); + yield* buildPatternCheck(schema, value); } Iterable buildAuthCheck( diff --git a/packages/dynamite/dynamite/lib/src/builder/imports.dart b/packages/dynamite/dynamite/lib/src/builder/imports.dart index bdd3bf51..a78adf0a 100644 --- a/packages/dynamite/dynamite/lib/src/builder/imports.dart +++ b/packages/dynamite/dynamite/lib/src/builder/imports.dart @@ -24,7 +24,7 @@ Iterable generateImports(final AssetId outputId, final State state) sync* Directive.import('package:dynamite_runtime/built_value.dart'), Directive.import('package:dynamite_runtime/http_client.dart'), Directive.import('package:dynamite_runtime/models.dart'), - Directive.import('package:dynamite_runtime/utils.dart'), + Directive.import('package:dynamite_runtime/utils.dart', as: 'dynamite_utils'), Directive.import('package:meta/meta.dart'), Directive.import('package:universal_io/io.dart'), Directive.import('package:uri/uri.dart'), diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart index 3467494b..b2fbd760 100644 --- a/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart @@ -4,6 +4,7 @@ import 'package:dynamite/src/builder/resolve_type.dart'; import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/built_value.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; +import 'package:dynamite/src/helpers/pattern_check.dart'; import 'package:dynamite/src/helpers/type_result.dart'; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; @@ -22,18 +23,23 @@ TypeResultObject resolveObject( ); if (state.resolvedTypes.add(result)) { final defaults = []; + final validators = []; for (final property in schema.properties!.entries) { final propertySchema = property.value; + final dartName = toDartName(property.key); + if (propertySchema.$default != null) { - final value = propertySchema.$default!.toString(); final result = resolveType( spec, state, propertySchema.type!.name, propertySchema, ); - defaults.add('..${toDartName(property.key)} = ${valueToEscapedValue(result, value)}'); + + final value = propertySchema.$default!.toString(); + defaults.add('..$dartName = ${valueToEscapedValue(result, value)}'); } + validators.addAll(buildPatternCheck(propertySchema, 'b.$dartName')); } resolveInterface( @@ -47,6 +53,7 @@ TypeResultObject resolveObject( buildBuiltClass( identifier, defaults: defaults, + validators: validators, customSerializer: isHeader, ), ); diff --git a/packages/dynamite/dynamite/lib/src/helpers/built_value.dart b/packages/dynamite/dynamite/lib/src/helpers/built_value.dart index 6360bf2a..438ee952 100644 --- a/packages/dynamite/dynamite/lib/src/helpers/built_value.dart +++ b/packages/dynamite/dynamite/lib/src/helpers/built_value.dart @@ -9,6 +9,7 @@ const interfaceSuffix = 'Interface'; Spec buildBuiltClass( final String className, { final Iterable? defaults, + final Iterable? validators, final Iterable? methods, final bool customSerializer = false, }) => @@ -66,6 +67,28 @@ Spec buildBuiltClass( ), ); } + + if (validators != null && validators.isNotEmpty) { + b.methods.add( + Method((final b) { + b + ..name = '_validate' + ..returns = refer('void') + ..annotations.add( + refer('BuiltValueHook').call([], {'finalizeBuilder': literalTrue}), + ) + ..static = true + ..requiredParameters.add( + Parameter( + (final b) => b + ..name = 'b' + ..type = refer('${className}Builder'), + ), + ) + ..body = Code(validators.join('\n')); + }), + ); + } }, ); diff --git a/packages/dynamite/dynamite/lib/src/helpers/pattern_check.dart b/packages/dynamite/dynamite/lib/src/helpers/pattern_check.dart new file mode 100644 index 00000000..a6239c09 --- /dev/null +++ b/packages/dynamite/dynamite/lib/src/helpers/pattern_check.dart @@ -0,0 +1,21 @@ +import 'package:dynamite/src/models/openapi.dart' as openapi; +import 'package:dynamite/src/models/openapi/schema.dart'; + +Iterable buildPatternCheck( + final openapi.Schema schema, + final String value, +) sync* { + final name = "'$value'"; + + if (schema.type == SchemaType.string) { + if (schema.pattern != null) { + yield "dynamite_utils.checkPattern($value, RegExp(r'${schema.pattern!}'), $name);"; + } + if (schema.minLength != null) { + yield 'dynamite_utils.checkMinLength($value, ${schema.minLength}, $name);'; + } + if (schema.maxLength != null) { + yield 'dynamite_utils.checkMaxLength($value, ${schema.maxLength}, $name);'; + } + } +} diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.dart b/packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.dart new file mode 100644 index 00000000..efa6abf9 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.dart @@ -0,0 +1,79 @@ +// ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures +// ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case + +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:built_value/standard_json_plugin.dart'; +import 'package:dynamite_runtime/built_value.dart'; +import 'package:dynamite_runtime/http_client.dart'; +import 'package:dynamite_runtime/utils.dart' as dynamite_utils; + +part 'pattern_check.openapi.g.dart'; + +class Client extends DynamiteClient { + Client( + super.baseURL, { + super.baseHeaders, + super.userAgent, + super.httpClient, + super.cookieJar, + }); + + Client.fromClient(final DynamiteClient client) + : super( + client.baseURL, + baseHeaders: client.baseHeaders, + httpClient: client.httpClient, + cookieJar: client.cookieJar, + authentications: client.authentications, + ); +} + +@BuiltValue(instantiable: false) +abstract interface class TestObjectInterface { + @BuiltValueField(wireName: 'only-numbers') + String? get onlyNumbers; + @BuiltValueField(wireName: 'min-length') + String? get minLength; + @BuiltValueField(wireName: 'max-length') + String? get maxLength; + @BuiltValueField(wireName: 'multiple-checks') + String? get multipleChecks; +} + +abstract class TestObject implements TestObjectInterface, Built { + factory TestObject([final void Function(TestObjectBuilder)? b]) = _$TestObject; + + const TestObject._(); + + factory TestObject.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$testObjectSerializer; + + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final TestObjectBuilder b) { + dynamite_utils.checkPattern(b.onlyNumbers, RegExp(r'^[0-9]*$'), 'b.onlyNumbers'); + dynamite_utils.checkMinLength(b.minLength, 3, 'b.minLength'); + dynamite_utils.checkMaxLength(b.maxLength, 20, 'b.maxLength'); + dynamite_utils.checkPattern(b.multipleChecks, RegExp(r'^[0-9]*$'), 'b.multipleChecks'); + dynamite_utils.checkMinLength(b.multipleChecks, 3, 'b.multipleChecks'); + dynamite_utils.checkMaxLength(b.multipleChecks, 20, 'b.multipleChecks'); + } +} + +// coverage:ignore-start +final Serializers _serializers = (Serializers().toBuilder() + ..addBuilderFactory(const FullType(TestObject), TestObject.new) + ..add(TestObject.serializer)) + .build(); + +final Serializers _jsonSerializers = (_serializers.toBuilder() + ..add(DynamiteDoubleSerializer()) + ..addPlugin(StandardJsonPlugin()) + ..addPlugin(const ContentStringPlugin())) + .build(); +// coverage:ignore-end diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.g.dart b/packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.g.dart new file mode 100644 index 00000000..de1db067 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.g.dart @@ -0,0 +1,204 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'pattern_check.openapi.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$testObjectSerializer = _$TestObjectSerializer(); + +class _$TestObjectSerializer implements StructuredSerializer { + @override + final Iterable types = const [TestObject, _$TestObject]; + @override + final String wireName = 'TestObject'; + + @override + Iterable serialize(Serializers serializers, TestObject object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + Object? value; + value = object.onlyNumbers; + if (value != null) { + result + ..add('only-numbers') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.minLength; + if (value != null) { + result + ..add('min-length') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.maxLength; + if (value != null) { + result + ..add('max-length') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.multipleChecks; + if (value != null) { + result + ..add('multiple-checks') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + return result; + } + + @override + TestObject deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = TestObjectBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'only-numbers': + result.onlyNumbers = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'min-length': + result.minLength = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'max-length': + result.maxLength = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'multiple-checks': + result.multipleChecks = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +abstract mixin class TestObjectInterfaceBuilder { + void replace(TestObjectInterface other); + void update(void Function(TestObjectInterfaceBuilder) updates); + String? get onlyNumbers; + set onlyNumbers(String? onlyNumbers); + + String? get minLength; + set minLength(String? minLength); + + String? get maxLength; + set maxLength(String? maxLength); + + String? get multipleChecks; + set multipleChecks(String? multipleChecks); +} + +class _$TestObject extends TestObject { + @override + final String? onlyNumbers; + @override + final String? minLength; + @override + final String? maxLength; + @override + final String? multipleChecks; + + factory _$TestObject([void Function(TestObjectBuilder)? updates]) => (TestObjectBuilder()..update(updates))._build(); + + _$TestObject._({this.onlyNumbers, this.minLength, this.maxLength, this.multipleChecks}) : super._(); + + @override + TestObject rebuild(void Function(TestObjectBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + TestObjectBuilder toBuilder() => TestObjectBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is TestObject && + onlyNumbers == other.onlyNumbers && + minLength == other.minLength && + maxLength == other.maxLength && + multipleChecks == other.multipleChecks; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, onlyNumbers.hashCode); + _$hash = $jc(_$hash, minLength.hashCode); + _$hash = $jc(_$hash, maxLength.hashCode); + _$hash = $jc(_$hash, multipleChecks.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'TestObject') + ..add('onlyNumbers', onlyNumbers) + ..add('minLength', minLength) + ..add('maxLength', maxLength) + ..add('multipleChecks', multipleChecks)) + .toString(); + } +} + +class TestObjectBuilder implements Builder, TestObjectInterfaceBuilder { + _$TestObject? _$v; + + String? _onlyNumbers; + String? get onlyNumbers => _$this._onlyNumbers; + set onlyNumbers(covariant String? onlyNumbers) => _$this._onlyNumbers = onlyNumbers; + + String? _minLength; + String? get minLength => _$this._minLength; + set minLength(covariant String? minLength) => _$this._minLength = minLength; + + String? _maxLength; + String? get maxLength => _$this._maxLength; + set maxLength(covariant String? maxLength) => _$this._maxLength = maxLength; + + String? _multipleChecks; + String? get multipleChecks => _$this._multipleChecks; + set multipleChecks(covariant String? multipleChecks) => _$this._multipleChecks = multipleChecks; + + TestObjectBuilder(); + + TestObjectBuilder get _$this { + final $v = _$v; + if ($v != null) { + _onlyNumbers = $v.onlyNumbers; + _minLength = $v.minLength; + _maxLength = $v.maxLength; + _multipleChecks = $v.multipleChecks; + _$v = null; + } + return this; + } + + @override + void replace(covariant TestObject other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$TestObject; + } + + @override + void update(void Function(TestObjectBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + TestObject build() => _build(); + + _$TestObject _build() { + TestObject._validate(this); + final _$result = _$v ?? + _$TestObject._( + onlyNumbers: onlyNumbers, minLength: minLength, maxLength: maxLength, multipleChecks: multipleChecks); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.json b/packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.json new file mode 100644 index 00000000..f705c567 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/pattern_check.openapi.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Pattern check test", + "version": "0.0.1" + }, + "components": { + "schemas": { + "TestObject": { + "type": "object", + "properties": { + "only-numbers": { + "type": "string", + "pattern": "^[0-9]*$" + }, + "min-length": { + "type": "string", + "minLength": 3 + }, + "max-length": { + "type": "string", + "maxLength": 20 + }, + "multiple-checks": { + "type": "string", + "pattern": "^[0-9]*$", + "minLength": 3, + "maxLength": 20 + } + } + } + } + }, + "paths": {}, + "tags": [] +} diff --git a/packages/dynamite/dynamite_end_to_end_test/test/pattern_check_test.dart b/packages/dynamite/dynamite_end_to_end_test/test/pattern_check_test.dart new file mode 100644 index 00000000..d9330973 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/test/pattern_check_test.dart @@ -0,0 +1,50 @@ +import 'package:dynamite_end_to_end_test/pattern_check.openapi.dart'; +import 'package:test/test.dart'; + +void main() { + const validString = '01234'; + final object = TestObject( + (final b) => b + ..onlyNumbers = validString + ..minLength = validString + ..maxLength = validString + ..multipleChecks = validString, + ); + + group('Pattern check', () { + test('onlyNumbers', () { + expect(() => object.rebuild((final b) => b..onlyNumbers = null), throwsA(isA())); + expect(() => object.rebuild((final b) => b..onlyNumbers = 'Text'), throwsA(isA())); + }); + + test('minLength', () { + expect(() => object.rebuild((final b) => b..minLength = null), throwsA(isA())); + expect(() => object.rebuild((final b) => b..minLength = ''), throwsA(isA())); + expect(() => object.rebuild((final b) => b..minLength = 'Te'), throwsA(isA())); + expect(() => object.rebuild((final b) => b..minLength = '12'), throwsA(isA())); + }); + + test('maxLength', () { + expect(() => object.rebuild((final b) => b..maxLength = null), throwsA(isA())); + expect( + () => object.rebuild((final b) => b..maxLength = 'Super long text should throw'), + throwsA(isA()), + ); + expect( + () => object.rebuild((final b) => b..maxLength = '419712642879393808962'), + throwsA(isA()), + ); + }); + + test('multipleChecks', () { + expect(() => object.rebuild((final b) => b..multipleChecks = null), throwsA(isA())); + expect(() => object.rebuild((final b) => b..multipleChecks = 'Text'), throwsA(isA())); + expect(() => object.rebuild((final b) => b..minLength = ''), throwsA(isA())); + expect(() => object.rebuild((final b) => b..minLength = '12'), throwsA(isA())); + expect( + () => object.rebuild((final b) => b..maxLength = '419712642879393808962'), + throwsA(isA()), + ); + }); + }); +} diff --git a/packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart b/packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart index 48a84724..7db4b758 100644 --- a/packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart +++ b/packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart @@ -5,7 +5,7 @@ import 'dart:typed_data'; import 'package:built_value/serializer.dart'; import 'package:cookie_jar/cookie_jar.dart'; import 'package:dynamite_runtime/src/http_extensions.dart'; -import 'package:dynamite_runtime/src/uri.dart'; +import 'package:dynamite_runtime/src/utils/uri.dart'; import 'package:meta/meta.dart'; import 'package:universal_io/io.dart'; diff --git a/packages/dynamite/dynamite_runtime/lib/src/string_checker.dart b/packages/dynamite/dynamite_runtime/lib/src/string_checker.dart deleted file mode 100644 index accfb49f..00000000 --- a/packages/dynamite/dynamite_runtime/lib/src/string_checker.dart +++ /dev/null @@ -1,26 +0,0 @@ -/// Checks the [input] against [pattern]. -/// -/// Throws an `Exception` containing the [parameterName] if the `pattern` does not match. -void checkPattern(final String input, final RegExp pattern, final String parameterName) { - if (!pattern.hasMatch(input)) { - throw Exception('Invalid value "$input" for parameter "$parameterName" with pattern "${pattern.pattern}"'); - } -} - -/// Checks the [input] length against [minLength]. -/// -/// Throws an `Exception` containing the [parameterName] if the `input` is to short. -void checkMinLength(final String input, final int minLength, final String parameterName) { - if (input.length < minLength) { - throw Exception('Parameter "$input" has to be at least $minLength characters long'); - } -} - -/// Checks the [input] length against [maxLength]. -/// -/// Throws an `Exception` containing the [parameterName] if the `input` is to long. -void checkMaxLength(final String input, final int maxLength, final String parameterName) { - if (input.length > maxLength) { - throw Exception('Parameter "$input" has to be at most $maxLength characters long'); - } -} diff --git a/packages/dynamite/dynamite_runtime/lib/src/utils/string_checker.dart b/packages/dynamite/dynamite_runtime/lib/src/utils/string_checker.dart new file mode 100644 index 00000000..08ce8ffc --- /dev/null +++ b/packages/dynamite/dynamite_runtime/lib/src/utils/string_checker.dart @@ -0,0 +1,26 @@ +/// Checks the [input] against [pattern]. +/// +/// Throws an `Exception` containing the [parameterName] if the `pattern` does not match. +void checkPattern(final String? input, final RegExp pattern, final String parameterName) { + if (input == null || !pattern.hasMatch(input)) { + throw FormatException('Invalid value "$input" for parameter "$parameterName" with pattern "${pattern.pattern}"'); + } +} + +/// Checks the [input] length against [minLength]. +/// +/// Throws an `Exception` containing the [parameterName] if the `input` is to short. +void checkMinLength(final String? input, final int minLength, final String parameterName) { + if (input == null || input.length < minLength) { + throw FormatException('Parameter "$input" has to be at least $minLength characters long'); + } +} + +/// Checks the [input] length against [maxLength]. +/// +/// Throws an `Exception` containing the [parameterName] if the `input` is to long. +void checkMaxLength(final String? input, final int maxLength, final String parameterName) { + if (input == null || input.length > maxLength) { + throw FormatException('Parameter "$input" has to be at most $maxLength characters long'); + } +} diff --git a/packages/dynamite/dynamite_runtime/lib/src/uri.dart b/packages/dynamite/dynamite_runtime/lib/src/utils/uri.dart similarity index 100% rename from packages/dynamite/dynamite_runtime/lib/src/uri.dart rename to packages/dynamite/dynamite_runtime/lib/src/utils/uri.dart diff --git a/packages/dynamite/dynamite_runtime/lib/utils.dart b/packages/dynamite/dynamite_runtime/lib/utils.dart index c8d7b711..b3d746fe 100644 --- a/packages/dynamite/dynamite_runtime/lib/utils.dart +++ b/packages/dynamite/dynamite_runtime/lib/utils.dart @@ -1,2 +1,2 @@ -export 'src/string_checker.dart'; -export 'src/uri.dart'; +export 'src/utils/string_checker.dart'; +export 'src/utils/uri.dart'; diff --git a/packages/dynamite/dynamite_runtime/test/uri_test.dart b/packages/dynamite/dynamite_runtime/test/uri_test.dart index 010ef7c1..bcf96a68 100644 --- a/packages/dynamite/dynamite_runtime/test/uri_test.dart +++ b/packages/dynamite/dynamite_runtime/test/uri_test.dart @@ -1,4 +1,4 @@ -import 'package:dynamite_runtime/src/uri.dart'; +import 'package:dynamite_runtime/src/utils/uri.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/nextcloud/lib/src/api/files.openapi.dart b/packages/nextcloud/lib/src/api/files.openapi.dart index 773169be..3625b1d1 100644 --- a/packages/nextcloud/lib/src/api/files.openapi.dart +++ b/packages/nextcloud/lib/src/api/files.openapi.dart @@ -12,7 +12,7 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/built_value.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:dynamite_runtime/utils.dart'; +import 'package:dynamite_runtime/utils.dart' as dynamite_utils; import 'package:meta/meta.dart'; import 'package:universal_io/io.dart'; import 'package:uri/uri.dart'; @@ -136,7 +136,7 @@ class ApiClient { // coverage:ignore-end pathParameters['x'] = x.toString(); pathParameters['y'] = y.toString(); - checkPattern(file, RegExp(r'^.+$'), 'file'); // coverage:ignore-line + dynamite_utils.checkPattern(file, RegExp(r'^.+$'), 'file'); pathParameters['file'] = file; var uri = Uri.parse(UriTemplate('/index.php/apps/files/api/v1/thumbnail/{x}/{y}/{file}').expand(pathParameters)); if (queryParameters.isNotEmpty) { diff --git a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart index a24b5216..dc9cb74a 100644 --- a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart @@ -11,7 +11,7 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/built_value.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:dynamite_runtime/utils.dart'; +import 'package:dynamite_runtime/utils.dart' as dynamite_utils; import 'package:meta/meta.dart'; import 'package:universal_io/io.dart'; import 'package:uri/uri.dart'; @@ -123,7 +123,7 @@ class ApiClient { } // coverage:ignore-end - checkPattern(version, RegExp(r'^1$'), 'version'); // coverage:ignore-line + dynamite_utils.checkPattern(version, RegExp(r'^1$'), 'version'); pathParameters['version'] = version; pathParameters['fileId'] = fileId.toString(); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -236,7 +236,7 @@ class ApiClient { // coverage:ignore-end queryParameters['dueDate'] = dueDate; - checkPattern(version, RegExp(r'^1$'), 'version'); // coverage:ignore-line + dynamite_utils.checkPattern(version, RegExp(r'^1$'), 'version'); pathParameters['version'] = version; pathParameters['fileId'] = fileId.toString(); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -339,7 +339,7 @@ class ApiClient { } // coverage:ignore-end - checkPattern(version, RegExp(r'^1$'), 'version'); // coverage:ignore-line + dynamite_utils.checkPattern(version, RegExp(r'^1$'), 'version'); pathParameters['version'] = version; pathParameters['fileId'] = fileId.toString(); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart index 5fd134c7..1e19ec98 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart @@ -13,7 +13,7 @@ import 'package:collection/collection.dart'; import 'package:dynamite_runtime/built_value.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:dynamite_runtime/models.dart'; -import 'package:dynamite_runtime/utils.dart'; +import 'package:dynamite_runtime/utils.dart' as dynamite_utils; import 'package:meta/meta.dart'; import 'package:universal_io/io.dart'; import 'package:uri/uri.dart'; @@ -1367,7 +1367,7 @@ class GroupsClient { } // coverage:ignore-end - checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line + dynamite_utils.checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); pathParameters['groupId'] = groupId; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); var uri = Uri.parse(UriTemplate('/ocs/v2.php/cloud/groups/{groupId}/users').expand(pathParameters)); @@ -1475,7 +1475,7 @@ class GroupsClient { } // coverage:ignore-end - checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line + dynamite_utils.checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); pathParameters['groupId'] = groupId; if (search != '') { queryParameters['search'] = search; @@ -1581,7 +1581,7 @@ class GroupsClient { } // coverage:ignore-end - checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line + dynamite_utils.checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); pathParameters['groupId'] = groupId; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); var uri = Uri.parse(UriTemplate('/ocs/v2.php/cloud/groups/{groupId}/subadmins').expand(pathParameters)); @@ -1676,7 +1676,7 @@ class GroupsClient { } // coverage:ignore-end - checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line + dynamite_utils.checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); pathParameters['groupId'] = groupId; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); var uri = Uri.parse(UriTemplate('/ocs/v2.php/cloud/groups/{groupId}').expand(pathParameters)); @@ -1785,7 +1785,7 @@ class GroupsClient { // coverage:ignore-end queryParameters['key'] = key; queryParameters['value'] = value; - checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line + dynamite_utils.checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); pathParameters['groupId'] = groupId; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); var uri = Uri.parse(UriTemplate('/ocs/v2.php/cloud/groups/{groupId}').expand(pathParameters)); @@ -1882,7 +1882,7 @@ class GroupsClient { } // coverage:ignore-end - checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line + dynamite_utils.checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); pathParameters['groupId'] = groupId; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); var uri = Uri.parse(UriTemplate('/ocs/v2.php/cloud/groups/{groupId}').expand(pathParameters)); @@ -3562,11 +3562,7 @@ class UsersClient { queryParameters['key'] = key; queryParameters['value'] = value; pathParameters['userId'] = userId; - checkPattern( - collectionName, - RegExp(r'^(?!enable$|disable$)[a-zA-Z0-9_]*$'), - 'collectionName', - ); // coverage:ignore-line + dynamite_utils.checkPattern(collectionName, RegExp(r'^(?!enable$|disable$)[a-zA-Z0-9_]*$'), 'collectionName'); pathParameters['collectionName'] = collectionName; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); var uri = Uri.parse(UriTemplate('/ocs/v2.php/cloud/users/{userId}/{collectionName}').expand(pathParameters)); diff --git a/packages/nextcloud/lib/src/api/spreed.openapi.dart b/packages/nextcloud/lib/src/api/spreed.openapi.dart index dd0faaf0..4ac2520c 100644 --- a/packages/nextcloud/lib/src/api/spreed.openapi.dart +++ b/packages/nextcloud/lib/src/api/spreed.openapi.dart @@ -14,7 +14,7 @@ import 'package:collection/collection.dart'; import 'package:dynamite_runtime/built_value.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:dynamite_runtime/models.dart'; -import 'package:dynamite_runtime/utils.dart'; +import 'package:dynamite_runtime/utils.dart' as dynamite_utils; import 'package:meta/meta.dart'; import 'package:universal_io/io.dart'; import 'package:uri/uri.dart'; @@ -165,7 +165,7 @@ class AvatarClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (darkTheme != 0) { queryParameters['darkTheme'] = darkTheme.toString(); @@ -268,7 +268,7 @@ class AvatarClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -366,7 +366,7 @@ class AvatarClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -477,7 +477,7 @@ class AvatarClient { // coverage:ignore-end queryParameters['emoji'] = emoji; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (color != null) { queryParameters['color'] = color; @@ -579,7 +579,7 @@ class AvatarClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -715,7 +715,7 @@ class BotClient { // coverage:ignore-end queryParameters['message'] = message; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (referenceId != '') { queryParameters['referenceId'] = referenceId; @@ -841,7 +841,7 @@ class BotClient { // coverage:ignore-end queryParameters['reaction'] = reaction; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['messageId'] = messageId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -958,7 +958,7 @@ class BotClient { // coverage:ignore-end queryParameters['reaction'] = reaction; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['messageId'] = messageId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -1156,7 +1156,7 @@ class BotClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -1264,7 +1264,7 @@ class BotClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['botId'] = botId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -1372,7 +1372,7 @@ class BotClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['botId'] = botId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -1498,7 +1498,7 @@ class BreakoutRoomClient { // coverage:ignore-end queryParameters['mode'] = mode.toString(); queryParameters['amount'] = amount.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (attendeeMap != '[]') { queryParameters['attendeeMap'] = attendeeMap; @@ -1602,7 +1602,7 @@ class BreakoutRoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -1713,7 +1713,7 @@ class BreakoutRoomClient { // coverage:ignore-end queryParameters['message'] = message; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -1822,7 +1822,7 @@ class BreakoutRoomClient { // coverage:ignore-end queryParameters['attendeeMap'] = attendeeMap; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -1925,7 +1925,7 @@ class BreakoutRoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -2032,7 +2032,7 @@ class BreakoutRoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -2136,7 +2136,7 @@ class BreakoutRoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -2239,7 +2239,7 @@ class BreakoutRoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -2348,7 +2348,7 @@ class BreakoutRoomClient { // coverage:ignore-end queryParameters['target'] = target; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -2453,7 +2453,7 @@ class CallClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -2560,7 +2560,7 @@ class CallClient { // coverage:ignore-end queryParameters['flags'] = flags.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -2681,7 +2681,7 @@ class CallClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (flags != null) { queryParameters['flags'] = flags.toString(); @@ -2797,7 +2797,7 @@ class CallClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (all != 0) { queryParameters['all'] = all.toString(); @@ -2904,7 +2904,7 @@ class CallClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['attendeeId'] = attendeeId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -3015,7 +3015,7 @@ class CallClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['attendeeId'] = attendeeId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -3289,7 +3289,7 @@ class ChatClient { // coverage:ignore-end queryParameters['lookIntoFuture'] = lookIntoFuture.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (limit != 100) { queryParameters['limit'] = limit.toString(); @@ -3446,7 +3446,7 @@ class ChatClient { // coverage:ignore-end queryParameters['message'] = message; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (actorDisplayName != '') { queryParameters['actorDisplayName'] = actorDisplayName; @@ -3561,7 +3561,7 @@ class ChatClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -3675,7 +3675,7 @@ class ChatClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['messageId'] = messageId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -3789,7 +3789,7 @@ class ChatClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['messageId'] = messageId.toString(); if (limit != 50) { @@ -3901,7 +3901,7 @@ class ChatClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['messageId'] = messageId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -4016,7 +4016,7 @@ class ChatClient { // coverage:ignore-end queryParameters['timestamp'] = timestamp.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['messageId'] = messageId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -4125,7 +4125,7 @@ class ChatClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['messageId'] = messageId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -4233,7 +4233,7 @@ class ChatClient { // coverage:ignore-end queryParameters['lastReadMessage'] = lastReadMessage.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -4333,7 +4333,7 @@ class ChatClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -4447,7 +4447,7 @@ class ChatClient { // coverage:ignore-end queryParameters['search'] = search; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (limit != 20) { queryParameters['limit'] = limit.toString(); @@ -4570,7 +4570,7 @@ class ChatClient { // coverage:ignore-end queryParameters['objectType'] = objectType; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (lastKnownMessageId != 0) { queryParameters['lastKnownMessageId'] = lastKnownMessageId.toString(); @@ -4714,7 +4714,7 @@ class ChatClient { // coverage:ignore-end queryParameters['objectType'] = objectType; queryParameters['objectId'] = objectId; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (metaData != '') { queryParameters['metaData'] = metaData; @@ -4828,7 +4828,7 @@ class ChatClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (limit != 7) { queryParameters['limit'] = limit.toString(); @@ -5254,7 +5254,7 @@ class FilesIntegrationClient { } // coverage:ignore-end - checkPattern(fileId, RegExp(r'^.+$'), 'fileId'); // coverage:ignore-line + dynamite_utils.checkPattern(fileId, RegExp(r'^.+$'), 'fileId'); pathParameters['fileId'] = fileId; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -5365,7 +5365,7 @@ class FilesIntegrationClient { } // coverage:ignore-end - checkPattern(shareToken, RegExp(r'^.+$'), 'shareToken'); // coverage:ignore-line + dynamite_utils.checkPattern(shareToken, RegExp(r'^.+$'), 'shareToken'); pathParameters['shareToken'] = shareToken; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -5480,7 +5480,7 @@ class GuestClient { // coverage:ignore-end queryParameters['displayName'] = displayName; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -5826,7 +5826,7 @@ class MatterbridgeClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -5938,7 +5938,7 @@ class MatterbridgeClient { // coverage:ignore-end queryParameters['enabled'] = enabled.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (parts != null) { queryParameters['parts'] = _jsonSerializers.serialize( @@ -6049,7 +6049,7 @@ class MatterbridgeClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -6148,7 +6148,7 @@ class MatterbridgeClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -6485,7 +6485,7 @@ class PollClient { queryParameters['options[]'] = options.map((final e) => e); queryParameters['resultMode'] = resultMode.toString(); queryParameters['maxVotes'] = maxVotes.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -6589,7 +6589,7 @@ class PollClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['pollId'] = pollId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -6703,7 +6703,7 @@ class PollClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['pollId'] = pollId.toString(); if (optionIds != const []) { @@ -6819,7 +6819,7 @@ class PollClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['pollId'] = pollId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -7047,7 +7047,7 @@ class ReactionClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['messageId'] = messageId.toString(); if (reaction != null) { @@ -7167,7 +7167,7 @@ class ReactionClient { // coverage:ignore-end queryParameters['reaction'] = reaction; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['messageId'] = messageId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -7282,7 +7282,7 @@ class ReactionClient { // coverage:ignore-end queryParameters['reaction'] = reaction; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['messageId'] = messageId.toString(); pathParameters['apiVersion'] = apiVersion.name; @@ -7506,7 +7506,7 @@ class RecordingClient { // coverage:ignore-end queryParameters['status'] = status.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -7608,7 +7608,7 @@ class RecordingClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -7716,7 +7716,7 @@ class RecordingClient { // coverage:ignore-end queryParameters['owner'] = owner; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -7825,7 +7825,7 @@ class RecordingClient { // coverage:ignore-end queryParameters['timestamp'] = timestamp.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -7940,7 +7940,7 @@ class RecordingClient { // coverage:ignore-end queryParameters['fileId'] = fileId.toString(); queryParameters['timestamp'] = timestamp.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -8512,7 +8512,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -8617,7 +8617,7 @@ class RoomClient { // coverage:ignore-end queryParameters['roomName'] = roomName; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -8716,7 +8716,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -8817,7 +8817,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -8920,7 +8920,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -9022,7 +9022,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -9128,7 +9128,7 @@ class RoomClient { // coverage:ignore-end queryParameters['description'] = description; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -9237,7 +9237,7 @@ class RoomClient { // coverage:ignore-end queryParameters['state'] = state.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -9346,7 +9346,7 @@ class RoomClient { // coverage:ignore-end queryParameters['scope'] = scope.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -9455,7 +9455,7 @@ class RoomClient { // coverage:ignore-end queryParameters['password'] = password; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -9567,9 +9567,9 @@ class RoomClient { // coverage:ignore-end queryParameters['permissions'] = permissions.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; - checkPattern(mode, RegExp(r'^(call|default)$'), 'mode'); // coverage:ignore-line + dynamite_utils.checkPattern(mode, RegExp(r'^(call|default)$'), 'mode'); pathParameters['mode'] = mode; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -9675,7 +9675,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (includeStatus != 0) { queryParameters['includeStatus'] = includeStatus.toString(); @@ -9796,7 +9796,7 @@ class RoomClient { // coverage:ignore-end queryParameters['newParticipant'] = newParticipant; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (source != 'users') { queryParameters['source'] = source; @@ -9910,7 +9910,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (includeStatus != 0) { queryParameters['includeStatus'] = includeStatus.toString(); @@ -10020,7 +10020,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -10131,7 +10131,7 @@ class RoomClient { // coverage:ignore-end queryParameters['attendeeId'] = attendeeId.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -10254,7 +10254,7 @@ class RoomClient { queryParameters['attendeeId'] = attendeeId.toString(); queryParameters['method'] = method; queryParameters['permissions'] = permissions.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -10367,7 +10367,7 @@ class RoomClient { // coverage:ignore-end queryParameters['method'] = method; queryParameters['permissions'] = permissions.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -10483,7 +10483,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (password != '') { queryParameters['password'] = password; @@ -10588,7 +10588,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -10696,7 +10696,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (attendeeId != null) { queryParameters['attendeeId'] = attendeeId.toString(); @@ -10807,7 +10807,7 @@ class RoomClient { // coverage:ignore-end queryParameters['state'] = state.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -10918,7 +10918,7 @@ class RoomClient { // coverage:ignore-end queryParameters['attendeeId'] = attendeeId.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -11029,7 +11029,7 @@ class RoomClient { // coverage:ignore-end queryParameters['attendeeId'] = attendeeId.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -11130,7 +11130,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -11231,7 +11231,7 @@ class RoomClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -11340,7 +11340,7 @@ class RoomClient { // coverage:ignore-end queryParameters['level'] = level.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -11448,7 +11448,7 @@ class RoomClient { // coverage:ignore-end queryParameters['level'] = level.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -11562,7 +11562,7 @@ class RoomClient { // coverage:ignore-end queryParameters['state'] = state.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; if (timer != null) { queryParameters['timer'] = timer.toString(); @@ -11680,7 +11680,7 @@ class RoomClient { // coverage:ignore-end queryParameters['state'] = state.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -11791,7 +11791,7 @@ class RoomClient { // coverage:ignore-end queryParameters['recordingConsent'] = recordingConsent.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -11898,7 +11898,7 @@ class RoomClient { // coverage:ignore-end queryParameters['seconds'] = seconds.toString(); - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -12459,7 +12459,7 @@ class SignalingClient { } // coverage:ignore-end - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -12565,7 +12565,7 @@ class SignalingClient { // coverage:ignore-end queryParameters['messages'] = messages; - checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); // coverage:ignore-line + dynamite_utils.checkPattern(token, RegExp(r'^[a-z0-9]{4,30}$'), 'token'); pathParameters['token'] = token; pathParameters['apiVersion'] = apiVersion.name; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); diff --git a/packages/nextcloud/lib/src/api/theming.openapi.dart b/packages/nextcloud/lib/src/api/theming.openapi.dart index a903c6c9..bd317012 100644 --- a/packages/nextcloud/lib/src/api/theming.openapi.dart +++ b/packages/nextcloud/lib/src/api/theming.openapi.dart @@ -12,7 +12,7 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/built_value.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:dynamite_runtime/utils.dart'; +import 'package:dynamite_runtime/utils.dart' as dynamite_utils; import 'package:meta/meta.dart'; import 'package:universal_io/io.dart'; import 'package:uri/uri.dart'; @@ -292,7 +292,7 @@ class IconClient { // coverage:ignore-end pathParameters['app'] = app; - checkPattern(image, RegExp(r'^.+$'), 'image'); // coverage:ignore-line + dynamite_utils.checkPattern(image, RegExp(r'^.+$'), 'image'); pathParameters['image'] = image; var uri = Uri.parse(UriTemplate('/index.php/apps/theming/img/{app}/{image}').expand(pathParameters)); if (queryParameters.isNotEmpty) { @@ -1108,6 +1108,11 @@ abstract class ThemingGetManifestResponseApplicationJson_Icons static Serializer get serializer => _$themingGetManifestResponseApplicationJsonIconsSerializer; + + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final ThemingGetManifestResponseApplicationJson_IconsBuilder b) { + dynamite_utils.checkMinLength(b.src, 1, 'b.src'); + } } @BuiltValue(instantiable: false) diff --git a/packages/nextcloud/lib/src/api/theming.openapi.g.dart b/packages/nextcloud/lib/src/api/theming.openapi.g.dart index 54e0d998..c052ea18 100644 --- a/packages/nextcloud/lib/src/api/theming.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/theming.openapi.g.dart @@ -721,6 +721,7 @@ class ThemingGetManifestResponseApplicationJson_IconsBuilder ThemingGetManifestResponseApplicationJson_Icons build() => _build(); _$ThemingGetManifestResponseApplicationJson_Icons _build() { + ThemingGetManifestResponseApplicationJson_Icons._validate(this); final _$result = _$v ?? _$ThemingGetManifestResponseApplicationJson_Icons._( src: BuiltValueNullFieldError.checkNotNull(src, r'ThemingGetManifestResponseApplicationJson_Icons', 'src'),