Generate API layer from Swagger by swagger-to-js

Usage no npm install needed!

<script type="module">
  import sergeysovaSwaggerToJsPreset from 'https://cdn.skypack.dev/@sergeysova/swagger-to-js-preset';




Install swagger-to-js and preset

yarn add -D swagger-to-js@^0.2.0 @sergeysova/swagger-to-js-preset

Create config

// swagger-to-js.config.js
module.exports = {
  file: 'path to local or remote swagger v2 or v3 spec',
  outputDir: 'relative path to generated api directory',
  presets: ['@sergeysova/swagger-to-js-preset'],

Run generation

yarn swagger-to-js
# or
npx swagger-to-js

Review generated files

ls -la ./path-to-generated-api