Przeglądaj źródła

Provide option highlightSizeThreshold to allow conditional syntax highlighting based on response size

bubble
John Bryson 10 lat temu
rodzic
commit
28c7597138
4 zmienionych plików z 7 dodań i 3 usunięć
  1. +1
    -0
      README.md
  2. +1
    -1
      src/main/coffeescript/view/MainView.coffee
  3. +4
    -1
      src/main/coffeescript/view/OperationView.coffee
  4. +1
    -1
      src/main/coffeescript/view/ResourceView.coffee

+ 1
- 0
README.md Wyświetl plik

@@ -62,6 +62,7 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
* *sorter* apply a sort to the API list. It can be 'alpha' (sort paths alphanumerically) or 'method' (sort operations by HTTP method). Default is the order returned by the server unchanged.
* *onComplete* is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
* *onFailure* is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
* *highlightSizeThreshold* any size response below this threshold will be highlighted syntactically, attempting to highlight large responses can lead to browser hangs, not including a threshold will default to highlight all returned responses
* All other parameters are explained in greater detail below




+ 1
- 1
src/main/coffeescript/view/MainView.coffee Wyświetl plik

@@ -33,7 +33,7 @@ class MainView extends Backbone.View

addResource: (resource) ->
# Render a resource and add it to resources li
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.id, className: 'resource'})
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.id, className: 'resource', swaggerOptions: @options.swaggerOptions})
$('#resources').append resourceView.render().el

clear: ->


+ 4
- 1
src/main/coffeescript/view/OperationView.coffee Wyświetl plik

@@ -365,7 +365,10 @@ class OperationView extends Backbone.View
$(".response", $(@el)).slideDown()
$(".response_hider", $(@el)).show()
$(".response_throbber", $(@el)).hide()
hljs.highlightBlock($('.response_body', $(@el))[0])
response_body_el = $('.response_body', $(@el))[0]
# only highlight the response if response is less than threshold, default state is highlight response
opts = @options.swaggerOptions
if opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold then response_body_el else hljs.highlightBlock(response_body_el)

toggleOperationContent: ->
elem = $('#' + Docs.escapeResourceName(@model.parentId) + "_" + @model.nickname + "_content")


+ 1
- 1
src/main/coffeescript/view/ResourceView.coffee Wyświetl plik

@@ -27,7 +27,7 @@ class ResourceView extends Backbone.View
operation.number = @number

# Render an operation and add it to operations li
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint'})
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint', swaggerOptions: @options.swaggerOptions})
$('.endpoints', $(@el)).append operationView.render().el

@number++

Ładowanie…
Anuluj
Zapisz