Compare commits

..
30 Commits
Author SHA1 Message Date
Kyle Shockey a3563b614a v3.0.2 2017-03-19 19:29:18 -07:00
Kyle Shockey 33e5775dcf Default OnlineValidator url; rebuild dist 2017-03-19 19:27:09 -07:00
Kyle Shockey db2caf62cb Remove npm start (for now) 2017-03-19 18:46:50 -07:00
Kyle Shockey 5a62509728 Rebuild dist 2017-03-19 18:42:37 -07:00
Kyle Shockey eb548f6396 Merge branch 'master' of github.com:swagger-api/swagger-ui 2017-03-19 18:25:42 -07:00
Kyle Shockey 00d23fb052 Merge branch 'bodnia-url-from-query' 2017-03-19 18:24:58 -07:00
Kyle Shockey c5222153d0 De-mystify compound logic 2017-03-19 18:23:56 -07:00
Kyle Shockey 62be80741e Clarify variable names for configs 2017-03-19 18:20:14 -07:00
Kyle Shockey b41c92f15a Merge branch 'url-from-query' of https://github.com/bodnia/swagger-ui into bodnia-url-from-query 2017-03-19 18:07:21 -07:00
shockey 3951c87ec0 Create .editorconfig 2017-03-19 17:34:09 -07:00
shockey 5f0cc74e89 Update index.js
Disabling the YAML config plugin, for now.
2017-03-19 17:31:49 -07:00
Kyle Shockey ce6ce9a5c2 Update swagger-client minimum version; rebuild dist 2017-03-19 15:48:59 -07:00
shockey 81be6d08a6 Merge pull request #2740 from Minasokoni/style-updates
Error styling updates / added missing operation colors
2017-03-19 12:38:20 -07:00
Minasokoni 2b37eeff9c removed expand button 2017-03-19 12:22:42 -07:00
Minasokoni bece956ad5 error styling updates, method colors added 2017-03-19 12:21:15 -07:00
Tony Tam eefe1267af Merge pull request #2739 from swagger-api/issue-2738
copy all files
2017-03-19 12:15:27 -07:00
Tony Tam a45cef0e24 copy all files 2017-03-19 12:14:18 -07:00
Josh Ponelat 9409320009 Merge pull request #2737 from swagger-api/feature/move-scheme-out-of-securtyDefinitions
Move the schemes component out of the securityDefinitions conditional
2017-03-19 18:59:00 +02:00
Josh Ponelat a82c466782 build 2017-03-19 17:41:57 +02:00
Josh Ponelat 4749b90350 move the securityDefinitions conditional, outside of Schemes 2017-03-19 17:35:26 +02:00
Anna Bodnia 0b56640273 fixed fetch config 2017-03-19 14:47:42 +02:00
Anna Bodnia 26d5305404 fetch spec from url provided in query parameter 2017-03-19 13:28:10 +02:00
Josh Ponelat 5c77857b2d Merge pull request #2734 from swagger-api/feature/small-fix-for-live-response
Add a fix for the live-response
2017-03-19 09:09:21 +02:00
Josh Ponelat 54ee7f9b67 build 2017-03-19 09:08:41 +02:00
Josh Ponelat 3a2185c158 remove double-encoding of response (ie: serializeRes ) 2017-03-19 08:38:16 +02:00
Josh Ponelat 2479b8cdde ensure live-response headers exist 2017-03-19 08:37:56 +02:00
Ron 3fe3f0bfdb Delete .gitmodules 2017-03-18 15:59:45 -07:00
Ron 323e0ef77d Update README.md 2017-03-18 15:58:47 -07:00
Ron e16954290b Merge pull request #2733 from swagger-api/feature/docker
Add docker support for 3.0.x
2017-03-18 14:02:57 -07:00
Tony Tam 9afe6802db added dockerfile instructions 2017-03-18 13:58:30 -07:00
26 changed files with 216 additions and 131 deletions
+10
View File
@@ -0,0 +1,10 @@
root = true
[*]
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
View File
+19
View File
@@ -0,0 +1,19 @@
FROM alpine:3.4
MAINTAINER fehguy
RUN apk add --update nginx
RUN mkdir -p /run/nginx
COPY nginx.conf /etc/nginx/
# copy swagger files to the `/js` folder
ADD ./dist/ /usr/share/nginx/html/js
ADD ./public/* /usr/share/nginx/html
# change the folder structure
RUN sed -i 's/\.\.\/dist/js/g' /usr/share/nginx/html/index.html
EXPOSE 8080
CMD exec nginx -g 'daemon off;'
+11 -1
View File
@@ -13,7 +13,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.0 | 2017-03-17 | 2.0 | [tag v3.0.0](https://github.com/swagger-api/swagger-ui/tree/v3.0.0) |
3.0.2 | 2017-03-19 | 2.0 | [tag v3.0.2](https://github.com/swagger-api/swagger-ui/tree/v3.0.2) |
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) |
@@ -23,6 +23,16 @@ Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
### How to run
##### Easy start! Docker
You can pull a pre-built docker image of the swagger-ui directly from Dockerhub:
```
docker pull swaggerapi/swagger-ui
docker run -p 80:8080 swaggerapi/swagger-ui
```
Will start nginx with swagger-ui on port 80.
##### Prerequisites
- Node 6.x
- NPM 3.x
+22 -22
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;;;;;;;;;;;;;;;;;;;;;;;;;;AA6OA;;;;;;AAoIA;AAm7FA;AAwtCA;AAg0IA;;;;;AAkxBA;AAo8IA;AA41GA;AA23FA;AAmqFA;AA0nFA;AA49CA;AAwhDA;AAkrCA;AAumFA;AAmnHA;;;;;;;;;;;;;;AAqjHA;AAyoIA;AAkuJA;AAilHA;AA4kGA;AAwkEA;AAs3DA;AAovDA;AAotBA;AAoqGA;;;;;;AAueA;AAimGA;AA44EA;;;;;AAoGA;AA2qFA;AAo2CA;AAgvDA;AA8tCA;AAoiEA;AA69FA;;;;;;;;;AA20BA;AA2zIA;AAm4DA","sourceRoot":""}
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;AAoOA;;;;;;AAoIA;AAm7FA;AAwtCA;AAg0IA;;;;;AAkxBA;AA+7IA;AAi2GA;AA43FA;AA6oFA;AAipFA;AA+9CA;AA0gDA;AA0rCA;AA80EA;AAs4HA;;;;;;;;;;;;;;AA8kHA;AAyoIA;AAkuJA;AAilHA;AA4kGA;AAwkEA;AAs3DA;AAovDA;AA0tBA;AA+pGA;;;;;;AAseA;AAimGA;AA44EA;;;;;AAoGA;AA2qFA;AAm2CA;AAmvDA;AAwtCA;AAuiEA;AA29FA;;;;;;;;;AA00BA;AA2zIA;AAm4DA","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;;;;;AAwSA;AAyiGA;AAqwFA;;;;;;AA4eA;AAkvFA;AAu+CA;AAo+CA;AAgrCA;AAgyEA","sourceRoot":""}
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AAwSA;AAyiGA","sourceRoot":""}
+1 -1
View File
File diff suppressed because one or more lines are too long
+8 -8
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;AAooGA;AAw0HA;AAijGA;AA6lCA;AA29BA;AAmwCA;AAw4BA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;AAqnGA;AAi2HA;AA6+FA;AAgqCA;AAi+BA;AAyvCA;AA84BA","sourceRoot":""}
+49
View File
@@ -0,0 +1,49 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}
}
}
+2 -3
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.0.1",
"version": "3.0.2",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -14,7 +14,6 @@
],
"license": "Apache-2.0",
"scripts": {
"start": "http-server -i -a 0.0.0.0 -p 3001",
"build": "npm run build-core && npm run build-bundle && npm run build-standalone",
"build-bundle": "webpack --config webpack-dist-bundle.config.js --colors",
"build-core": "webpack --config webpack-dist.config.js --colors",
@@ -64,7 +63,7 @@
"reselect": "2.5.3",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "^3.0.1",
"swagger-client": "^3.0.2",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",
"xml": "1.0.1",
+14 -12
View File
@@ -20,21 +20,23 @@ export default class LiveResponse extends React.Component {
}
render() {
let { request, response, getComponent } = this.props
const { request, response, getComponent } = this.props
const body = response.get("text")
const status = response.get("status")
const url = response.get("url")
const headers = response.get("headers").toJS()
const notDocumented = response.get("notDocumented")
const isError = response.get("error")
const headersKeys = Object.keys(headers)
const contentType = headers["content-type"]
const Curl = getComponent("curl")
let body = response.get("text")
let status = response.get("status")
let url = response.get("url")
let originalHeaders = response.get("headers")
let headers = originalHeaders && originalHeaders.toJS()
let headersKeys = Object.keys(headers)
let returnObject = headersKeys.map(key => {
const ResponseBody = getComponent("responseBody")
const returnObject = headersKeys.map(key => {
return <span className="headerline" key={key}> {key}: {headers[key]} </span>
})
let notDocumented = response.get("notDocumented")
let ResponseBody = getComponent("responseBody")
let contentType = headers && headers["content-type"]
let isError = response.get("error")
return (
<div>
@@ -7,7 +7,7 @@ export default class OnlineValidatorBadge extends React.Component {
let { validatorUrl } = getConfigs()
this.state = {
url: specSelectors.url(),
validatorUrl: validatorUrl
validatorUrl: validatorUrl || "https://online.swagger.io/validator"
}
}
@@ -17,7 +17,7 @@ export default class OnlineValidatorBadge extends React.Component {
this.setState({
url: specSelectors.url(),
validatorUrl: validatorUrl
validatorUrl: validatorUrl || "https://online.swagger.io/validator"
})
}
-6
View File
@@ -59,12 +59,6 @@ export default class Operations extends React.Component {
</small>
}
<button className="expand-methods" title="Expand all methods">
<svg className="expand" width="20" height="20">
<use xlinkHref="#expand" />
</svg>
</button>
<button className="expand-operation" title="Expand operation" onClick={() => layoutActions.show(isShownKey, !showTag)}>
<svg className="arrow" width="20" height="20">
<use xlinkHref={showTag ? "#large-arrow-down" : "#large-arrow"} />
+22 -31
View File
@@ -4,6 +4,7 @@ import System from "core/system"
import ApisPreset from "core/presets/apis"
import * as AllPlugins from "core/plugins/all"
import { filterConfigs } from "plugins/configs"
import { parseSeach } from "core/utils"
module.exports = function SwaggerUI(opts) {
@@ -35,79 +36,69 @@ module.exports = function SwaggerUI(opts) {
store: { },
}
const config = deepExtend({}, defaults, opts)
const constructorConfig = deepExtend({}, defaults, opts)
const storeConfigs = deepExtend({}, config.store, {
const storeConfigs = deepExtend({}, constructorConfig.store, {
system: {
configs: config.configs
configs: constructorConfig.configs
},
plugins: config.presets,
plugins: constructorConfig.presets,
state: {
layout: {
layout: config.layout
layout: constructorConfig.layout
},
spec: {
spec: "",
url: config.url
url: constructorConfig.url
}
}
})
let inlinePlugin = ()=> {
return {
fn: config.fn,
components: config.components,
state: config.state,
fn: constructorConfig.fn,
components: constructorConfig.components,
state: constructorConfig.state,
}
}
var store = new System(storeConfigs)
store.register([config.plugins, inlinePlugin])
store.register([constructorConfig.plugins, inlinePlugin])
var system = store.getSystem()
let queryConfig = parseSeach()
const downloadSpec = (configs) => {
if(typeof config !== "object") {
if(typeof constructorConfig !== "object") {
return system
}
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
let mergedConfig = deepExtend({}, config, configs, localConfig)
let mergedConfig = deepExtend({}, constructorConfig, localConfig, queryConfig)
store.setConfigs(filterConfigs(mergedConfig))
if(typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
if(!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
system.specActions.updateUrl("")
system.specActions.updateLoadingStatus("success");
system.specActions.updateSpec(JSON.stringify(mergedConfig.spec))
} else if(mergedConfig.url) {
} else if(system.specActions.download && mergedConfig.url) {
system.specActions.updateUrl(mergedConfig.url)
system.specActions.download(mergedConfig.url)
}
if(mergedConfig.dom_id)
if(mergedConfig.dom_id) {
system.render(mergedConfig.dom_id, "App")
} else {
console.error("Skipped rendering: no `dom_id` was specified")
}
return system
}
if (system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(downloadSpec)) {
return downloadSpec(config)
if (!system.specActions.getConfigByUrl || (system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(downloadSpec))) {
return downloadSpec(constructorConfig)
}
if (system.specActions.download && config.url) {
system.specActions.download(config.url)
}
if(config.spec && typeof config.spec === "string")
system.specActions.updateSpec(config.spec)
if(config.dom_id) {
system.render(config.dom_id, "App")
} else {
console.error("Skipped rendering: no `dom_id` was specified")
}
return system
}
// Add presets
+1 -1
View File
@@ -30,7 +30,7 @@ export default function downloadUrlPlugin (toolbox) {
},
updateLoadingStatus: (status) => {
let enums = [null, "loading", "failed", "success"]
let enums = [null, "loading", "failed", "success", "failedConfig"]
if(enums.indexOf(status) === -1) {
console.error(`Error: ${status} is not one of ${JSON.stringify(enums)}`)
}
-1
View File
@@ -194,7 +194,6 @@ export const executeRequest = (req) => ({fn, specActions, errActions}) => {
specActions.setRequest(req.pathName, req.method, parsedRequest)
return fn.execute(req)
.then( fn.serializeRes )
.then( res => specActions.setResponse(req.pathName, req.method, res))
.catch( err => specActions.setResponse(req.pathName, req.method, { error: true, err: serializeError(err) } ) )
}
+3
View File
@@ -84,6 +84,9 @@ export default {
result = res
}
// Ensure headers
result.headers = result.headers || {}
let newState = state.setIn( [ "responses", path, method ], fromJSOrdered(result) )
// ImmutableJS messes up Blob. Needs to reset its value.
+16
View File
@@ -549,3 +549,19 @@ export const getSampleSchema = (schema, contentType="", config={}) => {
return JSON.stringify(memoizedSampleFromSchema(schema, config), null, 2)
}
export const parseSeach = () => {
let map = {}
let search = window.location.search
if ( search != "" ) {
let params = search.substr(1).split("&");
for (let i in params) {
i = params[i].split("=");
map[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
}
}
return map;
}
+1 -16
View File
@@ -1,4 +1,5 @@
import YAML from "js-yaml"
import { parseSeach } from "core/utils"
import yamlConfig from "../../../swagger-config.yaml"
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
@@ -16,22 +17,6 @@ const parseYamlConfig = (yaml, system) => {
}
}
const parseSeach = () => {
let map = {}
let search = window.location.search
if ( search != "" ) {
let params = search.substr(1).split("&");
for (let i in params) {
i = params[i].split("=");
map[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
}
}
return map;
}
export default function configPlugin (toolbox) {
let { fn } = toolbox
-2
View File
@@ -2,13 +2,11 @@ import StandaloneLayout from './layout'
import '../style/main.scss'
import TopbarPlugin from "plugins/topbar"
import ConfigsPlugin from "plugins/configs"
// the Standalone preset
let preset = [
TopbarPlugin,
ConfigsPlugin,
() => {
return {
components: { StandaloneLayout }
+8 -6
View File
@@ -67,12 +67,14 @@ export default class StandaloneLayout extends React.Component {
</Col>
</Row>
<div className="scheme-container">
{ securityDefinitions &&
<Col className="schemes wrapper" mobile={12}>
{ schemes && schemes.size ? <Schemes schemes={ schemes } specActions={ specActions } /> : null }
<AuthorizeBtn />
</Col>
}
<Col className="schemes wrapper" mobile={12}>
{ schemes && schemes.size ? (
<Schemes schemes={ schemes } specActions={ specActions } />
) : null }
{ securityDefinitions ? (
<AuthorizeBtn />
) : null }
</Col>
</div>
<Row>
<Col mobile={12} desktop={12} >
+6 -1
View File
@@ -9,13 +9,18 @@
border-radius: 4px;
background: rgba($_color-delete, .1);
.error-wrapper
{
margin: 0 0 10px 0;
}
.errors
{
h4
{
font-size: 14px;
margin: 0 0 10px 0;
margin: 0;
@include text_code();
}
+15
View File
@@ -286,6 +286,21 @@ body
@include method($_color-get);
}
&.opblock-patch
{
@include method($_color-patch);
}
&.opblock-head
{
@include method($_color-head);
}
&.opblock-options
{
@include method($_color-options);
}
&.opblock-deprecated
{
opacity: .6;