Skip to content

Commit 196233e

Browse files
authored
Merge pull request #885 from ItzNotABug/883-fix-enum-casings
Fix Enum Casings For Swift & Dart
2 parents 412451c + dfe460b commit 196233e

File tree

20 files changed

+51
-5
lines changed

20 files changed

+51
-5
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) -v /var/run/docker.sock:/var/run/d
262262
* **description** -> Description of Appwrite SDK
263263
* **namespace** -> SDK Namespace
264264
* **version** -> SDK Version
265-
* **endpoint** -> Default Endpoint (example: "https://appwrite.io/v1")
266-
* **host** -> Default Host (example: "appwrite.io")
265+
* **endpoint** -> Default Endpoint (example: "https://cloud.appwrite.io/v1")
266+
* **host** -> Default Host (example: "cloud.appwrite.io")
267267
* **basePath** -> Default Path to API (example: "/v1")
268268
* **licenseName** -> Name of license for SDK
269269
* **licenseURL** -> URL to SDK license

mock-server/app/http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@
517517
->label('sdk.method', 'enum')
518518
->label('sdk.description', 'Mock an enum parameter.')
519519
->label('sdk.mock', true)
520-
->param('mockType', '', new WhiteList(['first', 'second', 'third']), 'Sample enum param')
520+
->param('mockType', '', new WhiteList(['first', 'second', 'third', 'FOURTH']), 'Sample enum param')
521521
->action(function (string $mockType) {
522522
});
523523

src/SDK/Language.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ protected function toCamelCase($str): string
108108

109109
$str = \preg_replace('/[^a-zA-Z0-9]+/', ' ', $str);
110110
$str = \trim($str);
111+
$str = strtolower($str);
111112
$str = \ucwords($str);
112113
$str = \str_replace(' ', '', $str);
113114
$str = \lcfirst($str);

tests/Base.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ abstract class Base extends TestCase
5454
];
5555

5656
protected const ENUM_RESPONSES = [
57-
'POST:/v1/mock/tests/general/enum:passed',
57+
'POST:/v1/mock/tests/general/enum:passed', // first enum
58+
'POST:/v1/mock/tests/general/enum:passed', // fourth enum
5859
];
5960

6061
protected const UPLOAD_RESPONSE = [

tests/languages/android/Tests.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ class ServiceTest {
138138
mock = general.enum(MockType.FIRST)
139139
writeToFile(mock.result)
140140

141+
mock = general.enum(MockType.FOURTH)
142+
writeToFile(mock.result)
143+
141144
try {
142145
general.error400()
143146
} catch (e: AppwriteException) {

tests/languages/apple/Tests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ class Tests: XCTestCase {
118118
mock = try await general.xenum(mockType: .first)
119119
print(mock.result)
120120

121+
mock = try await general.xenum(mockType: .fourth)
122+
print(mock.result)
123+
121124
do {
122125
try await general.error400()
123126
} catch {

tests/languages/dart/tests.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ void main() async {
7878
response = await general.xenum(mockType: MockType.first);
7979
print(response.result);
8080

81+
response = await general.xenum(mockType: MockType.fourth);
82+
print(response.result);
83+
8184
try {
8285
await general.error400();
8386
} on AppwriteException catch (e) {

tests/languages/deno/tests.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ async function start() {
114114
// @ts-ignore
115115
console.log(response.result);
116116

117+
response = await general.enum(appwrite.MockType.Fourth);
118+
// @ts-ignore
119+
console.log(response.result);
120+
117121
try {
118122
response = await general.error400();
119123
} catch (error) {

tests/languages/dotnet/Tests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ public async Task Test1()
8484
mock = await general.Enum(MockType.First);
8585
TestContext.WriteLine(mock.Result);
8686

87+
mock = await general.Enum(MockType.Fourth);
88+
TestContext.WriteLine(mock.Result);
89+
8790
try
8891
{
8992
await general.Error400();

tests/languages/flutter/tests.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ void main() async {
105105
response = await general.xenum(mockType: MockType.first);
106106
print(response.result);
107107

108+
response = await general.xenum(mockType: MockType.fourth);
109+
print(response.result);
110+
108111
try {
109112
await general.error400();
110113
} on AppwriteException catch (e) {

0 commit comments

Comments
 (0)