Skip to content

Commit

Permalink
fix(dynamite,nextcloud)!: escape http methods as reserved method names
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
  • Loading branch information
Leptopoda committed Mar 1, 2024
1 parent b9e837a commit 48233c5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
10 changes: 10 additions & 0 deletions packages/dynamite/dynamite/lib/src/helpers/dart_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ extension StringUtils on String {
const _reservedMethodNames = [
'executeRequest',
'executeRawRequest',
'send',
'head',
'get',
'post',
'put',
'patch',
'delete',
'read',
'readBytes',
'close',
];

/// A list of dart keywords and type names that need to be escaped.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ class $Client extends _i1.DynamiteClient {
/// * default
///
/// See:
/// * [postRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i1.DynamiteResponse<void, void>> post({String? string}) async {
final rawResponse = postRaw(
/// * [$postRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i1.DynamiteResponse<void, void>> $post({String? string}) async {
final rawResponse = $postRaw(
string: string,
);

Expand All @@ -110,9 +110,9 @@ class $Client extends _i1.DynamiteClient {
/// * default
///
/// See:
/// * [post] for an operation that returns a `DynamiteResponse` with a stable API.
/// * [$post] for an operation that returns a `DynamiteResponse` with a stable API.
@_i2.experimental
_i1.DynamiteRawResponse<void, void> postRaw({String? string}) {
_i1.DynamiteRawResponse<void, void> $postRaw({String? string}) {
final _headers = <String, String>{};
Uint8List? _body;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class $Client extends _i1.DynamiteClient {
/// * 201
///
/// See:
/// * [putRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i1.DynamiteResponse<String, void>> put() async {
final rawResponse = putRaw();
/// * [$putRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i1.DynamiteResponse<String, void>> $put() async {
final rawResponse = $putRaw();

return rawResponse.future;
}
Expand All @@ -99,9 +99,9 @@ class $Client extends _i1.DynamiteClient {
/// * 201
///
/// See:
/// * [put] for an operation that returns a `DynamiteResponse` with a stable API.
/// * [$put] for an operation that returns a `DynamiteResponse` with a stable API.
@_i2.experimental
_i1.DynamiteRawResponse<String, void> putRaw() {
_i1.DynamiteRawResponse<String, void> $putRaw() {
const _headers = <String, String>{'Accept': 'application/json'};

const _path = '/';
Expand All @@ -127,9 +127,9 @@ class $Client extends _i1.DynamiteClient {
/// * 201
///
/// See:
/// * [postRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i1.DynamiteResponse<String, void>> post() async {
final rawResponse = postRaw();
/// * [$postRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i1.DynamiteResponse<String, void>> $post() async {
final rawResponse = $postRaw();

return rawResponse.future;
}
Expand All @@ -145,9 +145,9 @@ class $Client extends _i1.DynamiteClient {
/// * 201
///
/// See:
/// * [post] for an operation that returns a `DynamiteResponse` with a stable API.
/// * [$post] for an operation that returns a `DynamiteResponse` with a stable API.
@_i2.experimental
_i1.DynamiteRawResponse<String, void> postRaw() {
_i1.DynamiteRawResponse<String, void> $postRaw() {
const _headers = <String, String>{'Accept': 'application/json'};

const _path = '/';
Expand All @@ -171,9 +171,9 @@ class $Client extends _i1.DynamiteClient {
/// * 201
///
/// See:
/// * [patchRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i1.DynamiteResponse<String, void>> patch() async {
final rawResponse = patchRaw();
/// * [$patchRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i1.DynamiteResponse<String, void>> $patch() async {
final rawResponse = $patchRaw();

return rawResponse.future;
}
Expand All @@ -188,9 +188,9 @@ class $Client extends _i1.DynamiteClient {
/// * 201
///
/// See:
/// * [patch] for an operation that returns a `DynamiteResponse` with a stable API.
/// * [$patch] for an operation that returns a `DynamiteResponse` with a stable API.
@_i2.experimental
_i1.DynamiteRawResponse<String, void> patchRaw() {
_i1.DynamiteRawResponse<String, void> $patchRaw() {
const _headers = <String, String>{'Accept': 'application/json'};

const _path = '/';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void main() async {
return Response('{}', 200);
}),
);
await client.post();
await client.$post();

// with body
client = $Client(
Expand All @@ -48,6 +48,6 @@ void main() async {
return Response('{}', 200);
}),
);
await client.post(string: 'value');
await client.$post(string: 'value');
});
}
10 changes: 5 additions & 5 deletions packages/nextcloud/lib/src/api/spreed.openapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7325,15 +7325,15 @@ class $ReactionClient {
/// * 404: Message not found
///
/// See:
/// * [deleteRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i1.DynamiteResponse<ReactionDeleteResponseApplicationJson, void>> delete({
/// * [$deleteRaw] for an experimental operation that returns a `DynamiteRawResponse` that can be serialized.
Future<_i1.DynamiteResponse<ReactionDeleteResponseApplicationJson, void>> $delete({
required String reaction,
required String token,
required int messageId,
ReactionDeleteApiVersion? apiVersion,
bool? oCSAPIRequest,
}) async {
final rawResponse = deleteRaw(
final rawResponse = $deleteRaw(
reaction: reaction,
token: token,
messageId: messageId,
Expand Down Expand Up @@ -7364,9 +7364,9 @@ class $ReactionClient {
/// * 404: Message not found
///
/// See:
/// * [delete] for an operation that returns a `DynamiteResponse` with a stable API.
/// * [$delete] for an operation that returns a `DynamiteResponse` with a stable API.
@_i4.experimental
_i1.DynamiteRawResponse<ReactionDeleteResponseApplicationJson, void> deleteRaw({
_i1.DynamiteRawResponse<ReactionDeleteResponseApplicationJson, void> $deleteRaw({
required String reaction,
required String token,
required int messageId,
Expand Down

0 comments on commit 48233c5

Please sign in to comment.