You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@sencrop/openapi-js-sdk-builder

Package Overview
Dependencies
Maintainers
13
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sencrop/openapi-js-sdk-builder

Create a JavaScript SDK from an OpenAPI 3 definition

1.1.7
latest
Source
npm
Version published
Maintainers
13
Created
Source

@sencrop/openapi-js-sdk-builder

Create a JavaScript SDK from an OpenAPI 3 definition

Usage

With a raw Node script:

import { generateSDKFromOpenAPI } from 'openapi-js-sdk-builder';
import { readFileSync, writeFileSync } from 'fs';

const openAPIContents = readFileSync('openapi.json', 'utf-8');
const sdkContents = generateSDKFromOpenAPI(openAPIContents);

writeFileSync('sdk.js', sdkContents, 'utf-8');

You can also use the built-in webpack loader in your frontends builds:

In webpack.config.js:

module.exports = {
  //...
  module: {
    rules: [
      {
        test: /(\.|^)openapi.json$/,
        loader: require.resolve('openapi-js-sdk-builder'),
        type: 'javascript/auto'
      }
    ]
  }
};

In your code:

import API from './myapi.openapi.json'

// Just use the API then
await API.getPing();

Useful resources

License

MIT

Useful resources

License

MIT

Keywords

openapi

FAQs

Package last updated on 02 Mar 2021

Did you know?

Socket

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.

Install

Related posts