Skip to content

Commit ff729af

Browse files
Merge branch 'master' into master
2 parents f234189 + f0a6ecf commit ff729af

File tree

8 files changed

+25
-284
lines changed

8 files changed

+25
-284
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ docker run --rm --interactive --tty --volume "%cd%":/app composer install
3838
First, create a new class for the new language in this directory:
3939
[/src/SDK/Language](https://github.com/appwrite/sdk-generator/tree/master/src/SDK/Language)
4040

41+
4142
You can use the interface to know which methods are required to be implemented:
4243
[/src/SDK/Language.php](https://github.com/appwrite/sdk-generator/blob/master/src/SDK/Language.php)
4344

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Appwrite SDK Generator
22

3-
[![Build Status](https://travis-ci.com/appwrite/sdk-generator.svg?branch=master)](https://travis-ci.com/appwrite/sdk-generator)
4-
[![Discord](https://img.shields.io/discord/564160730845151244)](https://discord.gg/GSeTUeA)
3+
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
4+
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
5+
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
6+
[![Follow Appwrite on StackShare](https://img.shields.io/badge/follow%20on-stackshare-blue?style=flat-square)](https://stackshare.io/appwrite)
7+
[![appwrite.io](https://img.shields.io/badge/appwrite-.io-f02e65?style=flat-square)](https://appwrite.io)
8+
59

610
**WORK IN PROGRESS - NOT READY FOR GENERAL USAGE**
711

@@ -69,31 +73,39 @@ $sdk->generate(__DIR__ . '/examples/php'); // Generate source code
6973

7074
## Supported Specs
7175

72-
* [OpenAPI 3](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md) (Not Ready)
7376
* [Swagger 2](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md)
77+
* [OpenAPI 3](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md) (Not Ready)
7478
* [RAML 1.0](https://raml.org/) (Not Ready)
7579
* [RAML 0.8](https://raml.org/) (Not Ready)
7680
* [Postman 2.0](https://schema.getpostman.com/json/collection/v2.0.0/docs/index.html) (Not Ready)
7781
* [Postman 1.0](https://schema.getpostman.com/json/collection/v1.0.0/docs/index.html) (Not Ready)
7882
* [API Blueprint 1A](https://github.com/apiaryio/api-blueprint/blob/master/API%20Blueprint%20Specification.md) (Not Ready)
7983

80-
## Supported Languages
84+
## Supported Client / Platform SDKs
85+
86+
| Language | Supported Versions | Coding Standards | Package Manager | Maintainer |
87+
|-----------------------|---------------------|------------------------|--------------------|----------------|
88+
| Web | ES5+ | [NPM Coding Style] | NPM, Yarn, | [@eldadfux] |
89+
| Flutter | | [Effective Dart] | pub tool | [@bartektartanus] [@Almoullim] |
90+
| Android (Kotlin) | | | ? | [You?](https://github.com/appwrite/sdk-generator/issues/20) |
91+
| iOS (Swift) | | | Swift Pkg Manager | [@armino-dev] |
92+
| Unity (Csharp) | | | ? | [You?](https://github.com/appwrite/sdk-generator/issues/20) |
93+
94+
## Supported Server SDKs
8195

8296
| Language | Supported Versions | Coding Standards | Package Manager | Maintainer |
8397
|------------|---------------------|------------------------|--------------------|----------------|
84-
| Web | ES5+ | [NPM Coding Style] | NPM, Yarn, | [@eldadfux] |
85-
| TypeScript | | [NPM Coding Style] | NPM, Yarn | [You?](https://github.com/appwrite/sdk-generator/issues/20) |
98+
| TypeScript | | [NPM Coding Style] | NPM, Yarn | [@eldadfux] |
8699
| NodeJS | 8, 10, 12 | [NPM Coding Style] | NPM, Yarn | [@eldadfux] |
87100
| PHP | 7.0+ | [PHP FIG] | Composer | [@eldadfux] |
88101
| Ruby | 2.4+ | [Ruby Style Guide] | GEM | [@eldadfux] |
89102
| Python | 3.5+ | [PEP8] | PIP | [@eldadfux] |
90-
| Flutter | | [Effective Dart] | pub tool | [@bartektartanus] [@Almoullim] |
91103
| Dart | | [Effective Dart] | pub tool | [You?](https://github.com/appwrite/sdk-generator/issues/20) |
92104
| Go | | [Effective Go] | go get | [@panz3r] |
93105
| .NET | .NET core 3.1 | [C# Coding Conventions]| NuGet | [@komemi] [@TorstenDittmann] |
94106
| D | | | ? | [You?](https://github.com/appwrite/sdk-generator/issues/20) |
95107
| Kotlin | | | ? | [You?](https://github.com/appwrite/sdk-generator/issues/20) |
96-
| Swift | | | Swift Pkg Manager | [@armino-dev] |
108+
| Swift | | | Swift Pkg Manager | [@armino-dev] |
97109

98110
[@Almoullim]: https://github.com/Almoullim
99111
[@eldadfux]: https://github.com/eldadfux

example.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use Appwrite\SDK\Language\DotNet;
2020
use Appwrite\SDK\Language\Flutter;
2121

22-
$languages = ['web', 'node', 'php', 'python', 'ruby', 'dart', 'go', 'java', 'swift', 'typescript', 'deno', 'http', 'dotnet'];
23-
2422
try {
2523

2624
function getSSLPage($url) {
@@ -195,7 +193,7 @@ function getSSLPage($url) {
195193

196194
$sdk->generate(__DIR__ . '/examples/dart');
197195

198-
// Dart
196+
// Flutter
199197
$sdk = new SDK(new Flutter(), new Swagger2($spec));
200198

201199
$sdk

mock/templates/deno.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/SDK/Language/Dart.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,3 @@ public function getFiles()
320320
];
321321
}
322322
}
323-

src/SDK/Language/Flutter.php

Lines changed: 1 addition & 228 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
namespace Appwrite\SDK\Language;
44

5-
use Appwrite\SDK\Language;
6-
7-
class Flutter extends Language {
5+
class Flutter extends Dart {
86

97
/**
108
* @var array
@@ -13,17 +11,6 @@ class Flutter extends Language {
1311
'packageName' => 'packageName',
1412
];
1513

16-
/**
17-
* @param string $name
18-
* @return $this
19-
*/
20-
public function setPackageName($name)
21-
{
22-
$this->setParam('packageName', $name);
23-
24-
return $this;
25-
}
26-
2714
/**
2815
* @return string
2916
*/
@@ -32,219 +19,6 @@ public function getName()
3219
return 'Flutter';
3320
}
3421

35-
/**
36-
* Get Language Keywords List
37-
*
38-
* @return array
39-
*/
40-
public function getKeywords()
41-
{
42-
return [
43-
"abstract",
44-
"dynamic",
45-
"implements",
46-
"show",
47-
"as",
48-
"else",
49-
"import",
50-
"static",
51-
"assert",
52-
"enum",
53-
"in",
54-
"super",
55-
"async",
56-
"export",
57-
"interface",
58-
"switch",
59-
"await",
60-
"extends",
61-
"is",
62-
"sync",
63-
"break",
64-
"external",
65-
"library",
66-
"this",
67-
"case",
68-
"factory",
69-
"mixin",
70-
"throw",
71-
"catch",
72-
"false",
73-
"new",
74-
"true",
75-
"class",
76-
"final",
77-
"null",
78-
"try",
79-
"const",
80-
"finally",
81-
"on",
82-
"typedef",
83-
"continue",
84-
"for",
85-
"operator",
86-
"var",
87-
"covariant",
88-
"Function",
89-
"part",
90-
"void",
91-
"default",
92-
"get",
93-
"rethrow",
94-
"while",
95-
"deferred",
96-
"hide",
97-
"return",
98-
"with",
99-
"do",
100-
"if",
101-
"set",
102-
"yield",
103-
];
104-
}
105-
106-
/**
107-
* @param $type
108-
* @return string
109-
*/
110-
public function getTypeName($type)
111-
{
112-
switch ($type) {
113-
case self::TYPE_INTEGER:
114-
return 'int';
115-
break;
116-
case self::TYPE_STRING:
117-
return 'String';
118-
break;
119-
case self::TYPE_FILE:
120-
return 'MultipartFile';
121-
break;
122-
case self::TYPE_BOOLEAN:
123-
return 'bool';
124-
break;
125-
case self::TYPE_ARRAY:
126-
return 'List';
127-
case self::TYPE_OBJECT:
128-
return 'dynamic';
129-
break;
130-
}
131-
132-
return $type;
133-
}
134-
135-
/**
136-
* @param array $param
137-
* @return string
138-
*/
139-
public function getParamDefault(array $param)
140-
{
141-
$type = $param['type'] ?? '';
142-
$default = $param['default'] ?? '';
143-
$required = $param['required'] ?? '';
144-
145-
if($required) {
146-
return '';
147-
}
148-
149-
$output = ' = ';
150-
151-
if(empty($default) && $default !== 0 && $default !== false) {
152-
switch ($type) {
153-
case self::TYPE_OBJECT:
154-
$output .= '{}';
155-
break;
156-
case self::TYPE_NUMBER:
157-
case self::TYPE_INTEGER:
158-
$output .= '0';
159-
break;
160-
case self::TYPE_BOOLEAN:
161-
$output .= 'false';
162-
break;
163-
case self::TYPE_ARRAY:
164-
$output .= '[]';
165-
break;
166-
case self::TYPE_STRING:
167-
$output .= "''";
168-
break;
169-
}
170-
}
171-
else {
172-
switch ($type) {
173-
case self::TYPE_OBJECT:
174-
case self::TYPE_NUMBER:
175-
case self::TYPE_INTEGER:
176-
$output .= $default;
177-
break;
178-
case self::TYPE_ARRAY:
179-
$output .= 'const '.$default;
180-
break;
181-
case self::TYPE_BOOLEAN:
182-
$output .= ($default) ? 'true' : 'false';
183-
break;
184-
case self::TYPE_STRING:
185-
$output .= "'{$default}'";
186-
break;
187-
}
188-
}
189-
190-
return $output;
191-
}
192-
193-
/**
194-
* @param array $param
195-
* @return string
196-
*/
197-
public function getParamExample(array $param)
198-
{
199-
$type = $param['type'] ?? '';
200-
$example = $param['example'] ?? '';
201-
202-
$output = '';
203-
204-
if(empty($example) && $example !== 0 && $example !== false) {
205-
switch ($type) {
206-
case self::TYPE_FILE:
207-
$output .= 'await MultipartFile.fromFile(\'./path-to-files/image.jpg\', \'image.jpg\')';
208-
break;
209-
case self::TYPE_NUMBER:
210-
case self::TYPE_INTEGER:
211-
$output .= '0';
212-
break;
213-
case self::TYPE_BOOLEAN:
214-
$output .= 'false';
215-
break;
216-
case self::TYPE_STRING:
217-
$output .= "''";
218-
break;
219-
case self::TYPE_OBJECT:
220-
$output .= '{}';
221-
break;
222-
case self::TYPE_ARRAY:
223-
$output .= '[]';
224-
break;
225-
}
226-
}
227-
else {
228-
switch ($type) {
229-
case self::TYPE_OBJECT:
230-
case self::TYPE_FILE:
231-
case self::TYPE_NUMBER:
232-
case self::TYPE_INTEGER:
233-
case self::TYPE_ARRAY:
234-
$output .= $example;
235-
break;
236-
case self::TYPE_BOOLEAN:
237-
$output .= ($example) ? 'true' : 'false';
238-
break;
239-
case self::TYPE_STRING:
240-
$output .= "'{$example}'";
241-
break;
242-
}
243-
}
244-
245-
return $output;
246-
}
247-
24822
/**
24923
* @return array
25024
*/
@@ -320,4 +94,3 @@ public function getFiles()
32094
];
32195
}
32296
}
323-

src/SDK/SDK.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,8 @@ public function generate($target)
465465
'sdk' => $this->getParams(),
466466
];
467467

468-
foreach ($this->language->getFiles() as $file) { /** @var $file [] */
469-
470-
/* @var $template \Twig\TemplateWrapper */
471-
$template = $this->twig->load($file['template']);
468+
foreach ($this->language->getFiles() as $file) {
469+
$template = $this->twig->load($file['template']); /* @var $template \Twig\TemplateWrapper */
472470
$destination = $target . '/' . $file['destination'];
473471
$block = $file['block'] ?? null;
474472
$minify = $file['minify'] ?? false;

0 commit comments

Comments
 (0)