2.1.0 • Published 4 years ago

fluke-api-generator v2.1.0

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
4 years ago

Fluke API generator

This NPM package provides ability to generate a Fluke API client for frontend TypeScript/Javascript projects from the API schema that can be obtain from one of the Fluke API services.

Setup

The package can be installed using the npm package manager in a TypeScript/JavaScript frontend project:

npm install --save-dev fluke-api-generator

Or globally:

npm install -g @fluke-api-generator

During installation the package will register a CLI-utility for API client generation.

Be advised that this package is developed and tested under Unix-like environment. Not tested on Win platforms.

Generation

As mentioned the package provides the CLI-utility to build an API client for any Fluke API that supports API schema exposing via a special endpoint. The CLI-utility can be call via shell:

npx fluke --help

Or if installed globally:

fluke --help

--help option will show available options for generation.

A common command to generate an API client:

npx fluke <api_schema_url> <output_dir>

Arguments:

  • <api_schema_url> - an API services endpoint that expose the API schema,
  • <output_dir> - the output directory for a generated API client.

Options:

  • --api-client-name <name> - an API client class name. Default name is just Api

Usage

A generated API client will be located in the provided output directory.

Now you can import and use the generated API client class into any project file:

import { Api } from "./output_dir"

const api = new Api("https://example.com");

...
await api.controllerName.controllerMethod(arg1, arg2);

Api structure

Every generated API client has a common structure that can be explored:

  • bootstrap - directory for some base classes
  • controllers - concrete API controller classes
  • types - all types used by the API controllers
  • values - common values used between client and server applications (like errors and etc.)
  • api.ts - file with the api client class
2.1.0

4 years ago

2.0.0

4 years ago

1.0.0

4 years ago