swagger-js icon indicating copy to clipboard operation
swagger-js copied to clipboard

Allow header to be specified for fetching swagger description

Open fehguy opened this issue 12 years ago • 4 comments

Currently the swagger-js module assumes application/json is the correct way to get the swagger resource declaration and api description. Need to allow passing options such as:

*/*
application/json;charset=utf8;

etc. Make it a configuration when initializing the client

fehguy avatar Sep 08 '14 23:09 fehguy

will this be per swagger url?

lluu avatar Sep 09 '14 18:09 lluu

I envision this would be part of the initialization of swagger-js (and therefore swagger-ui). Something like this (see defaultContentType below):

    $(function () {
      window.swaggerUi = new SwaggerUi({
      url: "http://petstore.swagger.wordnik.com/api/api-docs",
      dom_id: "swagger-ui-container",
      supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
      defaultContentType: '*/*',
      onComplete: function(swaggerApi, swaggerUi){
        log("Loaded SwaggerUI");
        }
        $('pre code').each(function(i, e) {
          hljs.highlightBlock(e)
        });
      },
      onFailure: function(data) {
        log("Unable to Load SwaggerUI");
      },
      docExpansion: "none",
      sorter : "alpha"
    });

fehguy avatar Sep 10 '14 00:09 fehguy

I wonder if swagger-ui should be more forgiving.. ie, it should accept "*/json" by default. So there won't be a need to make this part of the initialization.

lluu avatar Sep 10 '14 17:09 lluu

This was resolved in 2.0.39, released a few days ago.

fehguy avatar Sep 16 '14 18:09 fehguy