Skip to content

Commit

Permalink
Merge pull request #1401 from nextcloud/feat/dynamite/named-imports
Browse files Browse the repository at this point in the history
Feat/dynamite/named-imports
  • Loading branch information
Leptopoda committed Jan 1, 2024
2 parents f4cee46 + b84324e commit ffb519c
Show file tree
Hide file tree
Showing 52 changed files with 6,171 additions and 5,387 deletions.
1 change: 0 additions & 1 deletion packages/dynamite/dynamite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ dependencies:
collection: ^1.0.0
dynamite_runtime: ^0.0.1
meta: ^1.0.0
universal_io: ^2.0.0
uri: ^1.0.0
dev_dependencies:
build_runner: ^2.4.0
Expand Down
116 changes: 58 additions & 58 deletions packages/dynamite/dynamite/example/lib/petstore.openapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
// ignore_for_file: no_leading_underscores_for_local_identifiers
// ignore_for_file: public_member_api_docs, unreachable_switch_case

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:convert';
import 'dart:typed_data';

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:meta/meta.dart';
import 'package:universal_io/io.dart';
import 'package:uri/uri.dart';
import 'package:built_value/standard_json_plugin.dart' as _i5;
import 'package:dynamite_runtime/built_value.dart' as _i4;
import 'package:dynamite_runtime/http_client.dart' as _i2;
import 'package:meta/meta.dart' as _i3;
import 'package:uri/uri.dart' as _i1;

part 'petstore.openapi.g.dart';

class $Client extends DynamiteClient {
/// Creates a new [DynamiteClient] for untagged requests.
class $Client extends _i2.DynamiteClient {
/// Creates a new `DynamiteClient` for untagged requests.
$Client(
super.baseURL, {
super.baseHeaders,
Expand All @@ -30,7 +30,7 @@ class $Client extends DynamiteClient {
});

/// Creates a new [$Client] from another [client].
$Client.fromClient(DynamiteClient client)
$Client.fromClient(_i2.DynamiteClient client)
: super(
client.baseURL,
baseHeaders: client.baseHeaders,
Expand All @@ -45,8 +45,8 @@ class $Client extends DynamiteClient {
/// 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.
/// 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.
Expand All @@ -57,8 +57,8 @@ class $Client extends DynamiteClient {
/// * default: unexpected error
///
/// See:
/// * [findPetsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized.
Future<DynamiteResponse<BuiltList<Pet>, void>> findPets({
/// * [findPetsRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i2.DynamiteResponse<BuiltList<Pet>, void>> findPets({
BuiltList<String>? tags,
int? limit,
}) async {
Expand All @@ -78,8 +78,8 @@ class $Client extends DynamiteClient {
///
/// 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.
/// 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.
Expand All @@ -90,9 +90,9 @@ class $Client extends DynamiteClient {
/// * default: unexpected error
///
/// See:
/// * [findPets] for an operation that returns a [DynamiteResponse] with a stable API.
@experimental
DynamiteRawResponse<BuiltList<Pet>, void> findPetsRaw({
/// * [findPets] for an operation that returns a `DynamiteResponse` with a stable API.
@_i3.experimental
_i2.DynamiteRawResponse<BuiltList<Pet>, void> findPetsRaw({
BuiltList<String>? tags,
int? limit,
}) {
Expand All @@ -107,8 +107,8 @@ class $Client extends DynamiteClient {
final $limit = _$jsonSerializers.serialize(limit, specifiedType: const FullType(int));
_parameters['limit'] = $limit;

final _path = UriTemplate('/pets{?tags*,limit*}').expand(_parameters);
return DynamiteRawResponse<BuiltList<Pet>, void>(
final _path = _i1.UriTemplate('/pets{?tags*,limit*}').expand(_parameters);
return _i2.DynamiteRawResponse<BuiltList<Pet>, void>(
response: executeRequest(
'get',
_path,
Expand All @@ -124,16 +124,16 @@ class $Client extends DynamiteClient {

/// Creates a new pet in the store. Duplicates are allowed.
///
/// 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.
/// 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:
/// * 200: pet response
/// * default: unexpected error
///
/// See:
/// * [addPetRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized.
Future<DynamiteResponse<Pet, void>> addPet({required NewPet newPet}) async {
/// * [addPetRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i2.DynamiteResponse<Pet, void>> addPet({required NewPet newPet}) async {
final rawResponse = addPetRaw(
newPet: newPet,
);
Expand All @@ -145,17 +145,17 @@ class $Client extends DynamiteClient {
///
/// 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.
/// 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:
/// * 200: pet response
/// * default: unexpected error
///
/// See:
/// * [addPet] for an operation that returns a [DynamiteResponse] with a stable API.
@experimental
DynamiteRawResponse<Pet, void> addPetRaw({required NewPet newPet}) {
/// * [addPet] for an operation that returns a `DynamiteResponse` with a stable API.
@_i3.experimental
_i2.DynamiteRawResponse<Pet, void> addPetRaw({required NewPet newPet}) {
const _headers = <String, String>{
'Accept': 'application/json',
};
Expand All @@ -164,7 +164,7 @@ class $Client extends DynamiteClient {
_headers['Content-Type'] = 'application/json';
_body = utf8.encode(json.encode(_$jsonSerializers.serialize(newPet, specifiedType: const FullType(NewPet))));
const _path = '/pets';
return DynamiteRawResponse<Pet, void>(
return _i2.DynamiteRawResponse<Pet, void>(
response: executeRequest(
'post',
_path,
Expand All @@ -180,8 +180,8 @@ class $Client extends DynamiteClient {

/// Returns a user based on a single ID, if the user does not have access to the pet.
///
/// 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.
/// 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:
/// * [id] ID of pet to fetch.
Expand All @@ -191,8 +191,8 @@ class $Client extends DynamiteClient {
/// * default: unexpected error
///
/// See:
/// * [findPetByIdRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized.
Future<DynamiteResponse<Pet, void>> findPetById({required int id}) async {
/// * [findPetByIdRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i2.DynamiteResponse<Pet, void>> findPetById({required int id}) async {
final rawResponse = findPetByIdRaw(
id: id,
);
Expand All @@ -204,8 +204,8 @@ class $Client extends DynamiteClient {
///
/// 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.
/// 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:
/// * [id] ID of pet to fetch.
Expand All @@ -215,9 +215,9 @@ class $Client extends DynamiteClient {
/// * default: unexpected error
///
/// See:
/// * [findPetById] for an operation that returns a [DynamiteResponse] with a stable API.
@experimental
DynamiteRawResponse<Pet, void> findPetByIdRaw({required int id}) {
/// * [findPetById] for an operation that returns a `DynamiteResponse` with a stable API.
@_i3.experimental
_i2.DynamiteRawResponse<Pet, void> findPetByIdRaw({required int id}) {
final _parameters = <String, dynamic>{};
const _headers = <String, String>{
'Accept': 'application/json',
Expand All @@ -226,8 +226,8 @@ class $Client extends DynamiteClient {
final $id = _$jsonSerializers.serialize(id, specifiedType: const FullType(int));
_parameters['id'] = $id;

final _path = UriTemplate('/pets/{id}').expand(_parameters);
return DynamiteRawResponse<Pet, void>(
final _path = _i1.UriTemplate('/pets/{id}').expand(_parameters);
return _i2.DynamiteRawResponse<Pet, void>(
response: executeRequest(
'get',
_path,
Expand All @@ -243,8 +243,8 @@ class $Client extends DynamiteClient {

/// deletes a single pet based on the ID supplied.
///
/// 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.
/// 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:
/// * [id] ID of pet to delete.
Expand All @@ -254,8 +254,8 @@ class $Client extends DynamiteClient {
/// * default: unexpected error
///
/// See:
/// * [deletePetRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized.
Future<DynamiteResponse<void, void>> deletePet({required int id}) async {
/// * [deletePetRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i2.DynamiteResponse<void, void>> deletePet({required int id}) async {
final rawResponse = deletePetRaw(
id: id,
);
Expand All @@ -267,8 +267,8 @@ class $Client extends DynamiteClient {
///
/// 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.
/// 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:
/// * [id] ID of pet to delete.
Expand All @@ -278,17 +278,17 @@ class $Client extends DynamiteClient {
/// * default: unexpected error
///
/// See:
/// * [deletePet] for an operation that returns a [DynamiteResponse] with a stable API.
@experimental
DynamiteRawResponse<void, void> deletePetRaw({required int id}) {
/// * [deletePet] for an operation that returns a `DynamiteResponse` with a stable API.
@_i3.experimental
_i2.DynamiteRawResponse<void, void> deletePetRaw({required int id}) {
final _parameters = <String, dynamic>{};
final _headers = <String, String>{};

final $id = _$jsonSerializers.serialize(id, specifiedType: const FullType(int));
_parameters['id'] = $id;

final _path = UriTemplate('/pets/{id}').expand(_parameters);
return DynamiteRawResponse<void, void>(
final _path = _i1.UriTemplate('/pets/{id}').expand(_parameters);
return _i2.DynamiteRawResponse<void, void>(
response: executeRequest(
'delete',
_path,
Expand Down Expand Up @@ -394,7 +394,7 @@ abstract class Error implements $ErrorInterface, Built<Error, ErrorBuilder> {
///
/// Serializes values into the `built_value` wire format.
/// See: [$jsonSerializers] for serializing into json.
@visibleForTesting
@_i3.visibleForTesting
final Serializers $serializers = _$serializers;
final Serializers _$serializers = (Serializers().toBuilder()
..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder<String>.new)
Expand All @@ -411,12 +411,12 @@ final Serializers _$serializers = (Serializers().toBuilder()
///
/// 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
@_i3.visibleForTesting
final Serializers $jsonSerializers = _$jsonSerializers;
final Serializers _$jsonSerializers = (_$serializers.toBuilder()
..add(DynamiteDoubleSerializer())
..addPlugin(StandardJsonPlugin())
..addPlugin(const HeaderPlugin())
..addPlugin(const ContentStringPlugin()))
..add(_i4.DynamiteDoubleSerializer())
..addPlugin(_i5.StandardJsonPlugin())
..addPlugin(const _i4.HeaderPlugin())
..addPlugin(const _i4.ContentStringPlugin()))
.build();
// coverage:ignore-end
1 change: 0 additions & 1 deletion packages/dynamite/dynamite/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies:
built_value: ^8.0.1
dynamite_runtime: ^0.1.0
meta: ^1.0.0
universal_io: ^2.0.0
uri: ^1.0.0

dev_dependencies:
Expand Down
Loading

0 comments on commit ffb519c

Please sign in to comment.