Spot ===

Spot has a new home at @airtasker/spot. Use this package to get the latest updates.
Last updated 2 years ago by fwouts .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @zenclabs/spot 
SYNC missed versions from official npm registry.


Spot ("Single Point Of Truth") is a concise, developer-friendly way to describe your API contract.

Leveraging the TypeScript syntax, it lets you describe your API and generate any other API contract formats you need (OpenAPI, Swagger, JSON Schema, Pact, API Blueprint), client SDKs (TypeScript, Swift, Kotlin) or even server boilerplate (e.g. Express).

You don't need to use TypeScript in your codebase to benefit from using Spot.

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

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

class Api {
    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/spot generate --api api.ts

This is work in progress as of 14 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
  • [ ] Pact generator
  • [ ] API Blueprint generator
  • [x] TypeScript axios-based client generator
  • [x] TypeScript express-based server boilerplate generator

oclif Version CircleCI Downloads/week License


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

npx @zenclabs/spot init

You can then run a generator with:

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


spot generate

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

  $ spot generate

  -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

  $ 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

spot help [COMMAND]

display help for spot

  $ spot help [COMMAND]

  COMMAND  command to show help for

  --all  see all commands in CLI

See code: @oclif/plugin-help

spot init

Generates the boilerplate for an API.

  $ spot init

  -h, --help  show CLI help

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

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

Current Tags

  • 0.1.25                                ...           latest (2 years ago)

4 Versions

  • 0.1.25 [deprecated]           ...           2 years ago
  • 0.1.24 [deprecated]           ...           2 years ago
  • 0.1.23 [deprecated]           ...           2 years ago
  • 0.1.22 [deprecated]           ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (9)
Dev Dependencies (13)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |