From 055663a56eb8b09eaa61d59af30e60d86bbc7581 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Fri, 29 Dec 2023 18:02:54 +0100 Subject: [PATCH] test(dynamite): add tests for documentation Signed-off-by: Nikolas Rimikis --- .../dynamite_end_to_end_test/build.yaml | 9 + .../lib/documentation.openapi.dart | 451 ++++++++++++++++++ .../lib/documentation.openapi.g.dart | 355 ++++++++++++++ .../lib/documentation.openapi.json | 165 +++++++ 4 files changed, 980 insertions(+) create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.g.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.json diff --git a/packages/dynamite/dynamite_end_to_end_test/build.yaml b/packages/dynamite/dynamite_end_to_end_test/build.yaml index 7b44fb568f7..53674610efa 100644 --- a/packages/dynamite/dynamite_end_to_end_test/build.yaml +++ b/packages/dynamite/dynamite_end_to_end_test/build.yaml @@ -14,3 +14,12 @@ targets: - unreachable_switch_case - unused_element - no_leading_underscores_for_local_identifiers + overrides: + lib/documentation.openapi.json: + analyzer_ignores: + - camel_case_types + - camel_case_extensions + - discarded_futures + - unreachable_switch_case + - unused_element + - no_leading_underscores_for_local_identifiers diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.dart b/packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.dart new file mode 100644 index 00000000000..6149586ecc2 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.dart @@ -0,0 +1,451 @@ +// Use of this source code is governed by a Apache 2.0 license. It can be obtained at https://www.apache.org/licenses/LICENSE-2.0.html. + +// OpenAPI client generated by Dynamite. Do not manually edit this file. + +// ignore_for_file: camel_case_extensions, camel_case_types, discarded_futures +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: unreachable_switch_case, unused_element + +/// Documentation test. Version: 1.0.0. +/// Values are inspired by the petstore example. +/// +/// A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification. +/// +/// You can contact the Swagger API Team team under: +/// Email: `apiteam@swagger.io`. +/// Website: `http://swagger.io`. +/// +/// Use of this source code is governed by a Apache 2.0 license. +/// It can be obtained at https://www.apache.org/licenses/LICENSE-2.0.html. +/// +/// Usage of these apis must adhere to the terms of service: `http://swagger.io/terms/`. +library; + +import 'package:built_collection/built_collection.dart'; +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; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; +import 'package:uri/uri.dart'; + +part 'documentation.openapi.g.dart'; + +/// the root client used for root requests. +class $Client extends DynamiteClient { + /// Creates a new [DynamiteClient] for untagged requests. + $Client( + super.baseURL, { + super.baseHeaders, + super.userAgent, + super.httpClient, + super.cookieJar, + }); + + /// Creates a new [$Client] from another [client]. + $Client.fromClient(DynamiteClient client) + : super( + client.baseURL, + baseHeaders: client.baseHeaders, + httpClient: client.httpClient, + cookieJar: client.cookieJar, + authentications: client.authentications, + ); + + /// the non root client used for other requests. + $NonRootClientClient get nonRootClient => $NonRootClientClient(this); + + /// An optional, string summary, intended to apply to all operations in this path. + /// + /// Returns all pets from the system that the user has access to. + /// Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. + /// + /// Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. + /// + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [tags] tags to filter by. + /// * [limit] maximum number of results to return. + /// + /// Status codes: + /// * default: finds an object + /// + /// See: + /// * [findValuesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. + Future> findValues({ + BuiltList? tags, + int? limit, + }) async { + final rawResponse = findValuesRaw( + tags: tags, + limit: limit, + ); + + return rawResponse.future; + } + + /// An optional, string summary, intended to apply to all operations in this path. + /// + /// Returns all pets from the system that the user has access to. + /// Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. + /// + /// Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. + /// + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [tags] tags to filter by. + /// * [limit] maximum number of results to return. + /// + /// Status codes: + /// * default: finds an object + /// + /// See: + /// * [findValues] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental + DynamiteRawResponse findValuesRaw({ + BuiltList? tags, + int? limit, + }) { + final _parameters = {}; + const _headers = { + 'Accept': 'application/json', + }; + + final $tags = jsonSerializers.serialize(tags, specifiedType: const FullType(BuiltList, [FullType(String)])); + _parameters['tags'] = $tags; + + final $limit = jsonSerializers.serialize(limit, specifiedType: const FullType(int)); + _parameters['limit'] = $limit; + + final _path = UriTemplate('/{?tags*,limit*}').expand(_parameters); + return DynamiteRawResponse( + response: executeRequest( + 'get', + _path, + _headers, + null, + null, + ), + bodyType: const FullType(Object1), + headersType: null, + serializers: jsonSerializers, + ); + } +} + +/// the non root client used for other requests. +class $NonRootClientClient { + /// Creates a new [DynamiteClient] for non_root_client requests. + $NonRootClientClient(this._rootClient); + + final $Client _rootClient; + + /// Do something really cool. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * default: finds an object + /// + /// See: + /// * [setModeRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. + Future> setMode() async { + final rawResponse = setModeRaw(); + + return rawResponse.future; + } + + /// Do something really cool. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * default: finds an object + /// + /// See: + /// * [setMode] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental + DynamiteRawResponse setModeRaw() { + const _headers = { + 'Accept': 'application/json', + }; + + const _path = '/other-endpoint'; + return DynamiteRawResponse( + response: _rootClient.executeRequest( + 'post', + _path, + _headers, + null, + null, + ), + bodyType: const FullType(Object1), + headersType: null, + serializers: jsonSerializers, + ); + } +} + +/// @nodoc +typedef Redirect = Object2; + +/// @nodoc +@BuiltValue(instantiable: false) +abstract interface class $Object2Interface { + /// The name of this object. + String get name; + + /// The tag of an Object2 object. + String? get tag; +} + +/// A representation of the second Object type. +abstract class Object2 implements $Object2Interface, Built { + /// Creates a new Object2 object using the builder pattern. + factory Object2([void Function(Object2Builder)? b]) = _$Object2; + + const Object2._(); + + /// Creates a new object from the given [json] data. + /// + /// Use [toJson] to serialize it back into json. + factory Object2.fromJson(Map json) => jsonSerializers.deserializeWith(serializer, json)!; + + /// Parses this object into a json like map. + /// + /// Use the fromJson factory to revive it again. + Map toJson() => jsonSerializers.serializeWith(serializer, this)! as Map; + + /// Serializer for Object2. + static Serializer get serializer => _$object2Serializer; +} + +/// @nodoc +@BuiltValue(instantiable: false) +abstract interface class $Object1_1Interface { + /// The uuid in an UUIDv4 format. + int get id; +} + +/// @nodoc +@BuiltValue(instantiable: false) +abstract interface class $Object1Interface implements $Object2Interface, $Object1_1Interface {} + +/// A representation of the main object. +abstract class Object1 implements $Object1Interface, Built { + /// Creates a new Object1 object using the builder pattern. + factory Object1([void Function(Object1Builder)? b]) = _$Object1; + + const Object1._(); + + /// Creates a new object from the given [json] data. + /// + /// Use [toJson] to serialize it back into json. + factory Object1.fromJson(Map json) => jsonSerializers.deserializeWith(serializer, json)!; + + /// Parses this object into a json like map. + /// + /// Use the fromJson factory to revive it again. + Map toJson() => jsonSerializers.serializeWith(serializer, this)! as Map; + + /// Serializer for Object1. + static Serializer get serializer => _$object1Serializer; +} + +/// An Object to test the documentation of someOf extension methods and typdefs. +typedef Object3 = ({int? $int, String? string}); + +/// The measured skill for hunting. +class HuntingSkill extends EnumClass { + const HuntingSkill._(super.name); + + /// @nodoc + static const HuntingSkill clueless = _$huntingSkillClueless; + + /// @nodoc + static const HuntingSkill lazy = _$huntingSkillLazy; + + /// @nodoc + static const HuntingSkill adventurous = _$huntingSkillAdventurous; + + /// @nodoc + static const HuntingSkill aggressive = _$huntingSkillAggressive; + + /// Returns a set with all values this enum contains. + static BuiltSet get values => _$huntingSkillValues; + + /// Returns the enum value associated to the [name]. + static HuntingSkill valueOf(String name) => _$valueOfHuntingSkill(name); + + /// Returns the serialized value of this enum value. + dynamic get value => jsonSerializers.serializeWith(serializer, this)! as dynamic; + + /// Serializer for HuntingSkill. + @BuiltValueSerializer(custom: true) + static Serializer get serializer => const _$HuntingSkillSerializer(); +} + +class _$HuntingSkillSerializer implements PrimitiveSerializer { + const _$HuntingSkillSerializer(); + + static const Map _toWire = { + HuntingSkill.clueless: 'clueless', + HuntingSkill.lazy: 'lazy', + HuntingSkill.adventurous: 'adventurous', + HuntingSkill.aggressive: 'aggressive', + }; + + static const Map _fromWire = { + 'clueless': HuntingSkill.clueless, + 'lazy': HuntingSkill.lazy, + 'adventurous': HuntingSkill.adventurous, + 'aggressive': HuntingSkill.aggressive, + }; + + @override + Iterable get types => const [HuntingSkill]; + + @override + String get wireName => 'HuntingSkill'; + + @override + Object serialize( + Serializers serializers, + HuntingSkill object, { + FullType specifiedType = FullType.unspecified, + }) => + _toWire[object]!; + + @override + HuntingSkill deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) => + _fromWire[serialized]!; +} + +/// @nodoc +extension $Object3Extension on Object3 { + /// Serializer for Object3. + @BuiltValueSerializer(custom: true) + static Serializer get serializer => $b2c4857c0136baea42828d89c87c757dExtension._serializer; + + /// Creates a new object from the given [json] data. + /// + /// Use `toJson` to serialize it back into json. + static Object3 fromJson(Object? json) => $b2c4857c0136baea42828d89c87c757dExtension._fromJson(json); +} + +typedef _$b2c4857c0136baea42828d89c87c757d = ({int? $int, String? string}); + +/// @nodoc +// ignore: library_private_types_in_public_api +extension $b2c4857c0136baea42828d89c87c757dExtension on _$b2c4857c0136baea42828d89c87c757d { + List get _values => [$int, string]; + + /// {@macro Dynamite.validateOneOf} + void validateOneOf() => dynamite_utils.validateOneOf(_values); + + /// {@macro Dynamite.validateAnyOf} + void validateAnyOf() => dynamite_utils.validateAnyOf(_values); + static Serializer<_$b2c4857c0136baea42828d89c87c757d> get _serializer => + const _$b2c4857c0136baea42828d89c87c757dSerializer(); + static _$b2c4857c0136baea42828d89c87c757d _fromJson(Object? json) => + jsonSerializers.deserializeWith(_serializer, json)!; + + /// Parses this object into a json like map. + /// + /// Use the fromJson factory to revive it again. + Object? toJson() => jsonSerializers.serializeWith(_serializer, this); +} + +class _$b2c4857c0136baea42828d89c87c757dSerializer implements PrimitiveSerializer<_$b2c4857c0136baea42828d89c87c757d> { + const _$b2c4857c0136baea42828d89c87c757dSerializer(); + + @override + Iterable get types => const [_$b2c4857c0136baea42828d89c87c757d]; + + @override + String get wireName => r'_$b2c4857c0136baea42828d89c87c757d'; + + @override + Object serialize( + Serializers serializers, + _$b2c4857c0136baea42828d89c87c757d object, { + FullType specifiedType = FullType.unspecified, + }) { + dynamic value; + value = object.$int; + if (value != null) { + return serializers.serialize(value, specifiedType: const FullType(int))!; + } + value = object.string; + if (value != null) { + return serializers.serialize(value, specifiedType: const FullType(String))!; + } +// Should not be possible after validation. + throw StateError('Tried to serialize without any value.'); + } + + @override + _$b2c4857c0136baea42828d89c87c757d deserialize( + Serializers serializers, + Object data, { + FullType specifiedType = FullType.unspecified, + }) { + int? $int; + try { + $int = serializers.deserialize(data, specifiedType: const FullType(int))! as int; + } catch (_) {} + String? string; + try { + string = serializers.deserialize(data, specifiedType: const FullType(String))! as String; + } catch (_) {} + return ($int: $int, string: string); + } +} + +// coverage:ignore-start +/// Serializer for all values in this library. +/// +/// Serializes values into the `built_value` wire format. +/// See: [jsonSerializers] for serializing into json. +@visibleForTesting +final Serializers serializers = (Serializers().toBuilder() + ..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder.new) + ..addBuilderFactory(const FullType(Object1), Object1Builder.new) + ..add(Object1.serializer) + ..addBuilderFactory(const FullType(Object2), Object2Builder.new) + ..add(Object2.serializer) + ..add($b2c4857c0136baea42828d89c87c757dExtension._serializer) + ..add(HuntingSkill.serializer)) + .build(); + +/// Serializer for all values in this library. +/// +/// Serializes values into the json. Json serialization is more expensive than the built_value wire format. +/// See: [serializers] for serializing into the `built_value` wire format. +@visibleForTesting +final Serializers jsonSerializers = (serializers.toBuilder() + ..add(DynamiteDoubleSerializer()) + ..addPlugin(StandardJsonPlugin()) + ..addPlugin(const HeaderPlugin()) + ..addPlugin(const ContentStringPlugin())) + .build(); +// coverage:ignore-end diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.g.dart b/packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.g.dart new file mode 100644 index 00000000000..5464b2c8ba3 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.g.dart @@ -0,0 +1,355 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'documentation.openapi.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +const HuntingSkill _$huntingSkillClueless = HuntingSkill._('clueless'); +const HuntingSkill _$huntingSkillLazy = HuntingSkill._('lazy'); +const HuntingSkill _$huntingSkillAdventurous = HuntingSkill._('adventurous'); +const HuntingSkill _$huntingSkillAggressive = HuntingSkill._('aggressive'); + +HuntingSkill _$valueOfHuntingSkill(String name) { + switch (name) { + case 'clueless': + return _$huntingSkillClueless; + case 'lazy': + return _$huntingSkillLazy; + case 'adventurous': + return _$huntingSkillAdventurous; + case 'aggressive': + return _$huntingSkillAggressive; + default: + throw ArgumentError(name); + } +} + +final BuiltSet _$huntingSkillValues = BuiltSet(const [ + _$huntingSkillClueless, + _$huntingSkillLazy, + _$huntingSkillAdventurous, + _$huntingSkillAggressive, +]); + +Serializer _$object2Serializer = _$Object2Serializer(); +Serializer _$object1Serializer = _$Object1Serializer(); + +class _$Object2Serializer implements StructuredSerializer { + @override + final Iterable types = const [Object2, _$Object2]; + @override + final String wireName = 'Object2'; + + @override + Iterable serialize(Serializers serializers, Object2 object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.tag; + if (value != null) { + result + ..add('tag') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + return result; + } + + @override + Object2 deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = Object2Builder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'name': + result.name = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + case 'tag': + result.tag = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$Object1Serializer implements StructuredSerializer { + @override + final Iterable types = const [Object1, _$Object1]; + @override + final String wireName = 'Object1'; + + @override + Iterable serialize(Serializers serializers, Object1 object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(int)), + ]; + Object? value; + value = object.tag; + if (value != null) { + result + ..add('tag') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + return result; + } + + @override + Object1 deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = Object1Builder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'name': + result.name = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + case 'tag': + result.tag = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'id': + result.id = serializers.deserialize(value, specifiedType: const FullType(int))! as int; + break; + } + } + + return result.build(); + } +} + +abstract mixin class $Object2InterfaceBuilder { + void replace($Object2Interface other); + void update(void Function($Object2InterfaceBuilder) updates); + String? get name; + set name(String? name); + + String? get tag; + set tag(String? tag); +} + +class _$Object2 extends Object2 { + @override + final String name; + @override + final String? tag; + + factory _$Object2([void Function(Object2Builder)? updates]) => (Object2Builder()..update(updates))._build(); + + _$Object2._({required this.name, this.tag}) : super._() { + BuiltValueNullFieldError.checkNotNull(name, r'Object2', 'name'); + } + + @override + Object2 rebuild(void Function(Object2Builder) updates) => (toBuilder()..update(updates)).build(); + + @override + Object2Builder toBuilder() => Object2Builder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is Object2 && name == other.name && tag == other.tag; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, tag.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'Object2') + ..add('name', name) + ..add('tag', tag)) + .toString(); + } +} + +class Object2Builder implements Builder, $Object2InterfaceBuilder { + _$Object2? _$v; + + String? _name; + String? get name => _$this._name; + set name(covariant String? name) => _$this._name = name; + + String? _tag; + String? get tag => _$this._tag; + set tag(covariant String? tag) => _$this._tag = tag; + + Object2Builder(); + + Object2Builder get _$this { + final $v = _$v; + if ($v != null) { + _name = $v.name; + _tag = $v.tag; + _$v = null; + } + return this; + } + + @override + void replace(covariant Object2 other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$Object2; + } + + @override + void update(void Function(Object2Builder)? updates) { + if (updates != null) updates(this); + } + + @override + Object2 build() => _build(); + + _$Object2 _build() { + final _$result = + _$v ?? _$Object2._(name: BuiltValueNullFieldError.checkNotNull(name, r'Object2', 'name'), tag: tag); + replace(_$result); + return _$result; + } +} + +abstract mixin class $Object1_1InterfaceBuilder { + void replace($Object1_1Interface other); + void update(void Function($Object1_1InterfaceBuilder) updates); + int? get id; + set id(int? id); +} + +abstract mixin class $Object1InterfaceBuilder implements $Object2InterfaceBuilder, $Object1_1InterfaceBuilder { + void replace(covariant $Object1Interface other); + void update(void Function($Object1InterfaceBuilder) updates); + String? get name; + set name(covariant String? name); + + String? get tag; + set tag(covariant String? tag); + + int? get id; + set id(covariant int? id); +} + +class _$Object1 extends Object1 { + @override + final String name; + @override + final String? tag; + @override + final int id; + + factory _$Object1([void Function(Object1Builder)? updates]) => (Object1Builder()..update(updates))._build(); + + _$Object1._({required this.name, this.tag, required this.id}) : super._() { + BuiltValueNullFieldError.checkNotNull(name, r'Object1', 'name'); + BuiltValueNullFieldError.checkNotNull(id, r'Object1', 'id'); + } + + @override + Object1 rebuild(void Function(Object1Builder) updates) => (toBuilder()..update(updates)).build(); + + @override + Object1Builder toBuilder() => Object1Builder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is Object1 && name == other.name && tag == other.tag && id == other.id; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, tag.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'Object1') + ..add('name', name) + ..add('tag', tag) + ..add('id', id)) + .toString(); + } +} + +class Object1Builder implements Builder, $Object1InterfaceBuilder { + _$Object1? _$v; + + String? _name; + String? get name => _$this._name; + set name(covariant String? name) => _$this._name = name; + + String? _tag; + String? get tag => _$this._tag; + set tag(covariant String? tag) => _$this._tag = tag; + + int? _id; + int? get id => _$this._id; + set id(covariant int? id) => _$this._id = id; + + Object1Builder(); + + Object1Builder get _$this { + final $v = _$v; + if ($v != null) { + _name = $v.name; + _tag = $v.tag; + _id = $v.id; + _$v = null; + } + return this; + } + + @override + void replace(covariant Object1 other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$Object1; + } + + @override + void update(void Function(Object1Builder)? updates) { + if (updates != null) updates(this); + } + + @override + Object1 build() => _build(); + + _$Object1 _build() { + final _$result = _$v ?? + _$Object1._( + name: BuiltValueNullFieldError.checkNotNull(name, r'Object1', 'name'), + tag: tag, + id: BuiltValueNullFieldError.checkNotNull(id, r'Object1', 'id')); + 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/documentation.openapi.json b/packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.json new file mode 100644 index 00000000000..cc7dcfa807c --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/documentation.openapi.json @@ -0,0 +1,165 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Documentation test.", + "version": "1.0.0", + "summary": "Values are inspired by the petstore example.", + "description": "A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "Swagger API Team", + "email": "apiteam@swagger.io", + "url": "http://swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "paths": { + "/": { + "get": { + "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", + "summary": "An optional, string summary, intended to apply to all operations in this path.", + "operationId": "findValues", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "required": false, + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "default": { + "description": "finds an object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Object1" + } + } + } + } + } + } + }, + "/other-endpoint": { + "post": { + "operationId": "non_root_client-set-mode", + "summary": "Do something really cool.", + "tags": [ + "non_root_client" + ], + "responses": { + "default": { + "description": "finds an object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Object1" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Object1": { + "description": "A representation of the main object", + "allOf": [ + { + "$ref": "#/components/schemas/Object2" + }, + { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "description": "The uuid in an UUIDv4 format", + "type": "integer", + "format": "int64" + } + } + } + ] + }, + "Object2": { + "description": "A representation of the second Object type", + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "description": "The name of this object.", + "type": "string" + }, + "tag": { + "description": "The tag of an Object2 object", + "type": "string" + } + } + }, + "Object3": { + "description": "An Object to test the documentation of someOf extension methods and typdefs.", + "oneOf": [ + { + "description": "A strings for something", + "type": "string" + }, + { + "description": "An integer for something", + "type": "integer" + } + ] + }, + "huntingSkill": { + "description": "The measured skill for hunting", + "type": "object", + "enum": [ + "clueless", + "lazy", + "adventurous", + "aggressive" + ] + }, + "Redirect": { + "description": "Redirect for the Object2", + "$ref": "#/components/schemas/Object2" + } + } + }, + "tags": [ + { + "name": "", + "description": "the root client used for root requests." + }, + { + "name": "non_root_client", + "description": "the non root client used for other requests." + } + ] +}