Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@airtasker/spot
Advanced tools
**Spot** (_"Single Point Of Truth"_) is a concise, developer-friendly way to describe your API contract.
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, response } from "@airtasker/spot";
@api({
name: "My API",
description: "My really cool API"
})
class Api {
@endpoint({
method: "POST",
path: "/users"
})
createUser(@request req: CreateUserRequest): CreateUserResponse {
return response();
}
}
interface CreateUserRequest {
firstName: string;
lastName: string;
}
interface CreateUserResponse {
success: boolean;
}
For available methods, please check here
You can pass the definition above to a generator by simply running:
npx @airtasker/spot generate --api api.ts
This is work in progress as of 14 Nov 2018:
To get started and set up an API declaration in the current directory, run:
npx @airtasker/spot init
You can then run a generator with:
npx @airtasker/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.
USAGE
$ spot 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
$ spot 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
USAGE
$ spot help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI
See code: @oclif/plugin-help
spot init
Generates the boilerplate for an API.
USAGE
$ spot init
OPTIONS
-h, --help show CLI help
EXAMPLE
$ spot init
Generated the following files:
- api.ts
- tsconfig.json
- package.json
See code: build/cli/src/commands/init.js
spot mock SPOT_CONTRACT
Run a mock server based on a Spot contract
USAGE
$ spot mock SPOT_CONTRACT
ARGUMENTS
SPOT_CONTRACT path to Spot contract
OPTIONS
-h, --help show CLI help
-p, --port=port (required) [default: 3010] Port on which to run the mock server
--pathPrefix=pathPrefix Prefix to prepend to each endpoint path
EXAMPLE
$ spot mock api.ts
See code: build/cli/src/commands/mock.js
spot validate SPOT_CONTRACT
Validate a Spot contract
USAGE
$ spot validate SPOT_CONTRACT
ARGUMENTS
SPOT_CONTRACT path to Spot contract
OPTIONS
-h, --help show CLI help
EXAMPLE
$ spot validate api.ts
See code: build/cli/src/commands/validate.js
FAQs
**Spot** (_"Single Point Of Truth"_) is a concise, developer-friendly way to describe your API contract.
The npm package @airtasker/spot receives a total of 1,815 weekly downloads. As such, @airtasker/spot popularity was classified as popular.
We found that @airtasker/spot demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.