Git Product home page Git Product logo

swagger-to-js-api's Introduction

swagger-to-js-api

Generates a Javascript functional API to consume a Swagger based REST API

Things it does:

  • Provides a nice CLI with docs to consume a swagger JSON file and output to a folder.
  • Creates a JS API that doesn't rely on any library and doesn't assume you use any specific AJAX library. It only assumes that you have a function that accepts objects the same as $http and makes ajax calls for you.
  • It uses Babel core, to create JS code using AST.
  • The original code is generated with inline Flow type definitions based on the Swagger JSON.
  • The original code is given the extension .js.flow while it is compiled to remove Flow types and the compiled files are given the .js extension. This way you get to use compiled standard Javascript code, but the flow types are there if you use them. The flow types give you autocomplete while making API calls and check for mistakes when you pass the wrong types to the functions.
  • The flow types give you errors when you pass in the wrong types of params, and also gives you the type definitions for the response object once you pipeThrough a function.
  • A package.json file is generated and points to the one main file that requires all the functions. This makes the output folder compatible with NPM.
  • Browserify is used to make a standalone file that is written to the dist folder within the output folder. This file is usable with CommonJS, RequireJS or just a browser Global.
  • A bower.json file is generated which points to this standalone build for use in codebases that don't use commonJS (usually with NPM)

TODO

  • Add type for the query param

swagger-to-js-api's People

Contributors

nmn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.