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
2a206b0a
Commit
2a206b0a
authored
Jul 08, 2013
by
Tony Tam
Browse files
renamed discoveryUrl to url to match js change
parent
6a5dfdce
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
dist/index.html
View file @
2a206b0a
...
...
@@ -20,7 +20,7 @@
<script
type=
"text/javascript"
>
$
(
function
()
{
window
.
swaggerUi
=
new
SwaggerUi
({
discoveryU
rl
:
"
http://localhost:8002/api/api-docs
"
,
u
rl
:
"
http://localhost:8002/api/api-docs
"
,
dom_id
:
"
swagger-ui-container
"
,
supportHeaderParams
:
false
,
supportedSubmitMethods
:
[
'
get
'
,
'
post
'
,
'
put
'
,
'
delete
'
],
...
...
dist/lib/swagger.js
View file @
2a206b0a
...
...
@@ -5,7 +5,7 @@
SwaggerApi
=
(
function
()
{
SwaggerApi
.
prototype
.
discoveryU
rl
=
"
http://api.wordnik.com/v4/resources.json
"
;
SwaggerApi
.
prototype
.
u
rl
=
"
http://api.wordnik.com/v4/resources.json
"
;
SwaggerApi
.
prototype
.
debug
=
false
;
...
...
@@ -15,12 +15,21 @@
SwaggerApi
.
prototype
.
authorizationScheme
=
null
;
function
SwaggerApi
(
options
)
{
function
SwaggerApi
(
url
,
options
)
{
if
(
options
==
null
)
{
options
=
{};
}
if
(
options
.
discoveryUrl
!=
null
)
{
this
.
discoveryUrl
=
options
.
discoveryUrl
;
if
(
url
)
{
if
(
url
.
url
)
{
options
=
url
;
}
else
{
this
.
url
=
url
;
}
}
else
{
options
=
url
;
}
if
(
options
.
url
!=
null
)
{
this
.
url
=
options
.
url
;
}
this
.
supportedSubmitMethods
=
options
.
supportedSubmitMethods
!=
null
?
options
.
supportedSubmitMethods
:
[
'
get
'
];
if
(
options
.
success
!=
null
)
{
...
...
@@ -37,21 +46,21 @@
SwaggerApi
.
prototype
.
build
=
function
()
{
var
obj
,
_this
=
this
;
this
.
progress
(
'
fetching resource list:
'
+
this
.
discoveryU
rl
);
console
.
log
(
'
getting
'
+
this
.
discoveryU
rl
);
this
.
progress
(
'
fetching resource list:
'
+
this
.
u
rl
);
console
.
log
(
'
getting
'
+
this
.
u
rl
);
obj
=
{
url
:
this
.
discoveryU
rl
,
url
:
this
.
u
rl
,
method
:
"
get
"
,
on
:
{
error
:
function
(
response
)
{
if
(
_this
.
discoveryU
rl
.
substring
(
0
,
4
)
!==
'
http
'
)
{
return
_this
.
fail
(
'
Please specify the protocol for
'
+
_this
.
discoveryU
rl
);
if
(
_this
.
u
rl
.
substring
(
0
,
4
)
!==
'
http
'
)
{
return
_this
.
fail
(
'
Please specify the protocol for
'
+
_this
.
u
rl
);
}
else
if
(
error
.
status
===
0
)
{
return
_this
.
fail
(
'
Can
\'
t read from server. It may not have the appropriate access-control-origin settings.
'
);
}
else
if
(
error
.
status
===
404
)
{
return
_this
.
fail
(
'
Can
\'
t read swagger JSON from
'
+
_this
.
discoveryU
rl
);
return
_this
.
fail
(
'
Can
\'
t read swagger JSON from
'
+
_this
.
u
rl
);
}
else
{
return
_this
.
fail
(
error
.
status
+
'
:
'
+
error
.
statusText
+
'
'
+
_this
.
discoveryU
rl
);
return
_this
.
fail
(
error
.
status
+
'
:
'
+
error
.
statusText
+
'
'
+
_this
.
u
rl
);
}
},
response
:
function
(
rawResponse
)
{
...
...
@@ -83,10 +92,10 @@
}
else
{
if
(
response
.
basePath
)
{
_this
.
basePath
=
response
.
basePath
;
}
else
if
(
_this
.
discoveryU
rl
.
indexOf
(
'
?
'
)
>
0
)
{
_this
.
basePath
=
_this
.
discoveryU
rl
.
substring
(
0
,
_this
.
discoveryU
rl
.
lastIndexOf
(
'
?
'
));
}
else
if
(
_this
.
u
rl
.
indexOf
(
'
?
'
)
>
0
)
{
_this
.
basePath
=
_this
.
u
rl
.
substring
(
0
,
_this
.
u
rl
.
lastIndexOf
(
'
?
'
));
}
else
{
_this
.
basePath
=
_this
.
discoveryU
rl
;
_this
.
basePath
=
_this
.
u
rl
;
}
_ref2
=
response
.
apis
;
for
(
_k
=
0
,
_len2
=
_ref2
.
length
;
_k
<
_len2
;
_k
++
)
{
...
...
dist/swagger-ui.js
View file @
2a206b0a
...
...
@@ -1384,7 +1384,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
};
SwaggerUi
.
prototype
.
updateSwaggerUi
=
function
(
data
)
{
this
.
options
.
discoveryUrl
=
data
.
discoveryU
rl
;
this
.
options
.
url
=
data
.
u
rl
;
return
this
.
load
();
};
...
...
@@ -1393,7 +1393,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
if
((
_ref
=
this
.
mainView
)
!=
null
)
{
_ref
.
clear
();
}
this
.
headerView
.
update
(
this
.
options
.
discoveryU
rl
);
this
.
headerView
.
update
(
this
.
options
.
u
rl
);
return
this
.
api
=
new
SwaggerApi
(
this
.
options
);
};
...
...
@@ -1469,13 +1469,13 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
HeaderView
.
prototype
.
showPetStore
=
function
(
e
)
{
return
this
.
trigger
(
'
update-swagger-ui
'
,
{
discoveryU
rl
:
"
http://petstore.swagger.wordnik.com/api/api-docs.json
"
u
rl
:
"
http://petstore.swagger.wordnik.com/api/api-docs.json
"
});
};
HeaderView
.
prototype
.
showWordnikDev
=
function
(
e
)
{
return
this
.
trigger
(
'
update-swagger-ui
'
,
{
discoveryU
rl
:
"
http://api.wordnik.com/v4/resources.json
"
u
rl
:
"
http://api.wordnik.com/v4/resources.json
"
});
};
...
...
@@ -1490,7 +1490,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
e
.
preventDefault
();
}
return
this
.
trigger
(
'
update-swagger-ui
'
,
{
discoveryU
rl
:
$
(
'
#input_baseUrl
'
).
val
(),
u
rl
:
$
(
'
#input_baseUrl
'
).
val
(),
apiKey
:
$
(
'
#input_apiKey
'
).
val
()
});
};
...
...
@@ -1503,7 +1503,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
$
(
'
#input_apiKey
'
).
val
(
apiKey
);
if
(
trigger
)
{
return
this
.
trigger
(
'
update-swagger-ui
'
,
{
discoveryU
rl
:
url
,
u
rl
:
url
,
apiKey
:
apiKey
});
}
...
...
dist/swagger-ui.min.js
View file @
2a206b0a
This diff is collapsed.
Click to expand it.
lib/swagger.js
View file @
2a206b0a
...
...
@@ -5,7 +5,7 @@
SwaggerApi
=
(
function
()
{
SwaggerApi
.
prototype
.
discoveryU
rl
=
"
http://api.wordnik.com/v4/resources.json
"
;
SwaggerApi
.
prototype
.
u
rl
=
"
http://api.wordnik.com/v4/resources.json
"
;
SwaggerApi
.
prototype
.
debug
=
false
;
...
...
@@ -15,12 +15,21 @@
SwaggerApi
.
prototype
.
authorizationScheme
=
null
;
function
SwaggerApi
(
options
)
{
function
SwaggerApi
(
url
,
options
)
{
if
(
options
==
null
)
{
options
=
{};
}
if
(
options
.
discoveryUrl
!=
null
)
{
this
.
discoveryUrl
=
options
.
discoveryUrl
;
if
(
url
)
{
if
(
url
.
url
)
{
options
=
url
;
}
else
{
this
.
url
=
url
;
}
}
else
{
options
=
url
;
}
if
(
options
.
url
!=
null
)
{
this
.
url
=
options
.
url
;
}
this
.
supportedSubmitMethods
=
options
.
supportedSubmitMethods
!=
null
?
options
.
supportedSubmitMethods
:
[
'
get
'
];
if
(
options
.
success
!=
null
)
{
...
...
@@ -37,21 +46,21 @@
SwaggerApi
.
prototype
.
build
=
function
()
{
var
obj
,
_this
=
this
;
this
.
progress
(
'
fetching resource list:
'
+
this
.
discoveryU
rl
);
console
.
log
(
'
getting
'
+
this
.
discoveryU
rl
);
this
.
progress
(
'
fetching resource list:
'
+
this
.
u
rl
);
console
.
log
(
'
getting
'
+
this
.
u
rl
);
obj
=
{
url
:
this
.
discoveryU
rl
,
url
:
this
.
u
rl
,
method
:
"
get
"
,
on
:
{
error
:
function
(
response
)
{
if
(
_this
.
discoveryU
rl
.
substring
(
0
,
4
)
!==
'
http
'
)
{
return
_this
.
fail
(
'
Please specify the protocol for
'
+
_this
.
discoveryU
rl
);
if
(
_this
.
u
rl
.
substring
(
0
,
4
)
!==
'
http
'
)
{
return
_this
.
fail
(
'
Please specify the protocol for
'
+
_this
.
u
rl
);
}
else
if
(
error
.
status
===
0
)
{
return
_this
.
fail
(
'
Can
\'
t read from server. It may not have the appropriate access-control-origin settings.
'
);
}
else
if
(
error
.
status
===
404
)
{
return
_this
.
fail
(
'
Can
\'
t read swagger JSON from
'
+
_this
.
discoveryU
rl
);
return
_this
.
fail
(
'
Can
\'
t read swagger JSON from
'
+
_this
.
u
rl
);
}
else
{
return
_this
.
fail
(
error
.
status
+
'
:
'
+
error
.
statusText
+
'
'
+
_this
.
discoveryU
rl
);
return
_this
.
fail
(
error
.
status
+
'
:
'
+
error
.
statusText
+
'
'
+
_this
.
u
rl
);
}
},
response
:
function
(
rawResponse
)
{
...
...
@@ -83,10 +92,10 @@
}
else
{
if
(
response
.
basePath
)
{
_this
.
basePath
=
response
.
basePath
;
}
else
if
(
_this
.
discoveryU
rl
.
indexOf
(
'
?
'
)
>
0
)
{
_this
.
basePath
=
_this
.
discoveryU
rl
.
substring
(
0
,
_this
.
discoveryU
rl
.
lastIndexOf
(
'
?
'
));
}
else
if
(
_this
.
u
rl
.
indexOf
(
'
?
'
)
>
0
)
{
_this
.
basePath
=
_this
.
u
rl
.
substring
(
0
,
_this
.
u
rl
.
lastIndexOf
(
'
?
'
));
}
else
{
_this
.
basePath
=
_this
.
discoveryU
rl
;
_this
.
basePath
=
_this
.
u
rl
;
}
_ref2
=
response
.
apis
;
for
(
_k
=
0
,
_len2
=
_ref2
.
length
;
_k
<
_len2
;
_k
++
)
{
...
...
src/main/coffeescript/SwaggerUi.coffee
View file @
2a206b0a
...
...
@@ -34,14 +34,14 @@ class SwaggerUi extends Backbone.Router
# Event handler for when url/key is received from user
updateSwaggerUi
:
(
data
)
->
@
options
.
discoveryUrl
=
data
.
discoveryU
rl
@
options
.
url
=
data
.
u
rl
@
load
()
# Create an api and render
load
:
->
# Initialize the API object
@
mainView
?
.
clear
()
@
headerView
.
update
(
@
options
.
discoveryU
rl
)
@
headerView
.
update
(
@
options
.
u
rl
)
@
api
=
new
SwaggerApi
(
@
options
)
# This is bound to success handler for SwaggerApi
...
...
src/main/coffeescript/view/HeaderView.coffee
View file @
2a206b0a
...
...
@@ -12,13 +12,13 @@ class HeaderView extends Backbone.View
showPetStore
:
(
e
)
->
@
trigger
(
'update-swagger-ui'
{
discoveryU
rl
:
"http://petstore.swagger.wordnik.com/api/api-docs.json"
}
{
u
rl
:
"http://petstore.swagger.wordnik.com/api/api-docs.json"
}
)
showWordnikDev
:
(
e
)
->
@
trigger
(
'update-swagger-ui'
{
discoveryU
rl
:
"http://api.wordnik.com/v4/resources.json"
}
{
u
rl
:
"http://api.wordnik.com/v4/resources.json"
}
)
showCustomOnKeyup
:
(
e
)
->
...
...
@@ -28,10 +28,10 @@ class HeaderView extends Backbone.View
e
?
.
preventDefault
()
@
trigger
(
'update-swagger-ui'
{
discoveryU
rl
:
$
(
'#input_baseUrl'
).
val
(),
apiKey
:
$
(
'#input_apiKey'
).
val
()}
{
u
rl
:
$
(
'#input_baseUrl'
).
val
(),
apiKey
:
$
(
'#input_apiKey'
).
val
()}
)
update
:
(
url
,
apiKey
,
trigger
=
false
)
->
$
(
'#input_baseUrl'
).
val
url
$
(
'#input_apiKey'
).
val
apiKey
@
trigger
'update-swagger-ui'
,
{
discoveryU
rl
:
url
,
apiKey
:
apiKey
}
if
trigger
@
trigger
'update-swagger-ui'
,
{
u
rl
:
url
,
apiKey
:
apiKey
}
if
trigger
src/main/html/index.html
View file @
2a206b0a
...
...
@@ -20,7 +20,7 @@
<script
type=
"text/javascript"
>
$
(
function
()
{
window
.
swaggerUi
=
new
SwaggerUi
({
discoveryU
rl
:
"
http://localhost:8002/api/api-docs
"
,
u
rl
:
"
http://localhost:8002/api/api-docs
"
,
dom_id
:
"
swagger-ui-container
"
,
supportHeaderParams
:
false
,
supportedSubmitMethods
:
[
'
get
'
,
'
post
'
,
'
put
'
,
'
delete
'
],
...
...
src/test/swagger-ui-spec.coffee
View file @
2a206b0a
window
.
api_key
=
'a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5'
window
.
discoveryUrl
=
"http://api.wordnik.com/v4/resources.json"
window
.
url
=
"http://api.wordnik.com/v4/resources.json"
describe
'SwaggerUi'
,
->
...
...
@@ -8,7 +7,7 @@ describe 'SwaggerUi', ->
beforeEach
->
window
.
ui
=
new
SwaggerUi
api_key
:
window
.
api_key
discoveryU
rl
:
window
.
discoveryU
rl
u
rl
:
window
.
u
rl
waitsFor
->
ui
.
ready
...
...
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