diff --git a/make-webpack-config.js b/make-webpack-config.js index 2a6ed131..2eeb9bf9 100644 --- a/make-webpack-config.js +++ b/make-webpack-config.js @@ -61,7 +61,6 @@ module.exports = function(rules, options) { } if( specialOptions.minimize ) { - plugins.push( new webpack.optimize.UglifyJsPlugin({ sourceMap: true, diff --git a/package.json b/package.json index 4b754ce7..3e0465d7 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,6 @@ "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "2.0.3", "less": "2.7.2", - "less-loader": "4.0.4", "license-checker": "^11.0.0", "mocha": "^3.4.2", "node-sass": "^4.5.0", diff --git a/src/core/components/info.jsx b/src/core/components/info.jsx index 6ea1ed48..5e2b368a 100644 --- a/src/core/components/info.jsx +++ b/src/core/components/info.jsx @@ -15,7 +15,7 @@ class Path extends React.Component { return (
- [ Base url: {host}{basePath}]
+ [ Base URL: {host}{basePath} ]
)
}
diff --git a/src/core/path-translator.js b/src/core/path-translator.js
deleted file mode 100644
index 4d1ed27b..00000000
--- a/src/core/path-translator.js
+++ /dev/null
@@ -1,67 +0,0 @@
-import get from "lodash/get"
-
-export function transformPathToArray(property, jsSpec) {
- if(property.slice(0,9) === "instance.") {
- var str = property.slice(9)
- } else { // eslint-disable-next-line no-redeclare
- var str = property
- }
-
- var pathArr = []
-
- str
- .split(".")
- .map(item => {
- // "key[0]" becomes ["key", "0"]
- if(item.includes("[")) {
- let index = parseInt(item.match(/\[(.*)\]/)[1])
- let keyName = item.slice(0, item.indexOf("["))
- return [keyName, index.toString()]
- } else {
- return item
- }
- })
- .reduce(function(a, b) {
- // flatten!
- return a.concat(b)
- }, [])
- .concat([""]) // add an empty item into the array, so we don't get stuck with something in our buffer below
- .reduce((buffer, curr) => {
- let obj = pathArr.length ? get(jsSpec, pathArr) : jsSpec
-
- if(get(obj, makeAccessArray(buffer, curr))) {
- if(buffer.length) {
- pathArr.push(buffer)
- }
- if(curr.length) {
- pathArr.push(curr)
- }
- return ""
- } else {
- // attach key to buffer
- return `${buffer}${buffer.length ? "." : ""}${curr}`
- }
- }, "")
-
- if(typeof get(jsSpec, pathArr) !== "undefined") {
- return pathArr
- } else {
- // if our path is not correct (there is no value at the path),
- // return null
- return null
- }
-}
-
-function makeAccessArray(buffer, curr) {
- let arr = []
-
- if(buffer.length) {
- arr.push(buffer)
- }
-
- if(curr.length) {
- arr.push(curr)
- }
-
- return arr
-}
diff --git a/src/core/plugins/split-pane-mode/components/split-pane-mode.jsx b/src/core/plugins/split-pane-mode/components/split-pane-mode.jsx
index 73f2acbc..c1a8fa9c 100644
--- a/src/core/plugins/split-pane-mode/components/split-pane-mode.jsx
+++ b/src/core/plugins/split-pane-mode/components/split-pane-mode.jsx
@@ -1,7 +1,6 @@
import React from "react"
import PropTypes from "prop-types"
import SplitPane from "react-split-pane"
-import "./split-pane-mode.less"
const MODE_KEY = ["split-pane-mode"]
const MODE_LEFT = "left"
diff --git a/src/core/plugins/split-pane-mode/components/split-pane-mode.less b/src/core/plugins/split-pane-mode/components/split-pane-mode.less
deleted file mode 100644
index d5437b37..00000000
--- a/src/core/plugins/split-pane-mode/components/split-pane-mode.less
+++ /dev/null
@@ -1,5 +0,0 @@
-.swagger-ui {
- .Resizer.vertical.disabled {
- display: none;
- }
-}
diff --git a/src/core/plugins/util/index.js b/src/core/plugins/util/index.js
index 57e163f4..033288a6 100644
--- a/src/core/plugins/util/index.js
+++ b/src/core/plugins/util/index.js
@@ -1,8 +1,7 @@
import { shallowEqualKeys } from "core/utils"
-import { transformPathToArray } from "core/path-translator"
export default function() {
return {
- fn: { shallowEqualKeys, transformPathToArray }
+ fn: { shallowEqualKeys }
}
}
diff --git a/src/plugins/topbar/topbar.less b/src/plugins/topbar/topbar.less
deleted file mode 100644
index 9818940b..00000000
--- a/src/plugins/topbar/topbar.less
+++ /dev/null
@@ -1,52 +0,0 @@
-.swagger-ui {
- .topbar {
- background-color: #89bf04;
- }
-
- .topbar-wrapper {
- padding: 0.7em;
- }
-
- .topbar-logo__img {
- float: left;
- }
-
- .topbar-logo__title {
- display: inline-block;
- color: #fff;
- font-size: 1.5em;
- font-weight: bold;
- margin: 0.15em 0 0 0.5em;
- }
-
- .download-url-wrapper {
- text-align: right;
- float: right;
- }
-
- .topbar .download-url__text {
- width: 28em;
- height: 2em;
- margin-right: 0.5em;
- }
-
- .download-url__btn {
- background-color: #547f00;
- border-color: #547f00;
- text-decoration: none;
- font-weight: bold;
- padding: 0.2em 0.3em;
- color: white;
- border-radius: 0.1em;
-
- &:hover {
- &:extend(.download-url__btn);
- }
- }
-
- .center-700 {
- display: block;
- margin: 0 auto;
- width: 45em;
- }
-}
diff --git a/src/standalone/index.js b/src/standalone/index.js
index 6616a744..40e9a50c 100644
--- a/src/standalone/index.js
+++ b/src/standalone/index.js
@@ -1,6 +1,4 @@
import StandaloneLayout from "./layout"
-import "../style/main.scss"
-
import TopbarPlugin from "plugins/topbar"
import ConfigsPlugin from "plugins/configs"
diff --git a/src/style/_split-pane-mode.scss b/src/style/_split-pane-mode.scss
new file mode 100644
index 00000000..4a53d4c6
--- /dev/null
+++ b/src/style/_split-pane-mode.scss
@@ -0,0 +1,3 @@
+.Resizer.vertical.disabled {
+ display: none;
+}
\ No newline at end of file
diff --git a/src/style/main.scss b/src/style/main.scss
index f6ff00fb..443cc37c 100644
--- a/src/style/main.scss
+++ b/src/style/main.scss
@@ -14,4 +14,5 @@
@import 'information';
@import 'authorize';
@import 'errors';
+ @import 'split-pane-mode';
}
diff --git a/test/core/path-translator.js b/test/core/path-translator.js
deleted file mode 100644
index 7abc1d8e..00000000
--- a/test/core/path-translator.js
+++ /dev/null
@@ -1,183 +0,0 @@
-/* eslint-env mocha */
-import expect from "expect"
-import { transformPathToArray } from "core/path-translator"
-
-describe("validation plugin - path translator", function(){
-
- describe("string paths", function(){
-
- it("should translate a simple string path to an array", function(){
- // Given
- let jsSpec = {
- one: {
- a: "a thing",
- b: "another thing",
- c: "one more thing"
- },
- two: 2
- }
-
- let path = "instance.one.a"
-
- // Then
- expect(transformPathToArray(path, jsSpec)).toEqual(["one", "a"])
-
- })
-
- it("should translate an ambiguous string path to an array", function(){
- // Since JSONSchema uses periods to mark different properties,
- // a key with a period in it is ambiguous, because it can mean at least two things.
- // In our case, the path can mean:
- // ["google", "com", "a"] or ["google.com", "a"]
-
- // Given
- let jsSpec = {
- "google.com": {
- a: "a thing",
- b: "another thing",
- c: "one more thing"
- },
- "gmail.com": {
- d: "more stuff",
- e: "even more stuff"
- }
- }
-
- let path = "instance.google.com.a"
-
- // Then
- expect(transformPathToArray(path, jsSpec)).toEqual(["google.com", "a"])
-
- })
-
- it("should translate an doubly ambiguous string path to an array", function(){
- // Since JSONSchema uses periods to mark different properties,
- // a key with two periods in it (like "www.google.com") is doubly ambiguous,
- // because it can mean at least three things.
-
-
- // Given
- let jsSpec = {
- "www.google.com": {
- a: "a thing",
- b: "another thing",
- c: "one more thing"
- },
- "gmail.com": {
- d: "more stuff",
- e: "even more stuff"
- }
- }
-
- let path = "instance.www.google.com.a"
-
- // Then
- expect(transformPathToArray(path, jsSpec)).toEqual(["www.google.com", "a"])
-
- })
-
- it("should return null for an invalid path", function(){
-
- // Given
- let jsSpec = {
- "google.com": {
- a: "a thing",
- b: "another thing",
- c: "one more thing"
- },
- "gmail.com": {
- d: "more stuff",
- e: "even more stuff"
- }
- }
-
- let path = "instance.google.net.a"
-
- // Then
- expect(transformPathToArray(path, jsSpec)).toEqual(null)
-
- })
-
- it("should return inline array indices in their own value", function(){
- // "a[1]" => ["a", "1"]
-
- // Given
- let jsSpec = {
- "google.com": {
- a: [
- "hello",
- "here is the target"
- ],
- b: "another thing",
- c: "one more thing"
- },
- "gmail.com": {
- d: "more stuff",
- e: "even more stuff"
- }
- }
-
- let path = "instance.google.com.a[1]"
-
- // Then
- expect(transformPathToArray(path, jsSpec)).toEqual(["google.com", "a", "1"])
-
- })
-
- it("should return the correct path when the last part is ambiguous", function(){
-
- // Given
- let jsSpec = {
- "google.com": {
- a: [
- "hello",
- {
- "gmail.com": 1234
- }
- ],
- b: "another thing",
- c: "one more thing"
- },
- "gmail.com": {
- d: "more stuff",
- e: "even more stuff"
- }
- }
-
- let path = "instance.google.com.a[1].gmail.com"
-
- // Then
- expect(transformPathToArray(path, jsSpec)).toEqual(["google.com", "a", "1", "gmail.com"])
-
- })
-
- it("should return the correct path when the last part is doubly ambiguous", function(){
-
- // Given
- let jsSpec = {
- "google.com": {
- a: [
- "hello",
- {
- "www.gmail.com": 1234
- }
- ],
- b: "another thing",
- c: "one more thing"
- },
- "gmail.com": {
- d: "more stuff",
- e: "even more stuff"
- }
- }
-
- let path = "instance.google.com.a[1].www.gmail.com"
-
- // Then
- expect(transformPathToArray(path, jsSpec)).toEqual(["google.com", "a", "1", "www.gmail.com"])
-
- })
-
- })
-
-})
diff --git a/webpack-dist-bundle.config.js b/webpack-dist-bundle.config.js
index f805c8bf..27a26046 100644
--- a/webpack-dist-bundle.config.js
+++ b/webpack-dist-bundle.config.js
@@ -1,64 +1,32 @@
-var path = require('path')
-var rules = [
+const path = require("path")
+const styleRules = require("./webpack.dist-style.config.js")
+
+let rules = [
{ test: /\.(worker\.js)(\?.*)?$/,
use: [
{
- loader: 'worker-loader',
+ loader: "worker-loader",
options: {
inline: true,
- name: '[name].js'
+ name: "[name].js"
}
},
- { loader: 'babel-loader' }
- ]
- },
- { test: /\.(css)(\?.*)?$/,
- use: [
- 'style-loader',
- 'css-loader',
- 'postcss-loader'
- ]
- },
- { test: /\.(scss)(\?.*)?$/,
- use: [
- 'style-loader',
- 'css-loader',
- {
- loader: 'postcss-loader',
- options: { sourceMap: true }
- },
- { loader: 'sass-loader',
- options: {
- outputStyle: 'expanded',
- sourceMap: true,
- sourceMapContents: 'true'
- }
- }
- ]
- },
- { test: /\.(less)(\?.*)?$/,
- use: [
- 'style-loader',
- 'css-loader',
- {
- loader: 'postcss-loader',
- },
- 'less-loader'
+ { loader: "babel-loader" }
]
}
]
-module.exports = require('./make-webpack-config.js')(rules, {
+module.exports = require("./make-webpack-config.js")(rules, {
_special: {
- separateStylesheets: false,
+ separateStylesheets: true,
minimize: true,
sourcemaps: true,
},
entry: {
- 'swagger-ui-bundle': [
- './src/polyfills',
- './src/core/index.js'
+ "swagger-ui-bundle": [
+ "./src/polyfills",
+ "./src/core/index.js"
]
},
diff --git a/webpack-dist-standalone.config.js b/webpack-dist-standalone.config.js
index 66469098..e19f428b 100644
--- a/webpack-dist-standalone.config.js
+++ b/webpack-dist-standalone.config.js
@@ -1,65 +1,32 @@
-var path = require('path')
+const path = require("path")
+const styleRules = require("./webpack.dist-style.config.js")
-var rules = [
+let rules = [
{ test: /\.(worker\.js)(\?.*)?$/,
use: [
{
- loader: 'worker-loader',
+ loader: "worker-loader",
options: {
inline: true,
- name: '[name].js'
+ name: "[name].js"
}
},
- { loader: 'babel-loader' }
- ]
- },
- { test: /\.(css)(\?.*)?$/,
- use: [
- 'style-loader',
- 'css-loader',
- 'postcss-loader'
- ]
- },
- { test: /\.(scss)(\?.*)?$/,
- use: [
- 'style-loader',
- 'css-loader',
- {
- loader: 'postcss-loader',
- options: { sourceMap: true }
- },
- { loader: 'sass-loader',
- options: {
- outputStyle: 'expanded',
- sourceMap: true,
- sourceMapContents: 'true'
- }
- }
- ]
- },
- { test: /\.(less)(\?.*)?$/,
- use: [
- 'style-loader',
- 'css-loader',
- {
- loader: 'postcss-loader',
- },
- 'less-loader'
+ { loader: "babel-loader" }
]
}
]
-module.exports = require('./make-webpack-config.js')(rules, {
+module.exports = require("./make-webpack-config.js")(rules, {
_special: {
- separateStylesheets: false,
+ separateStylesheets: true,
minimize: true,
sourcemaps: true,
},
entry: {
- 'swagger-ui-standalone-preset': [
- './src/polyfills',
- './src/standalone/index.js'
+ "swagger-ui-standalone-preset": [
+ "./src/polyfills",
+ "./src/standalone/index.js"
]
},
diff --git a/webpack-dist.config.js b/webpack-dist.config.js
index b2e730dc..3aa65ed2 100644
--- a/webpack-dist.config.js
+++ b/webpack-dist.config.js
@@ -1,66 +1,25 @@
-var path = require('path')
-var fs = require('fs')
+const path = require("path")
+const fs = require("fs")
const nodeModules = fs.readdirSync("node_modules").filter(function(x) { return x !== ".bin" })
-var ExtractTextPlugin = require('extract-text-webpack-plugin')
+const styleRules = require("./webpack.dist-style.config.js")
-var rules = [
+let rules = [
{ test: /\.(worker\.js)(\?.*)?$/,
use: [
{
- loader: 'worker-loader',
+ loader: "worker-loader",
options: {
inline: true,
- name: '[name].js'
+ name: "[name].js"
}
},
- { loader: 'babel-loader' }
+ { loader: "babel-loader" }
]
- },
- { test: /\.(css)(\?.*)?$/,
- use: ExtractTextPlugin.extract({
- fallback: 'style-loader',
- use: [
- 'css-loader',
- 'postcss-loader'
- ]
- })
- },
- { test: /\.(scss)(\?.*)?$/,
- use: ExtractTextPlugin.extract({
- fallback: 'style-loader',
- use: [
- {
- loader: 'css-loader',
- options: { minimize: true }
- },
- {
- loader: 'postcss-loader',
- options: { sourceMap: true }
- },
- { loader: 'sass-loader',
- options: {
- outputStyle: 'expanded',
- sourceMap: true,
- sourceMapContents: 'true'
- }
- }
- ]
- })
- },
- { test: /\.(less)(\?.*)?$/,
- use: ExtractTextPlugin.extract({
- fallback: 'style-loader',
- use: ['css-loader',
- {
- loader: 'postcss-loader',
- },
- 'less-loader'
- ]
- })
}
]
+rules = rules.concat(styleRules)
-module.exports = require('./make-webpack-config.js')(rules, {
+module.exports = require("./make-webpack-config.js")(rules, {
_special: {
separateStylesheets: true,
minimize: true,
diff --git a/webpack-hot-dev-server.config.js b/webpack-hot-dev-server.config.js
index cb8e4b70..e002628f 100644
--- a/webpack-hot-dev-server.config.js
+++ b/webpack-hot-dev-server.config.js
@@ -1,56 +1,46 @@
-var path = require('path')
+const path = require("path")
-var rules = [
+const rules = [
{ test: /\.(worker\.js)(\?.*)?$/,
use: [
{
- loader: 'worker-loader',
+ loader: "worker-loader",
options: {
inline: true
}
},
- { loader: 'babel-loader' }
+ { loader: "babel-loader" }
]
},
{ test: /\.(jsx)(\?.*)?$/,
use: [
- { loader: 'react-hot-loader' },
- { loader: 'babel-loader' }
+ { loader: "react-hot-loader" },
+ { loader: "babel-loader" }
]
},
{ test: /\.(css)(\?.*)?$/,
use: [
- 'style-loader',
- 'css-loader',
- 'postcss-loader'
+ "style-loader",
+ "css-loader",
+ "postcss-loader"
]
},
{ test: /\.(scss)(\?.*)?$/,
use: [
- 'style-loader',
- 'css-loader',
+ "style-loader",
+ "css-loader",
{
- loader: 'postcss-loader',
+ loader: "postcss-loader",
options: { sourceMap: true }
},
- { loader: 'sass-loader',
+ { loader: "sass-loader",
options: {
- outputStyle: 'expanded',
+ outputStyle: "expanded",
sourceMap: true,
- sourceMapContents: 'true'
+ sourceMapContents: "true"
}
}
]
- },
- { test: /\.(less)(\?.*)?$/,
- use: [
- 'style-loader',
- 'css-loader',
- {
- loader: 'postcss-loader',
- },
- 'less-loader'
- ]
}
]
@@ -60,25 +50,26 @@ module.exports = require("./make-webpack-config")(rules, {
},
devtool: "eval",
entry: {
- 'swagger-ui-bundle': [
- './src/polyfills',
- './src/core/index.js'
+ "swagger-ui-bundle": [
+ "./src/polyfills",
+ "./src/core/index.js"
],
- 'swagger-ui-standalone-preset': [
- './src/polyfills',
- './src/standalone/index.js',
+ "swagger-ui-standalone-preset": [
+ "./src/style/main.scss",
+ "./src/polyfills",
+ "./src/standalone/index.js",
]
},
output: {
pathinfo: true,
- filename: '[name].js',
+ filename: "[name].js",
library: "[name]",
libraryTarget: "umd",
chunkFilename: "[id].js"
},
devServer: {
port: 3200,
- contentBase: path.join(__dirname, 'dev-helpers'),
+ contentBase: path.join(__dirname, "dev-helpers"),
publicPath: "/",
noInfo: true,
hot: true,
diff --git a/webpack-watch.config.js b/webpack-watch.config.js
index 4406b0aa..ed5c711c 100644
--- a/webpack-watch.config.js
+++ b/webpack-watch.config.js
@@ -1,3 +1,3 @@
-var config = require("./webpack-dist.config.js")
+const config = require("./webpack-dist.config.js")
module.exports = config
diff --git a/webpack.check.js b/webpack.check.js
index 02a47376..6f10188b 100644
--- a/webpack.check.js
+++ b/webpack.check.js
@@ -1,8 +1,7 @@
-const webpack = require('webpack')
-const path = require('path')
-const deepMerge = require('deepmerge')
-const webpackConfig = require('./webpack-dist-bundle.config.js')
-const DEPS_CHECK_DIR = require('./package.json').config.deps_check_dir
+const path = require("path")
+const deepMerge = require("deepmerge")
+const webpackConfig = require("./webpack-dist-bundle.config.js")
+const DEPS_CHECK_DIR = require("./package.json").config.deps_check_dir
module.exports = deepMerge(
webpackConfig, {
diff --git a/webpack.config.js b/webpack.config.js
index 0d22493e..f0ca3601 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,3 +1,3 @@
module.exports = require("./make-webpack-config")({
-});
\ No newline at end of file
+})
\ No newline at end of file
diff --git a/webpack.dist-style.config.js b/webpack.dist-style.config.js
new file mode 100644
index 00000000..2b36430a
--- /dev/null
+++ b/webpack.dist-style.config.js
@@ -0,0 +1,34 @@
+const ExtractTextPlugin = require("extract-text-webpack-plugin")
+
+module.exports = [{
+ test: /\.(css)(\?.*)?$/,
+ use: ExtractTextPlugin.extract({
+ fallback: "style-loader",
+ use: [
+ "css-loader",
+ "postcss-loader"
+ ]
+ })
+},
+{ test: /\.(scss)(\?.*)?$/,
+ use: ExtractTextPlugin.extract({
+ fallback: "style-loader",
+ use: [
+ {
+ loader: "css-loader",
+ options: { minimize: true }
+ },
+ {
+ loader: "postcss-loader",
+ options: { sourceMap: true }
+ },
+ { loader: "sass-loader",
+ options: {
+ outputStyle: "expanded",
+ sourceMap: true,
+ sourceMapContents: "true"
+ }
+ }
+ ]
+ })
+}]
\ No newline at end of file