All Projects → qingstor → Snips

qingstor / Snips

Licence: apache-2.0
A code generator for RESTful APIs.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Snips

Springbootcodegenerator
又名大狼狗代码生成器,基于SpringBoot2+Freemarker的JAVA代码生成器,以释放双手为目的,支持mysql/oracle/pgsql三大数据库, 用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL等相关代码.
Stars: ✭ 810 (+965.79%)
Mutual labels:  code-generator
Graphql Zeus
GraphQL client and GraphQL code generator with GraphQL autocomplete library generation ⚡⚡⚡ for browser,nodejs and react native
Stars: ✭ 1,043 (+1272.37%)
Mutual labels:  code-generator
Professional Codes Reader
Browse the web like a professional programmer!
Stars: ✭ 63 (-17.11%)
Mutual labels:  code-generator
Janett
Java to C#.Net Translator
Stars: ✭ 8 (-89.47%)
Mutual labels:  code-generator
Dart functional data
Simple and non-intrusive code generator for lenses and boilerplate of data types
Stars: ✭ 39 (-48.68%)
Mutual labels:  code-generator
Apiclientcodegen
A collection of Visual Studio custom tool code generators for Swagger / OpenAPI specification files
Stars: ✭ 50 (-34.21%)
Mutual labels:  code-generator
Freebuilder
Automatic generation of the Builder pattern for Java
Stars: ✭ 772 (+915.79%)
Mutual labels:  code-generator
Mid
mid is a generic domain-specific language for generating code and documentation
Stars: ✭ 68 (-10.53%)
Mutual labels:  code-generator
Dogen
Reference implementation of the MASD Code Generator.
Stars: ✭ 44 (-42.11%)
Mutual labels:  code-generator
Metafun
Compile Haskell-like code into C++ template metaprograms
Stars: ✭ 52 (-31.58%)
Mutual labels:  code-generator
Taco
The Tensor Algebra Compiler (taco) computes sparse tensor expressions on CPUs and GPUs
Stars: ✭ 846 (+1013.16%)
Mutual labels:  code-generator
Swiftgen
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!
Stars: ✭ 7,580 (+9873.68%)
Mutual labels:  code-generator
R.swift
Strong typed, autocompleted resources like images, fonts and segues in Swift projects
Stars: ✭ 8,419 (+10977.63%)
Mutual labels:  code-generator
Hel
Hel rules over Helheim, where the souls unworthy of Valhalla reside. It's also a mock generator for Go.
Stars: ✭ 16 (-78.95%)
Mutual labels:  code-generator
Automation
code generator
Stars: ✭ 65 (-14.47%)
Mutual labels:  code-generator
Graphql Code Generator
A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
Stars: ✭ 7,993 (+10417.11%)
Mutual labels:  code-generator
Scala Db Codegen
Scala code/boilerplate generator from a db schema
Stars: ✭ 49 (-35.53%)
Mutual labels:  code-generator
Aarkay Archived
AarKay is a language independent code generation framework. This project has been deprecated and is no longer maintained.
Stars: ✭ 69 (-9.21%)
Mutual labels:  code-generator
Kit Phpencoder
Highly customizable alternative to var_export for PHP code generation
Stars: ✭ 65 (-14.47%)
Mutual labels:  code-generator
Sql Boot
Advanced REST-wrapper for your SQL-queries (actually not only SQL)
Stars: ✭ 51 (-32.89%)
Mutual labels:  code-generator

Snips

Build Status Go Report Card License

A code generator for RESTful APIs.

Introduction

Snips generates various code using API specifications in OpenAPI Specification (Swagger) v2.0 format.

Run snips --help to get to help messages of snips.

$ snips --help
A code generator for RESTful APIs.

For example:
  $ snips -f ./specs/qingstor/api.json
          -t ./templates/qingstor/go \
          -o ./publish/qingstor-sdk-go/service
  $ ...
  $ snips --file=./specs/qingstor/api.json \
          --template=./templates/qingstor/ruby \
          --output=./publish/qingstor-sdk-ruby/lib/qingstor/sdk/service
  $ ...

Copyright (C) 2016 Yunify, Inc.

Usage:
  snips [flags]

Flags:
  -f, --file string       Specify the spec file.
      --format string     Specify the format of spec file. (default "OpenAPI-v2.0")
  -o, --output string     Specify the output directory.
  -t, --template string   Specify template files directory.
  -v, --version           Show version.

Installation

Snips is a command line tool, and it's easy to have it installed. You can build it from source code or download the precompiled binary directly.

Install from Source Code

Snips requires Go 1.6 or later's vendor feature, the dependencies the project used are included in the vendor directory. And we use glide to manage project dependence.

$ git clone [email protected]:yunify/snips.git
$ glide install
$ make install

Notice: You can also use Go 1.5 with the GO15VENDOREXPERIMENT=1.

Download Precompiled Binary

  1. Go to releases tab and download the binary for your operating system, for example snips-v0.0.7-darwin_amd64.tar.gz.
  2. Unarchive the downloaded file, and put the executable file snips into a directory that in the $PATH environment variable, for example /usr/local/bin.
  3. Run snips --help to get started.

SDK Development Workflow

Snips takes API specifications and template to generate lots of code for APIs, then these generated code plus the handcrafted code makes up the SDK. Next, we use scenario based test to make sure our SDKs are working properly, and ensure their functional consistency.

+---------------------------------------------+--------------------+
|                                             |  Workflow Diagram  |
|       API Specifications                    +--------------------|
|                   +                                              |
|                   |                               Scenario       |
|     Templates     |               +------------->  Based         |
|         +         |      +------>SDKs             Testing        |
|         |         |      |        ^                  +           |
|         |         v      |        |                  |           |
|         +-----> Snips+---+        |                  |           |
|                                   |                  |           |
|                                   |                  v           |
|       Handcraft+------------------+               Publish        |
|                                                                  |
+------------------------------------------------------------------+

Add an SDK for Another Programing Language

  1. Create handcraft files of SDK, to handle configuration, network request and etc.
  2. Writing templates for API code.
  3. Generate code using snips.
  4. Running tests.
  5. Publish.

Update an Exists SDK

  1. Change handcraft files (if needed) and update the API specs.
  2. Regenerate code.
  3. Running tests.
  4. Publish.

Example

Let's take Go SDK for QingStor (qingstor-sdk-go) for example.

Prepare

Tips: Include these files as git submodule.

Procedures

  1. Create template files which will be used to generate API code in ./template.

  2. Generate code using snips, and format the generated code.

    $ snips --version
    snips version 0.3.6
    $ snips -f ./specs/qingstor/2016-01-06/swagger/api_v2.0.json \
            -t ./template \
            -o ./service
    Loaded templates from ./template
    4 template(s) detected.
    Loaded specification file ./specs/qingstor/2016-01-06/swagger/api_v2.0.json (Swagger-v2.0)
    
    Generating to: ./service/qingstor.go
    Generating to: ./service/bucket.go
    Generating to: ./service/object.go
    Generating to: ./service/types.go
    
    Everything looks fine.
    $ gofmt -w .
    
  3. Implement test scenarios in ./test.

    $ ls ./test
    bucket.go                 config.yaml.example       test_config.yaml
    bucket_acl.go             features                  test_config.yaml.example
    bucket_cors.go            main.go                   utils.go
    bucket_external_mirror.go object.go                 vendor
    bucket_policy.go          object_multipart.go
    config.yaml               service.go
    
  4. Running scenarios test, and pass all tests.

    $ pushd ./test
    $ go run *.go
    ...
    38 scenarios (38 passed)
    84 steps (84 passed)
    1m2.408357076s
    $ popd
    
  5. Every time the QingStor API changes, just update the specs/qingstor and ./test/features submodule and regenerate code. Then add/change test for this API change, and rerun the online test to make sure the SDK is working properly.

References

Contributing

Please see Contributing Guidelines of this project before submitting patches.

LICENSE

The Apache License (Version 2.0, January 2004).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].