Git Product home page Git Product logo

swagger-ui-browserify's Introduction

swagger-ui-browserify

Build Status

Use swagger-ui with browserify.

Supports version 2.1.4 and 2.0.24. Why? Because 2.1.3 tries to convert a Swagger 1.2 into a Swagger 2 definition and it's not always a one-to-one mapping - for example see OAI/OpenAPI-Specification#182.

This is the 2.1.4/v2.0 branch. See 2.0.24/v1.2 if you cannot upgrade to v2.0 of the spec.

Installation

$ npm install --save swagger-ui-browserify

Example

// in your app.js file
var SwaggerUi = require('swagger-ui-browserify')

// SwaggerUI expects there to be a `swaggerUi` property on the window object :(
window.swaggerUi = new SwaggerUi({
  url: '/apidocs',
  dom_id: 'swagger-ui-container',
  supportHeaderParams: true,
  onComplete: function (swaggerApi, swaggerUi) {
    console.log('Loaded SwaggerUI')
  },
  onFailure: function (error) {
    console.error('Unable to Load SwaggerUI', error)
  },
  apisSorter: 'alpha',
  operationsSorter: 'alpha',
  docExpansion: 'none'
})
window.swaggerUi.load()

jQuery & Handlebars

SwaggerUI uses old versions of jQuery and Handlebars. If you are also using these libraries on the same page and wish to avoid loading multiple versions of them you should specify the same versions in your package.json file:

Library Version
Handlebars ^3.0.3
jQuery ^1.9.1

Assets

You will need to make the CSS/images/font assets bundled with swagger-ui available to be referenced from your app's html page. See the example gulpfile.js for more.

swagger-ui-browserify's People

Contributors

achingbrain avatar treythree avatar marla-singer 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.