Kate
1 year ago
committed by
GitHub
15 changed files with 1196 additions and 0 deletions
@ -0,0 +1 @@
|
||||
Subproject commit f73731dd34ffbf68512a363b579504b294986b53 |
@ -0,0 +1 @@
|
||||
../../../assets/AGPL-3.0.txt |
@ -0,0 +1,5 @@
|
||||
# dynamite petstore example |
||||
|
||||
An example showcasing the [dynamite generator](../dynamite) for OpenAPI using the [Swagger Petstore](https://github.com/swagger-api/swagger-petstore). |
||||
|
||||
Because dynamite does not support dynamic authentication yet a [patch](patch.json) is applied to the specification to make it work. It will be removed once dynamite supports API key and Oauth 2.0 authentication. |
@ -0,0 +1,18 @@
|
||||
targets: |
||||
$default: |
||||
builders: |
||||
built_value_generator|built_value: |
||||
enabled: true |
||||
dynamite: |
||||
options: |
||||
pageWidth: 120 |
||||
analyzer_ignores: |
||||
- camel_case_types |
||||
- discarded_futures |
||||
- public_member_api_docs |
||||
- unreachable_switch_case |
||||
coverage_ignores: |
||||
- 'const .*\._\(\);' |
||||
- 'factory .*\.fromJson\(Map<String, dynamic> json\) => _jsonSerializers\.deserializeWith\(serializer, json\)!;' |
||||
- 'Map<String, dynamic> toJson\(\) => _jsonSerializers\.serializeWith\(serializer, this\)! as Map<String, dynamic>;' |
||||
- 'static BuiltSet<.*> get values => _\$.*Values;' |
@ -0,0 +1,400 @@
|
||||
// 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 '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'; |
||||
|
||||
part 'petstore.openapi.g.dart'; |
||||
|
||||
class Client extends DynamiteClient { |
||||
Client( |
||||
super.baseURL, { |
||||
super.baseHeaders, |
||||
super.userAgent, |
||||
super.httpClient, |
||||
super.cookieJar, |
||||
}); |
||||
|
||||
Client.fromClient(DynamiteClient client) |
||||
: super( |
||||
client.baseURL, |
||||
baseHeaders: client.baseHeaders, |
||||
httpClient: client.httpClient, |
||||
cookieJar: client.cookieJar, |
||||
authentications: client.authentications, |
||||
); |
||||
|
||||
/// 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: |
||||
/// * 200: pet response |
||||
/// * default: unexpected error |
||||
/// |
||||
/// See: |
||||
/// * [findPetsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. |
||||
Future<DynamiteResponse<BuiltList<Pet>, void>> findPets({ |
||||
List<String>? tags, |
||||
int? limit, |
||||
}) async { |
||||
final rawResponse = findPetsRaw( |
||||
tags: tags, |
||||
limit: limit, |
||||
); |
||||
|
||||
return rawResponse.future; |
||||
} |
||||
|
||||
/// 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: |
||||
/// * 200: pet response |
||||
/// * default: unexpected error |
||||
/// |
||||
/// See: |
||||
/// * [findPets] for an operation that returns a [DynamiteResponse] with a stable API. |
||||
@experimental |
||||
DynamiteRawResponse<BuiltList<Pet>, void> findPetsRaw({ |
||||
List<String>? tags, |
||||
int? limit, |
||||
}) { |
||||
final _queryParameters = <String, dynamic>{}; |
||||
final _headers = <String, String>{ |
||||
'Accept': 'application/json', |
||||
}; |
||||
Uint8List? _body; |
||||
|
||||
if (tags != null) { |
||||
_queryParameters['tags'] = tags.map((final e) => e); |
||||
} |
||||
if (limit != null) { |
||||
_queryParameters['limit'] = limit.toString(); |
||||
} |
||||
final _path = '/pets'; |
||||
final _uri = Uri(path: _path, queryParameters: _queryParameters.isNotEmpty ? _queryParameters : null); |
||||
|
||||
return DynamiteRawResponse<BuiltList<Pet>, void>( |
||||
response: this.executeRequest( |
||||
'get', |
||||
_uri, |
||||
_headers, |
||||
_body, |
||||
const {200}, |
||||
), |
||||
bodyType: FullType(BuiltList, [FullType(Pet)]), |
||||
headersType: null, |
||||
serializers: _jsonSerializers, |
||||
); |
||||
} |
||||
|
||||
/// 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. |
||||
/// |
||||
/// 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 { |
||||
final rawResponse = addPetRaw( |
||||
newPet: newPet, |
||||
); |
||||
|
||||
return rawResponse.future; |
||||
} |
||||
|
||||
/// Creates a new pet in the store. Duplicates are allowed. |
||||
/// |
||||
/// 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: |
||||
/// * 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}) { |
||||
final _queryParameters = <String, dynamic>{}; |
||||
final _headers = <String, String>{ |
||||
'Accept': 'application/json', |
||||
}; |
||||
Uint8List? _body; |
||||
|
||||
_headers['Content-Type'] = 'application/json'; |
||||
_body = utf8.encode(json.encode(_jsonSerializers.serialize(newPet, specifiedType: const FullType(NewPet)))); |
||||
final _path = '/pets'; |
||||
final _uri = Uri(path: _path, queryParameters: _queryParameters.isNotEmpty ? _queryParameters : null); |
||||
|
||||
return DynamiteRawResponse<Pet, void>( |
||||
response: this.executeRequest( |
||||
'post', |
||||
_uri, |
||||
_headers, |
||||
_body, |
||||
const {200}, |
||||
), |
||||
bodyType: FullType(Pet), |
||||
headersType: null, |
||||
serializers: _jsonSerializers, |
||||
); |
||||
} |
||||
|
||||
/// 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. |
||||
/// |
||||
/// Parameters: |
||||
/// * [id] ID of pet to fetch. |
||||
/// |
||||
/// Status codes: |
||||
/// * 200: pet response |
||||
/// * 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 { |
||||
final rawResponse = findPetByIdRaw( |
||||
id: id, |
||||
); |
||||
|
||||
return rawResponse.future; |
||||
} |
||||
|
||||
/// Returns a user based on a single ID, if the user does not have access to the pet. |
||||
/// |
||||
/// 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: |
||||
/// * [id] ID of pet to fetch. |
||||
/// |
||||
/// Status codes: |
||||
/// * 200: pet response |
||||
/// * default: unexpected error |
||||
/// |
||||
/// See: |
||||
/// * [findPetById] for an operation that returns a [DynamiteResponse] with a stable API. |
||||
@experimental |
||||
DynamiteRawResponse<Pet, void> findPetByIdRaw({required int id}) { |
||||
final _queryParameters = <String, dynamic>{}; |
||||
final _headers = <String, String>{ |
||||
'Accept': 'application/json', |
||||
}; |
||||
Uint8List? _body; |
||||
|
||||
final _id = Uri.encodeQueryComponent(id.toString()); |
||||
final _path = '/pets/$_id'; |
||||
final _uri = Uri(path: _path, queryParameters: _queryParameters.isNotEmpty ? _queryParameters : null); |
||||
|
||||
return DynamiteRawResponse<Pet, void>( |
||||
response: this.executeRequest( |
||||
'get', |
||||
_uri, |
||||
_headers, |
||||
_body, |
||||
const {200}, |
||||
), |
||||
bodyType: FullType(Pet), |
||||
headersType: null, |
||||
serializers: _jsonSerializers, |
||||
); |
||||
} |
||||
|
||||
/// 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. |
||||
/// |
||||
/// Parameters: |
||||
/// * [id] ID of pet to delete. |
||||
/// |
||||
/// Status codes: |
||||
/// * 204: pet deleted |
||||
/// * 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 { |
||||
final rawResponse = deletePetRaw( |
||||
id: id, |
||||
); |
||||
|
||||
return rawResponse.future; |
||||
} |
||||
|
||||
/// deletes a single pet based on the ID supplied. |
||||
/// |
||||
/// 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: |
||||
/// * [id] ID of pet to delete. |
||||
/// |
||||
/// Status codes: |
||||
/// * 204: pet deleted |
||||
/// * default: unexpected error |
||||
/// |
||||
/// See: |
||||
/// * [deletePet] for an operation that returns a [DynamiteResponse] with a stable API. |
||||
@experimental |
||||
DynamiteRawResponse<void, void> deletePetRaw({required int id}) { |
||||
final _queryParameters = <String, dynamic>{}; |
||||
final _headers = <String, String>{}; |
||||
Uint8List? _body; |
||||
|
||||
final _id = Uri.encodeQueryComponent(id.toString()); |
||||
final _path = '/pets/$_id'; |
||||
final _uri = Uri(path: _path, queryParameters: _queryParameters.isNotEmpty ? _queryParameters : null); |
||||
|
||||
return DynamiteRawResponse<void, void>( |
||||
response: this.executeRequest( |
||||
'delete', |
||||
_uri, |
||||
_headers, |
||||
_body, |
||||
const {204}, |
||||
), |
||||
bodyType: null, |
||||
headersType: null, |
||||
serializers: _jsonSerializers, |
||||
); |
||||
} |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class NewPetInterface { |
||||
String get name; |
||||
String? get tag; |
||||
} |
||||
|
||||
abstract class NewPet implements NewPetInterface, Built<NewPet, NewPetBuilder> { |
||||
factory NewPet([void Function(NewPetBuilder)? b]) = _$NewPet; |
||||
|
||||
// coverage:ignore-start |
||||
const NewPet._(); |
||||
// coverage:ignore-end |
||||
|
||||
// coverage:ignore-start |
||||
factory NewPet.fromJson(Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
// coverage:ignore-end |
||||
|
||||
// coverage:ignore-start |
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
// coverage:ignore-end |
||||
|
||||
static Serializer<NewPet> get serializer => _$newPetSerializer; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class Pet_1Interface { |
||||
int get id; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class PetInterface implements NewPetInterface, Pet_1Interface {} |
||||
|
||||
abstract class Pet implements PetInterface, Built<Pet, PetBuilder> { |
||||
factory Pet([void Function(PetBuilder)? b]) = _$Pet; |
||||
|
||||
// coverage:ignore-start |
||||
const Pet._(); |
||||
// coverage:ignore-end |
||||
|
||||
// coverage:ignore-start |
||||
factory Pet.fromJson(Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
// coverage:ignore-end |
||||
|
||||
// coverage:ignore-start |
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
// coverage:ignore-end |
||||
|
||||
static Serializer<Pet> get serializer => _$petSerializer; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class ErrorInterface { |
||||
int get code; |
||||
String get message; |
||||
} |
||||
|
||||
abstract class Error implements ErrorInterface, Built<Error, ErrorBuilder> { |
||||
factory Error([void Function(ErrorBuilder)? b]) = _$Error; |
||||
|
||||
// coverage:ignore-start |
||||
const Error._(); |
||||
// coverage:ignore-end |
||||
|
||||
// coverage:ignore-start |
||||
factory Error.fromJson(Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
// coverage:ignore-end |
||||
|
||||
// coverage:ignore-start |
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
// coverage:ignore-end |
||||
|
||||
static Serializer<Error> get serializer => _$errorSerializer; |
||||
} |
||||
|
||||
// coverage:ignore-start |
||||
final Serializers _serializers = (Serializers().toBuilder() |
||||
..addBuilderFactory(FullType(BuiltList, [FullType(String)]), ListBuilder<String>.new) |
||||
..addBuilderFactory(FullType(Pet), Pet.new) |
||||
..add(Pet.serializer) |
||||
..addBuilderFactory(FullType(NewPet), NewPet.new) |
||||
..add(NewPet.serializer) |
||||
..addBuilderFactory(FullType(BuiltList, [FullType(Pet)]), ListBuilder<Pet>.new) |
||||
..addBuilderFactory(FullType(Error), Error.new) |
||||
..add(Error.serializer)) |
||||
.build(); |
||||
|
||||
final Serializers _jsonSerializers = (_serializers.toBuilder() |
||||
..add(DynamiteDoubleSerializer()) |
||||
..addPlugin(StandardJsonPlugin()) |
||||
..addPlugin(const ContentStringPlugin())) |
||||
.build(); |
||||
// coverage:ignore-end |
@ -0,0 +1,468 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'petstore.openapi.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// BuiltValueGenerator |
||||
// ************************************************************************** |
||||
|
||||
Serializer<NewPet> _$newPetSerializer = _$NewPetSerializer(); |
||||
Serializer<Pet> _$petSerializer = _$PetSerializer(); |
||||
Serializer<Error> _$errorSerializer = _$ErrorSerializer(); |
||||
|
||||
class _$NewPetSerializer implements StructuredSerializer<NewPet> { |
||||
@override |
||||
final Iterable<Type> types = const [NewPet, _$NewPet]; |
||||
@override |
||||
final String wireName = 'NewPet'; |
||||
|
||||
@override |
||||
Iterable<Object?> serialize(Serializers serializers, NewPet object, {FullType specifiedType = FullType.unspecified}) { |
||||
final result = <Object?>[ |
||||
'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 |
||||
NewPet deserialize(Serializers serializers, Iterable<Object?> serialized, |
||||
{FullType specifiedType = FullType.unspecified}) { |
||||
final result = NewPetBuilder(); |
||||
|
||||
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 _$PetSerializer implements StructuredSerializer<Pet> { |
||||
@override |
||||
final Iterable<Type> types = const [Pet, _$Pet]; |
||||
@override |
||||
final String wireName = 'Pet'; |
||||
|
||||
@override |
||||
Iterable<Object?> serialize(Serializers serializers, Pet object, {FullType specifiedType = FullType.unspecified}) { |
||||
final result = <Object?>[ |
||||
'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 |
||||
Pet deserialize(Serializers serializers, Iterable<Object?> serialized, |
||||
{FullType specifiedType = FullType.unspecified}) { |
||||
final result = PetBuilder(); |
||||
|
||||
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(); |
||||
} |
||||
} |
||||
|
||||
class _$ErrorSerializer implements StructuredSerializer<Error> { |
||||
@override |
||||
final Iterable<Type> types = const [Error, _$Error]; |
||||
@override |
||||
final String wireName = 'Error'; |
||||
|
||||
@override |
||||
Iterable<Object?> serialize(Serializers serializers, Error object, {FullType specifiedType = FullType.unspecified}) { |
||||
final result = <Object?>[ |
||||
'code', |
||||
serializers.serialize(object.code, specifiedType: const FullType(int)), |
||||
'message', |
||||
serializers.serialize(object.message, specifiedType: const FullType(String)), |
||||
]; |
||||
|
||||
return result; |
||||
} |
||||
|
||||
@override |
||||
Error deserialize(Serializers serializers, Iterable<Object?> serialized, |
||||
{FullType specifiedType = FullType.unspecified}) { |
||||
final result = ErrorBuilder(); |
||||
|
||||
final iterator = serialized.iterator; |
||||
while (iterator.moveNext()) { |
||||
final key = iterator.current! as String; |
||||
iterator.moveNext(); |
||||
final Object? value = iterator.current; |
||||
switch (key) { |
||||
case 'code': |
||||
result.code = serializers.deserialize(value, specifiedType: const FullType(int))! as int; |
||||
break; |
||||
case 'message': |
||||
result.message = serializers.deserialize(value, specifiedType: const FullType(String))! as String; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return result.build(); |
||||
} |
||||
} |
||||
|
||||
abstract mixin class NewPetInterfaceBuilder { |
||||
void replace(NewPetInterface other); |
||||
void update(void Function(NewPetInterfaceBuilder) updates); |
||||
String? get name; |
||||
set name(String? name); |
||||
|
||||
String? get tag; |
||||
set tag(String? tag); |
||||
} |
||||
|
||||
class _$NewPet extends NewPet { |
||||
@override |
||||
final String name; |
||||
@override |
||||
final String? tag; |
||||
|
||||
factory _$NewPet([void Function(NewPetBuilder)? updates]) => (NewPetBuilder()..update(updates))._build(); |
||||
|
||||
_$NewPet._({required this.name, this.tag}) : super._() { |
||||
BuiltValueNullFieldError.checkNotNull(name, r'NewPet', 'name'); |
||||
} |
||||
|
||||
@override |
||||
NewPet rebuild(void Function(NewPetBuilder) updates) => (toBuilder()..update(updates)).build(); |
||||
|
||||
@override |
||||
NewPetBuilder toBuilder() => NewPetBuilder()..replace(this); |
||||
|
||||
@override |
||||
bool operator ==(Object other) { |
||||
if (identical(other, this)) return true; |
||||
return other is NewPet && 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'NewPet') |
||||
..add('name', name) |
||||
..add('tag', tag)) |
||||
.toString(); |
||||
} |
||||
} |
||||
|
||||
class NewPetBuilder implements Builder<NewPet, NewPetBuilder>, NewPetInterfaceBuilder { |
||||
_$NewPet? _$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; |
||||
|
||||
NewPetBuilder(); |
||||
|
||||
NewPetBuilder get _$this { |
||||
final $v = _$v; |
||||
if ($v != null) { |
||||
_name = $v.name; |
||||
_tag = $v.tag; |
||||
_$v = null; |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
@override |
||||
void replace(covariant NewPet other) { |
||||
ArgumentError.checkNotNull(other, 'other'); |
||||
_$v = other as _$NewPet; |
||||
} |
||||
|
||||
@override |
||||
void update(void Function(NewPetBuilder)? updates) { |
||||
if (updates != null) updates(this); |
||||
} |
||||
|
||||
@override |
||||
NewPet build() => _build(); |
||||
|
||||
_$NewPet _build() { |
||||
final _$result = _$v ?? _$NewPet._(name: BuiltValueNullFieldError.checkNotNull(name, r'NewPet', 'name'), tag: tag); |
||||
replace(_$result); |
||||
return _$result; |
||||
} |
||||
} |
||||
|
||||
abstract mixin class Pet_1InterfaceBuilder { |
||||
void replace(Pet_1Interface other); |
||||
void update(void Function(Pet_1InterfaceBuilder) updates); |
||||
int? get id; |
||||
set id(int? id); |
||||
} |
||||
|
||||
abstract mixin class PetInterfaceBuilder implements NewPetInterfaceBuilder, Pet_1InterfaceBuilder { |
||||
void replace(covariant PetInterface other); |
||||
void update(void Function(PetInterfaceBuilder) 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 _$Pet extends Pet { |
||||
@override |
||||
final String name; |
||||
@override |
||||
final String? tag; |
||||
@override |
||||
final int id; |
||||
|
||||
factory _$Pet([void Function(PetBuilder)? updates]) => (PetBuilder()..update(updates))._build(); |
||||
|
||||
_$Pet._({required this.name, this.tag, required this.id}) : super._() { |
||||
BuiltValueNullFieldError.checkNotNull(name, r'Pet', 'name'); |
||||
BuiltValueNullFieldError.checkNotNull(id, r'Pet', 'id'); |
||||
} |
||||
|
||||
@override |
||||
Pet rebuild(void Function(PetBuilder) updates) => (toBuilder()..update(updates)).build(); |
||||
|
||||
@override |
||||
PetBuilder toBuilder() => PetBuilder()..replace(this); |
||||
|
||||
@override |
||||
bool operator ==(Object other) { |
||||
if (identical(other, this)) return true; |
||||
return other is Pet && 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'Pet') |
||||
..add('name', name) |
||||
..add('tag', tag) |
||||
..add('id', id)) |
||||
.toString(); |
||||
} |
||||
} |
||||
|
||||
class PetBuilder implements Builder<Pet, PetBuilder>, PetInterfaceBuilder { |
||||
_$Pet? _$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; |
||||
|
||||
PetBuilder(); |
||||
|
||||
PetBuilder 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 Pet other) { |
||||
ArgumentError.checkNotNull(other, 'other'); |
||||
_$v = other as _$Pet; |
||||
} |
||||
|
||||
@override |
||||
void update(void Function(PetBuilder)? updates) { |
||||
if (updates != null) updates(this); |
||||
} |
||||
|
||||
@override |
||||
Pet build() => _build(); |
||||
|
||||
_$Pet _build() { |
||||
final _$result = _$v ?? |
||||
_$Pet._( |
||||
name: BuiltValueNullFieldError.checkNotNull(name, r'Pet', 'name'), |
||||
tag: tag, |
||||
id: BuiltValueNullFieldError.checkNotNull(id, r'Pet', 'id')); |
||||
replace(_$result); |
||||
return _$result; |
||||
} |
||||
} |
||||
|
||||
abstract mixin class ErrorInterfaceBuilder { |
||||
void replace(ErrorInterface other); |
||||
void update(void Function(ErrorInterfaceBuilder) updates); |
||||
int? get code; |
||||
set code(int? code); |
||||
|
||||
String? get message; |
||||
set message(String? message); |
||||
} |
||||
|
||||
class _$Error extends Error { |
||||
@override |
||||
final int code; |
||||
@override |
||||
final String message; |
||||
|
||||
factory _$Error([void Function(ErrorBuilder)? updates]) => (ErrorBuilder()..update(updates))._build(); |
||||
|
||||
_$Error._({required this.code, required this.message}) : super._() { |
||||
BuiltValueNullFieldError.checkNotNull(code, r'Error', 'code'); |
||||
BuiltValueNullFieldError.checkNotNull(message, r'Error', 'message'); |
||||
} |
||||
|
||||
@override |
||||
Error rebuild(void Function(ErrorBuilder) updates) => (toBuilder()..update(updates)).build(); |
||||
|
||||
@override |
||||
ErrorBuilder toBuilder() => ErrorBuilder()..replace(this); |
||||
|
||||
@override |
||||
bool operator ==(Object other) { |
||||
if (identical(other, this)) return true; |
||||
return other is Error && code == other.code && message == other.message; |
||||
} |
||||
|
||||
@override |
||||
int get hashCode { |
||||
var _$hash = 0; |
||||
_$hash = $jc(_$hash, code.hashCode); |
||||
_$hash = $jc(_$hash, message.hashCode); |
||||
_$hash = $jf(_$hash); |
||||
return _$hash; |
||||
} |
||||
|
||||
@override |
||||
String toString() { |
||||
return (newBuiltValueToStringHelper(r'Error') |
||||
..add('code', code) |
||||
..add('message', message)) |
||||
.toString(); |
||||
} |
||||
} |
||||
|
||||
class ErrorBuilder implements Builder<Error, ErrorBuilder>, ErrorInterfaceBuilder { |
||||
_$Error? _$v; |
||||
|
||||
int? _code; |
||||
int? get code => _$this._code; |
||||
set code(covariant int? code) => _$this._code = code; |
||||
|
||||
String? _message; |
||||
String? get message => _$this._message; |
||||
set message(covariant String? message) => _$this._message = message; |
||||
|
||||
ErrorBuilder(); |
||||
|
||||
ErrorBuilder get _$this { |
||||
final $v = _$v; |
||||
if ($v != null) { |
||||
_code = $v.code; |
||||
_message = $v.message; |
||||
_$v = null; |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
@override |
||||
void replace(covariant Error other) { |
||||
ArgumentError.checkNotNull(other, 'other'); |
||||
_$v = other as _$Error; |
||||
} |
||||
|
||||
@override |
||||
void update(void Function(ErrorBuilder)? updates) { |
||||
if (updates != null) updates(this); |
||||
} |
||||
|
||||
@override |
||||
Error build() => _build(); |
||||
|
||||
_$Error _build() { |
||||
final _$result = _$v ?? |
||||
_$Error._( |
||||
code: BuiltValueNullFieldError.checkNotNull(code, r'Error', 'code'), |
||||
message: BuiltValueNullFieldError.checkNotNull(message, r'Error', 'message')); |
||||
replace(_$result); |
||||
return _$result; |
||||
} |
||||
} |
||||
|
||||
// ignore_for_file: deprecated_member_use_from_same_package,type=lint |
@ -0,0 +1,242 @@
|
||||
{ |
||||
"openapi": "3.0.0", |
||||
"info": { |
||||
"version": "1.0.0", |
||||
"title": "Swagger Petstore", |
||||
"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" |
||||
} |
||||
}, |
||||
"servers": [ |
||||
{ |
||||
"url": "https://petstore.swagger.io/v2" |
||||
} |
||||
], |
||||
"paths": { |
||||
"/pets": { |
||||
"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", |
||||
"operationId": "findPets", |
||||
"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": { |
||||
"200": { |
||||
"description": "pet response", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"type": "array", |
||||
"items": { |
||||
"$ref": "#/components/schemas/Pet" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"default": { |
||||
"description": "unexpected error", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"$ref": "#/components/schemas/Error" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"post": { |
||||
"description": "Creates a new pet in the store. Duplicates are allowed", |
||||
"operationId": "addPet", |
||||
"requestBody": { |
||||
"description": "Pet to add to the store", |
||||
"required": true, |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"$ref": "#/components/schemas/NewPet" |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"responses": { |
||||
"200": { |
||||
"description": "pet response", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"$ref": "#/components/schemas/Pet" |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"default": { |
||||
"description": "unexpected error", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"$ref": "#/components/schemas/Error" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"/pets/{id}": { |
||||
"get": { |
||||
"description": "Returns a user based on a single ID, if the user does not have access to the pet", |
||||
"operationId": "find pet by id", |
||||
"parameters": [ |
||||
{ |
||||
"name": "id", |
||||
"in": "path", |
||||
"description": "ID of pet to fetch", |
||||
"required": true, |
||||
"schema": { |
||||
"type": "integer", |
||||
"format": "int64" |
||||
} |
||||
} |
||||
], |
||||
"responses": { |
||||
"200": { |
||||
"description": "pet response", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"$ref": "#/components/schemas/Pet" |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"default": { |
||||
"description": "unexpected error", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"$ref": "#/components/schemas/Error" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"delete": { |
||||
"description": "deletes a single pet based on the ID supplied", |
||||
"operationId": "deletePet", |
||||
"parameters": [ |
||||
{ |
||||
"name": "id", |
||||
"in": "path", |
||||
"description": "ID of pet to delete", |
||||
"required": true, |
||||
"schema": { |
||||
"type": "integer", |
||||
"format": "int64" |
||||
} |
||||
} |
||||
], |
||||
"responses": { |
||||
"204": { |
||||
"description": "pet deleted" |
||||
}, |
||||
"default": { |
||||
"description": "unexpected error", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"$ref": "#/components/schemas/Error" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"components": { |
||||
"schemas": { |
||||
"Pet": { |
||||
"allOf": [ |
||||
{ |
||||
"$ref": "#/components/schemas/NewPet" |
||||
}, |
||||
{ |
||||
"type": "object", |
||||
"required": [ |
||||
"id" |
||||
], |
||||
"properties": { |
||||
"id": { |
||||
"type": "integer", |
||||
"format": "int64" |
||||
} |
||||
} |
||||
} |
||||
] |
||||
}, |
||||
"NewPet": { |
||||
"type": "object", |
||||
"required": [ |
||||
"name" |
||||
], |
||||
"properties": { |
||||
"name": { |
||||
"type": "string" |
||||
}, |
||||
"tag": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"Error": { |
||||
"type": "object", |
||||
"required": [ |
||||
"code", |
||||
"message" |
||||
], |
||||
"properties": { |
||||
"code": { |
||||
"type": "integer", |
||||
"format": "int32" |
||||
}, |
||||
"message": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
name: dynamite_petstore_example |
||||
description: An example showing how to use dynamite for the Petstore example API. |
||||
version: 1.0.0 |
||||
publish_to: none |
||||
|
||||
environment: |
||||
sdk: '>=3.1.3 <4.0.0' |
||||
|
||||
dependencies: |
||||
built_collection: ^5.0.0 |
||||
built_value: ^8.0.1 |
||||
dynamite_runtime: |
||||
git: |
||||
url: https://github.com/nextcloud/neon |
||||
path: packages/dynamite/dynamite_runtime |
||||
|
||||
dev_dependencies: |
||||
build_runner: ^2.4.6 |
||||
built_value_generator: ^8.7.0 |
||||
dynamite: |
||||
git: |
||||
url: https://github.com/nextcloud/neon |
||||
path: packages/dynamite/dynamite |
@ -0,0 +1,6 @@
|
||||
# melos_managed_dependency_overrides: dynamite,dynamite_runtime |
||||
dependency_overrides: |
||||
dynamite: |
||||
path: ../dynamite |
||||
dynamite_runtime: |
||||
path: ../dynamite_runtime |
@ -0,0 +1,13 @@
|
||||
#!/bin/bash |
||||
set -euxo pipefail |
||||
cd "$(dirname "$0")/.." |
||||
|
||||
cp external/openapi-specification/examples/v3.0/petstore-expanded.json packages/dynamite/dynamite_petstore_example/lib/petstore.openapi.json |
||||
|
||||
( |
||||
cd packages/dynamite/dynamite_petstore_example |
||||
rm -rf .dart_tool/build/generated/dynamite |
||||
fvm dart pub run build_runner build --delete-conflicting-outputs |
||||
fvm dart fix --apply lib/ |
||||
melos run format |
||||
) |
Loading…
Reference in new issue