Skip to content

Commit 86d5a30

Browse files
committed
Update swagger site
1 parent c053ed3 commit 86d5a30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+81
-31569
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
*.iml
22
vendor
33
*node_modules
4+
ui
5+
js

netlify.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[build]
22
publish = "ui"
3+
command = "npm run build"

package.json

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,40 @@
44
"description": "Netlify's open-api definition as a module",
55
"main": "js/swagger.json",
66
"dependencies": {
7-
"netlify-s-api-definition": "^0.1.0",
8-
"request": "^2.87.0"
7+
"swagger-ui": "^3.17.5"
8+
},
9+
"devDependencies": {
10+
"autoprefixer": "^9.0.0",
11+
"browserify": "^16.0.0",
12+
"budo": "^11.3.2",
13+
"cpx": "^1.5.0",
14+
"js-yaml": "^3.12.0",
15+
"mkdirp": "^0.5.1",
16+
"npm-run-all": "^4.1.3",
17+
"postcss": "^7.0.0",
18+
"postcss-browser-reporter": "^0.5.0",
19+
"postcss-cli": "^6.0.0",
20+
"postcss-import": "^11.0.0",
21+
"postcss-reporter": "^5.0.0",
22+
"postcss-url": "^7.3.1",
23+
"rimraf": "^2.6.2"
924
},
10-
"devDependencies": {},
1125
"scripts": {
12-
"test": "echo \"Error: no test specified\" && exit 1"
26+
"clean": "rimraf js ui && mkdirp js ui",
27+
"prepublishOnly": "run-s build",
28+
"build": "run-s clean js site",
29+
"js": "node ./src/generate-js-module.js",
30+
"site": "run-p site:*",
31+
"site:static": "cpx 'src/site/{index.html,static/**}' ui",
32+
"site:swagger": "cpx 'js/swagger.{json,yml}' ui",
33+
"site:css": "postcss src/site/index.css -o ui/bundle.css",
34+
"site:js": "browserify src/site/index.js -o ui/bundle.js",
35+
"start": "run-s build serve",
36+
"serve": "budo --dir ui"
1337
},
38+
"files": [
39+
"js/**/*"
40+
],
1441
"repository": {
1542
"type": "git",
1643
"url": "git+https://github.com/netlify/open-api.git"

postcss.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = (ctx) => ({
2+
map: { inline: false },
3+
plugins: {
4+
'autoprefixer': {},
5+
'postcss-import': { root: ctx.file.dirname },
6+
'postcss-url': {
7+
url: 'copy',
8+
useHash: true,
9+
assetsPath: 'assets'
10+
},
11+
'postcss-browser-reporter': {},
12+
'postcss-reporter': {}
13+
}
14+
})

src/generate-js-module.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const yaml = require('js-yaml')
4+
const swaggerYaml = fs.readFileSync(path.resolve(__dirname, '..', 'swagger.yml'), 'utf8')
5+
const dfn = yaml.safeLoad(swaggerYaml)
6+
7+
const OUTPUT = path.join(__dirname, '..', 'js')
8+
9+
10+
fs.writeFileSync(path.join(OUTPUT, 'swagger.json'), JSON.stringify(dfn, null, '\t'))
11+
fs.writeFileSync(path.join(OUTPUT, 'swagger.yml'), swaggerYaml)

src/site/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import 'swagger-ui/dist/swagger-ui.css';

src/site/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Swagger UI</title>
6+
<link rel="icon" type="image/png" href="static/favicon-32x32.png" sizes="32x32" />
7+
<link rel="icon" type="image/png" href="static/favicon-16x16.png" sizes="16x16" />
8+
<link rel="stylesheet" href="/bundle.css">
9+
</head>
10+
11+
<body>
12+
<div id="container"></div>
13+
<script src="/bundle.js"></script>
14+
</body>
15+
</html>

src/site/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const SwaggerUI = require('swagger-ui')
2+
3+
SwaggerUI({
4+
dom_id: '#container',
5+
url: '/swagger.json'
6+
})
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)