Coder Social home page Coder Social logo

rynam0 / ember-swagger-ui Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 15.0 1.49 MB

An Ember addon for quickly and easily adding a swagger-ui to your Ember App.

Home Page: http://rynam0.github.io/ember-swagger-ui/

License: MIT License

JavaScript 92.12% HTML 4.40% CSS 2.26% Shell 0.93% Handlebars 0.30%
addon ember ember-addon ember-cli swagger-ui

ember-swagger-ui's People

Contributors

drauschenbach avatar ember-tomster avatar ffissore avatar rynam0 avatar theaxeman301 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ember-swagger-ui's Issues

sort out jquery dependencies

swagger-ui depends on jquery-1.8.0 due to its dependency on the jquery.ba-bbq plugin. This plugin makes use of jquery APIs that have been removed in jquery-1.9+ ($.browser). As apps already get jquery (Ember.$) we do not want to import this second jquery dependency.

Re-initialize swagger UI based on binding to controller property

Is there a way to re-render the swagger-ui component based on changing the swagger.json url or in-memory swagger JSON object? I'm trying to make a single swagger-ui page that can point to different swagger JSON specifications.

Is there a way to re-call _initSwaggerUi when the controller's url or JSON swagger object changes? At least I think that's what I'm asking. Here's an example of something I'm interested in.

// app/controllers/some-swagger-controller
export default Ember.Controller.extend({
  // value that will be passed to the swagger-ui component
  swaggerUrl: 'https://petstore.swagger.io/v2/swagger.json', 

  actions: {
    updateUrl(newUrl) {
      this.set('swaggerUrl', newUrl);
    }
  }
})
<!-- 
menu for toggling different version of an API
-->
<ul>
  <button {{action 'updateUrl' 'https://petstore.swagger.io/swagger.json' }}>V1 API</button>
  <button {{action 'updateUrl' 'https://petstore.swagger.io/v2/swagger.json' }}>V2 API</button>
</ul>

<!--
when swaggerUrl changes on some-swagger-controller could the swagger-ui re-render?
-->
{{swagger-ui url=swaggerUrl}}

Support various swagger-ui configuration options

Configuration options documented on the swagger-ui repo should be made available to consuming apps by the component.

  • url
  • title
  • authorizations
  • spec
  • validatorUrl
  • booleanValues
  • docExpansion
  • apisSorter
  • operationsSorter
  • onComplete
  • onFailure
  • supportedSubmitMethods
  • oauth2RedirectUrl
  • showRequestHeaders

Support block syntax

It seems consuming apps will want to be able to create their own elements inside the component (custom header, footer, etc.) Currently the default layout (swagger-ui/dist/index.html) is used as the component template and a yield has not been added.

The petstore example OAuth flow isn't currently working

The OAuth flow isn't currently working.
The dialog is written to document.body by swagger-oauth.js and therefore does not get the correct styling. This also means that the element won't get torn down w/ the component.

The dialog also tries to redirect to o2c.html. Will have to investigate how this can be supported (would it be enough for the addon to simply make this file available?)

request: eliminate Bower

Is there any way we can eliminate the bower dependency? It is obsolete and Ember no longer uses it.

swagger-ui 2.1.4 compatibility

Getting ENOENT due to missing resources hardcoded in ember-swagger-ui's build. For example, these fonts do not exist in swagger-ui 2.1.4.

The folder structure seems to be the same, so maybe the lib can do something like cp path/to/fonts/* dist/fonts/?

Issue with ember 2.10.0

Issue

Doesn't work with ember 2.10.0

Error

Uncaught TypeError: Cannot create property 'default' on boolean 'true'
    at new module.exports (vendor.js:84168)
    at vendor.js:81201
    at arrayEach (vendor.js:91925)
    at Object.forEach (vendor.js:93258)
    at vendor.js:81180
    at vendor.js:93140
    at baseForOwn (vendor.js:92345)
    at vendor.js:93105
    at Object.forEach (vendor.js:93259)
    at module.exports.SwaggerClient.buildFromSpec (vendor.js:81174)

Demo Project

https://github.com/deanmraz/ember-swagger-demo

Implementation

https://github.com/deanmraz/ember-swagger-demo/blob/master/app/templates/index.hbs

@rynam0 I was hoping you can point me in the right direction to fix this. Let me know if you have any suggestions.

Don't strip href

First off, I'm really happy to discover this addon. swagger-ui leaves something to be desired in SPA-land. This is a handy integration I didn't want to bootstrap myself. Thank you!

I'm having trouble with swagger-ui.js#L69-L73:

        // and remove href links that will also attempt to route us out of our known ember routes
        let anchors = that.$('#resources_container a');
        if (anchors) {
          anchors.removeAttr('href');
        }

This makes external links unclickable. Can't have the whole world in my Ember app :). I'm missing its original intent. I've deleted it in my fork, but I don't think that's the answer. Could you explain your code comment more?

Can you restore links? Or warn if they'll route you outside the app? Or make it configurable? (Not that swagger-ui needs yet another input param.)

fresh install of ember-swagger-ui does not fetch petstore swagger spec

I'm getting Uncaught TypeError: Cannot read property 'type' of undefined on a fresh install of the ember-swagger-ui addon. The top of the console error log points to bower_components/swagger-ui/dist/swagger-ui.js:253.

Here are the steps I took.

ember new ember-swag
cd ember-swag
# update bower.json file
# ember to 2.2.0
# ember-data to 2.2.0
# jquery to 2.1.x
bower install # update dependencies
ember install ember-swagger-ui
npm install
# update security policy in config/environment
ember s
# navigate to localhost:4200

screen shot 2016-01-11 at 12 02 33 pm

Security Policy

    contentSecurityPolicy: {
      'default-src': "'none'",
      'script-src': "'self' 'unsafe-inline' 'unsafe-eval' use.typekit.net",
      'font-src': "'self' data: use.typekit.net",
      'connect-src': "'self' *",
      'img-src': "'self' www.facebook.com p.typekit.net",
      'style-src': "'self' 'unsafe-inline' use.typekit.net"
    }

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.