Compare commits

...
80 Commits
Author SHA1 Message Date
Kyle Shockey b289d5992a MOAR deploy fixes 2017-04-21 21:43:24 -07:00
Kyle Shockey 5573f4d32d Skip cleanup on script deploy 2017-04-21 20:06:01 -07:00
Kyle Shockey d6c498b5f3 Fix shell script error 2017-04-21 20:04:57 -07:00
shockey a600280441 Merge pull request #2956 from shockey/v/3.0.7
v3.0.7
2017-04-21 19:56:20 -07:00
Kyle Shockey 0f95724829 v3.0.7 2017-04-21 19:52:06 -07:00
shockey 5ae195074f Merge pull request #2955 from shockey/ft/swagger-ui-dist
Publish swagger-ui-dist npm module
2017-04-21 19:10:19 -07:00
Kyle Shockey f5137da130 Update readme 2017-04-21 19:07:30 -07:00
Kyle Shockey 2bc6c5aa75 Revert git commit hash changes (mistake) 2017-04-21 19:04:25 -07:00
Kyle Shockey 51dac3eea1 Rebuild dist 2017-04-21 19:02:56 -07:00
Kyle Shockey 10b5c8ef8b Remove build files after dist build 2017-04-21 18:43:11 -07:00
Kyle Shockey e871871724 Add build setup for swagger-ui-dist 2017-04-21 18:37:40 -07:00
Tony Tam a6a02997e5 Merge pull request #2950 from redsux/issue-2936
Fix issue #2936 : docker and VALIDATOR_URL variable
2017-04-21 11:04:02 -07:00
Tony Tam 58e29934fd Merge branch 'master' into issue-2936 2017-04-21 08:58:03 -07:00
Anna e0ecffd7c1 Merge pull request #2952 from bodnia/issue-2929-fix
fixes #2929
2017-04-21 12:47:45 +02:00
Anna Bodnia 5a260971cc fixes #2929 2017-04-21 13:29:18 +03:00
redsux 037dc71197 Merge branch 'master' into issue-2936 2017-04-21 11:02:51 +02:00
redsux adf9f2d8aa Fix issue #2936
Fix "sed" regex in docker-run.sh to use the VALIDATOR_URL environment variable.
Don't use it in quotes if it's defined to "null" or "undefined".
2017-04-21 10:58:50 +02:00
Kyle Shockey 06c82bb325 Add message that reveals commit that SwaggerUI was derived from 2017-04-20 17:11:54 -07:00
Anna 6cd66bb4f9 Merge pull request #2942 from bodnia/issue-2890
fixes #2890
2017-04-20 22:48:06 +02:00
Anna Bodnia 4e238ce889 fixes #2890 2017-04-20 23:38:49 +03:00
Anna 1418653144 Merge pull request #2940 from bodnia/issue-2881
fixes #2881
2017-04-20 19:47:39 +02:00
Anna Bodnia ca048f42a4 fixes #2881 2017-04-20 20:40:56 +03:00
Anna 26a3ed26e8 Merge pull request #2938 from bodnia/issue-2929
fixes #2929
2017-04-20 18:57:39 +02:00
Anna Bodnia 84b408849d fixes #2929 2017-04-20 19:54:14 +03:00
Anna 7790383ba6 Merge pull request #2924 from bodnia/config-operationsSorter
operationsSorter config
2017-04-19 10:44:25 +02:00
Anna Bodnia 32d7cd7204 build 2017-04-19 11:39:28 +03:00
Anna Bodnia 4963c3016c merge 2017-04-19 11:28:35 +03:00
shockey 0e00a68f7f Merge pull request #2927 from shockey/bug/2919-relative-spec-infer-scheme
Infer scheme with relative-path specs
2017-04-18 19:58:41 -07:00
shockey 754d57396a Merge branch 'master' into bug/2919-relative-spec-infer-scheme 2017-04-18 19:55:29 -07:00
Kyle Shockey db66f56b83 Rebuild dist 2017-04-18 19:51:58 -07:00
Kyle Shockey 8e5be08992 Bump swagger-client 2017-04-18 19:48:19 -07:00
Kyle Shockey 40d7740779 Rebuild dist 2017-04-18 18:16:32 -07:00
Kyle Shockey 8b78d9bd13 Default to no scheme if we can't find an assigned scheme 2017-04-18 18:13:52 -07:00
Kyle Shockey 5fc064e2ac Reorganize tests 2017-04-18 15:08:36 -07:00
shockey f36a66a1b1 Merge pull request #2925 from shockey/bug/2918-null-operations
Add deep access guard to operation update reducer
2017-04-18 11:29:50 -07:00
shockey d5b79c70c9 Merge branch 'master' into bug/2918-null-operations 2017-04-18 11:25:26 -07:00
Kyle Shockey 35769f9b47 Fix #2918; add control/test tests 2017-04-18 11:20:15 -07:00
Anna Bodnia 8e64c866e8 operationsSorter config 2017-04-18 19:06:15 +03:00
Tony Tam 4b984e3c42 Merge pull request #2920 from swagger-api/issue-fix-travis
push tag version
2017-04-17 01:40:40 -04:00
Tony Tam 1794de1679 push tag version 2017-04-16 22:34:58 -07:00
Kyle Shockey db8bd52f16 v3.0.6 2017-04-14 21:08:42 -07:00
Kyle Shockey 7172ed6fe9 Rebuild dist 2017-04-14 21:05:22 -07:00
Kyle Shockey 48e0cb10b5 Revert "Fix bug where reducer dies on empty operation"
This reverts commit 08b3c38b8a.
2017-04-14 21:00:56 -07:00
Kyle Shockey bedd509a4a Rebuild dist 2017-04-14 20:19:13 -07:00
shockey c6279e5f25 Merge pull request #2917 from shockey/ft/base-layout
Base layout
2017-04-14 19:07:21 -07:00
Kyle Shockey 81f74d9d51 Move loadingStatus code into StandaloneLayout (where it belongs!) 2017-04-14 19:01:57 -07:00
Kyle Shockey 208694e9a8 Fix linter & tests 2017-04-14 18:46:27 -07:00
Kyle Shockey ba7a1369b8 Dist rebuild 2017-04-14 18:41:34 -07:00
Kyle Shockey d1d663b35f Consume BaseLayout in UI standalone 2017-04-14 18:39:31 -07:00
Kyle Shockey cf80839d11 Add BaseLayout to core 2017-04-14 18:38:59 -07:00
Kyle Shockey de92f8deb4 Merge branch 'master' of github.com:swagger-api/swagger-ui 2017-04-14 18:22:29 -07:00
Kyle Shockey 99b8543562 Merge branch 'show_readonly_values_in_responses' of https://github.com/furkanayhan/swagger-ui into furkanayhan-show_readonly_values_in_responses 2017-04-14 18:21:44 -07:00
Tony Tam ef60fb07a4 added push 2017-04-14 17:35:09 -07:00
Kyle Shockey c45e5a3158 Rebuild dist 2017-04-14 17:16:25 -07:00
Kyle Shockey 08b3c38b8a Fix bug where reducer dies on empty operation 2017-04-14 17:15:27 -07:00
shockey c7ae644c96 Merge pull request #2912 from shockey/bug/2904-try-it-out
Fix inferring issues with Try-It-Out
2017-04-14 16:42:04 -07:00
Tony Tam 283722a20e added push 2017-04-14 14:36:29 -07:00
Tony Tam 89adefe392 Merge pull request #2916 from swagger-api/feature/docker-tag-fix
Feature/docker tag fix
2017-04-14 17:28:20 -04:00
Tony Tam 205197d04f fixed variable 2017-04-14 14:19:52 -07:00
Tony Tam 74008954c3 update tag logic to latest and unstable 2017-04-14 14:13:11 -07:00
Tony Tam 2b159372a9 removed dead line 2017-04-14 14:12:55 -07:00
Kyle Shockey 5be31ac909 Pass around contextUrl correctly 2017-04-13 19:24:02 -07:00
Kyle Shockey fce0916dca Merge branch 'bug/2760-infer-host' into bug/2904-try-it-out 2017-04-13 19:12:39 -07:00
Kyle Shockey 4c1a5488bb Parse spec url when deciding scheme for operation 2017-04-13 17:26:47 -07:00
Furkan Ayhan 2e91ab0a2e Add react-test-renderer as devDependencies 2017-04-13 16:36:35 +03:00
Furkan Ayhan 6965a496fb Show readOnly values in responses 2017-04-13 16:01:29 +03:00
Tony Tam e33efa1b36 Merge pull request #2901 from swagger-api/feature/docker-config
added variables for docker
2017-04-11 17:07:26 -04:00
Tony Tam 3ce9baee30 added variables for docker 2017-04-11 13:59:34 -07:00
Tony Tam 1f424afe0f Merge pull request #2900 from swagger-api/issue-2899
updated docker push logic
2017-04-11 16:48:59 -04:00
Tony Tam 4da6126d10 Merge branch 'master' into issue-2899 2017-04-11 16:43:13 -04:00
Tony Tam 9465d1251b updated docker push logic 2017-04-11 13:42:26 -07:00
shockey f7c5515dff Merge pull request #2894 from shockey/bug/2763-malformed-security-render-error
Protect AuthorizeOperationBtn from malformed security values
2017-04-10 14:03:49 -07:00
shockey 44ea2773cf Merge branch 'master' into bug/2763-malformed-security-render-error 2017-04-10 13:58:48 -07:00
Kyle Shockey 3c98939732 Fix name masking for render error messages 2017-04-10 13:58:18 -07:00
Kyle Shockey f2ae188722 Fix #2763 2017-04-10 13:50:51 -07:00
shockey 5e571fac51 Merge pull request #2821 from jeffweeksio/master
Update utils.js to allow negative numbers
2017-04-10 11:29:25 -07:00
shockey 8e60343417 Merge branch 'master' into master 2017-04-10 11:21:23 -07:00
Kyle Shockey e2b1757f8f Infer contextUrl through documentation scheme + host if spec url is relative 2017-04-07 20:51:07 -07:00
Jeff Weeks 2535758adf Merge branch 'master' into master 2017-04-04 14:26:48 -04:00
Jeff Weeks 2a6ecb2d38 Update utils.js 2017-03-29 16:30:25 -04:00
41 changed files with 501 additions and 187 deletions
+34 -16
View File
@@ -7,26 +7,44 @@ branches:
only:
- master
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
before_deploy: "npm run build-core"
before_deploy:
- npm run build
env:
- DOCKER_IMAGE_NAME=swaggerapi/swagger-ui
deploy:
provider: npm
email: apiteam@swagger.io
skip_cleanup: true
api_key:
secure: "IJkLaACa+rfERf1O5nwlqOyuo9sbul3FBhBt4Un9P+DvEet3AoDPV9NQVLd8SkmQYKGbGQWF4BIdjrO5nqFD6Te+JTeUX5Uo/DFS/fu9qw1xv0dQpvbJFuoYnnFlbzGTEs4CFa8lbu3ZromFHQGOQxRobjsG1Kf0dWFSSzmND3g="
on:
tags: true
repo: swagger-api/swagger-ui
node: '6.9'
- provider: npm
email: apiteam@swagger.io
skip_cleanup: true
api_key:
secure: "IJkLaACa+rfERf1O5nwlqOyuo9sbul3FBhBt4Un9P+DvEet3AoDPV9NQVLd8SkmQYKGbGQWF4BIdjrO5nqFD6Te+JTeUX5Uo/DFS/fu9qw1xv0dQpvbJFuoYnnFlbzGTEs4CFa8lbu3ZromFHQGOQxRobjsG1Kf0dWFSSzmND3g="
on:
tags: true
repo: swagger-api/swagger-ui
node: '6.9'
- provider: script
skip_cleanup: true
script: swagger-ui-dist-package/deploy.sh
on:
tags: true
repo: swagger-api/swagger-ui
node: '6.9'
after_success:
- if [ $DOCKER_HUB_USERNAME ]; then
- if [ $DOCKER_HUB_USERNAME ]; then
docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD;
docker build -t $DOCKER_IMAGE_NAME .;
if [ "$TRAVIS_TAG" != "master" && -z "$TRAVIS_TAG"]; then
docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:$TRAVIS_TAG;
fi;
docker push $DOCKER_IMAGE_NAME;
if [ ! -z "$TRAVIS_TAG" ]; then
DOCKER_IMAGE_TAG=$TRAVIS_TAG;
else
DOCKER_IMAGE_TAG=unstable;
fi;
docker build -t $DOCKER_IMAGE_NAME .;
if [ ! -z "$TRAVIS_TAG" ]; then
docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
docker push $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:latest;
docker push $DOCKER_IMAGE_NAME:latest;
else
docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
docker push $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
fi;
fi;
+14 -1
View File
@@ -2,6 +2,18 @@ FROM alpine:3.4
MAINTAINER fehguy
ENV VERSION "v2.2.10"
ENV FOLDER "swagger-ui-2.2.10"
ENV API_URL "http://petstore.swagger.io/v2/swagger.json"
ENV API_KEY "**None**"
ENV OAUTH_CLIENT_ID "**None**"
ENV OAUTH_CLIENT_SECRET "**None**"
ENV OAUTH_REALM "**None**"
ENV OAUTH_APP_NAME "**None**"
ENV OAUTH_ADDITIONAL_PARAMS "**None**"
ENV SWAGGER_JSON "/app/swagger.json"
ENV PORT 80
RUN apk add --update nginx
RUN mkdir -p /run/nginx
@@ -9,7 +21,8 @@ COPY nginx.conf /etc/nginx/
# copy swagger files to the `/js` folder
ADD ./dist/* /usr/share/nginx/html/
ADD ./docker-run.sh /usr/share/nginx/
EXPOSE 8080
CMD exec nginx -g 'daemon off;'
CMD ["sh", "/usr/share/nginx/docker-run.sh"]
+4 -2
View File
@@ -15,7 +15,7 @@ The OpenAPI Specification has undergone 4 revisions since initial creation in 20
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
------------------ | ------------ | -------------------------- | ----- | ------
3.0.5 | 2017-03-19 | 2.0 | [tag v3.0.5](https://github.com/swagger-api/swagger-ui/tree/v3.0.5) |
3.0.7 | 2017-03-19 | 2.0 | [tag v3.0.7](https://github.com/swagger-api/swagger-ui/tree/v3.0.7) |
2.2.10 | 2017-01-04 | 1.1, 1.2, 2.0 | [tag v2.2.10](https://github.com/swagger-api/swagger-ui/tree/v2.2.10) |
2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5) |
2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) |
@@ -58,7 +58,7 @@ To help with the migration, here are the currently known issues with 3.X. This l
- Relative path support for external files is not implemented.
### SwaggerUIBundle
To use swagger-ui you should take a look at the [source of swagger-ui html page](https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html) and customize it. This basically requires you to instantiate a SwaggerUi object and call load() on it as below:
To use swagger-ui's bundles, you should take a look at the [source of swagger-ui html page](https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html) and customize it. This basically requires you to instantiate a SwaggerUi object as below:
```javascript
const ui = SwaggerUIBundle({
@@ -75,6 +75,8 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
})
```
If you'd like to use the bundle files via npm, check out the [`swagger-ui-dist` package](npmjs.com/package/swagger-ui-dist).
#### Parameters
Parameter Name | Description
+1 -1
View File
@@ -90,4 +90,4 @@ window.onload = function() {
</script>
</body>
</html>
</html>
+41 -41
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0dA;;;;;;AAoIA;AAk7FA;AAmtCA;;;;;AA0uIA;AA66IA;AA27FA;AAuwGA;AAilFA;AAikFA;AAs9CA;AA8jDA;AA2qCA;AA4tEA;AAgkIA;;;;;;;;;;;;;;AAw4GA;AAyoIA;AAiuJA;AA8kHA;AAonGA;AAukEA;AA02DA;AAyxDA;AAw6BA;;;;;;AA8vEA;AA+zFA;;;;;AA23CA;AA2qFA;AAq2CA;AA0kCA;AAs/CA;AA0wEA;AA49FA;;;;;;;;;AA20BA;AA2zIA;AAi4DA;AA6tDA","sourceRoot":""}
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0dA;;;;;;AAoIA;AAk7FA;AAmtCA;;;;;AA0uIA;AA+4IA;AAm9FA;AA2rGA;AA8lFA;AA2nFA;AAu9CA;AAyhDA;AAqrCA;AAy4EA;AA8/GA;;;;;;;;;;;;;;AA+mJA;AA4mIA;AAquJA;AAwsHA;AAinGA;AAmiEA;AAy4DA;AAm2DA;AA0nBA;;;;;;AA4iFA;AAk0FA;;;;;AA23CA;AA2qFA;AAw2CA;AAglCA;AA0/CA;AAykFA;AA+1FA;;;;;;;;;AAk4CA;AA2zIA;AAk4DA;AAolDA","sourceRoot":""}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA2SA;AAyiGA","sourceRoot":""}
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA4QA;AAitGA","sourceRoot":""}
+1 -1
View File
File diff suppressed because one or more lines are too long
+9 -9
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAuwCA;AAoyHA;AA2wHA;AA07FA;AA+nCA;AAohCA;AAghCA;AAk4BA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AA4wCA;AAoyHA;AAuxHA;AAy4FA;AA8rCA;AAugCA;AA+hCA;AA24BA","sourceRoot":""}
+48
View File
@@ -0,0 +1,48 @@
#! /bin/sh
set -e
INDEX_FILE=/usr/share/nginx/html/index.html
replace_in_index () {
if [ "$1" != "**None**" ]; then
sed -i "s|/\*||g" $INDEX_FILE
sed -i "s|\*/||g" $INDEX_FILE
sed -i "s|$1|$2|g" $INDEX_FILE
fi
}
replace_or_delete_in_index () {
if [ -z "$2" ]; then
sed -i "/$1/d" $INDEX_FILE
else
replace_in_index $1 $2
fi
}
replace_in_index myApiKeyXXXX123456789 $API_KEY
replace_or_delete_in_index your-client-id $OAUTH_CLIENT_ID
replace_or_delete_in_index your-client-secret-if-required $OAUTH_CLIENT_SECRET
replace_or_delete_in_index your-realms $OAUTH_REALM
replace_or_delete_in_index your-app-name $OAUTH_APP_NAME
if [ "$OAUTH_ADDITIONAL_PARAMS" != "**None**" ]; then
replace_in_index "additionalQueryStringParams: {}" "additionalQueryStringParams: {$OAUTH_ADDITIONAL_PARAMS}"
fi
if [[ -f $SWAGGER_JSON ]]; then
sed -i "s|http://petstore.swagger.io/v2/swagger.json|swagger.json|g" $INDEX_FILE
sed -i "s|http://example.com/api|swagger.json|g" $INDEX_FILE
else
sed -i "s|http://petstore.swagger.io/v2/swagger.json|$API_URL|g" $INDEX_FILE
sed -i "s|http://example.com/api|$API_URL|g" $INDEX_FILE
fi
if [[ -n "$VALIDATOR_URL" ]]; then
sed -i "s|.*validatorUrl:.*$||g" $INDEX_FILE
TMP_VU="$VALIDATOR_URL"
[[ "$VALIDATOR_URL" != "null" && "$VALIDATOR_URL" != "undefined" ]] && TMP_VU="\"${VALIDATOR_URL}\""
sed -i "s|\(url: .*,\)|\1\n validatorUrl: ${TMP_VU},|g" $INDEX_FILE
unset TMP_VU
fi
exec nginx -g 'daemon off;'
+1 -1
View File
@@ -59,7 +59,7 @@ module.exports = function(options) {
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: specialOptions.minimize ? JSON.stringify('production') : null,
WEBPACK_INLINE_STYLES: !Boolean(specialOptions.separateStylesheets)
WEBPACK_INLINE_STYLES: !Boolean(specialOptions.separateStylesheets)
},
}))
+4 -2
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.0.5",
"version": "3.0.7",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -67,7 +67,8 @@
"reselect": "2.5.3",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "^3.0.5",
"swagger-client": "^3.0.7",
"url-parse": "^1.1.8",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",
"xml": "1.0.1",
@@ -111,6 +112,7 @@
"postcss-loader": "0.7.0",
"raw-loader": "0.5.1",
"react-hot-loader": "^1.3.1",
"react-test-renderer": "^15.5.4",
"rimraf": "^2.6.0",
"sass-loader": "^6.0.2",
"standard": "^8.6.0",
+4 -5
View File
@@ -64,11 +64,10 @@ export default class ApiKeyAuth extends React.Component {
</Row>
<Row>
<label>Value:</label>
<Col>
{
value || <Input type="text" onChange={ this.onChange }/>
}
</Col>
{
value ? <code> ****** </code>
: <Col><Input type="text" onChange={ this.onChange }/></Col>
}
</Row>
{
errors.valueSeq().map( (error, key) => {
@@ -16,6 +16,10 @@ export default class AuthorizeOperationBtn extends React.Component {
let isAuthorized = authSelectors.isAuthorized(security)
if(isAuthorized === null) {
return null
}
return (
<button className={isAuthorized ? "authorization__btn locked" : "authorization__btn unlocked"} onClick={ this.onClick }>
<svg width="20" height="20">
+14 -10
View File
@@ -63,19 +63,23 @@ export default class BasicAuth extends React.Component {
source={ schema.get("description") } />
</Row>
<Row>
<Col tablet={2} desktop={2}>username:</Col>
<Col tablet={10} desktop={10}>
<label>Username:</label>
{
username ? <code> { username } </code>
: <Col><Input type="text" required="required" name="username" onChange={ this.onChange }/></Col>
}
</Row>
<Row>
<label>Password:</label>
{
username || <Input type="text" required="required" name="username" onChange={ this.onChange }/>
username ? <code> ****** </code>
: <Col><Input required="required"
autoComplete="new-password"
name="password"
type="password"
onChange={ this.onChange }/></Col>
}
</Col>
</Row>
{
!username && <Row>
<Col tablet={2} desktop={2}>password:</Col>
<Col tablet={10} desktop={10}><Input required="required" autoComplete="new-password" name="password" type="password" onChange={ this.onChange }/></Col>
</Row>
}
{
errors.valueSeq().map( (error, key) => {
return <AuthError error={ error }
+13 -12
View File
@@ -148,26 +148,27 @@ export default class Oauth2 extends React.Component {
( flow === APPLICATION || flow === IMPLICIT || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) &&
( !isAuthorized || isAuthorized && this.state.clientId) && <Row>
<label htmlFor="client_id">client_id:</label>
<Col tablet={10} desktop={10}>
{
isAuthorized ? <span>{ this.state.clientId }</span>
: <input id="client_id" type="text" required={ flow === PASSWORD } data-name="clientId"
{
isAuthorized ? <code> ****** </code>
: <Col tablet={10} desktop={10}>
<input id="client_id" type="text" required={ flow === PASSWORD } data-name="clientId"
onChange={ this.onInputChange }/>
}
</Col>
</Col>
}
</Row>
}
{
( flow === APPLICATION || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) && <Row>
<label htmlFor="client_secret">client_secret:</label>
<Col tablet={10} desktop={10}>
{
isAuthorized ? <span>{ this.state.clientSecret }</span>
: <input id="client_secret" type="text" data-name="clientSecret"
{
isAuthorized ? <code> ****** </code>
: <Col tablet={10} desktop={10}>
<input id="client_secret" type="text" data-name="clientSecret"
onChange={ this.onInputChange }/>
}
</Col>
</Col>
}
</Row>
}
+80
View File
@@ -0,0 +1,80 @@
import React, { PropTypes } from "react"
export default class BaseLayout extends React.Component {
static propTypes = {
errSelectors: PropTypes.object.isRequired,
errActions: PropTypes.object.isRequired,
specActions: PropTypes.object.isRequired,
specSelectors: PropTypes.object.isRequired,
layoutSelectors: PropTypes.object.isRequired,
layoutActions: PropTypes.object.isRequired,
getComponent: PropTypes.func.isRequired
}
render() {
let { specSelectors, specActions, getComponent } = this.props
let info = specSelectors.info()
let url = specSelectors.url()
let basePath = specSelectors.basePath()
let host = specSelectors.host()
let securityDefinitions = specSelectors.securityDefinitions()
let externalDocs = specSelectors.externalDocs()
let schemes = specSelectors.schemes()
let Info = getComponent("info")
let Operations = getComponent("operations", true)
let Models = getComponent("models", true)
let AuthorizeBtn = getComponent("authorizeBtn", true)
let Row = getComponent("Row")
let Col = getComponent("Col")
let Errors = getComponent("errors", true)
const Schemes = getComponent("schemes")
const isSpecEmpty = !specSelectors.specStr()
if(isSpecEmpty) {
return <h4>No spec provided.</h4>
}
return (
<div className='swagger-ui'>
<div>
<Errors/>
<Row className="information-container">
<Col mobile={12}>
{ info.count() ? (
<Info info={ info } url={ url } host={ host } basePath={ basePath } externalDocs={externalDocs} getComponent={getComponent}/>
) : null }
</Col>
</Row>
{ schemes && schemes.size || securityDefinitions ? (
<div className="scheme-container">
<Col className="schemes wrapper" mobile={12}>
{ schemes && schemes.size ? (
<Schemes schemes={ schemes } specActions={ specActions } />
) : null }
{ securityDefinitions ? (
<AuthorizeBtn />
) : null }
</Col>
</div>
) : null }
<Row>
<Col mobile={12} desktop={12} >
<Operations/>
</Col>
</Row>
<Row>
<Col mobile={12} desktop={12} >
<Models/>
</Col>
</Row>
</div>
</div>
)
}
}
+4 -3
View File
@@ -55,9 +55,10 @@ export default class ParamBody extends Component {
let isXml = /xml/i.test(consumesValue)
let paramValue = isXml ? parameter.get("value_xml") : parameter.get("value")
if ( paramValue ) {
this.setState({ value: paramValue })
this.onChange(paramValue, {isXml: isXml, isEditBox: isExecute})
if ( paramValue !== undefined ) {
let val = !paramValue && !isXml ? "{}" : paramValue
this.setState({ value: val })
this.onChange(val, {isXml: isXml, isEditBox: isExecute})
} else {
if (isXml) {
this.onChange(this.sample("xml"), {isXml: isXml, isEditBox: isExecute})
+1 -1
View File
@@ -13,7 +13,7 @@ module.exports = function SwaggerUI(opts) {
dom_id: null,
spec: {},
url: "",
layout: "Layout",
layout: "BaseLayout",
validatorUrl: "https://online.swagger.io/validator",
configs: {
},
+3 -3
View File
@@ -150,9 +150,9 @@ export class JsonSchema_array extends Component {
(errors.length ? <span style={{ color: "red", fortWeight: "bold" }}>{ errors[0] }</span> : null) :
value.map( (item,i) => {
let schema = Object.assign({}, itemSchema)
let err = errors.filter((err) => err.index === i)
if ( err.length ) {
schema.errors = [ err[0].error + i ]
if ( errors.length ) {
let err = errors.filter((err) => err.index === i)
if (err.length) schema.errors = [ err[0].error + i ]
}
return (
<div key={i} className="json-schema-form-item">
+2 -1
View File
@@ -1,11 +1,12 @@
import win from "core/window"
import { btoa } from "core/utils"
export default function authorize ( auth, authActions, errActions, configs ) {
let { schema, scopes, name, clientId } = auth
let redirectUrl = configs.oauth2RedirectUrl
let scopeSeparator = " "
let state = name
let state = btoa(new Date())
let flow = schema.get("flow")
let url
+4
View File
@@ -67,6 +67,10 @@ export const authorized = createSelector(
export const isAuthorized = ( state, securities ) =>( { authSelectors } ) => {
let authorized = authSelectors.authorized()
if(!List.isList(securities)) {
return null
}
return !!securities.toJS().filter( ( security ) => {
let isAuthorized = true
+3 -3
View File
@@ -47,7 +47,7 @@ export const sampleFromSchema = (schema, config={}) => {
let obj = {}
for (var name in props) {
if ( !props[name].readOnly || includeReadOnly ) {
obj[name] = sampleFromSchema(props[name])
obj[name] = sampleFromSchema(props[name], { includeReadOnly: includeReadOnly })
}
}
@@ -55,7 +55,7 @@ export const sampleFromSchema = (schema, config={}) => {
obj.additionalProp1 = {}
} else if ( additionalProperties ) {
let additionalProps = objectify(additionalProperties)
let additionalPropVal = sampleFromSchema(additionalProps)
let additionalPropVal = sampleFromSchema(additionalProps, { includeReadOnly: includeReadOnly })
for (let i = 1; i < 4; i++) {
obj["additionalProp" + i] = additionalPropVal
@@ -65,7 +65,7 @@ export const sampleFromSchema = (schema, config={}) => {
}
if(type === "array") {
return [ sampleFromSchema(items) ]
return [ sampleFromSchema(items, { includeReadOnly: includeReadOnly }) ]
}
if(schema["enum"]) {
+6 -1
View File
@@ -1,4 +1,5 @@
import YAML from "js-yaml"
import parseUrl from "url-parse"
import serializeError from "serialize-error"
// Actions conform to FSA (flux-standard-actions)
@@ -186,7 +187,11 @@ export const logRequest = (req) => {
// (For debugging) and ease of testing
export const executeRequest = (req) => ({fn, specActions, specSelectors}) => {
let { pathName, method } = req
let parsedRequest = Object.assign({ contextUrl: specSelectors.url() }, req)
// if url is relative, parseUrl makes it absolute by inferring from `window.location`
req.contextUrl = parseUrl(specSelectors.url()).toString()
let parsedRequest = Object.assign({}, req)
if ( pathName && method ) {
parsedRequest.operationId = method.toLowerCase() + "-" + pathName
}
+5 -1
View File
@@ -97,7 +97,11 @@ export default {
},
[UPDATE_OPERATION_VALUE]: (state, { payload: { path, value, key } }) => {
return state.setIn(["resolved", "paths", ...path, key], fromJS(value))
let operationPath = ["resolved", "paths", ...path]
if(!state.getIn(operationPath)) {
return state
}
return state.setIn([...operationPath, key], fromJS(value))
},
[CLEAR_RESPONSE]: (state, { payload: { path, method } } ) =>{
+16 -8
View File
@@ -1,4 +1,5 @@
import { createSelector } from "reselect"
import { sorters } from "core/utils"
import { fromJS, Set, Map, List } from "immutable"
const DEFAULT_TAG = "default"
@@ -198,13 +199,16 @@ export const operationsWithTags = createSelector(
}
)
export const taggedOperations = createSelector(
state,
operationsWithTags,
(state, tagMap) => {
return tagMap.map((ops, tag) => Map({tagDetails: tagDetails(state, tag), operations: ops}))
}
)
export const taggedOperations = ( state ) =>( { getConfigs } ) => {
let { operationsSorter }= getConfigs()
return operationsWithTags(state).map((ops, tag) => {
let sortFn = typeof operationsSorter === "function" ? operationsSorter
: sorters.operationsSorter[operationsSorter]
let operations = !sortFn ? ops : ops.sort(sortFn)
return Map({tagDetails: tagDetails(state, tag), operations: operations})})
}
export const responses = createSelector(
state,
@@ -291,7 +295,11 @@ export function operationConsumes(state, pathMethod) {
}
export const operationScheme = ( state, path, method ) => {
return state.getIn(["scheme", path, method]) || state.getIn(["scheme", "_defaultScheme"]) || "http"
let url = state.get("url")
let matchResult = url.match(/^([a-z][a-z0-9+\-.]*):/)
let urlScheme = Array.isArray(matchResult) ? matchResult[1] : null
return state.getIn(["scheme", path, method]) || state.getIn(["scheme", "_defaultScheme"]) || urlScheme || ""
}
export const canExecuteScheme = ( state, path, method ) => {
+1 -1
View File
@@ -74,7 +74,7 @@ const createClass = component => React.createClass({
const Fallback = ({ name }) => <div style={{ // eslint-disable-line react/prop-types
padding: "1em",
"color": "#aaa"
}}>😱 <i>Could not render { name || name === "t" ? name : "this component" }, see the console.</i></div>
}}>😱 <i>Could not render { name === "t" ? "this component" : name }, see the console.</i></div>
const wrapRender = (component) => {
const isStateless = component => !(component.prototype && component.prototype.isReactComponent)
+3
View File
@@ -46,6 +46,8 @@ import Model from "core/components/model"
import Models from "core/components/models"
import TryItOutButton from "core/components/try-it-out-button"
import BaseLayout from "core/components/layouts/base"
import * as LayoutUtils from "core/components/layout-utils"
import * as JsonSchemaComponents from "core/json-schema-components"
@@ -87,6 +89,7 @@ export default function() {
model: Model,
models: Models,
TryItOutButton,
BaseLayout
}
}
+9 -2
View File
@@ -453,13 +453,13 @@ export const propChecker = (props, nextProps, objectList=[], ignoreList=[]) => {
}
const validateNumber = ( val ) => {
if ( !/^\d+(.?\d+)?$/.test(val)) {
if ( !/^-?\d+(.?\d+)?$/.test(val)) {
return "Value must be a number"
}
}
const validateInteger = ( val ) => {
if ( !/^\d+$/.test(val)) {
if ( !/^-?\d+$/.test(val)) {
return "Value must be integer"
}
}
@@ -559,3 +559,10 @@ export const btoa = (str) => {
return buffer.toString("base64")
}
export const sorters = {
operationsSorter: {
alpha: (a, b) => a.get("path").localeCompare(b.get("path")),
method: (a, b) => a.get("method").localeCompare(b.get("method"))
}
}
+9 -55
View File
@@ -13,28 +13,16 @@ export default class StandaloneLayout extends React.Component {
}
render() {
let { specSelectors, specActions, getComponent } = this.props
let { getComponent, specSelectors } = this.props
let info = specSelectors.info()
let url = specSelectors.url()
let basePath = specSelectors.basePath()
let host = specSelectors.host()
let securityDefinitions = specSelectors.securityDefinitions()
let externalDocs = specSelectors.externalDocs()
let schemes = specSelectors.schemes()
let Info = getComponent("info")
let Operations = getComponent("operations", true)
let Models = getComponent("models", true)
let AuthorizeBtn = getComponent("authorizeBtn", true)
let Container = getComponent("Container")
let Row = getComponent("Row")
let Col = getComponent("Col")
let Errors = getComponent("errors", true)
const Schemes = getComponent("schemes")
const Topbar = getComponent("Topbar", true)
const BaseLayout = getComponent("BaseLayout", true)
const OnlineValidatorBadge = getComponent("onlineValidatorBadge", true)
const loadingStatus = specSelectors.loadingStatus()
return (
@@ -56,46 +44,12 @@ export default class StandaloneLayout extends React.Component {
<h4 className="title">Failed to load config.</h4>
</div>
}
{ loadingStatus === "success" &&
<div>
<Errors/>
<Row className="information-container">
<Col mobile={12}>
{ info.count() ? (
<Info info={ info } url={ url } host={ host } basePath={ basePath } externalDocs={externalDocs} getComponent={getComponent}/>
) : null }
</Col>
</Row>
{ schemes && schemes.size || securityDefinitions ? (
<div className="scheme-container">
<Col className="schemes wrapper" mobile={12}>
{ schemes && schemes.size ? (
<Schemes schemes={ schemes } specActions={ specActions } />
) : null }
{ securityDefinitions ? (
<AuthorizeBtn />
) : null }
</Col>
</div>
) : null }
<Row>
<Col mobile={12} desktop={12} >
<Operations/>
</Col>
</Row>
<Row>
<Col mobile={12} desktop={12} >
<Models/>
</Col>
</Row>
</div> }
<Row>
<Col>
<OnlineValidatorBadge />
</Col>
</Row>
{ !loadingStatus || loadingStatus === "success" && <BaseLayout/> }
<Row>
<Col>
<OnlineValidatorBadge />
</Col>
</Row>
</Container>
)
}
+2
View File
@@ -0,0 +1,2 @@
README.md
deploy.sh
+1
View File
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
+3
View File
@@ -0,0 +1,3 @@
This directory is used to build the `swagger-ui-dist` npm package.
For anything else, check the [Swagger-UI](https://github.com/swagger-api/swagger-ui) repository.
+21
View File
@@ -0,0 +1,21 @@
# Deploy `swagger-ui-dist` to npm.
# Parameter Expansion: http://stackoverflow.com/questions/6393551/what-is-the-meaning-of-0-in-a-bash-script
cd "${0%/*}"
# Get UI version
UI_VERSION=$(node -p "require('../package.json').version")
# Replace our version placeholder with UI's version
sed -i "s|\$\$VERSION|$UI_VERSION|g" package.json
# Copy UI's dist files to our directory
cp ../dist/* .
if [ "$PUBLISH_DIST" = "true" ] || [ "$TRAVIS" = "true" ] ; then
npm publish .
else
npm pack .
fi
find . -not -name .npmignore -not -name .npmrc -not -name deploy.sh -not -name package.json -not -name README.md -not -name *.tgz -delete
+18
View File
@@ -0,0 +1,18 @@
{
"name": "swagger-ui-dist",
"version": "$$VERSION",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
"(in alphabetical order)",
"Anna Bodnia <anna.bodnia@gmail.com>",
"Buu Nguyen <buunguyen@gmail.com>",
"Josh Ponelat <jponelat@gmail.com>",
"Kyle Shockey <kyleshockey1@gmail.com>",
"Robert Barnwell <robert@robertismy.name>",
"Sahar Jafari <shr.jafari@gmail.com>"
],
"license": "Apache-2.0",
"dependencies": {},
"devDependencies": {}
}
+72
View File
@@ -0,0 +1,72 @@
/* eslint-env mocha */
import expect from "expect"
import { fromJS } from "immutable"
import reducer from "corePlugins/spec/reducers"
describe("spec plugin - reducer", function(){
describe("update operation value", function() {
it("should update the operation at the specified key", () => {
const updateOperationValue = reducer["spec_update_operation_value"]
const state = fromJS({
resolved: {
"paths": {
"/pet": {
"post": {
"description": "my operation"
}
}
}
}
})
let result = updateOperationValue(state, {
payload: {
path: ["/pet", "post"],
value: "application/json",
key: "consumes_value"
}
})
let expectedResult = {
resolved: {
"paths": {
"/pet": {
"post": {
"description": "my operation",
"consumes_value": "application/json"
}
}
}
}
}
expect(result.toJS()).toEqual(expectedResult)
})
it("shouldn't throw an error if we try to update the consumes_value of a null operation", () => {
const updateOperationValue = reducer["spec_update_operation_value"]
const state = fromJS({
resolved: {
"paths": {
"/pet": {
"post": null
}
}
}
})
let result = updateOperationValue(state, {
payload: {
path: ["/pet", "post"],
value: "application/json",
key: "consumes_value"
}
})
expect(result.toJS()).toEqual(state.toJS())
})
})
})
@@ -1,7 +1,7 @@
/* eslint-env mocha */
import expect from "expect"
import { fromJS } from "immutable"
import { parameterValues, contentTypeValues } from "corePlugins/spec/selectors"
import { parameterValues, contentTypeValues, operationScheme } from "corePlugins/spec/selectors"
describe("spec plugin - selectors", function(){
@@ -92,4 +92,43 @@ describe("spec plugin - selectors", function(){
})
describe("operationScheme", function(){
it("should return the correct scheme for a remote spec that doesn't specify a scheme", function(){
// Given
let state = fromJS({
url: "https://generator.swagger.io/api/swagger.json",
resolved: {
paths: {
"/one": {
get: {
"consumes_value": "one",
"produces_value": "two"
}
}
}
}
})
// When
let scheme = operationScheme(state, ["/one"], "get")
// Then
expect(scheme).toEqual("https")
})
// it("should be ok, if no operation found", function(){
// // Given
// let state = fromJS({ })
//
// // When
// let contentTypes = contentTypeValues(state, [ "/one", "get" ])
// // Then
// expect(contentTypes.toJS()).toEqual({
// requestContentType: undefined,
// responseContentType: undefined
// })
// })
})
})