@zenclabs/api

@zenclabs/api ===

WARNING: This project has been renamed to @zenclabs/spot. Please use the new package name to receive updates.
Last updated 4 months ago by fwouts .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @zenclabs/api 
SYNC missed versions from official npm registry.

@zenclabs/api

A TypeScript-based DSL to generate API contracts (OpenAPI, Swagger, JSON Schema, API Blueprint), client SDKs (TypeScript, Swift, Kotlin) or even server boilerplate (e.g. Express).

Example of an API definition file api.ts which defines a single POST endpoint to create a user:

import { api, endpoint, request } from "@zenclabs/api";

@api()
class Api {
  @endpoint({
    method: "POST",
    path: "/users"
  })
  createUser(@request req: CreateUserRequest): CreateUserResponse {
    throw "contract";
  }
}

interface CreateUserRequest {
  firstName: string;
  lastName: string;
}

interface CreateUserResponse {
  success: boolean;
}

You can pass the definition above to a generator by simply running:

npx @zenclabs/api generate --api api.ts

This is work in progress as of 3 Nov 2018:

  • [x] Functional TypeScript DSL
  • [x] Support for multiple files (using import statements)
  • [x] OpenAPI 3 generator
  • [x] OpenAPI 2 generator
  • [x] JSON Schema generator
  • [ ] API Blueprint generator
  • [x] TypeScript axios-based client generator
  • [x] TypeScript express-based server boilerplate generator
  • [ ] Swift client generator
  • [ ] Kotlin client generator

oclif Version CircleCI Downloads/week License

Usage

To get started and set up an API declaration in the current directory, run:

npx @zenclabs/api init

You can then run a generator with:

npx @zenclabs/api generate --api api.ts

Commands

api generate

Runs a generator on an API. Used to produce client libraries, server boilerplates and well-known API contract formats such as OpenAPI.

USAGE
  $ api generate

OPTIONS
  -a, --api=api              (required) Path to a TypeScript API definition
  -g, --generator=generator  Generator to run
  -h, --help                 show CLI help
  -l, --language=language    Language to generate
  -o, --out=out              Directory in which to output generated files

EXAMPLE
  $ api generate --language typescript --generator axios-client --out src/
  Generated the following files:
  - src/types.ts
  - src/validators.ts
  - src/client.ts

See code: build/cli/src/commands/generate.js

api help [COMMAND]

display help for api

USAGE
  $ api help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

api init

Generates the boilerplate for an API.

USAGE
  $ api init

OPTIONS
  -h, --help  show CLI help

EXAMPLE
  $ api init
  Generated the following files:
  - api.ts
  - tsconfig.json
  - package.json

See code: build/cli/src/commands/init.js

Current Tags

  • 0.1.22                                ...           latest (4 months ago)

43 Versions

  • 0.1.22 [deprecated]           ...           4 months ago
  • 0.1.21 [deprecated]           ...           5 months ago
  • 0.1.20 [deprecated]           ...           5 months ago
  • 0.1.19 [deprecated]           ...           5 months ago
  • 0.1.18 [deprecated]           ...           5 months ago
  • 0.1.17 [deprecated]           ...           5 months ago
  • 0.1.16 [deprecated]           ...           5 months ago
  • 0.1.15 [deprecated]           ...           5 months ago
  • 0.1.14 [deprecated]           ...           5 months ago
  • 0.1.12 [deprecated]           ...           5 months ago
  • 0.1.9 [deprecated]           ...           5 months ago
  • 0.1.8 [deprecated]           ...           5 months ago
  • 0.1.7 [deprecated]           ...           5 months ago
  • 0.1.6 [deprecated]           ...           5 months ago
  • 0.1.5 [deprecated]           ...           5 months ago
  • 0.1.4 [deprecated]           ...           5 months ago
  • 0.1.3 [deprecated]           ...           5 months ago
  • 0.1.2 [deprecated]           ...           5 months ago
  • 0.1.1 [deprecated]           ...           5 months ago
  • 0.1.0 [deprecated]           ...           5 months ago
  • 0.0.23 [deprecated]           ...           a year ago
  • 0.0.22 [deprecated]           ...           a year ago
  • 0.0.21 [deprecated]           ...           a year ago
  • 0.0.20 [deprecated]           ...           a year ago
  • 0.0.19 [deprecated]           ...           a year ago
  • 0.0.18 [deprecated]           ...           a year ago
  • 0.0.17 [deprecated]           ...           a year ago
  • 0.0.16 [deprecated]           ...           a year ago
  • 0.0.15 [deprecated]           ...           a year ago
  • 0.0.14 [deprecated]           ...           a year ago
  • 0.0.13 [deprecated]           ...           a year ago
  • 0.0.12 [deprecated]           ...           a year ago
  • 0.0.11 [deprecated]           ...           a year ago
  • 0.0.10 [deprecated]           ...           a year ago
  • 0.0.9 [deprecated]           ...           a year ago
  • 0.0.8 [deprecated]           ...           a year ago
  • 0.0.7 [deprecated]           ...           a year ago
  • 0.0.6 [deprecated]           ...           a year ago
  • 0.0.5 [deprecated]           ...           a year ago
  • 0.0.4 [deprecated]           ...           a year ago
  • 0.0.3 [deprecated]           ...           a year ago
  • 0.0.2 [deprecated]           ...           a year ago
  • 0.0.1 [deprecated]           ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 43
This Month 43
Last Day 0
Last Week 0
Last Month 174
Dependencies (9)
Dev Dependencies (13)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |