updated files

This commit is contained in:
Tony Tam
2014-09-07 17:12:03 -07:00
parent 9b0aa32941
commit bdec07e8c3
11 changed files with 2748 additions and 40 deletions

View File

@@ -8,10 +8,11 @@ class MainView extends Backbone.View
if opts.swaggerOptions.sorter
sorterName = opts.swaggerOptions.sorter
sorter = sorters[sorterName]
for route in @model.apisArray
route.operationsArray.sort sorter
if (sorterName == "alpha") # sort top level paths if alpha
@model.apisArray.sort sorter
if @model.apisArray
for route in @model.apisArray
route.operationsArray.sort sorter
if (sorterName == "alpha") # sort top level paths if alpha
@model.apisArray.sort sorter
render: ->
# Render the outer container for resources

View File

@@ -44,6 +44,9 @@ class OperationView extends Backbone.View
isMethodSubmissionSupported = true #jQuery.inArray(@model.method, @model.supportedSubmitMethods) >= 0
@model.isReadOnly = true unless isMethodSubmissionSupported
#@model.responseClassSignature = "hello"
#@model.responseSampleJSON = @model.createJSONSample
@model.oauth = null
if @model.authorizations
for k, v of @model.authorizations
@@ -66,6 +69,7 @@ class OperationView extends Backbone.View
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
$('.model-signature', $(@el)).append responseSignatureView.render().el
else
@model.responseClassSignature = 'string'
$('.model-signature', $(@el)).html(@model.type)
contentTypeModel =
@@ -76,10 +80,18 @@ class OperationView extends Backbone.View
for param in @model.parameters
type = param.type || param.dataType
if type.toLowerCase() == 'file'
if typeof type is 'undefined'
schema = param.schema
if schema['$ref']
ref = schema['$ref']
if ref.indexOf('#/definitions/') is 0
type = ref.substring('#/definitions/'.length)
else
type = ref
if type and type.toLowerCase() == 'file'
if !contentTypeModel.consumes
log "set content type "
contentTypeModel.consumes = 'multipart/form-data'
param.type = type
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
$('.response-content-type', $(@el)).append responseContentTypeView.render().el
@@ -88,6 +100,8 @@ class OperationView extends Backbone.View
@addParameter param, contentTypeModel.consumes for param in @model.parameters
# Render each response code
if typeof @model.responseMessages is 'undefined'
@model.responseMessages = []
@addStatusCode statusCode for statusCode in @model.responseMessages
@
@@ -171,8 +185,6 @@ class OperationView extends Backbone.View
if param.paramType is 'header'
headerParams[param.name] = map[param.name]
log headerParams
# add files
for el in form.find('input[type~="file"]')
if typeof el.files[0] isnt 'undefined'

View File

@@ -9,8 +9,21 @@ class ParameterView extends Backbone.View
render: ->
type = @model.type || @model.dataType
if typeof type is 'undefined'
schema = @model.schema
if schema['$ref']
ref = schema['$ref']
if ref.indexOf('#/definitions/') is 0
type = ref.substring('#/definitions/'.length)
else
type = ref
@model.type = type
@model.paramType = @model.in || @model.paramType
@model.isBody = true if @model.paramType == 'body'
@model.isFile = true if type.toLowerCase() == 'file'
@model.isFile = true if type and type.toLowerCase() == 'file'
#@model.signature = type
template = @template()
$(@el).html(template(@model))

View File

@@ -1,5 +1,7 @@
class ResourceView extends Backbone.View
initialize: ->
if "" is @model.description
@model.description = null
render: ->
$(@el).html(Handlebars.templates.resource(@model))