Giter VIP home page Giter VIP logo

sdk-generator's Introduction

Appwrite SDK Generator

WORK IN PROGRESS - NOT READY FOR USAGE

Appwrite SDK generator is a PHP library for auto generating SDK library for multiple languages or platforms.

The SDK uses predefined language setting and Twig templates to generate code base on different API specs.

Currently the only spec supported is Swagger 2.0, but we intend to add support for more specification in the near future.

Examples

You can view examples of generated code libraries in the examples directory.

Getting Started

Install using composer:

composer require appwrite/sdk-generator

Create language and SDK instances and generate code to target directory.

<?php

require_once 'vendor/autoload.php';

use Appwrite\Spec\Swagger2;
use Appwrite\SDK\SDK;
use Appwrite\SDK\Language\PHP;

// Read API specification file (Swagger 2) anc create spec instance
$spec = new Swagger2(file_get_contents('https://appwrite.io/v1/open-api-2.json?extension=1'));

// Create language instance
$lang = new PHP();

$lang // Set language or platform specific options
    ->setComposerPackage('my-api')
    ->setComposerVendor('my-company')
;

// Create the SDK object with the language and spec instances
$sdk  = new SDK($lang, $spec);

$sdk
    ->setLogo('https://appwrite.io/v1/images/console.png')
    ->setLicenseContent('License content here.')
    ->setVersion('v1.1.0')
;

$sdk->generate(__DIR__ . '/examples/php'); // Generate source code

Supported Specs

Supported Languages

Language Coding Standards Package Manager Maintainer
PHP PHP FIG Composer @eldadfux
Javascript NPM Coding Style NPM, Yarn, Bower @eldadfux
NodeJS NPM Coding Style NPM, Yarn @eldadfux
Ruby Ruby Style Guide GEM @eldadfux
Python PEP8 PIP @eldadfux
Dart Effective Dart pub tool @Almoullim
Kotlin ?
Swift ?

Development

composer update --ignore-platform-reqs --optimize-autoloader

TODO List

  • Better spec modeling
  • Spec Validators
  • XML Content Types

SDK Checklist

It is very important to us to create a both consistent structure and architecture and native like feel for the SDKs we are generating. In order to accomplish that we have a checklist of points to support when adding a new language to the SDK generator.

The checklist aims to balance between consistency between language and follow each platform best practices and coding standards.

  • Proper Coding Standards and Conventions
  • Proper Skeleton Structure
  • Readme Doc
  • HTTP Client class or object
    • Client Setters
      • Set Auth Keys Method
      • Set Basic Auth Method
      • Set OAuth Dialog Method
      • Set Endpoint Method
      • Set Self Signed Certificates
    • Default Headers
      • 'appwrite-sdk-version' header
      • Add 'User-Agent' header with server name and language version (ubuntu-18.02:php-7.0.1)
    • Methods
      • addHeader(key, value)
      • call(method, path = '', headers = [], params = [])
        • Concat GET params to path
        • Parse request params by content type header
        • Parse response params by content type header
        • Throw error on bad response
  • Service Abstraction (optional)
    • Constructor receiving an instance of the client class
  • Service Class
    • Headers Support (Content Type)
    • Parameters Support
      • Default Values Support
      • Required Values Support
      • String Support
      • Integer Support
      • Boolean Support
      • Files Support (+array file and multiple header support and params flatten)
      • Arrays / Dictionaries / Lists Support (+concatenation type)
  • Usage Example Docs
  • Definitions / Models Classes - with setters and getters

Contributing

All code contributions - including those of people having commit access - must go through a pull request and approved by a core developer before being merged. This is to ensure proper review of all the code.

Fork the project, create a feature branch, and send us a pull request.

Copyright and license

The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php

sdk-generator's People

Contributors

eldadfux avatar almoullim avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.