Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ihor Kaharlichenko
swagger-ui-oms
Commits
205125cd
Commit
205125cd
authored
Aug 14, 2013
by
Tony Tam
Browse files
fixes for content-type
parent
4b5e4e5d
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
dist/index.html
View file @
205125cd
...
...
@@ -20,7 +20,7 @@
<script
type=
"text/javascript"
>
$
(
function
()
{
window
.
swaggerUi
=
new
SwaggerUi
({
url
:
"
http://
petstore.swagger.wordnik.com
/api/api-docs
"
,
url
:
"
http://
localhost:8002
/api/api-docs
"
,
dom_id
:
"
swagger-ui-container
"
,
supportedSubmitMethods
:
[
'
get
'
,
'
post
'
,
'
put
'
,
'
delete
'
],
onComplete
:
function
(
swaggerApi
,
swaggerUi
){
...
...
dist/lib/swagger.js
View file @
205125cd
...
...
@@ -73,6 +73,7 @@
}
_this
.
apis
=
{};
_this
.
apisArray
=
[];
_this
.
produces
=
response
.
produces
;
if
(
response
.
info
!=
null
)
{
_this
.
info
=
response
.
info
;
}
...
...
@@ -215,6 +216,7 @@
produces
=
[];
consumes
=
[];
this
.
path
=
this
.
api
.
resourcePath
!=
null
?
this
.
api
.
resourcePath
:
resourceObj
.
path
;
console
.
log
(
"
we produce
"
+
resourceObj
.
produces
);
console
.
log
(
'
using path
'
+
this
.
path
);
this
.
description
=
resourceObj
.
description
;
parts
=
this
.
path
.
split
(
"
/
"
);
...
...
@@ -278,7 +280,7 @@
_ref
=
response
.
apis
;
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
endpoint
=
_ref
[
_i
];
this
.
addOperations
(
endpoint
.
path
,
endpoint
.
operations
);
this
.
addOperations
(
endpoint
.
path
,
endpoint
.
operations
,
response
.
consumes
,
response
.
produces
);
}
}
this
.
api
[
this
.
name
]
=
this
;
...
...
@@ -306,14 +308,14 @@
}
};
SwaggerResource
.
prototype
.
addOperations
=
function
(
resource_path
,
ops
)
{
var
consumes
,
method
,
o
,
op
,
produces
,
responseMessages
,
_i
,
_len
,
_results
;
SwaggerResource
.
prototype
.
addOperations
=
function
(
resource_path
,
ops
,
consumes
,
produces
)
{
var
method
,
o
,
op
,
responseMessages
,
type
,
_i
,
_len
,
_results
;
if
(
ops
)
{
_results
=
[];
for
(
_i
=
0
,
_len
=
ops
.
length
;
_i
<
_len
;
_i
++
)
{
o
=
ops
[
_i
];
consumes
=
null
;
produces
=
null
;
consumes
=
this
.
consumes
;
produces
=
this
.
produces
;
if
(
o
.
consumes
!=
null
)
{
consumes
=
o
.
consumes
;
}
else
{
...
...
@@ -324,6 +326,7 @@
}
else
{
produces
=
this
.
produces
;
}
type
=
o
.
type
||
o
.
responseClass
;
responseMessages
=
o
.
responseMessages
;
method
=
o
.
method
;
if
(
o
.
httpMethod
)
{
...
...
@@ -336,7 +339,7 @@
responseMessages
=
o
.
errorResponses
;
}
o
.
nickname
=
this
.
sanitize
(
o
.
nickname
);
op
=
new
SwaggerOperation
(
o
.
nickname
,
resource_path
,
method
,
o
.
parameters
,
o
.
summary
,
o
.
notes
,
o
.
responseClass
,
responseMessages
,
this
,
consumes
,
produces
);
op
=
new
SwaggerOperation
(
o
.
nickname
,
resource_path
,
method
,
o
.
parameters
,
o
.
summary
,
o
.
notes
,
type
,
responseMessages
,
this
,
consumes
,
produces
);
this
.
operations
[
op
.
nickname
]
=
op
;
_results
.
push
(
this
.
operationsArray
.
push
(
op
));
}
...
...
@@ -515,8 +518,8 @@
SwaggerOperation
=
(
function
()
{
function
SwaggerOperation
(
nickname
,
path
,
method
,
parameters
,
summary
,
notes
,
responseClass
,
responseMessages
,
resource
,
consumes
,
produces
)
{
var
parameter
,
type
,
v
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_ref1
,
_ref2
,
function
SwaggerOperation
(
nickname
,
path
,
method
,
parameters
,
summary
,
notes
,
type
,
responseMessages
,
resource
,
consumes
,
produces
)
{
var
parameter
,
v
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_ref1
,
_ref2
,
_this
=
this
;
this
.
nickname
=
nickname
;
this
.
path
=
path
;
...
...
@@ -524,7 +527,7 @@
this
.
parameters
=
parameters
!=
null
?
parameters
:
[];
this
.
summary
=
summary
;
this
.
notes
=
notes
;
this
.
responseClass
=
responseClass
;
this
.
type
=
type
;
this
.
responseMessages
=
responseMessages
;
this
.
resource
=
resource
;
this
.
consumes
=
consumes
;
...
...
@@ -544,12 +547,12 @@
this
.
method
=
this
.
method
.
toLowerCase
();
this
.
isGetMethod
=
this
.
method
===
"
get
"
;
this
.
resourceName
=
this
.
resource
.
name
;
if
(((
_ref
=
this
.
responseClass
)
!=
null
?
_ref
.
toLowerCase
()
:
void
0
)
===
'
void
'
)
{
this
.
responseClass
=
void
0
;
if
(((
_ref
=
this
.
type
)
!=
null
?
_ref
.
toLowerCase
()
:
void
0
)
===
'
void
'
)
{
this
.
type
=
void
0
;
}
if
(
this
.
responseClass
!=
null
)
{
this
.
responseClassSignature
=
this
.
getSignature
(
this
.
responseClass
,
this
.
resource
.
models
);
this
.
responseSampleJSON
=
this
.
getSampleJSON
(
this
.
responseClass
,
this
.
resource
.
models
);
if
(
this
.
type
!=
null
)
{
this
.
responseClassSignature
=
this
.
getSignature
(
this
.
type
,
this
.
resource
.
models
);
this
.
responseSampleJSON
=
this
.
getSampleJSON
(
this
.
type
,
this
.
resource
.
models
);
}
this
.
responseMessages
=
this
.
responseMessages
||
[];
_ref1
=
this
.
parameters
;
...
...
@@ -880,14 +883,14 @@
}
}
responseContentType
=
null
;
if
(
this
.
type
===
"
POST
"
||
this
.
type
===
"
GET
"
||
this
.
type
===
"
PATCH
"
||
this
.
type
===
"
PUT
"
)
{
if
(
this
.
type
===
"
POST
"
||
this
.
type
===
"
GET
"
||
this
.
type
===
"
PATCH
"
)
{
if
(
this
.
opts
.
responseContentType
)
{
re
quest
ContentType
=
this
.
opts
.
re
quest
ContentType
;
re
sponse
ContentType
=
this
.
opts
.
re
sponse
ContentType
;
}
else
{
re
quest
ContentType
=
"
application/json
"
;
re
sponse
ContentType
=
"
application/json
"
;
}
}
else
{
re
quest
ContentType
=
null
;
re
sponse
ContentType
=
null
;
}
if
(
responseContentType
&&
this
.
operation
.
produces
)
{
if
(
this
.
operation
.
produces
.
indexOf
(
responseContentType
)
===
-
1
)
{
...
...
dist/swagger-ui.js
View file @
205125cd
...
...
@@ -552,8 +552,8 @@ function program11(depth0,data) {
stack1
=
stack2
.
call
(
depth0
,
stack1
,
tmp1
);
if
(
stack1
||
stack1
===
0
)
{
buffer
+=
stack1
;
}
buffer
+=
"
\n
"
;
foundHelper
=
helpers
.
responseClass
;
stack1
=
foundHelper
||
depth0
.
responseClass
;
foundHelper
=
helpers
.
type
;
stack1
=
foundHelper
||
depth0
.
type
;
stack2
=
helpers
[
'
if
'
];
tmp1
=
self
.
program
(
3
,
program3
,
data
);
tmp1
.
hash
=
{};
...
...
@@ -1747,7 +1747,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
});
$
(
'
.model-signature
'
,
$
(
this
.
el
)).
append
(
responseSignatureView
.
render
().
el
);
}
else
{
$
(
'
.model-signature
'
,
$
(
this
.
el
)).
html
(
this
.
model
.
responseClass
);
$
(
'
.model-signature
'
,
$
(
this
.
el
)).
html
(
this
.
model
.
type
);
}
contentTypeModel
=
{
isParam
:
false
...
...
dist/swagger-ui.min.js
View file @
205125cd
This diff is collapsed.
Click to expand it.
lib/swagger.js
View file @
205125cd
...
...
@@ -73,6 +73,7 @@
}
_this
.
apis
=
{};
_this
.
apisArray
=
[];
_this
.
produces
=
response
.
produces
;
if
(
response
.
info
!=
null
)
{
_this
.
info
=
response
.
info
;
}
...
...
@@ -215,6 +216,7 @@
produces
=
[];
consumes
=
[];
this
.
path
=
this
.
api
.
resourcePath
!=
null
?
this
.
api
.
resourcePath
:
resourceObj
.
path
;
console
.
log
(
"
we produce
"
+
resourceObj
.
produces
);
console
.
log
(
'
using path
'
+
this
.
path
);
this
.
description
=
resourceObj
.
description
;
parts
=
this
.
path
.
split
(
"
/
"
);
...
...
@@ -278,7 +280,7 @@
_ref
=
response
.
apis
;
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
endpoint
=
_ref
[
_i
];
this
.
addOperations
(
endpoint
.
path
,
endpoint
.
operations
);
this
.
addOperations
(
endpoint
.
path
,
endpoint
.
operations
,
response
.
consumes
,
response
.
produces
);
}
}
this
.
api
[
this
.
name
]
=
this
;
...
...
@@ -306,14 +308,14 @@
}
};
SwaggerResource
.
prototype
.
addOperations
=
function
(
resource_path
,
ops
)
{
var
consumes
,
method
,
o
,
op
,
produces
,
responseMessages
,
_i
,
_len
,
_results
;
SwaggerResource
.
prototype
.
addOperations
=
function
(
resource_path
,
ops
,
consumes
,
produces
)
{
var
method
,
o
,
op
,
responseMessages
,
type
,
_i
,
_len
,
_results
;
if
(
ops
)
{
_results
=
[];
for
(
_i
=
0
,
_len
=
ops
.
length
;
_i
<
_len
;
_i
++
)
{
o
=
ops
[
_i
];
consumes
=
null
;
produces
=
null
;
consumes
=
this
.
consumes
;
produces
=
this
.
produces
;
if
(
o
.
consumes
!=
null
)
{
consumes
=
o
.
consumes
;
}
else
{
...
...
@@ -324,6 +326,7 @@
}
else
{
produces
=
this
.
produces
;
}
type
=
o
.
type
||
o
.
responseClass
;
responseMessages
=
o
.
responseMessages
;
method
=
o
.
method
;
if
(
o
.
httpMethod
)
{
...
...
@@ -336,7 +339,7 @@
responseMessages
=
o
.
errorResponses
;
}
o
.
nickname
=
this
.
sanitize
(
o
.
nickname
);
op
=
new
SwaggerOperation
(
o
.
nickname
,
resource_path
,
method
,
o
.
parameters
,
o
.
summary
,
o
.
notes
,
o
.
responseClass
,
responseMessages
,
this
,
consumes
,
produces
);
op
=
new
SwaggerOperation
(
o
.
nickname
,
resource_path
,
method
,
o
.
parameters
,
o
.
summary
,
o
.
notes
,
type
,
responseMessages
,
this
,
consumes
,
produces
);
this
.
operations
[
op
.
nickname
]
=
op
;
_results
.
push
(
this
.
operationsArray
.
push
(
op
));
}
...
...
@@ -515,8 +518,8 @@
SwaggerOperation
=
(
function
()
{
function
SwaggerOperation
(
nickname
,
path
,
method
,
parameters
,
summary
,
notes
,
responseClass
,
responseMessages
,
resource
,
consumes
,
produces
)
{
var
parameter
,
type
,
v
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_ref1
,
_ref2
,
function
SwaggerOperation
(
nickname
,
path
,
method
,
parameters
,
summary
,
notes
,
type
,
responseMessages
,
resource
,
consumes
,
produces
)
{
var
parameter
,
v
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_ref1
,
_ref2
,
_this
=
this
;
this
.
nickname
=
nickname
;
this
.
path
=
path
;
...
...
@@ -524,7 +527,7 @@
this
.
parameters
=
parameters
!=
null
?
parameters
:
[];
this
.
summary
=
summary
;
this
.
notes
=
notes
;
this
.
responseClass
=
responseClass
;
this
.
type
=
type
;
this
.
responseMessages
=
responseMessages
;
this
.
resource
=
resource
;
this
.
consumes
=
consumes
;
...
...
@@ -544,12 +547,12 @@
this
.
method
=
this
.
method
.
toLowerCase
();
this
.
isGetMethod
=
this
.
method
===
"
get
"
;
this
.
resourceName
=
this
.
resource
.
name
;
if
(((
_ref
=
this
.
responseClass
)
!=
null
?
_ref
.
toLowerCase
()
:
void
0
)
===
'
void
'
)
{
this
.
responseClass
=
void
0
;
if
(((
_ref
=
this
.
type
)
!=
null
?
_ref
.
toLowerCase
()
:
void
0
)
===
'
void
'
)
{
this
.
type
=
void
0
;
}
if
(
this
.
responseClass
!=
null
)
{
this
.
responseClassSignature
=
this
.
getSignature
(
this
.
responseClass
,
this
.
resource
.
models
);
this
.
responseSampleJSON
=
this
.
getSampleJSON
(
this
.
responseClass
,
this
.
resource
.
models
);
if
(
this
.
type
!=
null
)
{
this
.
responseClassSignature
=
this
.
getSignature
(
this
.
type
,
this
.
resource
.
models
);
this
.
responseSampleJSON
=
this
.
getSampleJSON
(
this
.
type
,
this
.
resource
.
models
);
}
this
.
responseMessages
=
this
.
responseMessages
||
[];
_ref1
=
this
.
parameters
;
...
...
@@ -880,14 +883,14 @@
}
}
responseContentType
=
null
;
if
(
this
.
type
===
"
POST
"
||
this
.
type
===
"
GET
"
||
this
.
type
===
"
PATCH
"
||
this
.
type
===
"
PUT
"
)
{
if
(
this
.
type
===
"
POST
"
||
this
.
type
===
"
GET
"
||
this
.
type
===
"
PATCH
"
)
{
if
(
this
.
opts
.
responseContentType
)
{
re
quest
ContentType
=
this
.
opts
.
re
quest
ContentType
;
re
sponse
ContentType
=
this
.
opts
.
re
sponse
ContentType
;
}
else
{
re
quest
ContentType
=
"
application/json
"
;
re
sponse
ContentType
=
"
application/json
"
;
}
}
else
{
re
quest
ContentType
=
null
;
re
sponse
ContentType
=
null
;
}
if
(
responseContentType
&&
this
.
operation
.
produces
)
{
if
(
this
.
operation
.
produces
.
indexOf
(
responseContentType
)
===
-
1
)
{
...
...
package.json
View file @
205125cd
{
"name"
:
"swagger-ui"
,
"version"
:
"2.0.0
-develop
"
,
"version"
:
"2.0.0"
,
"description"
:
"Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API"
,
"scripts"
:
{
"build"
:
"PATH=$PATH:./node_modules/.bin cake dist"
,
...
...
src/main/coffeescript/view/OperationView.coffee
View file @
205125cd
...
...
@@ -23,7 +23,7 @@ class OperationView extends Backbone.View
responseSignatureView
=
new
SignatureView
({
model
:
signatureModel
,
tagName
:
'div'
})
$
(
'.model-signature'
,
$
(
@
el
)).
append
responseSignatureView
.
render
().
el
else
$
(
'.model-signature'
,
$
(
@
el
)).
html
(
@
model
.
responseClass
)
$
(
'.model-signature'
,
$
(
@
el
)).
html
(
@
model
.
type
)
contentTypeModel
=
isParam
:
false
...
...
src/main/template/operation.handlebars
View file @
205125cd
...
...
@@ -21,7 +21,7 @@
<h4>
Implementation Notes
</h4>
<p>
{{{
notes
}}}
</p>
{{/if}}
{{#if
responseClass
}}
{{#if
type
}}
<h4>
Response Class
</h4>
<p><span
class=
"model-signature"
/></p>
<br/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment