merged from https://github.com/wordnik/swagger-ui/pull/642
This commit is contained in:
@@ -39,6 +39,14 @@ class SwaggerUi extends Backbone.Router
|
||||
# Event handler for when the baseUrl/apiKey is entered by user
|
||||
@headerView.on 'update-swagger-ui', (data) => @updateSwaggerUi(data)
|
||||
|
||||
# Set an option after initializing
|
||||
setOption: (option,value) ->
|
||||
@options[option] = value
|
||||
|
||||
# Get the value of a previously set option
|
||||
getOption: (option) ->
|
||||
@options[option]
|
||||
|
||||
# Event handler for when url/key is received from user
|
||||
updateSwaggerUi: (data) ->
|
||||
@options.url = data.url
|
||||
|
||||
@@ -27,8 +27,15 @@ class MainView extends Backbone.View
|
||||
if !@model.info.version
|
||||
@model.info.version = @model.apiVersion
|
||||
|
||||
if @model.url.indexOf('http://localhost') is -1 and @model.swaggerVersion is 2
|
||||
if "validatorUrl" of opts.swaggerOptions
|
||||
# Validator URL specified explicitly
|
||||
@model.validatorUrl = opts.swaggerOptions.validatorUrl
|
||||
else if @model.url.match(/https?:\/\/localhost/) and @model.swaggerVersion is 2
|
||||
# Localhost override
|
||||
@model.validatorUrl = @model.url
|
||||
else
|
||||
# Default validator
|
||||
@model.validatorUrl = "http://online.swagger.io/validator"
|
||||
|
||||
render: ->
|
||||
# Render the outer container for resources
|
||||
|
||||
Reference in New Issue
Block a user