JSPM

@sencrop/openapi-js-sdk-builder

1.1.7
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q42153F
  • License MIT

Create a JavaScript SDK from an OpenAPI 3 definition

Package Exports

  • @sencrop/openapi-js-sdk-builder

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sencrop/openapi-js-sdk-builder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@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