This commit is contained in:
Tony Tam
2014-10-17 06:21:00 -07:00
parent 7957201b61
commit f882750e5c
5 changed files with 41 additions and 6 deletions

View File

@@ -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

View File

@@ -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