From d0bfad60eb091a302d072c3a94505d6252944ad2 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 1 Oct 2015 09:41:02 +0300 Subject: [PATCH 01/97] Initial commit --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..579d9790 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ + ReDoc prototype + =============== + + Prototype of component based Swagger documentation From 03d43e3bc79c5fc521c44dd8d1a986eab091d710 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 3 Oct 2015 11:54:09 +0300 Subject: [PATCH 02/97] Initial configuration + build tasks --- .gitignore | 25 +++ .jshintrc | 117 +++++++++++++ build/paths.js | 6 + build/tasks/build.js | 28 ++++ build/tasks/clean.js | 9 + build/tasks/serve.js | 13 ++ build/tasks/watch.js | 12 ++ demo/app.js | 3 + demo/index.html | 20 +++ gulpfile.js | 1 + lib/RedocTest/redoc-test.js | 10 ++ lib/index.js | 13 ++ package.json | 43 +++++ system.config.js | 319 ++++++++++++++++++++++++++++++++++++ 14 files changed, 619 insertions(+) create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 build/paths.js create mode 100644 build/tasks/build.js create mode 100644 build/tasks/clean.js create mode 100644 build/tasks/serve.js create mode 100644 build/tasks/watch.js create mode 100644 demo/app.js create mode 100644 demo/index.html create mode 100644 gulpfile.js create mode 100644 lib/RedocTest/redoc-test.js create mode 100644 lib/index.js create mode 100644 package.json create mode 100644 system.config.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..44d7f605 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +### Linux ### +*~ + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + + +### Node ### +# Logs +logs +*.log +npm-debug.log* + +# Dependency directory +# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git +node_modules + +#jspm +jspm_packages + +/dist +/demo/build diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..60df8a47 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,117 @@ +{ + "bitwise" : false, + "curly" : false, + "eqeqeq" : true, + "forin" : true, + "immed" : true, + "latedef" : true, + "newcap" : true, + "noarg" : true, + "noempty" : true, + "nonew" : true, + "plusplus" : false, + "quotmark" : "single", + "regexp" : false, + "undef" : true, + "unused" : true, + "strict" : false, + "camelcase" : false, + "trailing" : true, + "indent" : 2, + "maxlen" : 120, + "maxdepth" : 4, + "maxstatements" : 30, + "maxcomplexity" : 5, + + "asi" : false, + "boss" : true, + "debug" : true, + "eqnull" : true, + "esnext" : true, + "evil" : true, + "expr" : true, + "funcscope" : false, + "globalstrict" : false, + "iterator" : false, + "lastsemic" : true, + "laxbreak" : false, + "laxcomma" : false, + "loopfunc" : false, + "multistr" : false, + "onecase" : false, + "proto" : false, + "regexdash" : false, + "scripturl" : false, + "smarttabs" : false, + "shadow" : false, + "sub" : false, + "supernew" : false, + "validthis" : false, + + "browser" : true, + "couch" : false, + "devel" : true, + "dojo" : false, + "jquery" : true, + "mootools" : false, + "node" : true, + "nonstandard" : false, + "prototypejs" : false, + "rhino" : false, + "wsh" : false, + + "nomen" : false, + "onevar" : false, + "passfail" : false, + "white" : false, + + "maxerr" : 100, + "globals": { + "_": true, + "queryCss": true, + "SVGInjector": true + }, + "predef" : [ + "__dirname", + "System", + "element", + "browser", + "require", + "jasmine", + "protractor", + "ptor", + "describe", + "ddescribe", + "xdescribe", + "it", + "iit", + "angular", + "inject", + "xit", + "beforeEach", + "afterEach", + "expect", + "input", + "pause", + "spyOn", + "runs", + "waits", + "waitsFor", + "Benchmark", + "Raphael", + "Backbone", + "Modernizr", + "Handlebars", + "Ext", + "_gaq", + "module", + "exports", + "define", + "$", + "jQuery", + "grunt", + "phantom", + "WebPage", + "by" + ] +} diff --git a/build/paths.js b/build/paths.js new file mode 100644 index 00000000..d6737fee --- /dev/null +++ b/build/paths.js @@ -0,0 +1,6 @@ +module.exports = { + source: 'lib/**/*.js', + sourceEntryPoint: 'lib/index.js', + outputFolder: 'dist/', + demo: 'demo/**/*' +}; diff --git a/build/tasks/build.js b/build/tasks/build.js new file mode 100644 index 00000000..290f73f8 --- /dev/null +++ b/build/tasks/build.js @@ -0,0 +1,28 @@ +var gulp = require('gulp'); +var runSequence = require('run-sequence'); +var Builder = require('systemjs-builder'); +var path = require('path'); + +var paths = require('../paths'); + +gulp.task('build', function (callback) { + return runSequence( + 'clean', + ['bundle'], + callback + ); +}); + +gulp.task('bundle', function(cb) { + var builder = new Builder('./', 'system.config.js'); + builder + .buildStatic(paths.sourceEntryPoint, path.join(paths.outputFolder, 'redoc.full.js'), + { globalName: 'Redoc' }) + .then(function() { + console.log('Bundle complete'); + cb(); + }) + .catch(function(err) { + cb(new Error(err)); + }); +}); diff --git a/build/tasks/clean.js b/build/tasks/clean.js new file mode 100644 index 00000000..2f9c3bc1 --- /dev/null +++ b/build/tasks/clean.js @@ -0,0 +1,9 @@ +var gulp = require('gulp'); +var paths = require('../paths'); +var del = require('del'); +var vinylPaths = require('vinyl-paths'); + +gulp.task('clean', function () { + return gulp.src([paths.outputFolder]) + .pipe(vinylPaths(del)); +}); diff --git a/build/tasks/serve.js b/build/tasks/serve.js new file mode 100644 index 00000000..4c28ef26 --- /dev/null +++ b/build/tasks/serve.js @@ -0,0 +1,13 @@ +var gulp = require('gulp'); +var browserSync = require('browser-sync').create('bs'); + +gulp.task('serve', ['watch'], function (done) { + browserSync.init({ + open: false, + notify: false, + port: 9000, + server: { + baseDir: ['./demo', '.'] + } + }, done); +}); diff --git a/build/tasks/watch.js b/build/tasks/watch.js new file mode 100644 index 00000000..0454a86f --- /dev/null +++ b/build/tasks/watch.js @@ -0,0 +1,12 @@ +var gulp = require('gulp'); +var paths = require('../paths'); +var browserSync = require('browser-sync').get('bs'); + +function changed(event) { + console.log('File ' + event.path + ' was ' + event.type + ', running tasks...'); +} + +gulp.task('watch', ['build'], function () { + gulp.watch([ paths.source ], [ 'bundle', browserSync.reload ]).on('change', changed); + gulp.watch([ paths.demo ], [ '', browserSync.reload ]).on('change', changed); +}); diff --git a/demo/app.js b/demo/app.js new file mode 100644 index 00000000..c80e2550 --- /dev/null +++ b/demo/app.js @@ -0,0 +1,3 @@ + +console.log("test"); +console.log("test2"); diff --git a/demo/index.html b/demo/index.html new file mode 100644 index 00000000..f1f2f56c --- /dev/null +++ b/demo/index.html @@ -0,0 +1,20 @@ + + + + Angular 2 Quickstart + Angular 2 Quickstart + + + + + Loading... + + + + + + + diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..978fd983 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1 @@ +require('require-dir')('build/tasks'); diff --git a/lib/RedocTest/redoc-test.js b/lib/RedocTest/redoc-test.js new file mode 100644 index 00000000..b79ad223 --- /dev/null +++ b/lib/RedocTest/redoc-test.js @@ -0,0 +1,10 @@ +import {Component, View} from 'angular2/angular2'; + +@Component({selector: 'redoc-test'}) +@View({template: '

Hello {{ name }}!

'}) +// Component controller +export class RedocTest { + constructor() { + this.name = 'ReDoc'; + } +} diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 00000000..5de85392 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,13 @@ +import 'zone.js'; +import 'reflect-metadata'; +import { bootstrap } from 'angular2/angular2'; +import { RedocTest } from './RedocTest/redoc-test'; + +export * from './RedocTest/redoc-test'; + +export function init() { + bootstrap(RedocTest).then( + () => console.log('ReDoc bootstrapped!'), + error => console.log(error) + ); +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..577a358a --- /dev/null +++ b/package.json @@ -0,0 +1,43 @@ +{ + "name": "redoc-proto", + "description": "Prototype of component based Swagger documentation", + "version": "0.0.1", + "scripts": { + "server": "webpack-dev-server --hot --inline --colors --display-error-details --display-cached", + "start": "npm run server", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "Swagger", + "JSON-Schema", + "API", + "documentation", + "Angular 2" + ], + "author": "Roman Hotsiy", + "license": "MIT", + "jspm": { + "configFile": "system.config.js", + "dependencies": { + "angular2": "npm:angular2@^2.0.0-alpha.37", + "es6-shim": "github:es-shims/es6-shim@^0.33.6", + "reflect-metadata": "npm:reflect-metadata@^0.1.2", + "zone.js": "npm:zone.js@^0.5.7" + }, + "devDependencies": { + "babel": "npm:babel-core@^5.8.24", + "babel-runtime": "npm:babel-runtime@^5.8.24", + "core-js": "npm:core-js@^1.1.4" + } + }, + "devDependencies": { + "browser-sync": "^2.9.8", + "del": "^2.0.2", + "gulp": "^3.9.0", + "jspm": "^0.16.11", + "require-dir": "^0.3.0", + "run-sequence": "^1.1.4", + "systemjs-builder": "^0.14.7", + "vinyl-paths": "^2.0.0" + } +} diff --git a/system.config.js b/system.config.js new file mode 100644 index 00000000..99f24dcc --- /dev/null +++ b/system.config.js @@ -0,0 +1,319 @@ +System.config({ + baseURL: "/", + defaultJSExtensions: true, + transpiler: "babel", + babelOptions: { + "optional": [ + "runtime", + "optimisation.modules.system", + 'es7.decorators', + 'es7.classProperties' + ] + }, + paths: { + "github:*": "jspm_packages/github/*", + "npm:*": "jspm_packages/npm/*" + }, + + map: { + "angular2": "npm:angular2@2.0.0-alpha.37", + "babel": "npm:babel-core@5.8.25", + "babel-runtime": "npm:babel-runtime@5.8.25", + "core-js": "npm:core-js@1.2.0", + "es6-shim": "github:es-shims/es6-shim@0.33.6", + "reflect-metadata": "npm:reflect-metadata@0.1.2", + "zone.js": "npm:zone.js@0.5.7", + "github:jspm/nodelibs-assert@0.1.0": { + "assert": "npm:assert@1.3.0" + }, + "github:jspm/nodelibs-buffer@0.1.0": { + "buffer": "npm:buffer@3.5.0" + }, + "github:jspm/nodelibs-constants@0.1.0": { + "constants-browserify": "npm:constants-browserify@0.0.1" + }, + "github:jspm/nodelibs-crypto@0.1.0": { + "crypto-browserify": "npm:crypto-browserify@3.10.0" + }, + "github:jspm/nodelibs-events@0.1.1": { + "events": "npm:events@1.0.2" + }, + "github:jspm/nodelibs-path@0.1.0": { + "path-browserify": "npm:path-browserify@0.0.0" + }, + "github:jspm/nodelibs-process@0.1.1": { + "process": "npm:process@0.10.1" + }, + "github:jspm/nodelibs-stream@0.1.0": { + "stream-browserify": "npm:stream-browserify@1.0.0" + }, + "github:jspm/nodelibs-string_decoder@0.1.0": { + "string_decoder": "npm:string_decoder@0.10.31" + }, + "github:jspm/nodelibs-url@0.1.0": { + "url": "npm:url@0.10.3" + }, + "github:jspm/nodelibs-util@0.1.0": { + "util": "npm:util@0.10.3" + }, + "github:jspm/nodelibs-vm@0.1.0": { + "vm-browserify": "npm:vm-browserify@0.0.4" + }, + "npm:angular2@2.0.0-alpha.37": { + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1", + "reflect-metadata": "npm:reflect-metadata@0.1.2", + "rx": "npm:rx@2.5.1", + "url": "github:jspm/nodelibs-url@0.1.0", + "zone.js": "npm:zone.js@0.5.7" + }, + "npm:asn1.js@2.2.1": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "bn.js": "npm:bn.js@2.2.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "inherits": "npm:inherits@2.0.1", + "minimalistic-assert": "npm:minimalistic-assert@1.0.0", + "vm": "github:jspm/nodelibs-vm@0.1.0" + }, + "npm:assert@1.3.0": { + "util": "npm:util@0.10.3" + }, + "npm:babel-runtime@5.8.25": { + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:browserify-aes@1.0.5": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "buffer-xor": "npm:buffer-xor@1.0.3", + "cipher-base": "npm:cipher-base@1.0.1", + "create-hash": "npm:create-hash@1.1.2", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "evp_bytestokey": "npm:evp_bytestokey@1.0.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "inherits": "npm:inherits@2.0.1", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:browserify-cipher@1.0.0": { + "browserify-aes": "npm:browserify-aes@1.0.5", + "browserify-des": "npm:browserify-des@1.0.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "evp_bytestokey": "npm:evp_bytestokey@1.0.0" + }, + "npm:browserify-des@1.0.0": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "cipher-base": "npm:cipher-base@1.0.1", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "des.js": "npm:des.js@1.0.0", + "inherits": "npm:inherits@2.0.1" + }, + "npm:browserify-rsa@2.0.1": { + "bn.js": "npm:bn.js@2.2.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "constants": "github:jspm/nodelibs-constants@0.1.0", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "randombytes": "npm:randombytes@2.0.1" + }, + "npm:browserify-sign@3.0.8": { + "bn.js": "npm:bn.js@2.2.0", + "browserify-rsa": "npm:browserify-rsa@2.0.1", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "create-hash": "npm:create-hash@1.1.2", + "create-hmac": "npm:create-hmac@1.1.4", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "elliptic": "npm:elliptic@3.1.0", + "inherits": "npm:inherits@2.0.1", + "parse-asn1": "npm:parse-asn1@3.0.2", + "stream": "github:jspm/nodelibs-stream@0.1.0" + }, + "npm:buffer-xor@1.0.3": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:buffer@3.5.0": { + "base64-js": "npm:base64-js@0.0.8", + "ieee754": "npm:ieee754@1.1.6", + "is-array": "npm:is-array@1.0.1" + }, + "npm:cipher-base@1.0.1": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "inherits": "npm:inherits@2.0.1", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0" + }, + "npm:constants-browserify@0.0.1": { + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:core-js@1.2.0": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.1", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:core-util-is@1.0.1": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0" + }, + "npm:create-ecdh@2.0.1": { + "bn.js": "npm:bn.js@2.2.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "elliptic": "npm:elliptic@3.1.0" + }, + "npm:create-hash@1.1.2": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "cipher-base": "npm:cipher-base@1.0.1", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "inherits": "npm:inherits@2.0.1", + "ripemd160": "npm:ripemd160@1.0.1", + "sha.js": "npm:sha.js@2.4.4" + }, + "npm:create-hmac@1.1.4": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "create-hash": "npm:create-hash@1.1.2", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "inherits": "npm:inherits@2.0.1", + "stream": "github:jspm/nodelibs-stream@0.1.0" + }, + "npm:crypto-browserify@3.10.0": { + "browserify-cipher": "npm:browserify-cipher@1.0.0", + "browserify-sign": "npm:browserify-sign@3.0.8", + "create-ecdh": "npm:create-ecdh@2.0.1", + "create-hash": "npm:create-hash@1.1.2", + "create-hmac": "npm:create-hmac@1.1.4", + "diffie-hellman": "npm:diffie-hellman@3.0.2", + "inherits": "npm:inherits@2.0.1", + "pbkdf2": "npm:pbkdf2@3.0.4", + "public-encrypt": "npm:public-encrypt@2.0.1", + "randombytes": "npm:randombytes@2.0.1" + }, + "npm:des.js@1.0.0": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "inherits": "npm:inherits@2.0.1", + "minimalistic-assert": "npm:minimalistic-assert@1.0.0" + }, + "npm:diffie-hellman@3.0.2": { + "bn.js": "npm:bn.js@2.2.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "miller-rabin": "npm:miller-rabin@2.0.1", + "randombytes": "npm:randombytes@2.0.1", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:elliptic@3.1.0": { + "bn.js": "npm:bn.js@2.2.0", + "brorand": "npm:brorand@1.0.5", + "hash.js": "npm:hash.js@1.0.3", + "inherits": "npm:inherits@2.0.1", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:es6-promise@3.0.2": { + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:evp_bytestokey@1.0.0": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "create-hash": "npm:create-hash@1.1.2", + "crypto": "github:jspm/nodelibs-crypto@0.1.0" + }, + "npm:hash.js@1.0.3": { + "inherits": "npm:inherits@2.0.1" + }, + "npm:inherits@2.0.1": { + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:miller-rabin@2.0.1": { + "bn.js": "npm:bn.js@2.2.0", + "brorand": "npm:brorand@1.0.5" + }, + "npm:parse-asn1@3.0.2": { + "asn1.js": "npm:asn1.js@2.2.1", + "browserify-aes": "npm:browserify-aes@1.0.5", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "create-hash": "npm:create-hash@1.1.2", + "evp_bytestokey": "npm:evp_bytestokey@1.0.0", + "pbkdf2": "npm:pbkdf2@3.0.4", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:path-browserify@0.0.0": { + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:pbkdf2@3.0.4": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "child_process": "github:jspm/nodelibs-child_process@0.1.0", + "create-hmac": "npm:create-hmac@1.1.4", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:public-encrypt@2.0.1": { + "bn.js": "npm:bn.js@2.2.0", + "browserify-rsa": "npm:browserify-rsa@2.0.1", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "create-hash": "npm:create-hash@1.1.2", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "parse-asn1": "npm:parse-asn1@3.0.2", + "randombytes": "npm:randombytes@2.0.1" + }, + "npm:punycode@1.3.2": { + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:randombytes@2.0.1": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:readable-stream@1.1.13": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "core-util-is": "npm:core-util-is@1.0.1", + "events": "github:jspm/nodelibs-events@0.1.1", + "inherits": "npm:inherits@2.0.1", + "isarray": "npm:isarray@0.0.1", + "process": "github:jspm/nodelibs-process@0.1.1", + "stream-browserify": "npm:stream-browserify@1.0.0", + "string_decoder": "npm:string_decoder@0.10.31" + }, + "npm:reflect-metadata@0.1.2": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:ripemd160@1.0.1": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:rx@2.5.1": { + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:sha.js@2.4.4": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "inherits": "npm:inherits@2.0.1", + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:stream-browserify@1.0.0": { + "events": "github:jspm/nodelibs-events@0.1.1", + "inherits": "npm:inherits@2.0.1", + "readable-stream": "npm:readable-stream@1.1.13" + }, + "npm:string_decoder@0.10.31": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0" + }, + "npm:url@0.10.3": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "punycode": "npm:punycode@1.3.2", + "querystring": "npm:querystring@0.2.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:util@0.10.3": { + "inherits": "npm:inherits@2.0.1", + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:vm-browserify@0.0.4": { + "indexof": "npm:indexof@0.0.1" + }, + "npm:zone.js@0.5.7": { + "es6-promise": "npm:es6-promise@3.0.2", + "process": "github:jspm/nodelibs-process@0.1.1" + } + } +}); From acaba493d98f3131c3baa486e282c0fbc8fa55c7 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 3 Oct 2015 12:50:35 +0300 Subject: [PATCH 03/97] Support for html and css in separate files --- .gitignore | 1 + build/paths.js | 5 ++++- build/tasks/build.js | 16 ++++++++++++---- build/tasks/clean.js | 2 +- build/tasks/watch.js | 4 +++- lib/RedocTest/redoc-test.css | 3 +++ lib/RedocTest/redoc-test.html | 1 + lib/RedocTest/redoc-test.js | 5 ++++- package.json | 1 + 9 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 lib/RedocTest/redoc-test.css create mode 100644 lib/RedocTest/redoc-test.html diff --git a/.gitignore b/.gitignore index 44d7f605..a999e0b3 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ jspm_packages /dist /demo/build +.tmp diff --git a/build/paths.js b/build/paths.js index d6737fee..f5210ba7 100644 --- a/build/paths.js +++ b/build/paths.js @@ -1,6 +1,9 @@ module.exports = { source: 'lib/**/*.js', + html: 'lib/**/*.html', + css: 'lib/**/*.css', sourceEntryPoint: 'lib/index.js', - outputFolder: 'dist/', + output: 'dist/', + tmp: '.tmp/', demo: 'demo/**/*' }; diff --git a/build/tasks/build.js b/build/tasks/build.js index 290f73f8..736e4b39 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -1,25 +1,33 @@ var gulp = require('gulp'); var runSequence = require('run-sequence'); var Builder = require('systemjs-builder'); +var inlineNg2Template = require('gulp-inline-ng2-template'); var path = require('path'); var paths = require('../paths'); +var fs= require('fs'); gulp.task('build', function (callback) { return runSequence( 'clean', - ['bundle'], + 'bundleSfx', callback ); }); -gulp.task('bundle', function(cb) { +gulp.task('inlineTemplates', function() { + return gulp.src(paths.source, { base: './' }) + .pipe(inlineNg2Template({ base: '/' })) + .pipe(gulp.dest(paths.tmp)); +}); + +gulp.task('bundleSfx', ['inlineTemplates'], function(cb) { var builder = new Builder('./', 'system.config.js'); builder - .buildStatic(paths.sourceEntryPoint, path.join(paths.outputFolder, 'redoc.full.js'), + .buildStatic(path.join(paths.tmp, paths.sourceEntryPoint), + path.join(paths.output, 'redoc.full.js'), { globalName: 'Redoc' }) .then(function() { - console.log('Bundle complete'); cb(); }) .catch(function(err) { diff --git a/build/tasks/clean.js b/build/tasks/clean.js index 2f9c3bc1..f96f5682 100644 --- a/build/tasks/clean.js +++ b/build/tasks/clean.js @@ -4,6 +4,6 @@ var del = require('del'); var vinylPaths = require('vinyl-paths'); gulp.task('clean', function () { - return gulp.src([paths.outputFolder]) + return gulp.src([paths.output, paths.tmp]) .pipe(vinylPaths(del)); }); diff --git a/build/tasks/watch.js b/build/tasks/watch.js index 0454a86f..ee6e9100 100644 --- a/build/tasks/watch.js +++ b/build/tasks/watch.js @@ -7,6 +7,8 @@ function changed(event) { } gulp.task('watch', ['build'], function () { - gulp.watch([ paths.source ], [ 'bundle', browserSync.reload ]).on('change', changed); + gulp.watch([ paths.source ], [ 'bundleSfx', browserSync.reload ]).on('change', changed); + gulp.watch([ paths.html ], [ 'bundleSfx', browserSync.reload]).on('change', changed); + gulp.watch([ paths.css ], [ 'bundleSfx', browserSync.reload]).on('change', changed); gulp.watch([ paths.demo ], [ '', browserSync.reload ]).on('change', changed); }); diff --git a/lib/RedocTest/redoc-test.css b/lib/RedocTest/redoc-test.css new file mode 100644 index 00000000..4803c77c --- /dev/null +++ b/lib/RedocTest/redoc-test.css @@ -0,0 +1,3 @@ +h1 strong { + color: #1976D3; +} diff --git a/lib/RedocTest/redoc-test.html b/lib/RedocTest/redoc-test.html new file mode 100644 index 00000000..13a505da --- /dev/null +++ b/lib/RedocTest/redoc-test.html @@ -0,0 +1 @@ +

Hello {{ name }}!

diff --git a/lib/RedocTest/redoc-test.js b/lib/RedocTest/redoc-test.js index b79ad223..dc75a85a 100644 --- a/lib/RedocTest/redoc-test.js +++ b/lib/RedocTest/redoc-test.js @@ -1,7 +1,10 @@ import {Component, View} from 'angular2/angular2'; @Component({selector: 'redoc-test'}) -@View({template: '

Hello {{ name }}!

'}) +@View({ + templateUrl: './lib/RedocTest/redoc-test.html', + styleUrls: ['./lib/RedocTest/redoc-test.css'], +}) // Component controller export class RedocTest { constructor() { diff --git a/package.json b/package.json index 577a358a..36780221 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "browser-sync": "^2.9.8", "del": "^2.0.2", "gulp": "^3.9.0", + "gulp-inline-ng2-template": "0.0.7", "jspm": "^0.16.11", "require-dir": "^0.3.0", "run-sequence": "^1.1.4", From 75b4eeb33489ac503d13fcf52b688253446764b6 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 3 Oct 2015 12:57:37 +0300 Subject: [PATCH 04/97] updated demo title --- demo/index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/demo/index.html b/demo/index.html index f1f2f56c..4408873e 100644 --- a/demo/index.html +++ b/demo/index.html @@ -1,8 +1,7 @@ - Angular 2 Quickstart - Angular 2 Quickstart + ReDoc prototype From 454667730d20200a04c12655581e273ec07b87c1 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 3 Oct 2015 13:37:03 +0300 Subject: [PATCH 05/97] Updated packeage.json with repository info --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 36780221..dd98e2e4 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,8 @@ "name": "redoc-proto", "description": "Prototype of component based Swagger documentation", "version": "0.0.1", + "private": true, + "repository": "RomanGotsiy/redoc-prototype", "scripts": { "server": "webpack-dev-server --hot --inline --colors --display-error-details --display-cached", "start": "npm run server", From bfb0f6446eba3c7f3e277e1138b3151da6e0aa2c Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 3 Oct 2015 15:11:57 +0300 Subject: [PATCH 06/97] Added linting --- .eslintrc | 15 +++++ .jshintrc | 117 ------------------------------------ build/tasks/lint.js | 10 +++ lib/RedocTest/redoc-test.js | 4 +- lib/index.js | 2 + package.json | 9 ++- 6 files changed, 36 insertions(+), 121 deletions(-) create mode 100644 .eslintrc delete mode 100644 .jshintrc create mode 100644 build/tasks/lint.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..a4e474cb --- /dev/null +++ b/.eslintrc @@ -0,0 +1,15 @@ +{ + "parser": "babel-eslint", + "extends": "eslint:recommended", + "env": { + "browser": true, + }, + "rules": { + "quotes": [2, "single"], + "no-console": 0, + "comma-spacing": 2, + "comma-style": [2, "last"], + "consistent-return": 2, + "strict": [2, "global"] + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 60df8a47..00000000 --- a/.jshintrc +++ /dev/null @@ -1,117 +0,0 @@ -{ - "bitwise" : false, - "curly" : false, - "eqeqeq" : true, - "forin" : true, - "immed" : true, - "latedef" : true, - "newcap" : true, - "noarg" : true, - "noempty" : true, - "nonew" : true, - "plusplus" : false, - "quotmark" : "single", - "regexp" : false, - "undef" : true, - "unused" : true, - "strict" : false, - "camelcase" : false, - "trailing" : true, - "indent" : 2, - "maxlen" : 120, - "maxdepth" : 4, - "maxstatements" : 30, - "maxcomplexity" : 5, - - "asi" : false, - "boss" : true, - "debug" : true, - "eqnull" : true, - "esnext" : true, - "evil" : true, - "expr" : true, - "funcscope" : false, - "globalstrict" : false, - "iterator" : false, - "lastsemic" : true, - "laxbreak" : false, - "laxcomma" : false, - "loopfunc" : false, - "multistr" : false, - "onecase" : false, - "proto" : false, - "regexdash" : false, - "scripturl" : false, - "smarttabs" : false, - "shadow" : false, - "sub" : false, - "supernew" : false, - "validthis" : false, - - "browser" : true, - "couch" : false, - "devel" : true, - "dojo" : false, - "jquery" : true, - "mootools" : false, - "node" : true, - "nonstandard" : false, - "prototypejs" : false, - "rhino" : false, - "wsh" : false, - - "nomen" : false, - "onevar" : false, - "passfail" : false, - "white" : false, - - "maxerr" : 100, - "globals": { - "_": true, - "queryCss": true, - "SVGInjector": true - }, - "predef" : [ - "__dirname", - "System", - "element", - "browser", - "require", - "jasmine", - "protractor", - "ptor", - "describe", - "ddescribe", - "xdescribe", - "it", - "iit", - "angular", - "inject", - "xit", - "beforeEach", - "afterEach", - "expect", - "input", - "pause", - "spyOn", - "runs", - "waits", - "waitsFor", - "Benchmark", - "Raphael", - "Backbone", - "Modernizr", - "Handlebars", - "Ext", - "_gaq", - "module", - "exports", - "define", - "$", - "jQuery", - "grunt", - "phantom", - "WebPage", - "by" - ] -} diff --git a/build/tasks/lint.js b/build/tasks/lint.js new file mode 100644 index 00000000..e073f8fa --- /dev/null +++ b/build/tasks/lint.js @@ -0,0 +1,10 @@ +var gulp = require('gulp'); +var eslint = require('gulp-eslint'); +var paths = require('../paths'); + +gulp.task('lint', function () { + return gulp.src(paths.source) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); diff --git a/lib/RedocTest/redoc-test.js b/lib/RedocTest/redoc-test.js index dc75a85a..9b150ca9 100644 --- a/lib/RedocTest/redoc-test.js +++ b/lib/RedocTest/redoc-test.js @@ -1,9 +1,11 @@ +'use strict'; + import {Component, View} from 'angular2/angular2'; @Component({selector: 'redoc-test'}) @View({ templateUrl: './lib/RedocTest/redoc-test.html', - styleUrls: ['./lib/RedocTest/redoc-test.css'], + styleUrls: ['./lib/RedocTest/redoc-test.css'] }) // Component controller export class RedocTest { diff --git a/lib/index.js b/lib/index.js index 5de85392..78c2dc2f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,3 +1,5 @@ +'use strict'; + import 'zone.js'; import 'reflect-metadata'; import { bootstrap } from 'angular2/angular2'; diff --git a/package.json b/package.json index dd98e2e4..08304ef4 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,8 @@ "private": true, "repository": "RomanGotsiy/redoc-prototype", "scripts": { - "server": "webpack-dev-server --hot --inline --colors --display-error-details --display-cached", - "start": "npm run server", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "gulp lint", + "postinstall": "jspm install" }, "keywords": [ "Swagger", @@ -33,10 +32,14 @@ } }, "devDependencies": { + "babel-eslint": "^4.1.3", "browser-sync": "^2.9.8", "del": "^2.0.2", "gulp": "^3.9.0", + "gulp-eslint": "^1.0.0", "gulp-inline-ng2-template": "0.0.7", + "gulp-jshint": "^1.11.2", + "jshint-stylish": "^2.0.1", "jspm": "^0.16.11", "require-dir": "^0.3.0", "run-sequence": "^1.1.4", From 10e8f199d2b97daf09eb4e8b67c4dd27fe394a66 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 3 Oct 2015 15:24:12 +0300 Subject: [PATCH 07/97] Set up travis build and gh-pages deploy --- .travis.yml | 16 ++++++++++++++++ deploy_gh_pages.sh | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .travis.yml create mode 100755 deploy_gh_pages.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..df266815 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: node_js +node_js: + - "0.12" +env: + global: + - GH_REF: "github.com/RomanGotsiy/redoc-prototype.git" + - secure: "gpLnG4Jgac401YmoOPVD5D2oiCAlOAgDXIQmISYDQOX1HwzDK0B+9210Nu+Vf1HY5OCWEYK+9Fc+MliAQgX1JIX3VXODd7PKLBY53YJEha9KyiQePBvH8QLzVEhVWb4PU/Rird/h4ndBLhlVeVZ9kXH5Qi2wAFV0GJHIOl3lapRqqDO5l3OcHTT/q9E4NdgTBa5tX0xRDB6015nb8We55lL+RvmAAFKaDY0g11LySj8aCVsyEgRgnFAHiM27GrsulDLcEXxu2+Om9Lwx7cnMzRs773GNVAyFeE+JChO94XHB4C0cVmTSXZE57lxRFhtAGcwdSpVSDU++xIGbdhCpuQ5swT3bk/Old0kxbvp6OpWlZTYzFTY40G/E+bs3NmITBc5mxy1hRYHyTi6nMBE0UpczEiFSOLr0eOMEFVKcOhusGrGD4veKm9Ho3M9fJYh6m8jLvqLKovui3Td3W2i/x9NIA88UWlfOUVfpIbNmxgWVBCKnQFMR+5XxkLeSV6E6Hx/zUNGuRSLEQNIBw9aj8FPOem0Rg3PmSjExyAx+QWB+vW1s90J4S+r7LZPsvSJNMAQI9kBDP75D9qrv1YBfs+kNY+PPRXjk2MhyGJLByhdxQsYQ7nOV0OPjxj3gUm2kH9uQIYx7zgSv4rcTphdh6rWfWCggbHJBeWBdrtdnf+M=" +before_script: + - npm install -g gulp +before_deploy: + - gulp build +deploy: + provider: script + script: ./deploy_gh_pages.sh + on: + branch: master diff --git a/deploy_gh_pages.sh b/deploy_gh_pages.sh new file mode 100755 index 00000000..a921493b --- /dev/null +++ b/deploy_gh_pages.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -o pipefail +( + set -e + set -x + cd demo + git init + git config user.name "Travis-CI" + git config user.email "travis@travis" + cp -r ../dist ./dist + git add . + git commit -m "Deployed to Github Pages" + git push --force "https://${GH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1 +) 2>&1 | sed "s/${GH_TOKEN}/xxPASSxx/" From 9e9857cf61c6017d607fc208cae2d96476d4b180 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 3 Oct 2015 15:55:29 +0300 Subject: [PATCH 08/97] Fixed jspm install github rate limit (travis) --- .travis.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index df266815..a5148008 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,23 @@ language: node_js node_js: - - "0.12" +- '0.12' env: global: - - GH_REF: "github.com/RomanGotsiy/redoc-prototype.git" - - secure: "gpLnG4Jgac401YmoOPVD5D2oiCAlOAgDXIQmISYDQOX1HwzDK0B+9210Nu+Vf1HY5OCWEYK+9Fc+MliAQgX1JIX3VXODd7PKLBY53YJEha9KyiQePBvH8QLzVEhVWb4PU/Rird/h4ndBLhlVeVZ9kXH5Qi2wAFV0GJHIOl3lapRqqDO5l3OcHTT/q9E4NdgTBa5tX0xRDB6015nb8We55lL+RvmAAFKaDY0g11LySj8aCVsyEgRgnFAHiM27GrsulDLcEXxu2+Om9Lwx7cnMzRs773GNVAyFeE+JChO94XHB4C0cVmTSXZE57lxRFhtAGcwdSpVSDU++xIGbdhCpuQ5swT3bk/Old0kxbvp6OpWlZTYzFTY40G/E+bs3NmITBc5mxy1hRYHyTi6nMBE0UpczEiFSOLr0eOMEFVKcOhusGrGD4veKm9Ho3M9fJYh6m8jLvqLKovui3Td3W2i/x9NIA88UWlfOUVfpIbNmxgWVBCKnQFMR+5XxkLeSV6E6Hx/zUNGuRSLEQNIBw9aj8FPOem0Rg3PmSjExyAx+QWB+vW1s90J4S+r7LZPsvSJNMAQI9kBDP75D9qrv1YBfs+kNY+PPRXjk2MhyGJLByhdxQsYQ7nOV0OPjxj3gUm2kH9uQIYx7zgSv4rcTphdh6rWfWCggbHJBeWBdrtdnf+M=" + - GH_REF: github.com/RomanGotsiy/redoc-prototype.git + - secure: gpLnG4Jgac401YmoOPVD5D2oiCAlOAgDXIQmISYDQOX1HwzDK0B+9210Nu+Vf1HY5OCWEYK+9Fc+MliAQgX1JIX3VXODd7PKLBY53YJEha9KyiQePBvH8QLzVEhVWb4PU/Rird/h4ndBLhlVeVZ9kXH5Qi2wAFV0GJHIOl3lapRqqDO5l3OcHTT/q9E4NdgTBa5tX0xRDB6015nb8We55lL+RvmAAFKaDY0g11LySj8aCVsyEgRgnFAHiM27GrsulDLcEXxu2+Om9Lwx7cnMzRs773GNVAyFeE+JChO94XHB4C0cVmTSXZE57lxRFhtAGcwdSpVSDU++xIGbdhCpuQ5swT3bk/Old0kxbvp6OpWlZTYzFTY40G/E+bs3NmITBc5mxy1hRYHyTi6nMBE0UpczEiFSOLr0eOMEFVKcOhusGrGD4veKm9Ho3M9fJYh6m8jLvqLKovui3Td3W2i/x9NIA88UWlfOUVfpIbNmxgWVBCKnQFMR+5XxkLeSV6E6Hx/zUNGuRSLEQNIBw9aj8FPOem0Rg3PmSjExyAx+QWB+vW1s90J4S+r7LZPsvSJNMAQI9kBDP75D9qrv1YBfs+kNY+PPRXjk2MhyGJLByhdxQsYQ7nOV0OPjxj3gUm2kH9uQIYx7zgSv4rcTphdh6rWfWCggbHJBeWBdrtdnf+M= + - secure: EbOO3vHJAsuzvW1encS7lGFOQtoHrTF45HP+tcu9YW6VmMr9FPJXsf7AFmquama3w3miWJayAXtoEdrx3WM5kRnK7sP9xg/X4emWKIE8MAlS//PyiQlrRRNakA5L7vlEX/w/goIApapWiwQ9OFDlVZAnH1/y05Hf411qsVCThfuKCdUfrbjnMkaVBuWVXggfllBVyFKVzk97AJiYrZtOw4rUljyG6pb3EhHKwP6QbJN/I4rKRtlQ0gMFnDFCqrcBntaQjMRZK3HNMuAoEzhzLRjNc6j8mcJdBHcon0+HhLCpn2Isoo3WRQQB85eaAg9xryPBWXGAGS/e2yyL6nHNqnrbrA7O27HA53L5jQFNnzrWtCJMSApVJXGtLxwYpdHFln4QYNSKVXP5tNyLidvq+7iUFRHMyIyAlOiOXNDcYk7Wo0/TBbAawmfhQ0oSj8SweA2XEfH0gqFEiYedjlzafyLkB6tmiX6POOEgDRkDB6QrI5gWJpRsNbcA+/lMwBbaZbfncZ1zolyMA8l71Q/yuMFfrw32qJlwFG7cwMqHqMhUlVri3129XYOzkuE5DDsK5xpd9n/jRMgZXz+hJdAPCeUds9TTjXP0f4NGhxPL8vJpuHiiQ6dnZ9YuQqz4AHKbWqlEYaF681XnOlEb1360hIQOFT7ixcWl1A//bq5Ip3w= +cache: + directories: + - node_modules +before_install: +- npm install -g jspm +- jspm config registries.github.auth $JSPM_GITHUB_AUTH_TOKEN before_script: - - npm install -g gulp +- npm install -g gulp before_deploy: - - gulp build +- gulp build deploy: provider: script - script: ./deploy_gh_pages.sh + script: "./deploy_gh_pages.sh" on: branch: master From 024e17206ff35e921c562f0f3536e1585f85992c Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 3 Oct 2015 16:05:19 +0300 Subject: [PATCH 09/97] Added skip_cleanup flag to travis deploy --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a5148008..5c0c61db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ before_script: before_deploy: - gulp build deploy: + skip_cleanup: true provider: script script: "./deploy_gh_pages.sh" on: From 6f13786fa96da15de8d308cfd1a2efd32dac5ab9 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 3 Oct 2015 16:17:19 +0300 Subject: [PATCH 10/97] Updated README [ci skip] --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 579d9790..bb17f642 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ - ReDoc prototype - =============== - - Prototype of component based Swagger documentation +# ReDoc prototype + +[![Build Status](https://travis-ci.org/RomanGotsiy/redoc-prototype.svg?branch=master)](https://travis-ci.org/RomanGotsiy/redoc-prototype) + +Prototype of component-based Swagger documentation + +**Under development** + +[Live demo](http://romangotsiy.github.io/redoc-prototype/) From bf3ab9f96eb700939ff735525640705174340c14 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 7 Oct 2015 10:18:02 +0300 Subject: [PATCH 11/97] Added sourcemaps --- build/tasks/build.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index 736e4b39..aa87df19 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -26,7 +26,8 @@ gulp.task('bundleSfx', ['inlineTemplates'], function(cb) { builder .buildStatic(path.join(paths.tmp, paths.sourceEntryPoint), path.join(paths.output, 'redoc.full.js'), - { globalName: 'Redoc' }) + { globalName: 'Redoc', sourceMaps: true } + ) .then(function() { cb(); }) From eeb8941fbaad483ec63027b04db4091f4e24f94d Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 7 Oct 2015 11:58:07 +0300 Subject: [PATCH 12/97] Added test petstore description --- demo/petstore.json | 819 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 819 insertions(+) create mode 100644 demo/petstore.json diff --git a/demo/petstore.json b/demo/petstore.json new file mode 100644 index 00000000..9324cca2 --- /dev/null +++ b/demo/petstore.json @@ -0,0 +1,819 @@ +{ + "swagger": "2.0", + "info": { + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "version": "1.0.0", + "title": "Swagger Petstore", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "email": "apiteam@swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "host": "petstore.swagger.io", + "basePath": "/v2", + "tags": [{ + "name": "pet", + "description": "Everything about your Pets", + "externalDocs": { + "description": "Find out more", + "url": "http://swagger.io" + } + }, { + "name": "store", + "description": "Access to Petstore orders" + }, { + "name": "user", + "description": "Operations about user", + "externalDocs": { + "description": "Find out more about our store", + "url": "http://swagger.io" + } + }], + "schemes": ["http"], + "paths": { + "/pet": { + "post": { + "tags": ["pet"], + "summary": "Add a new pet to the store", + "description": "", + "operationId": "addPet", + "consumes": ["application/json", "application/xml"], + "produces": ["application/xml", "application/json"], + "parameters": [{ + "in": "body", + "name": "body", + "description": "Pet object that needs to be added to the store", + "required": true, + "schema": { + "$ref": "#/definitions/Pet" + } + }], + "responses": { + "405": { + "description": "Invalid input" + } + }, + "security": [{ + "petstore_auth": ["write:pets", "read:pets"] + }] + }, + "put": { + "tags": ["pet"], + "summary": "Update an existing pet", + "description": "", + "operationId": "updatePet", + "consumes": ["application/json", "application/xml"], + "produces": ["application/xml", "application/json"], + "parameters": [{ + "in": "body", + "name": "body", + "description": "Pet object that needs to be added to the store", + "required": true, + "schema": { + "$ref": "#/definitions/Pet" + } + }], + "responses": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" + } + }, + "security": [{ + "petstore_auth": ["write:pets", "read:pets"] + }] + } + }, + "/pet/findByStatus": { + "get": { + "tags": ["pet"], + "summary": "Finds Pets by status", + "description": "Multiple status values can be provided with comma seperated strings", + "operationId": "findPetsByStatus", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "status", + "in": "query", + "description": "Status values that need to be considered for filter", + "required": true, + "type": "array", + "items": { + "type": "string", + "enum": ["available", "pending", "sold"], + "default": "available" + }, + "collectionFormat": "csv" + }], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Pet" + } + } + }, + "400": { + "description": "Invalid status value" + } + }, + "security": [{ + "petstore_auth": ["write:pets", "read:pets"] + }] + } + }, + "/pet/findByTags": { + "get": { + "tags": ["pet"], + "summary": "Finds Pets by tags", + "description": "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", + "operationId": "findPetsByTags", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "tags", + "in": "query", + "description": "Tags to filter by", + "required": true, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "csv" + }], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Pet" + } + } + }, + "400": { + "description": "Invalid tag value" + } + }, + "security": [{ + "petstore_auth": ["write:pets", "read:pets"] + }] + } + }, + "/pet/{petId}": { + "get": { + "tags": ["pet"], + "summary": "Find pet by ID", + "description": "Returns a single pet", + "operationId": "getPetById", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "petId", + "in": "path", + "description": "ID of pet to return", + "required": true, + "type": "integer", + "format": "int64" + }], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/Pet" + } + }, + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + } + }, + "security": [{ + "api_key": [] + }] + }, + "post": { + "tags": ["pet"], + "summary": "Updates a pet in the store with form data", + "description": "", + "operationId": "updatePetWithForm", + "consumes": ["application/x-www-form-urlencoded"], + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "petId", + "in": "path", + "description": "ID of pet that needs to be updated", + "required": true, + "type": "integer", + "format": "int64" + }, { + "name": "name", + "in": "formData", + "description": "Updated name of the pet", + "required": false, + "type": "string" + }, { + "name": "status", + "in": "formData", + "description": "Updated status of the pet", + "required": false, + "type": "string" + }], + "responses": { + "405": { + "description": "Invalid input" + } + }, + "security": [{ + "petstore_auth": ["write:pets", "read:pets"] + }] + }, + "delete": { + "tags": ["pet"], + "summary": "Deletes a pet", + "description": "", + "operationId": "deletePet", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "api_key", + "in": "header", + "required": false, + "type": "string" + }, { + "name": "petId", + "in": "path", + "description": "Pet id to delete", + "required": true, + "type": "integer", + "format": "int64" + }], + "responses": { + "400": { + "description": "Invalid pet value" + } + }, + "security": [{ + "petstore_auth": ["write:pets", "read:pets"] + }] + } + }, + "/pet/{petId}/uploadImage": { + "post": { + "tags": ["pet"], + "summary": "uploads an image", + "description": "", + "operationId": "uploadFile", + "consumes": ["multipart/form-data"], + "produces": ["application/json"], + "parameters": [{ + "name": "petId", + "in": "path", + "description": "ID of pet to update", + "required": true, + "type": "integer", + "format": "int64" + }, { + "name": "additionalMetadata", + "in": "formData", + "description": "Additional data to pass to server", + "required": false, + "type": "string" + }, { + "name": "file", + "in": "formData", + "description": "file to upload", + "required": false, + "type": "file" + }], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/ApiResponse" + } + } + }, + "security": [{ + "petstore_auth": ["write:pets", "read:pets"] + }] + } + }, + "/store/inventory": { + "get": { + "tags": ["store"], + "summary": "Returns pet inventories by status", + "description": "Returns a map of status codes to quantities", + "operationId": "getInventory", + "produces": ["application/json"], + "parameters": [], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int32" + } + } + } + }, + "security": [{ + "api_key": [] + }] + } + }, + "/store/order": { + "post": { + "tags": ["store"], + "summary": "Place an order for a pet", + "description": "", + "operationId": "placeOrder", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "in": "body", + "name": "body", + "description": "order placed for purchasing the pet", + "required": true, + "schema": { + "$ref": "#/definitions/Order" + } + }], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/Order" + } + }, + "400": { + "description": "Invalid Order" + } + } + } + }, + "/store/order/{orderId}": { + "get": { + "tags": ["store"], + "summary": "Find purchase order by ID", + "description": "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", + "operationId": "getOrderById", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "orderId", + "in": "path", + "description": "ID of pet that needs to be fetched", + "required": true, + "type": "integer", + "maximum": 5.0, + "minimum": 1.0, + "format": "int64" + }], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/Order" + } + }, + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Order not found" + } + } + }, + "delete": { + "tags": ["store"], + "summary": "Delete purchase order by ID", + "description": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId": "deleteOrder", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "orderId", + "in": "path", + "description": "ID of the order that needs to be deleted", + "required": true, + "type": "string", + "minimum": 1.0 + }], + "responses": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Order not found" + } + } + } + }, + "/user": { + "post": { + "tags": ["user"], + "summary": "Create user", + "description": "This can only be done by the logged in user.", + "operationId": "createUser", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "in": "body", + "name": "body", + "description": "Created user object", + "required": true, + "schema": { + "$ref": "#/definitions/User" + } + }], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/user/createWithArray": { + "post": { + "tags": ["user"], + "summary": "Creates list of users with given input array", + "description": "", + "operationId": "createUsersWithArrayInput", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "in": "body", + "name": "body", + "description": "List of user object", + "required": true, + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + } + }], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/user/createWithList": { + "post": { + "tags": ["user"], + "summary": "Creates list of users with given input array", + "description": "", + "operationId": "createUsersWithListInput", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "in": "body", + "name": "body", + "description": "List of user object", + "required": true, + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + } + }], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/user/login": { + "get": { + "tags": ["user"], + "summary": "Logs user into the system", + "description": "", + "operationId": "loginUser", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "username", + "in": "query", + "description": "The user name for login", + "required": true, + "type": "string" + }, { + "name": "password", + "in": "query", + "description": "The password for login in clear text", + "required": true, + "type": "string" + }], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "string" + }, + "headers": { + "X-Rate-Limit": { + "type": "integer", + "format": "int32", + "description": "calls per hour allowed by the user" + }, + "X-Expires-After": { + "type": "string", + "format": "date-time", + "description": "date in UTC when toekn expires" + } + } + }, + "400": { + "description": "Invalid username/password supplied" + } + } + } + }, + "/user/logout": { + "get": { + "tags": ["user"], + "summary": "Logs out current logged in user session", + "description": "", + "operationId": "logoutUser", + "produces": ["application/xml", "application/json"], + "parameters": [], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/user/{username}": { + "get": { + "tags": ["user"], + "summary": "Get user by user name", + "description": "", + "operationId": "getUserByName", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "username", + "in": "path", + "description": "The name that needs to be fetched. Use user1 for testing. ", + "required": true, + "type": "string" + }], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/User" + } + }, + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" + } + } + }, + "put": { + "tags": ["user"], + "summary": "Updated user", + "description": "This can only be done by the logged in user.", + "operationId": "updateUser", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "username", + "in": "path", + "description": "name that need to be deleted", + "required": true, + "type": "string" + }, { + "in": "body", + "name": "body", + "description": "Updated user object", + "required": true, + "schema": { + "$ref": "#/definitions/User" + } + }], + "responses": { + "400": { + "description": "Invalid user supplied" + }, + "404": { + "description": "User not found" + } + } + }, + "delete": { + "tags": ["user"], + "summary": "Delete user", + "description": "This can only be done by the logged in user.", + "operationId": "deleteUser", + "produces": ["application/xml", "application/json"], + "parameters": [{ + "name": "username", + "in": "path", + "description": "The name that needs to be deleted", + "required": true, + "type": "string" + }], + "responses": { + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" + } + } + } + } + }, + "securityDefinitions": { + "petstore_auth": { + "type": "oauth2", + "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", + "flow": "implicit", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + }, + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header" + } + }, + "definitions": { + "Order": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "petId": { + "type": "integer", + "format": "int64" + }, + "quantity": { + "type": "integer", + "format": "int32" + }, + "shipDate": { + "type": "string", + "format": "date-time" + }, + "status": { + "type": "string", + "description": "Order Status", + "enum": ["placed", "approved", "delivered"] + }, + "complete": { + "type": "boolean", + "default": false + } + }, + "xml": { + "name": "Order" + } + }, + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "username": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "userStatus": { + "type": "integer", + "format": "int32", + "description": "User Status" + } + }, + "xml": { + "name": "User" + } + }, + "Category": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + }, + "xml": { + "name": "Category" + } + }, + "Tag": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + }, + "xml": { + "name": "Tag" + } + }, + "Pet": { + "type": "object", + "required": ["name", "photoUrls"], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "category": { + "$ref": "#/definitions/Category" + }, + "name": { + "type": "string", + "example": "doggie" + }, + "photoUrls": { + "type": "array", + "xml": { + "name": "photoUrl", + "wrapped": true + }, + "items": { + "type": "string" + } + }, + "tags": { + "type": "array", + "xml": { + "name": "tag", + "wrapped": true + }, + "items": { + "$ref": "#/definitions/Tag" + } + }, + "status": { + "type": "string", + "description": "pet status in the store", + "enum": ["available", "pending", "sold"] + } + }, + "xml": { + "name": "Pet" + } + }, + "ApiResponse": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + }, + "message": { + "type": "string" + } + } + } + }, + "externalDocs": { + "description": "Find out more about Swagger", + "url": "http://swagger.io" + } +} From 920c5c0497fd0578b7997c1bbd5d50be057f2b5d Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 7 Oct 2015 12:47:57 +0300 Subject: [PATCH 13/97] Schema loader and Schema Info component --- demo/index.html | 6 +- lib/RedocTest/redoc-test.html | 1 - lib/RedocTest/redoc-test.js | 15 - lib/components/Redoc/redoc.html | 1 + lib/components/Redoc/redoc.js | 27 + .../RedocInfo/redoc-info.css} | 0 lib/components/RedocInfo/redoc-info.html | 15 + lib/components/RedocInfo/redoc-info.js | 27 + lib/components/index.js | 4 + lib/index.js | 13 +- lib/utils/SchemaManager.js | 44 ++ package.json | 4 +- system.config.js | 466 +++++++++++++++++- 13 files changed, 580 insertions(+), 43 deletions(-) delete mode 100644 lib/RedocTest/redoc-test.html delete mode 100644 lib/RedocTest/redoc-test.js create mode 100644 lib/components/Redoc/redoc.html create mode 100644 lib/components/Redoc/redoc.js rename lib/{RedocTest/redoc-test.css => components/RedocInfo/redoc-info.css} (100%) create mode 100644 lib/components/RedocInfo/redoc-info.html create mode 100644 lib/components/RedocInfo/redoc-info.js create mode 100644 lib/components/index.js create mode 100644 lib/utils/SchemaManager.js diff --git a/demo/index.html b/demo/index.html index 4408873e..354b0554 100644 --- a/demo/index.html +++ b/demo/index.html @@ -5,15 +5,15 @@ - + Loading... - + diff --git a/lib/RedocTest/redoc-test.html b/lib/RedocTest/redoc-test.html deleted file mode 100644 index 13a505da..00000000 --- a/lib/RedocTest/redoc-test.html +++ /dev/null @@ -1 +0,0 @@ -

Hello {{ name }}!

diff --git a/lib/RedocTest/redoc-test.js b/lib/RedocTest/redoc-test.js deleted file mode 100644 index 9b150ca9..00000000 --- a/lib/RedocTest/redoc-test.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -import {Component, View} from 'angular2/angular2'; - -@Component({selector: 'redoc-test'}) -@View({ - templateUrl: './lib/RedocTest/redoc-test.html', - styleUrls: ['./lib/RedocTest/redoc-test.css'] -}) -// Component controller -export class RedocTest { - constructor() { - this.name = 'ReDoc'; - } -} diff --git a/lib/components/Redoc/redoc.html b/lib/components/Redoc/redoc.html new file mode 100644 index 00000000..d12e7c66 --- /dev/null +++ b/lib/components/Redoc/redoc.html @@ -0,0 +1 @@ + diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js new file mode 100644 index 00000000..f5b5b4e6 --- /dev/null +++ b/lib/components/Redoc/redoc.js @@ -0,0 +1,27 @@ +'use strict'; + +import {Component, View} from 'angular2/angular2'; +import {SchemaManager} from '../../utils/SchemaManager'; +import {RedocInfo} from '../RedocInfo/redoc-info' + +@Component({ + selector: 'redoc', + bindings: [SchemaManager] +}) +@View({ + templateUrl: './lib/components/Redoc/redoc.html', + directives: [RedocInfo] +}) +export class Redoc { + constructor(schemaMgr) { + this.data = null; + this.schema = schemaMgr.schema; + this.extractData(); + } + + extractData() { + this.data = this.schema + //TODO: check and apply hooks to modify data + } +} +Redoc.parameters = [[SchemaManager]] diff --git a/lib/RedocTest/redoc-test.css b/lib/components/RedocInfo/redoc-info.css similarity index 100% rename from lib/RedocTest/redoc-test.css rename to lib/components/RedocInfo/redoc-info.css diff --git a/lib/components/RedocInfo/redoc-info.html b/lib/components/RedocInfo/redoc-info.html new file mode 100644 index 00000000..7c3e72ea --- /dev/null +++ b/lib/components/RedocInfo/redoc-info.html @@ -0,0 +1,15 @@ +

{{data.title}} ({{data.version}})

+

{{data.description}}

+

+ + Contatct: + + {{data.contact.name || data.contact.url}} + + {{data.contact.email}} + + License: + {{data.license.name}} + {{data.license.name}} + +

diff --git a/lib/components/RedocInfo/redoc-info.js b/lib/components/RedocInfo/redoc-info.js new file mode 100644 index 00000000..cdac3ec0 --- /dev/null +++ b/lib/components/RedocInfo/redoc-info.js @@ -0,0 +1,27 @@ +'use strict'; + +import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2'; +import {SchemaManager} from '../../utils/SchemaManager'; + +@Component({ + selector: 'redoc-api-info' +}) +@View({ + templateUrl: './lib/components/RedocInfo/redoc-info.html', + styleUrls: ['./lib/components/RedocInfo/redoc-info.css'], + directives: [CORE_DIRECTIVES] +}) +export class RedocInfo { + constructor(schemaMgr) { + this.data = null; + this.schema = schemaMgr.schema; + this.extractData(); + } + + extractData() { + this.data = this.schema.info; + + //TODO: check and apply hooks to modify data + } +} +RedocInfo.parameters = [[SchemaManager]] diff --git a/lib/components/index.js b/lib/components/index.js new file mode 100644 index 00000000..dea0c5a0 --- /dev/null +++ b/lib/components/index.js @@ -0,0 +1,4 @@ +'use strict'; + +export * from './Redoc/redoc'; +export * from './RedocInfo/redoc-info'; diff --git a/lib/index.js b/lib/index.js index 78c2dc2f..cf90778e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,12 +3,17 @@ import 'zone.js'; import 'reflect-metadata'; import { bootstrap } from 'angular2/angular2'; -import { RedocTest } from './RedocTest/redoc-test'; +import { Redoc } from './components/Redoc/redoc'; +import { SchemaManager} from './utils/SchemaManager'; -export * from './RedocTest/redoc-test'; +export * from './components/index'; -export function init() { - bootstrap(RedocTest).then( +export function init(schemaUrl) { + SchemaManager.instance().load(schemaUrl).then( + () => { + return bootstrap(Redoc); + } + ).then( () => console.log('ReDoc bootstrapped!'), error => console.log(error) ); diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js new file mode 100644 index 00000000..0af1aa2a --- /dev/null +++ b/lib/utils/SchemaManager.js @@ -0,0 +1,44 @@ +'use strict'; +import SwaggerParser from 'swagger-parser'; + +export class SchemaManager { + constructor() { + if (SchemaManager.prototype._instance) { + return SchemaManager.prototype._instance; + } + + SchemaManager.prototype._instance = this; + + this._schema = {}; + } + + static instance() { + return new SchemaManager(); + } + + load(url) { + let promise = new Promise((resolve, reject) => { + this._schema = {}; + + SwaggerParser.bundle(url) + .then( + (schema) => { + this._schema = schema; + resolve(this._schema); + }, + (err) => reject(err) + ); + }); + + return promise; + } + + get schema() { + // TODO: consider returning promise + return this._schema; + } + + getByJsonPath(/* path */) { + //TODO: implement + } +} diff --git a/package.json b/package.json index 08304ef4..54cd060b 100644 --- a/package.json +++ b/package.json @@ -23,12 +23,14 @@ "angular2": "npm:angular2@^2.0.0-alpha.37", "es6-shim": "github:es-shims/es6-shim@^0.33.6", "reflect-metadata": "npm:reflect-metadata@^0.1.2", + "swagger-parser": "npm:swagger-parser@^3.3.0", "zone.js": "npm:zone.js@^0.5.7" }, "devDependencies": { "babel": "npm:babel-core@^5.8.24", "babel-runtime": "npm:babel-runtime@^5.8.24", - "core-js": "npm:core-js@^1.1.4" + "core-js": "npm:core-js@^1.1.4", + "systemjs/plugin-json": "github:systemjs/plugin-json@^0.1.0" } }, "devDependencies": { diff --git a/system.config.js b/system.config.js index 99f24dcc..b6d98884 100644 --- a/system.config.js +++ b/system.config.js @@ -15,6 +15,18 @@ System.config({ "npm:*": "jspm_packages/npm/*" }, + packages: { + "npm:swagger-schema-official@2.0.0-d79c205": { + "defaultExtension": "json", + "main": "schema.json", + "meta": { + "*": { + "loader": "json" + } + } + } + }, + map: { "angular2": "npm:angular2@2.0.0-alpha.37", "babel": "npm:babel-core@5.8.25", @@ -22,6 +34,9 @@ System.config({ "core-js": "npm:core-js@1.2.0", "es6-shim": "github:es-shims/es6-shim@0.33.6", "reflect-metadata": "npm:reflect-metadata@0.1.2", + "swagger-parser": "npm:swagger-parser@3.3.0", + "json": "github:systemjs/plugin-json@0.1.0", + "systemjs/plugin-json": "github:systemjs/plugin-json@0.1.0", "zone.js": "npm:zone.js@0.5.7", "github:jspm/nodelibs-assert@0.1.0": { "assert": "npm:assert@1.3.0" @@ -38,11 +53,38 @@ System.config({ "github:jspm/nodelibs-events@0.1.1": { "events": "npm:events@1.0.2" }, + "github:jspm/nodelibs-http@1.7.1": { + "Base64": "npm:Base64@0.2.1", + "events": "github:jspm/nodelibs-events@0.1.1", + "inherits": "npm:inherits@2.0.1", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "url": "github:jspm/nodelibs-url@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "github:jspm/nodelibs-https@0.1.0": { + "https-browserify": "npm:https-browserify@0.0.0" + }, + "github:jspm/nodelibs-net@0.1.2": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "http": "github:jspm/nodelibs-http@1.7.1", + "net": "github:jspm/nodelibs-net@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.2", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "timers": "github:jspm/nodelibs-timers@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, "github:jspm/nodelibs-path@0.1.0": { "path-browserify": "npm:path-browserify@0.0.0" }, - "github:jspm/nodelibs-process@0.1.1": { - "process": "npm:process@0.10.1" + "github:jspm/nodelibs-process@0.1.2": { + "process": "npm:process@0.11.2" + }, + "github:jspm/nodelibs-punycode@0.1.0": { + "punycode": "npm:punycode@1.3.2" + }, + "github:jspm/nodelibs-querystring@0.1.0": { + "querystring": "npm:querystring@0.2.0" }, "github:jspm/nodelibs-stream@0.1.0": { "stream-browserify": "npm:stream-browserify@1.0.0" @@ -50,6 +92,12 @@ System.config({ "github:jspm/nodelibs-string_decoder@0.1.0": { "string_decoder": "npm:string_decoder@0.10.31" }, + "github:jspm/nodelibs-timers@0.1.0": { + "timers-browserify": "npm:timers-browserify@1.4.1" + }, + "github:jspm/nodelibs-tty@0.1.0": { + "tty-browserify": "npm:tty-browserify@0.0.0" + }, "github:jspm/nodelibs-url@0.1.0": { "url": "npm:url@0.10.3" }, @@ -59,16 +107,28 @@ System.config({ "github:jspm/nodelibs-vm@0.1.0": { "vm-browserify": "npm:vm-browserify@0.0.4" }, + "github:jspm/nodelibs-zlib@0.1.0": { + "browserify-zlib": "npm:browserify-zlib@0.1.4" + }, "npm:angular2@2.0.0-alpha.37": { "crypto": "github:jspm/nodelibs-crypto@0.1.0", "fs": "github:jspm/nodelibs-fs@0.1.2", "path": "github:jspm/nodelibs-path@0.1.0", - "process": "github:jspm/nodelibs-process@0.1.1", + "process": "github:jspm/nodelibs-process@0.1.2", "reflect-metadata": "npm:reflect-metadata@0.1.2", "rx": "npm:rx@2.5.1", "url": "github:jspm/nodelibs-url@0.1.0", "zone.js": "npm:zone.js@0.5.7" }, + "npm:argparse@1.0.2": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "lodash": "npm:lodash@3.10.1", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "sprintf-js": "npm:sprintf-js@1.0.3", + "util": "github:jspm/nodelibs-util@0.1.0" + }, "npm:asn1.js@2.2.1": { "assert": "github:jspm/nodelibs-assert@0.1.0", "bn.js": "npm:bn.js@2.2.0", @@ -77,11 +137,43 @@ System.config({ "minimalistic-assert": "npm:minimalistic-assert@1.0.0", "vm": "github:jspm/nodelibs-vm@0.1.0" }, + "npm:asn1@0.1.11": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "sys": "github:jspm/nodelibs-util@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:assert-plus@0.1.5": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, "npm:assert@1.3.0": { "util": "npm:util@0.10.3" }, + "npm:async@1.4.2": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:aws-sign2@0.5.0": { + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "url": "github:jspm/nodelibs-url@0.1.0" + }, "npm:babel-runtime@5.8.25": { - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:bl@1.0.0": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "readable-stream": "npm:readable-stream@2.0.2", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:bluebird@2.10.2": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:boom@2.9.0": { + "hoek": "npm:hoek@2.16.3", + "http": "github:jspm/nodelibs-http@1.7.1" }, "npm:browserify-aes@1.0.5": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", @@ -127,6 +219,14 @@ System.config({ "parse-asn1": "npm:parse-asn1@3.0.2", "stream": "github:jspm/nodelibs-stream@0.1.0" }, + "npm:browserify-zlib@0.1.4": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "pako": "npm:pako@0.2.8", + "process": "github:jspm/nodelibs-process@0.1.2", + "readable-stream": "npm:readable-stream@1.1.13", + "util": "github:jspm/nodelibs-util@0.1.0" + }, "npm:buffer-xor@1.0.3": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "systemjs-json": "github:systemjs/plugin-json@0.1.0" @@ -136,24 +236,49 @@ System.config({ "ieee754": "npm:ieee754@1.1.6", "is-array": "npm:is-array@1.0.1" }, + "npm:call-me-maybe@1.0.1": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:chalk@1.1.1": { + "ansi-styles": "npm:ansi-styles@2.1.0", + "escape-string-regexp": "npm:escape-string-regexp@1.0.3", + "has-ansi": "npm:has-ansi@2.0.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "strip-ansi": "npm:strip-ansi@3.0.0", + "supports-color": "npm:supports-color@2.0.0" + }, "npm:cipher-base@1.0.1": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "inherits": "npm:inherits@2.0.1", "stream": "github:jspm/nodelibs-stream@0.1.0", "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0" }, + "npm:combined-stream@1.0.5": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "delayed-stream": "npm:delayed-stream@1.0.0", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:commander@2.8.1": { + "child_process": "github:jspm/nodelibs-child_process@0.1.0", + "events": "github:jspm/nodelibs-events@0.1.1", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "graceful-readlink": "npm:graceful-readlink@1.0.1", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, "npm:constants-browserify@0.0.1": { "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, "npm:core-js@1.2.0": { "fs": "github:jspm/nodelibs-fs@0.1.2", - "process": "github:jspm/nodelibs-process@0.1.1", + "process": "github:jspm/nodelibs-process@0.1.2", "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, "npm:core-util-is@1.0.1": { "buffer": "github:jspm/nodelibs-buffer@0.1.0" }, - "npm:create-ecdh@2.0.1": { + "npm:create-ecdh@2.0.2": { "bn.js": "npm:bn.js@2.2.0", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", @@ -175,10 +300,14 @@ System.config({ "inherits": "npm:inherits@2.0.1", "stream": "github:jspm/nodelibs-stream@0.1.0" }, + "npm:cryptiles@2.0.5": { + "boom": "npm:boom@2.9.0", + "crypto": "github:jspm/nodelibs-crypto@0.1.0" + }, "npm:crypto-browserify@3.10.0": { "browserify-cipher": "npm:browserify-cipher@1.0.0", "browserify-sign": "npm:browserify-sign@3.0.8", - "create-ecdh": "npm:create-ecdh@2.0.1", + "create-ecdh": "npm:create-ecdh@2.0.2", "create-hash": "npm:create-hash@1.1.2", "create-hmac": "npm:create-hmac@1.1.4", "diffie-hellman": "npm:diffie-hellman@3.0.2", @@ -187,6 +316,23 @@ System.config({ "public-encrypt": "npm:public-encrypt@2.0.1", "randombytes": "npm:randombytes@2.0.1" }, + "npm:ctype@0.5.3": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:debug@2.2.0": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "ms": "npm:ms@0.7.1", + "net": "github:jspm/nodelibs-net@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.2", + "tty": "github:jspm/nodelibs-tty@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:delayed-stream@1.0.0": { + "stream": "github:jspm/nodelibs-stream@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, "npm:des.js@1.0.0": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "inherits": "npm:inherits@2.0.1", @@ -208,23 +354,176 @@ System.config({ "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, "npm:es6-promise@3.0.2": { - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:esprima@2.2.0": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:evp_bytestokey@1.0.0": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "create-hash": "npm:create-hash@1.1.2", "crypto": "github:jspm/nodelibs-crypto@0.1.0" }, + "npm:forever-agent@0.6.1": { + "http": "github:jspm/nodelibs-http@1.7.1", + "https": "github:jspm/nodelibs-https@0.1.0", + "net": "github:jspm/nodelibs-net@0.1.2", + "tls": "github:jspm/nodelibs-tls@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:form-data@1.0.0-rc3": { + "async": "npm:async@1.4.2", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "combined-stream": "npm:combined-stream@1.0.5", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "http": "github:jspm/nodelibs-http@1.7.1", + "https": "github:jspm/nodelibs-https@0.1.0", + "mime-types": "npm:mime-types@2.1.7", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "url": "github:jspm/nodelibs-url@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:generate-function@2.0.0": { + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:generate-object-property@1.2.0": { + "is-property": "npm:is-property@1.0.2" + }, + "npm:graceful-readlink@1.0.1": { + "fs": "github:jspm/nodelibs-fs@0.1.2" + }, + "npm:har-validator@1.8.0": { + "bluebird": "npm:bluebird@2.10.2", + "chalk": "npm:chalk@1.1.1", + "commander": "npm:commander@2.8.1", + "is-my-json-valid": "npm:is-my-json-valid@2.12.2", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:has-ansi@2.0.0": { + "ansi-regex": "npm:ansi-regex@2.0.0" + }, "npm:hash.js@1.0.3": { "inherits": "npm:inherits@2.0.1" }, + "npm:hawk@3.1.0": { + "boom": "npm:boom@2.9.0", + "cryptiles": "npm:cryptiles@2.0.5", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "hoek": "npm:hoek@2.16.3", + "process": "github:jspm/nodelibs-process@0.1.2", + "sntp": "npm:sntp@1.0.9", + "systemjs-json": "github:systemjs/plugin-json@0.1.0", + "url": "github:jspm/nodelibs-url@0.1.0" + }, + "npm:hoek@2.16.3": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:http-signature@0.11.0": { + "asn1": "npm:asn1@0.1.11", + "assert-plus": "npm:assert-plus@0.1.5", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "ctype": "npm:ctype@0.5.3", + "http": "github:jspm/nodelibs-http@1.7.1", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:https-browserify@0.0.0": { + "http": "github:jspm/nodelibs-http@1.7.1" + }, "npm:inherits@2.0.1": { "util": "github:jspm/nodelibs-util@0.1.0" }, + "npm:is-my-json-valid@2.12.2": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "generate-function": "npm:generate-function@2.0.0", + "generate-object-property": "npm:generate-object-property@1.2.0", + "jsonpointer": "npm:jsonpointer@2.0.0", + "path": "github:jspm/nodelibs-path@0.1.0", + "xtend": "npm:xtend@4.0.0" + }, + "npm:isstream@0.1.2": { + "events": "github:jspm/nodelibs-events@0.1.1", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:js-yaml@3.4.2": { + "argparse": "npm:argparse@1.0.2", + "esprima": "npm:esprima@2.2.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.2", + "systemjs-json": "github:systemjs/plugin-json@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:json-schema-ref-parser@1.4.0": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "call-me-maybe": "npm:call-me-maybe@1.0.1", + "debug": "npm:debug@2.2.0", + "es6-promise": "npm:es6-promise@3.0.2", + "events": "github:jspm/nodelibs-events@0.1.1", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "http": "github:jspm/nodelibs-http@1.7.1", + "https": "github:jspm/nodelibs-https@0.1.0", + "js-yaml": "npm:js-yaml@3.4.2", + "ono": "npm:ono@1.0.22", + "process": "github:jspm/nodelibs-process@0.1.2", + "punycode": "github:jspm/nodelibs-punycode@0.1.0", + "querystring": "github:jspm/nodelibs-querystring@0.1.0", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0", + "url": "github:jspm/nodelibs-url@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:jsonpointer@2.0.0": { + "assert": "github:jspm/nodelibs-assert@0.1.0" + }, + "npm:lodash._baseget@3.7.2": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:lodash._topath@3.8.1": { + "lodash.isarray": "npm:lodash.isarray@3.0.4", + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:lodash.get@3.7.0": { + "lodash._baseget": "npm:lodash._baseget@3.7.2", + "lodash._topath": "npm:lodash._topath@3.8.1" + }, + "npm:lodash@3.10.1": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, "npm:miller-rabin@2.0.1": { "bn.js": "npm:bn.js@2.2.0", "brorand": "npm:brorand@1.0.5" }, + "npm:mime-db@1.19.0": { + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:mime-types@2.1.7": { + "mime-db": "npm:mime-db@1.19.0", + "path": "github:jspm/nodelibs-path@0.1.0" + }, + "npm:node-uuid@1.4.3": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0" + }, + "npm:oauth-sign@0.8.0": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "querystring": "github:jspm/nodelibs-querystring@0.1.0" + }, + "npm:ono@1.0.22": { + "process": "github:jspm/nodelibs-process@0.1.2", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:pako@0.2.8": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, "npm:parse-asn1@3.0.2": { "asn1.js": "npm:asn1.js@2.2.1", "browserify-aes": "npm:browserify-aes@1.0.5", @@ -235,7 +534,7 @@ System.config({ "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, "npm:path-browserify@0.0.0": { - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:pbkdf2@3.0.4": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", @@ -243,9 +542,15 @@ System.config({ "create-hmac": "npm:create-hmac@1.1.4", "crypto": "github:jspm/nodelibs-crypto@0.1.0", "path": "github:jspm/nodelibs-path@0.1.0", - "process": "github:jspm/nodelibs-process@0.1.1", + "process": "github:jspm/nodelibs-process@0.1.2", "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, + "npm:process-nextick-args@1.0.3": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:process@0.11.2": { + "assert": "github:jspm/nodelibs-assert@0.1.0" + }, "npm:public-encrypt@2.0.1": { "bn.js": "npm:bn.js@2.2.0", "browserify-rsa": "npm:browserify-rsa@2.0.1", @@ -256,12 +561,12 @@ System.config({ "randombytes": "npm:randombytes@2.0.1" }, "npm:punycode@1.3.2": { - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:randombytes@2.0.1": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:readable-stream@1.1.13": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", @@ -269,26 +574,76 @@ System.config({ "events": "github:jspm/nodelibs-events@0.1.1", "inherits": "npm:inherits@2.0.1", "isarray": "npm:isarray@0.0.1", - "process": "github:jspm/nodelibs-process@0.1.1", + "process": "github:jspm/nodelibs-process@0.1.2", "stream-browserify": "npm:stream-browserify@1.0.0", "string_decoder": "npm:string_decoder@0.10.31" }, + "npm:readable-stream@2.0.2": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "core-util-is": "npm:core-util-is@1.0.1", + "events": "github:jspm/nodelibs-events@0.1.1", + "inherits": "npm:inherits@2.0.1", + "isarray": "npm:isarray@0.0.1", + "process": "github:jspm/nodelibs-process@0.1.2", + "process-nextick-args": "npm:process-nextick-args@1.0.3", + "string_decoder": "npm:string_decoder@0.10.31", + "util-deprecate": "npm:util-deprecate@1.0.1" + }, "npm:reflect-metadata@0.1.2": { "assert": "github:jspm/nodelibs-assert@0.1.0", - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:request@2.64.0": { + "aws-sign2": "npm:aws-sign2@0.5.0", + "bl": "npm:bl@1.0.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "caseless": "npm:caseless@0.11.0", + "combined-stream": "npm:combined-stream@1.0.5", + "crypto": "github:jspm/nodelibs-crypto@0.1.0", + "extend": "npm:extend@3.0.0", + "forever-agent": "npm:forever-agent@0.6.1", + "form-data": "npm:form-data@1.0.0-rc3", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "har-validator": "npm:har-validator@1.8.0", + "hawk": "npm:hawk@3.1.0", + "http": "github:jspm/nodelibs-http@1.7.1", + "http-signature": "npm:http-signature@0.11.0", + "https": "github:jspm/nodelibs-https@0.1.0", + "isstream": "npm:isstream@0.1.2", + "json-stringify-safe": "npm:json-stringify-safe@5.0.1", + "mime-types": "npm:mime-types@2.1.7", + "node-uuid": "npm:node-uuid@1.4.3", + "oauth-sign": "npm:oauth-sign@0.8.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "qs": "npm:qs@5.1.0", + "querystring": "github:jspm/nodelibs-querystring@0.1.0", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "stringstream": "npm:stringstream@0.0.4", + "tough-cookie": "npm:tough-cookie@2.1.0", + "tunnel-agent": "npm:tunnel-agent@0.4.1", + "url": "github:jspm/nodelibs-url@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0", + "zlib": "github:jspm/nodelibs-zlib@0.1.0" }, "npm:ripemd160@1.0.1": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:rx@2.5.1": { - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:sha.js@2.4.4": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "fs": "github:jspm/nodelibs-fs@0.1.2", "inherits": "npm:inherits@2.0.1", - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:sntp@1.0.9": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "dgram": "github:jspm/nodelibs-dgram@0.1.0", + "dns": "github:jspm/nodelibs-dns@0.1.0", + "hoek": "npm:hoek@2.16.3", + "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:stream-browserify@1.0.0": { "events": "github:jspm/nodelibs-events@0.1.1", @@ -298,22 +653,95 @@ System.config({ "npm:string_decoder@0.10.31": { "buffer": "github:jspm/nodelibs-buffer@0.1.0" }, + "npm:stringstream@0.0.4": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.2", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0", + "zlib": "github:jspm/nodelibs-zlib@0.1.0" + }, + "npm:strip-ansi@3.0.0": { + "ansi-regex": "npm:ansi-regex@2.0.0" + }, + "npm:supports-color@2.0.0": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:swagger-parser@3.3.0": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "call-me-maybe": "npm:call-me-maybe@1.0.1", + "debug": "npm:debug@2.2.0", + "es6-promise": "npm:es6-promise@3.0.2", + "events": "github:jspm/nodelibs-events@0.1.1", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "http": "github:jspm/nodelibs-http@1.7.1", + "https": "github:jspm/nodelibs-https@0.1.0", + "json-schema-ref-parser": "npm:json-schema-ref-parser@1.4.0", + "ono": "npm:ono@1.0.22", + "process": "github:jspm/nodelibs-process@0.1.2", + "punycode": "github:jspm/nodelibs-punycode@0.1.0", + "querystring": "github:jspm/nodelibs-querystring@0.1.0", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0", + "swagger-methods": "npm:swagger-methods@1.0.0", + "swagger-schema-official": "npm:swagger-schema-official@2.0.0-d79c205", + "systemjs-json": "github:systemjs/plugin-json@0.1.0", + "url": "github:jspm/nodelibs-url@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0", + "z-schema": "npm:z-schema@3.15.3" + }, + "npm:timers-browserify@1.4.1": { + "process": "npm:process@0.11.2" + }, + "npm:tough-cookie@2.1.0": { + "net": "github:jspm/nodelibs-net@0.1.2", + "punycode": "github:jspm/nodelibs-punycode@0.1.0", + "systemjs-json": "github:systemjs/plugin-json@0.1.0", + "url": "github:jspm/nodelibs-url@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:tunnel-agent@0.4.1": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "events": "github:jspm/nodelibs-events@0.1.1", + "http": "github:jspm/nodelibs-http@1.7.1", + "https": "github:jspm/nodelibs-https@0.1.0", + "net": "github:jspm/nodelibs-net@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.2", + "tls": "github:jspm/nodelibs-tls@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, "npm:url@0.10.3": { "assert": "github:jspm/nodelibs-assert@0.1.0", "punycode": "npm:punycode@1.3.2", "querystring": "npm:querystring@0.2.0", "util": "github:jspm/nodelibs-util@0.1.0" }, + "npm:util-deprecate@1.0.1": { + "util": "github:jspm/nodelibs-util@0.1.0" + }, "npm:util@0.10.3": { "inherits": "npm:inherits@2.0.1", - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:validator@4.1.0": { + "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, "npm:vm-browserify@0.0.4": { "indexof": "npm:indexof@0.0.1" }, + "npm:z-schema@3.15.3": { + "commander": "npm:commander@2.8.1", + "lodash.get": "npm:lodash.get@3.7.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "request": "npm:request@2.64.0", + "systemjs-json": "github:systemjs/plugin-json@0.1.0", + "validator": "npm:validator@4.1.0" + }, "npm:zone.js@0.5.7": { "es6-promise": "npm:es6-promise@3.0.2", - "process": "github:jspm/nodelibs-process@0.1.1" + "process": "github:jspm/nodelibs-process@0.1.2" } } }); From 6e3c0b912efc352d869cd1c25fbe7919c1ea85c1 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 8 Oct 2015 12:58:40 +0300 Subject: [PATCH 14/97] moved and minor fixed deployment script --- .travis.yml | 2 +- deploy_gh_pages.sh => build/deploy_gh_pages.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename deploy_gh_pages.sh => build/deploy_gh_pages.sh (94%) diff --git a/.travis.yml b/.travis.yml index 5c0c61db..47de63f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,6 @@ before_deploy: deploy: skip_cleanup: true provider: script - script: "./deploy_gh_pages.sh" + script: "./build/deploy_gh_pages.sh" on: branch: master diff --git a/deploy_gh_pages.sh b/build/deploy_gh_pages.sh similarity index 94% rename from deploy_gh_pages.sh rename to build/deploy_gh_pages.sh index a921493b..c676d79e 100755 --- a/deploy_gh_pages.sh +++ b/build/deploy_gh_pages.sh @@ -10,5 +10,5 @@ set -o pipefail cp -r ../dist ./dist git add . git commit -m "Deployed to Github Pages" - git push --force "https://${GH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1 + git push --force "https://${GH_TOKEN}@${GH_REF}" master:gh-pages 2>&1 ) 2>&1 | sed "s/${GH_TOKEN}/xxPASSxx/" From 2594cf950321d6f56bf4840d49ee8a3f5de6fa5b Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 8 Oct 2015 20:15:21 +0300 Subject: [PATCH 15/97] Updated angular2 to latest alpha --- lib/index.js | 1 - package.json | 4 +++- system.config.js | 31 ++++++++++++++++++++----------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/index.js b/lib/index.js index cf90778e..2a8a0b02 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,5 @@ 'use strict'; -import 'zone.js'; import 'reflect-metadata'; import { bootstrap } from 'angular2/angular2'; import { Redoc } from './components/Redoc/redoc'; diff --git a/package.json b/package.json index 54cd060b..2ea209e6 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,10 @@ "jspm": { "configFile": "system.config.js", "dependencies": { - "angular2": "npm:angular2@^2.0.0-alpha.37", + "@reactivex/rxjs": "npm:@reactivex/rxjs@^5.0.0-alpha.2", + "angular2": "npm:angular2@^2.0.0-alpha.39", "es6-shim": "github:es-shims/es6-shim@^0.33.6", + "json-pointer": "npm:json-pointer@^0.3.0", "reflect-metadata": "npm:reflect-metadata@^0.1.2", "swagger-parser": "npm:swagger-parser@^3.3.0", "zone.js": "npm:zone.js@^0.5.7" diff --git a/system.config.js b/system.config.js index b6d98884..c79aba03 100644 --- a/system.config.js +++ b/system.config.js @@ -6,8 +6,8 @@ System.config({ "optional": [ "runtime", "optimisation.modules.system", - 'es7.decorators', - 'es7.classProperties' + "es7.decorators", + "es7.classProperties" ] }, paths: { @@ -28,21 +28,23 @@ System.config({ }, map: { - "angular2": "npm:angular2@2.0.0-alpha.37", + "@reactivex/rxjs": "npm:@reactivex/rxjs@5.0.0-alpha.2", + "angular2": "npm:angular2@2.0.0-alpha.39", "babel": "npm:babel-core@5.8.25", "babel-runtime": "npm:babel-runtime@5.8.25", "core-js": "npm:core-js@1.2.0", "es6-shim": "github:es-shims/es6-shim@0.33.6", + "json": "github:systemjs/plugin-json@0.1.0", + "json-pointer": "npm:json-pointer@0.3.0", "reflect-metadata": "npm:reflect-metadata@0.1.2", "swagger-parser": "npm:swagger-parser@3.3.0", - "json": "github:systemjs/plugin-json@0.1.0", "systemjs/plugin-json": "github:systemjs/plugin-json@0.1.0", - "zone.js": "npm:zone.js@0.5.7", + "zone.js": "npm:zone.js@0.5.8", "github:jspm/nodelibs-assert@0.1.0": { "assert": "npm:assert@1.3.0" }, "github:jspm/nodelibs-buffer@0.1.0": { - "buffer": "npm:buffer@3.5.0" + "buffer": "npm:buffer@3.5.1" }, "github:jspm/nodelibs-constants@0.1.0": { "constants-browserify": "npm:constants-browserify@0.0.1" @@ -110,15 +112,19 @@ System.config({ "github:jspm/nodelibs-zlib@0.1.0": { "browserify-zlib": "npm:browserify-zlib@0.1.4" }, - "npm:angular2@2.0.0-alpha.37": { + "npm:@reactivex/rxjs@5.0.0-alpha.2": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:angular2@2.0.0-alpha.39": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", "fs": "github:jspm/nodelibs-fs@0.1.2", "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2", "reflect-metadata": "npm:reflect-metadata@0.1.2", "rx": "npm:rx@2.5.1", - "url": "github:jspm/nodelibs-url@0.1.0", - "zone.js": "npm:zone.js@0.5.7" + "zone.js": "npm:zone.js@0.5.8" }, "npm:argparse@1.0.2": { "assert": "github:jspm/nodelibs-assert@0.1.0", @@ -231,7 +237,7 @@ System.config({ "buffer": "github:jspm/nodelibs-buffer@0.1.0", "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, - "npm:buffer@3.5.0": { + "npm:buffer@3.5.1": { "base64-js": "npm:base64-js@0.0.8", "ieee754": "npm:ieee754@1.1.6", "is-array": "npm:is-array@1.0.1" @@ -460,6 +466,9 @@ System.config({ "systemjs-json": "github:systemjs/plugin-json@0.1.0", "util": "github:jspm/nodelibs-util@0.1.0" }, + "npm:json-pointer@0.3.0": { + "foreach": "npm:foreach@2.0.5" + }, "npm:json-schema-ref-parser@1.4.0": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "call-me-maybe": "npm:call-me-maybe@1.0.1", @@ -739,7 +748,7 @@ System.config({ "systemjs-json": "github:systemjs/plugin-json@0.1.0", "validator": "npm:validator@4.1.0" }, - "npm:zone.js@0.5.7": { + "npm:zone.js@0.5.8": { "es6-promise": "npm:es6-promise@3.0.2", "process": "github:jspm/nodelibs-process@0.1.2" } From aaa78d7c50959a1d089aa7fe5737a5c8f9d5c562 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 8 Oct 2015 20:16:45 +0300 Subject: [PATCH 16/97] Added few utils methods --- lib/utils/JsonPointer.js | 18 ++++++++++++++++++ lib/utils/pipes.js | 31 +++++++++++++++++++++++++++++++ lib/utils/swagger-defs.js | 3 +++ 3 files changed, 52 insertions(+) create mode 100644 lib/utils/JsonPointer.js create mode 100644 lib/utils/pipes.js create mode 100644 lib/utils/swagger-defs.js diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.js new file mode 100644 index 00000000..eb0e9bc2 --- /dev/null +++ b/lib/utils/JsonPointer.js @@ -0,0 +1,18 @@ +'use strict'; +import JsonPointerLib from 'json-pointer'; + +/** + * Wrapper for JsonPointer. Provides common operations + */ +export class JsonPointer extends JsonPointerLib { + + /** + * returns last JsonPointer token + * @example + * // returns subpath + * new JsonPointerHelper.dirName('/path/0/subpath') + */ + static dirName(pointer) { + return JsonPointer.parse(pointer).pop(); + } +} diff --git a/lib/utils/pipes.js b/lib/utils/pipes.js new file mode 100644 index 00000000..ed3c8ab8 --- /dev/null +++ b/lib/utils/pipes.js @@ -0,0 +1,31 @@ +'use strict'; + +import {Pipe} from 'angular2/angular2'; +import {JsonPointer} from './JsonPointer'; + +@Pipe({ + name: 'keys' +}) +export class KeysPipe { + transform(obj) { + return Object.keys(obj); + } +} + +@Pipe({ + name: 'values' +}) +export class ValuesPipe { + transform(obj) { + return Object.keys(obj).map(key => obj[key]); + } +} + +@Pipe({ + name: 'jsonPointerEscape' +}) +export class JsonPointerEscapePipe { + transform(str) { + return JsonPointer.escape(str); + } +} diff --git a/lib/utils/swagger-defs.js b/lib/utils/swagger-defs.js new file mode 100644 index 00000000..16c1afd6 --- /dev/null +++ b/lib/utils/swagger-defs.js @@ -0,0 +1,3 @@ +'use strict'; + +export var methods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch']); From 3d1b52922215ea05313464bba8dafc4629bfe9c9 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 8 Oct 2015 23:21:51 +0300 Subject: [PATCH 17/97] Added few basic components --- lib/components/Method/method.html | 7 ++++ lib/components/Method/method.js | 36 +++++++++++++++++ lib/components/MethodsList/methods-list.html | 3 ++ lib/components/MethodsList/methods-list.js | 41 ++++++++++++++++++++ lib/components/PathsList/paths-list.html | 3 ++ lib/components/PathsList/paths-list.js | 30 ++++++++++++++ lib/components/Redoc/redoc.html | 1 + lib/components/Redoc/redoc.js | 5 ++- lib/utils/JsonPointer.js | 7 +++- lib/utils/SchemaManager.js | 6 ++- 10 files changed, 133 insertions(+), 6 deletions(-) create mode 100644 lib/components/Method/method.html create mode 100644 lib/components/Method/method.js create mode 100644 lib/components/MethodsList/methods-list.html create mode 100644 lib/components/MethodsList/methods-list.js create mode 100644 lib/components/PathsList/paths-list.html create mode 100644 lib/components/PathsList/paths-list.js diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html new file mode 100644 index 00000000..ea00a532 --- /dev/null +++ b/lib/components/Method/method.html @@ -0,0 +1,7 @@ +
+

{{data.methodInfo.summary}}

+

{{data.method}} {{data.path}}

+

+ {{data.methodInfo.description}} +

+
diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js new file mode 100644 index 00000000..885646ce --- /dev/null +++ b/lib/components/Method/method.js @@ -0,0 +1,36 @@ +'use strict'; + +import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2'; +import {SchemaManager} from '../../utils/SchemaManager'; +import {JsonPointer} from '../../utils/JsonPointer'; + +@Component({ + selector: 'method', + properties: ['pointer'], + lifecycle: [OnInit] +}) +@View({ + templateUrl: './lib/components/Method/method.html', + directives: [CORE_DIRECTIVES] +}) +export class Method { + constructor(schemaMgr) { + this.data = null; + this.schemaMgr = schemaMgr; + } + + onInit() { + this.extractData(); + } + + extractData() { + this.data = {}; + var methodInfo = this.schemaMgr.byPointer(this.pointer); + + this.data.method = JsonPointer.dirName(this.pointer); + this.data.path = JsonPointer.dirName(this.pointer, 2); + this.data.methodInfo = methodInfo; + //TODO: check and apply hooks to modify data + } +} +Method.parameters = [[SchemaManager]]; diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html new file mode 100644 index 00000000..37846147 --- /dev/null +++ b/lib/components/MethodsList/methods-list.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js new file mode 100644 index 00000000..560711fe --- /dev/null +++ b/lib/components/MethodsList/methods-list.js @@ -0,0 +1,41 @@ +'use strict'; + +import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2'; +import {SchemaManager} from '../../utils/SchemaManager'; +import {JsonPointer} from '../../utils/JsonPointer'; +import {methods as swaggerMethods} from '../../utils/swagger-defs'; +import {Method} from '../Method/method'; + +@Component({ + selector: 'methods-list', + properties: ['pointer'], + lifecycle: [OnInit] +}) +@View({ + templateUrl: './lib/components/MethodsList/methods-list.html', + directives: [CORE_DIRECTIVES, Method] +}) +export class MethodsList { + _name: string; + + constructor(schemaMgr) { + this.data = null; + this.schemaMgr = schemaMgr; + //this.pointer = pointer; + //this.extractData(); + } + + onInit() { + this.extractData(); + } + + extractData() { + this.data = {}; + var pathInfo = this.schemaMgr.byPointer(this.pointer); + + this.data.path = JsonPointer.dirName(this.pointer); + this.data.methods = Object.keys(pathInfo).filter((k) => swaggerMethods.has(k)); + //TODO: check and apply hooks to modify data + } +} +MethodsList.parameters = [[SchemaManager]]; diff --git a/lib/components/PathsList/paths-list.html b/lib/components/PathsList/paths-list.html new file mode 100644 index 00000000..3f316095 --- /dev/null +++ b/lib/components/PathsList/paths-list.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/lib/components/PathsList/paths-list.js b/lib/components/PathsList/paths-list.js new file mode 100644 index 00000000..47164ed2 --- /dev/null +++ b/lib/components/PathsList/paths-list.js @@ -0,0 +1,30 @@ +'use strict'; + +import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2'; +import {SchemaManager} from '../../utils/SchemaManager'; +import {MethodsList} from '../MethodsList/methods-list'; +import {JsonPointerEscapePipe} from '../../utils/pipes'; + +@Component({ + selector: 'paths-list' +}) +@View({ + templateUrl: './lib/components/PathsList/paths-list.html', + directives: [CORE_DIRECTIVES, MethodsList], + pipes: [JsonPointerEscapePipe] +}) +export class PathsList { + constructor(schemaMgr) { + this.data = null; + this.schema = schemaMgr.schema; + this.extractData(); + } + + extractData() { + this.data = {}; + this.data.paths = Object.keys(this.schema.paths) + + //TODO: check and apply hooks to modify data + } +} +PathsList.parameters = [[SchemaManager]] diff --git a/lib/components/Redoc/redoc.html b/lib/components/Redoc/redoc.html index d12e7c66..c8188c44 100644 --- a/lib/components/Redoc/redoc.html +++ b/lib/components/Redoc/redoc.html @@ -1 +1,2 @@ + diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index f5b5b4e6..d2c523ca 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -2,7 +2,8 @@ import {Component, View} from 'angular2/angular2'; import {SchemaManager} from '../../utils/SchemaManager'; -import {RedocInfo} from '../RedocInfo/redoc-info' +import {RedocInfo} from '../RedocInfo/redoc-info'; +import {PathsList} from '../PathsList/paths-list'; @Component({ selector: 'redoc', @@ -10,7 +11,7 @@ import {RedocInfo} from '../RedocInfo/redoc-info' }) @View({ templateUrl: './lib/components/Redoc/redoc.html', - directives: [RedocInfo] + directives: [RedocInfo, PathsList] }) export class Redoc { constructor(schemaMgr) { diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.js index eb0e9bc2..12d8a204 100644 --- a/lib/utils/JsonPointer.js +++ b/lib/utils/JsonPointer.js @@ -12,7 +12,10 @@ export class JsonPointer extends JsonPointerLib { * // returns subpath * new JsonPointerHelper.dirName('/path/0/subpath') */ - static dirName(pointer) { - return JsonPointer.parse(pointer).pop(); + static dirName(pointer, level=1) { + var tokens = JsonPointer.parse(pointer); + return tokens[tokens.length - (level)]; } } + +export default JsonPointer; diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index 0af1aa2a..905b7626 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -1,5 +1,6 @@ 'use strict'; import SwaggerParser from 'swagger-parser'; +import JsonPointer from './JsonPointer' export class SchemaManager { constructor() { @@ -38,7 +39,8 @@ export class SchemaManager { return this._schema; } - getByJsonPath(/* path */) { - //TODO: implement + byPointer(pointer) { + return JsonPointer.get(this._schema, pointer); } + } From fce4ca1b9f399f5c67d80285a4e421b5556d2f44 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 8 Oct 2015 23:27:02 +0300 Subject: [PATCH 18/97] Renamed RedocInfo to ApiInfo --- .../{RedocInfo/redoc-info.css => ApiInfo/api-info.css} | 2 +- .../redoc-info.html => ApiInfo/api-info.html} | 0 .../{RedocInfo/redoc-info.js => ApiInfo/api-info.js} | 10 +++++----- lib/components/Redoc/redoc.html | 2 +- lib/components/Redoc/redoc.js | 4 ++-- lib/components/index.js | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) rename lib/components/{RedocInfo/redoc-info.css => ApiInfo/api-info.css} (62%) rename lib/components/{RedocInfo/redoc-info.html => ApiInfo/api-info.html} (100%) rename lib/components/{RedocInfo/redoc-info.js => ApiInfo/api-info.js} (66%) diff --git a/lib/components/RedocInfo/redoc-info.css b/lib/components/ApiInfo/api-info.css similarity index 62% rename from lib/components/RedocInfo/redoc-info.css rename to lib/components/ApiInfo/api-info.css index 4803c77c..434350f2 100644 --- a/lib/components/RedocInfo/redoc-info.css +++ b/lib/components/ApiInfo/api-info.css @@ -1,3 +1,3 @@ -h1 strong { +h1 { color: #1976D3; } diff --git a/lib/components/RedocInfo/redoc-info.html b/lib/components/ApiInfo/api-info.html similarity index 100% rename from lib/components/RedocInfo/redoc-info.html rename to lib/components/ApiInfo/api-info.html diff --git a/lib/components/RedocInfo/redoc-info.js b/lib/components/ApiInfo/api-info.js similarity index 66% rename from lib/components/RedocInfo/redoc-info.js rename to lib/components/ApiInfo/api-info.js index cdac3ec0..0accf836 100644 --- a/lib/components/RedocInfo/redoc-info.js +++ b/lib/components/ApiInfo/api-info.js @@ -4,14 +4,14 @@ import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2'; import {SchemaManager} from '../../utils/SchemaManager'; @Component({ - selector: 'redoc-api-info' + selector: 'api-info' }) @View({ - templateUrl: './lib/components/RedocInfo/redoc-info.html', - styleUrls: ['./lib/components/RedocInfo/redoc-info.css'], + templateUrl: './lib/components/ApiInfo/api-info.html', + styleUrls: ['./lib/components/ApiInfo/api-info.css'], directives: [CORE_DIRECTIVES] }) -export class RedocInfo { +export class ApiInfo { constructor(schemaMgr) { this.data = null; this.schema = schemaMgr.schema; @@ -24,4 +24,4 @@ export class RedocInfo { //TODO: check and apply hooks to modify data } } -RedocInfo.parameters = [[SchemaManager]] +ApiInfo.parameters = [[SchemaManager]] diff --git a/lib/components/Redoc/redoc.html b/lib/components/Redoc/redoc.html index c8188c44..5509bc31 100644 --- a/lib/components/Redoc/redoc.html +++ b/lib/components/Redoc/redoc.html @@ -1,2 +1,2 @@ - + diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index d2c523ca..fff800c5 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -2,7 +2,7 @@ import {Component, View} from 'angular2/angular2'; import {SchemaManager} from '../../utils/SchemaManager'; -import {RedocInfo} from '../RedocInfo/redoc-info'; +import {ApiInfo} from '../ApiInfo/api-info'; import {PathsList} from '../PathsList/paths-list'; @Component({ @@ -11,7 +11,7 @@ import {PathsList} from '../PathsList/paths-list'; }) @View({ templateUrl: './lib/components/Redoc/redoc.html', - directives: [RedocInfo, PathsList] + directives: [ApiInfo, PathsList] }) export class Redoc { constructor(schemaMgr) { diff --git a/lib/components/index.js b/lib/components/index.js index dea0c5a0..bf07f4c9 100644 --- a/lib/components/index.js +++ b/lib/components/index.js @@ -1,4 +1,4 @@ 'use strict'; export * from './Redoc/redoc'; -export * from './RedocInfo/redoc-info'; +export * from './ApiInfo/api-info'; From cc5c324bc10fa002ef02b08a77f62305fa5c4b35 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 9 Oct 2015 08:16:11 +0300 Subject: [PATCH 19/97] Removed unused file --- demo/app.js | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 demo/app.js diff --git a/demo/app.js b/demo/app.js deleted file mode 100644 index c80e2550..00000000 --- a/demo/app.js +++ /dev/null @@ -1,3 +0,0 @@ - -console.log("test"); -console.log("test2"); From cf7391e5d9e6955c5d0d7fd2ba175772dc594daf Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 9 Oct 2015 08:31:09 +0300 Subject: [PATCH 20/97] Renamed JsonPointer.dirName to baseName --- lib/components/Method/method.js | 4 ++-- lib/components/MethodsList/methods-list.js | 1 - lib/utils/JsonPointer.js | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 885646ce..9aa5ae42 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -27,8 +27,8 @@ export class Method { this.data = {}; var methodInfo = this.schemaMgr.byPointer(this.pointer); - this.data.method = JsonPointer.dirName(this.pointer); - this.data.path = JsonPointer.dirName(this.pointer, 2); + this.data.method = JsonPointer.baseName(this.pointer); + this.data.path = JsonPointer.baseName(this.pointer, 2); this.data.methodInfo = methodInfo; //TODO: check and apply hooks to modify data } diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index 560711fe..145736e1 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -33,7 +33,6 @@ export class MethodsList { this.data = {}; var pathInfo = this.schemaMgr.byPointer(this.pointer); - this.data.path = JsonPointer.dirName(this.pointer); this.data.methods = Object.keys(pathInfo).filter((k) => swaggerMethods.has(k)); //TODO: check and apply hooks to modify data } diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.js index 12d8a204..dfb3d2a6 100644 --- a/lib/utils/JsonPointer.js +++ b/lib/utils/JsonPointer.js @@ -8,11 +8,14 @@ export class JsonPointer extends JsonPointerLib { /** * returns last JsonPointer token + * if level > 1 returns levels last (second last/third last) * @example * // returns subpath - * new JsonPointerHelper.dirName('/path/0/subpath') + * JsonPointerHelper.baseName('/path/0/subpath') + * // returns foo + * JsonPointerHelper.baseName('/path/foo/subpath', 2) */ - static dirName(pointer, level=1) { + static baseName(pointer, level=1) { var tokens = JsonPointer.parse(pointer); return tokens[tokens.length - (level)]; } From c8d04cc1fa610dabecedcff8027f841011807990 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 9 Oct 2015 10:50:02 +0300 Subject: [PATCH 21/97] Added extra linting options --- .eslintrc | 15 -------------- lib/.eslintrc | 24 ++++++++++++++++++++++ lib/components/ApiInfo/api-info.js | 2 +- lib/components/MethodsList/methods-list.js | 1 - lib/components/PathsList/paths-list.js | 4 ++-- lib/components/Redoc/redoc.js | 4 ++-- lib/utils/SchemaManager.js | 2 +- 7 files changed, 30 insertions(+), 22 deletions(-) delete mode 100644 .eslintrc create mode 100644 lib/.eslintrc diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index a4e474cb..00000000 --- a/.eslintrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "parser": "babel-eslint", - "extends": "eslint:recommended", - "env": { - "browser": true, - }, - "rules": { - "quotes": [2, "single"], - "no-console": 0, - "comma-spacing": 2, - "comma-style": [2, "last"], - "consistent-return": 2, - "strict": [2, "global"] - } -} diff --git a/lib/.eslintrc b/lib/.eslintrc new file mode 100644 index 00000000..8274c48b --- /dev/null +++ b/lib/.eslintrc @@ -0,0 +1,24 @@ +{ + "parser": "babel-eslint", + "extends": "eslint:recommended", + "env": { + "browser": true, + }, + "rules": { + "quotes": [2, "single"], + "no-console": 0, + "comma-spacing": 2, + "comma-style": [2, "last"], + "consistent-return": 2, + "strict": [2, "global"], + "eqeqeq": [2, "smart"], + "curly": [2, "multi-line"], + "semi-spacing": [2, {"before": false, "after": true}], + "semi": [2, "always"], + "no-extra-semi": 2, + "comma-dangle": [2, "never"], + "no-sequences": 2, + "comma-spacing": [2, {"before": false, "after": true}], + "comma-style": [2, "last"] + } +} diff --git a/lib/components/ApiInfo/api-info.js b/lib/components/ApiInfo/api-info.js index 0accf836..6bd41add 100644 --- a/lib/components/ApiInfo/api-info.js +++ b/lib/components/ApiInfo/api-info.js @@ -24,4 +24,4 @@ export class ApiInfo { //TODO: check and apply hooks to modify data } } -ApiInfo.parameters = [[SchemaManager]] +ApiInfo.parameters = [[SchemaManager]]; diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index 145736e1..9ab7753f 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -2,7 +2,6 @@ import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2'; import {SchemaManager} from '../../utils/SchemaManager'; -import {JsonPointer} from '../../utils/JsonPointer'; import {methods as swaggerMethods} from '../../utils/swagger-defs'; import {Method} from '../Method/method'; diff --git a/lib/components/PathsList/paths-list.js b/lib/components/PathsList/paths-list.js index 47164ed2..9d822d3f 100644 --- a/lib/components/PathsList/paths-list.js +++ b/lib/components/PathsList/paths-list.js @@ -22,9 +22,9 @@ export class PathsList { extractData() { this.data = {}; - this.data.paths = Object.keys(this.schema.paths) + this.data.paths = Object.keys(this.schema.paths); //TODO: check and apply hooks to modify data } } -PathsList.parameters = [[SchemaManager]] +PathsList.parameters = [[SchemaManager]]; diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index fff800c5..f1e0459e 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -21,8 +21,8 @@ export class Redoc { } extractData() { - this.data = this.schema + this.data = this.schema; //TODO: check and apply hooks to modify data } } -Redoc.parameters = [[SchemaManager]] +Redoc.parameters = [[SchemaManager]]; diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index 905b7626..d1135ab9 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -1,6 +1,6 @@ 'use strict'; import SwaggerParser from 'swagger-parser'; -import JsonPointer from './JsonPointer' +import JsonPointer from './JsonPointer'; export class SchemaManager { constructor() { From a2fe4c9ca46319e40210e0ed10b0bd14a351045d Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 9 Oct 2015 23:19:35 +0300 Subject: [PATCH 22/97] Moved duplicated code into base class/decorator --- demo/index.html | 4 +- lib/components/ApiInfo/api-info.js | 25 +++---- lib/components/Method/method.js | 29 ++------ lib/components/MethodsList/methods-list.js | 29 ++------ lib/components/PathsList/paths-list.js | 26 +++---- lib/components/Redoc/redoc.js | 20 ++---- lib/components/base.js | 81 ++++++++++++++++++++++ lib/utils/JsonPointer.js | 2 +- 8 files changed, 119 insertions(+), 97 deletions(-) create mode 100644 lib/components/base.js diff --git a/demo/index.html b/demo/index.html index 354b0554..3cd89bef 100644 --- a/demo/index.html +++ b/demo/index.html @@ -4,7 +4,7 @@ ReDoc prototype - + Loading... @@ -12,7 +12,7 @@ diff --git a/lib/components/ApiInfo/api-info.js b/lib/components/ApiInfo/api-info.js index 6bd41add..e1cf1cc1 100644 --- a/lib/components/ApiInfo/api-info.js +++ b/lib/components/ApiInfo/api-info.js @@ -1,27 +1,18 @@ 'use strict'; -import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2'; -import {SchemaManager} from '../../utils/SchemaManager'; +import {RedocComponent, BaseComponent} from '../base'; -@Component({ - selector: 'api-info' -}) -@View({ - templateUrl: './lib/components/ApiInfo/api-info.html', +@RedocComponent({ + selector: 'api-info', styleUrls: ['./lib/components/ApiInfo/api-info.css'], - directives: [CORE_DIRECTIVES] + templateUrl: './lib/components/ApiInfo/api-info.html' }) -export class ApiInfo { +export class ApiInfo extends BaseComponent { constructor(schemaMgr) { - this.data = null; - this.schema = schemaMgr.schema; - this.extractData(); + super(schemaMgr); } - extractData() { - this.data = this.schema.info; - - //TODO: check and apply hooks to modify data + prepareModel() { + this.data = this.componentSchema.info; } } -ApiInfo.parameters = [[SchemaManager]]; diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 9aa5ae42..a2565db5 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -1,36 +1,21 @@ 'use strict'; -import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2'; -import {SchemaManager} from '../../utils/SchemaManager'; import {JsonPointer} from '../../utils/JsonPointer'; +import {RedocComponent, BaseComponent} from '../base'; -@Component({ +@RedocComponent({ selector: 'method', - properties: ['pointer'], - lifecycle: [OnInit] + templateUrl: './lib/components/Method/method.html' }) -@View({ - templateUrl: './lib/components/Method/method.html', - directives: [CORE_DIRECTIVES] -}) -export class Method { +export class Method extends BaseComponent { constructor(schemaMgr) { - this.data = null; - this.schemaMgr = schemaMgr; + super(schemaMgr); } - onInit() { - this.extractData(); - } - - extractData() { + prepareModel() { this.data = {}; - var methodInfo = this.schemaMgr.byPointer(this.pointer); - this.data.method = JsonPointer.baseName(this.pointer); this.data.path = JsonPointer.baseName(this.pointer, 2); - this.data.methodInfo = methodInfo; - //TODO: check and apply hooks to modify data + this.data.methodInfo = this.componentSchema; } } -Method.parameters = [[SchemaManager]]; diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index 9ab7753f..e0e7c4f0 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -1,39 +1,24 @@ 'use strict'; -import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2'; -import {SchemaManager} from '../../utils/SchemaManager'; +import {RedocComponent, BaseComponent} from '../base'; import {methods as swaggerMethods} from '../../utils/swagger-defs'; import {Method} from '../Method/method'; -@Component({ +@RedocComponent({ selector: 'methods-list', - properties: ['pointer'], - lifecycle: [OnInit] -}) -@View({ templateUrl: './lib/components/MethodsList/methods-list.html', - directives: [CORE_DIRECTIVES, Method] + directives: [Method] }) -export class MethodsList { - _name: string; +export class MethodsList extends BaseComponent { constructor(schemaMgr) { - this.data = null; - this.schemaMgr = schemaMgr; - //this.pointer = pointer; - //this.extractData(); + super(schemaMgr); } - onInit() { - this.extractData(); - } - - extractData() { + prepareModel() { this.data = {}; - var pathInfo = this.schemaMgr.byPointer(this.pointer); + let pathInfo = this.componentSchema; this.data.methods = Object.keys(pathInfo).filter((k) => swaggerMethods.has(k)); - //TODO: check and apply hooks to modify data } } -MethodsList.parameters = [[SchemaManager]]; diff --git a/lib/components/PathsList/paths-list.js b/lib/components/PathsList/paths-list.js index 9d822d3f..ba3ab03c 100644 --- a/lib/components/PathsList/paths-list.js +++ b/lib/components/PathsList/paths-list.js @@ -1,30 +1,20 @@ 'use strict'; -import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2'; -import {SchemaManager} from '../../utils/SchemaManager'; +import {RedocComponent, BaseComponent} from '../base'; import {MethodsList} from '../MethodsList/methods-list'; -import {JsonPointerEscapePipe} from '../../utils/pipes'; -@Component({ - selector: 'paths-list' -}) -@View({ +@RedocComponent({ + selector: 'paths-list', templateUrl: './lib/components/PathsList/paths-list.html', - directives: [CORE_DIRECTIVES, MethodsList], - pipes: [JsonPointerEscapePipe] + directives: [MethodsList] }) -export class PathsList { +export class PathsList extends BaseComponent { constructor(schemaMgr) { - this.data = null; - this.schema = schemaMgr.schema; - this.extractData(); + super(schemaMgr); } - extractData() { + prepareModel() { this.data = {}; - this.data.paths = Object.keys(this.schema.paths); - - //TODO: check and apply hooks to modify data + this.data.paths = Object.keys(this.componentSchema.paths); } } -PathsList.parameters = [[SchemaManager]]; diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index f1e0459e..0f9c44b9 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -1,28 +1,18 @@ 'use strict'; -import {Component, View} from 'angular2/angular2'; +import {RedocComponent, BaseComponent} from '../base'; import {SchemaManager} from '../../utils/SchemaManager'; import {ApiInfo} from '../ApiInfo/api-info'; import {PathsList} from '../PathsList/paths-list'; -@Component({ +@RedocComponent({ selector: 'redoc', - bindings: [SchemaManager] -}) -@View({ + bindings: [SchemaManager], templateUrl: './lib/components/Redoc/redoc.html', directives: [ApiInfo, PathsList] }) -export class Redoc { +export class Redoc extends BaseComponent { constructor(schemaMgr) { - this.data = null; - this.schema = schemaMgr.schema; - this.extractData(); - } - - extractData() { - this.data = this.schema; - //TODO: check and apply hooks to modify data + super(schemaMgr); } } -Redoc.parameters = [[SchemaManager]]; diff --git a/lib/components/base.js b/lib/components/base.js new file mode 100644 index 00000000..030da682 --- /dev/null +++ b/lib/components/base.js @@ -0,0 +1,81 @@ +'use strict'; +import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2'; +import {SchemaManager} from '../utils/SchemaManager'; +import {JsonPointerEscapePipe} from '../utils/pipes'; + +// common inputs for all components +let commonInputs = ['pointer']; // json pointer to the schema chunk + +// internal helper function +function safeConcat(a, b) { + let res = a && a.slice() || []; + b = (b == null) ? [] : b; + return res.concat(b); +} + +/** + * Class decorator + * Simplifies setup of component metainfo + * All options are options from either Component or View angular2 decorator + * For detailed info look angular2 doc + * @param {Object} options - component options + * @param {string[]} options.inputs - component inputs + * @param {*[]} options.directives - directives used by component + * (except CORE_DIRECTIVES) + * @param {*[]} options.pipes - pipes used by component + * @param {*[]} options.bindings - component bindings + * @param {string} options.templateUrl - path to component template + * @param {string} options.template - component template html + * @param {string} options.styles - component css styles + */ +export function RedocComponent(options) { + let inputs = safeConcat(options.inputs, commonInputs); + let directives = safeConcat(options.directives, CORE_DIRECTIVES); + let pipes = safeConcat(options.pipes, [JsonPointerEscapePipe]); + + return function decorator(target) { + + let componentDecorator = Component({ + selector: options.selector, + inputs: inputs, + lifecycle: [OnInit], + bindings: options.bindings + }); + let viewDecorator = View({ + templateUrl: options.templateUrl, + template: options.template, + styles: options.styles, + directives: directives, + pipes: pipes + }); + + return componentDecorator(viewDecorator(target) || target) || target; + }; +} + +/** + * Generic Component + * @class + */ +export class BaseComponent { + constructor(schemaMgr) { + this.schemaMgr = schemaMgr; + this.schema = schemaMgr.schema; + this.componentSchema = null; + } + + /** + * onInit method is run by angular2 after all component inputs are resolved + */ + onInit() { + this.componentSchema = this.schemaMgr.byPointer(this.pointer || ''); + this.prepareModel(); + } + + /** + * Used to prepare model based on component schema + * @abstract + */ + prepareModel() {} +} +BaseComponent.parameters = [[SchemaManager]]; diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.js index dfb3d2a6..a6775c37 100644 --- a/lib/utils/JsonPointer.js +++ b/lib/utils/JsonPointer.js @@ -16,7 +16,7 @@ export class JsonPointer extends JsonPointerLib { * JsonPointerHelper.baseName('/path/foo/subpath', 2) */ static baseName(pointer, level=1) { - var tokens = JsonPointer.parse(pointer); + let tokens = JsonPointer.parse(pointer); return tokens[tokens.length - (level)]; } } From ff437c9b006f0b1cf62f173f1c70e9ba2642e738 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 10 Oct 2015 15:34:46 +0300 Subject: [PATCH 23/97] Added some styling --- demo/index.html | 1 + demo/main.css | 6 +++ lib/components/ApiInfo/api-info.html | 2 +- lib/components/Method/method.css | 44 ++++++++++++++++++++++ lib/components/Method/method.html | 15 ++++---- lib/components/Method/method.js | 3 +- lib/components/MethodsList/methods-list.js | 1 + 7 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 demo/main.css create mode 100644 lib/components/Method/method.css diff --git a/demo/index.html b/demo/index.html index 3cd89bef..d24a8659 100644 --- a/demo/index.html +++ b/demo/index.html @@ -2,6 +2,7 @@ ReDoc prototype + diff --git a/demo/main.css b/demo/main.css new file mode 100644 index 00000000..bd7110a3 --- /dev/null +++ b/demo/main.css @@ -0,0 +1,6 @@ +body { + font-family: Verdana, Geneva, sans-serif; + font-size: 14px; + padding: 10px 20px; + color: #333; +} diff --git a/lib/components/ApiInfo/api-info.html b/lib/components/ApiInfo/api-info.html index 7c3e72ea..e596009e 100644 --- a/lib/components/ApiInfo/api-info.html +++ b/lib/components/ApiInfo/api-info.html @@ -2,7 +2,7 @@

{{data.description}}

- Contatct: + Contact: {{data.contact.name || data.contact.url}} diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css new file mode 100644 index 00000000..32e768e2 --- /dev/null +++ b/lib/components/Method/method.css @@ -0,0 +1,44 @@ +h2 { + font-size: 32px; + font-weight: 200; +} + +h3 { + margin: 0; + font-weight: 200; +} + +h3 > span { + padding: 5px 10px; + vertical-align: middle; +} + +.http-method { + font-size: 13px; + color: white; + background-color: #1976D3; +} + +.http-method.delete { + background-color: red; +} + +.http-method.post { + background-color: green; +} + +.http-method.patch { + background-color: orange; +} + +.http-method.put { + background-color: crimson; +} + +.http-method.options { + background-color: black; +} + +.http-method.head { + background-color: darkkhaki; +} diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index ea00a532..79e42085 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -1,7 +1,8 @@ -

+

{{data.methodInfo.summary}}

+

+ {{data.method}} + {{data.path}} +

+

+ {{data.methodInfo.description}} +

diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index a2565db5..780a9b81 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -5,7 +5,8 @@ import {RedocComponent, BaseComponent} from '../base'; @RedocComponent({ selector: 'method', - templateUrl: './lib/components/Method/method.html' + templateUrl: './lib/components/Method/method.html', + styleUrls: ['./lib/components/Method/method.css'] }) export class Method extends BaseComponent { constructor(schemaMgr) { diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index e0e7c4f0..151058b1 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -20,5 +20,6 @@ export class MethodsList extends BaseComponent { let pathInfo = this.componentSchema; this.data.methods = Object.keys(pathInfo).filter((k) => swaggerMethods.has(k)); + // TODO: check $ref field } } From b30bf9840270b5ea54a90d0cd1d650a7bc17a54e Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 10 Oct 2015 16:01:41 +0300 Subject: [PATCH 24/97] Added simple paramaters list --- lib/components/Method/method.html | 1 + lib/components/Method/method.js | 4 +- lib/components/MethodsList/methods-list.css | 5 ++ lib/components/MethodsList/methods-list.js | 1 + lib/components/ParamsList/params-list.css | 24 +++++++++ lib/components/ParamsList/params-list.html | 18 +++++++ lib/components/ParamsList/params-list.js | 59 +++++++++++++++++++++ lib/utils/JsonPointer.js | 28 +++++++++- lib/utils/SchemaManager.js | 6 ++- 9 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 lib/components/MethodsList/methods-list.css create mode 100644 lib/components/ParamsList/params-list.css create mode 100644 lib/components/ParamsList/params-list.html create mode 100644 lib/components/ParamsList/params-list.js diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index 79e42085..bf378160 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -6,3 +6,4 @@

{{data.methodInfo.description}}

+ diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 780a9b81..58e29f9f 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -2,11 +2,13 @@ import {JsonPointer} from '../../utils/JsonPointer'; import {RedocComponent, BaseComponent} from '../base'; +import {ParamsList} from '../ParamsList/params-list'; @RedocComponent({ selector: 'method', templateUrl: './lib/components/Method/method.html', - styleUrls: ['./lib/components/Method/method.css'] + styleUrls: ['./lib/components/Method/method.css'], + directives: [ParamsList] }) export class Method extends BaseComponent { constructor(schemaMgr) { diff --git a/lib/components/MethodsList/methods-list.css b/lib/components/MethodsList/methods-list.css new file mode 100644 index 00000000..35b9afdf --- /dev/null +++ b/lib/components/MethodsList/methods-list.css @@ -0,0 +1,5 @@ +method { + padding-bottom: 50px; + display: block; + border-bottom: 1px solid silver; +} diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index 151058b1..60364f56 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -7,6 +7,7 @@ import {Method} from '../Method/method'; @RedocComponent({ selector: 'methods-list', templateUrl: './lib/components/MethodsList/methods-list.html', + styleUrls: ['./lib/components/MethodsList/methods-list.css'], directives: [Method] }) export class MethodsList extends BaseComponent { diff --git a/lib/components/ParamsList/params-list.css b/lib/components/ParamsList/params-list.css new file mode 100644 index 00000000..febf6df3 --- /dev/null +++ b/lib/components/ParamsList/params-list.css @@ -0,0 +1,24 @@ +h4 { + font-size: 16px; + font-weight: 200; + color: black; +} + +.param { + padding: 10px 0; +} + +.param > span { + padding: 5px 10px; + vertical-align: middle; +} + +.param-name { + font-weight: bold; +} + +.param-type { + padding: 2px 10px; + background-color: #EAEAEA; + border: silver 1px solid; +} diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html new file mode 100644 index 00000000..8750f4a8 --- /dev/null +++ b/lib/components/ParamsList/params-list.html @@ -0,0 +1,18 @@ +

Parameters

+ No parameters +
+
+ {{param.name}} + {{param.type}} + {{param.description}} +
+
+
+ {{data.bodyParam.name}} + {{data.bodyParam.type}} + + {{data.bodyParam.description}} + + Body Schema would be somewhere here (unimplemented yet) +
diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js new file mode 100644 index 00000000..c4dd89e9 --- /dev/null +++ b/lib/components/ParamsList/params-list.js @@ -0,0 +1,59 @@ +'use strict'; + +import {JsonPointer} from '../../utils/JsonPointer'; +import {RedocComponent, BaseComponent} from '../base'; + +@RedocComponent({ + selector: 'params-list', + templateUrl: './lib/components/ParamsList/params-list.html', + styleUrls: ['./lib/components/ParamsList/params-list.css'] +}) +export class ParamsList extends BaseComponent { + constructor(schemaMgr) { + super(schemaMgr); + } + + prepareModel() { + this.data = {}; + let params = this.componentSchema; + let pathParams = this.getPathParams(); + if (pathParams) params.concat(pathParams); + this.sortParams(params); + + // temporary hanlde body param + if (params.length && params[params.length - 1].in === 'body') { + let bodyParam = params.pop(); + bodyParam.type = bodyParam.schema.type + || `Object(${JsonPointer.baseName(bodyParam.schema.$ref)})`; + this.data.bodyParam = bodyParam; + } + + this.data.noParams = !(params.length || this.data.bodyParam); + this.data.params = params; + } + + getPathParams() { + let ptr = JsonPointer.dirName(this.pointer, 2) + '/parameters'; + let pathParams = this.schemaMgr.byPointer(ptr); + if (Array.isArray(pathParams)) { + return pathParams; + } + if (pathParams && pathParams.$ref) { + return this.schemaMgr.byPointer(pathParams.$ref); + } + + return []; + } + + sortParams(params) { + const sortOrder = { + 'path' : 0, + 'query' : 10, + 'formData' : 20, + 'header': 40, + 'body': 50 + }; + + params.sort((a, b) => sortOrder[a] - sortOrder[b]); + } +} diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.js index a6775c37..96337138 100644 --- a/lib/utils/JsonPointer.js +++ b/lib/utils/JsonPointer.js @@ -5,7 +5,6 @@ import JsonPointerLib from 'json-pointer'; * Wrapper for JsonPointer. Provides common operations */ export class JsonPointer extends JsonPointerLib { - /** * returns last JsonPointer token * if level > 1 returns levels last (second last/third last) @@ -19,6 +18,31 @@ export class JsonPointer extends JsonPointerLib { let tokens = JsonPointer.parse(pointer); return tokens[tokens.length - (level)]; } -} + /** + * returns dirname of pointer + * if level > 1 returns corresponding dirname in the hierarchy + * @example + * // returns /path/0 + * JsonPointerHelper.dirName('/path/0/subpath') + * // returns /path + * JsonPointerHelper.dirName('/path/foo/subpath', 2) + */ + static dirName(pointer, level=1) { + let tokens = JsonPointer.parse(pointer); + return JsonPointer.compile(tokens.slice(0, tokens.length - level)); + } + + /** + * overridden JsonPointer original parse to take care of prefixing '#' symbol + * that is not valid JsonPointer + */ + static parse(pointer) { + let ptr = pointer; + if (ptr.charAt(0) === '#') { + ptr = ptr.substring(1); + } + return JsonPointerLib.parse(ptr); + } +} export default JsonPointer; diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index d1135ab9..33f6ed3c 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -40,7 +40,11 @@ export class SchemaManager { } byPointer(pointer) { - return JsonPointer.get(this._schema, pointer); + let res = null; + try { + res = JsonPointer.get(this._schema, pointer); + } catch(e) {/*skip*/ } + return res; } } From 01990f265a0a8c0316dc986e1f0155061eb3cee7 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 10 Oct 2015 16:48:17 +0300 Subject: [PATCH 25/97] Fixed parameters list issues --- lib/components/ParamsList/params-list.js | 19 +++++++++++++++---- lib/utils/JsonPointer.js | 6 +++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index c4dd89e9..f3036d4a 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -15,9 +15,10 @@ export class ParamsList extends BaseComponent { prepareModel() { this.data = {}; - let params = this.componentSchema; - let pathParams = this.getPathParams(); - if (pathParams) params.concat(pathParams); + let params = this.componentSchema || []; + let pathParams = this.getPathParams() || []; + params = params.concat(pathParams); + params = this.resolveRefs(params); this.sortParams(params); // temporary hanlde body param @@ -45,6 +46,16 @@ export class ParamsList extends BaseComponent { return []; } + resolveRefs(params) { + return params.map(param => { + if (param.$ref) { + return this.schemaMgr.byPointer(param.$ref); + } else { + return param; + } + }); + } + sortParams(params) { const sortOrder = { 'path' : 0, @@ -54,6 +65,6 @@ export class ParamsList extends BaseComponent { 'body': 50 }; - params.sort((a, b) => sortOrder[a] - sortOrder[b]); + params.sort((a, b) => sortOrder[a.in] - sortOrder[b.in]); } } diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.js index 96337138..bd5851cd 100644 --- a/lib/utils/JsonPointer.js +++ b/lib/utils/JsonPointer.js @@ -42,7 +42,11 @@ export class JsonPointer extends JsonPointerLib { if (ptr.charAt(0) === '#') { ptr = ptr.substring(1); } - return JsonPointerLib.parse(ptr); + return JsonPointerLib._origParse(ptr); } } + +JsonPointerLib._origParse = JsonPointerLib.parse; +JsonPointerLib.parse = JsonPointer.parse; + export default JsonPointer; From ae7b99700f78bda7126482680ab0a2b14f5939ac Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 11 Oct 2015 21:23:34 +0300 Subject: [PATCH 26/97] Added start script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ea209e6..0c04eb94 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "repository": "RomanGotsiy/redoc-prototype", "scripts": { "test": "gulp lint", - "postinstall": "jspm install" + "postinstall": "jspm install", + "start": "gulp serve" }, "keywords": [ "Swagger", From f4dfe929192b388a105daffd51f192e912e90153 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 11 Oct 2015 21:32:40 +0300 Subject: [PATCH 27/97] Renamed petstore.json to swagger.json --- demo/index.html | 2 +- demo/{petstore.json => swagger.json} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename demo/{petstore.json => swagger.json} (100%) diff --git a/demo/index.html b/demo/index.html index d24a8659..dce8c797 100644 --- a/demo/index.html +++ b/demo/index.html @@ -14,7 +14,7 @@ diff --git a/demo/petstore.json b/demo/swagger.json similarity index 100% rename from demo/petstore.json rename to demo/swagger.json From 624e2bfb2bf82fb33e96cc593f14003747879835 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 11 Oct 2015 21:33:13 +0300 Subject: [PATCH 28/97] Added run instructions --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index bb17f642..48a9ec73 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,16 @@ Prototype of component-based Swagger documentation **Under development** [Live demo](http://romangotsiy.github.io/redoc-prototype/) + +## Running locally + +1. Clone repository +`git clone https://github.com/RomanGotsiy/redoc-prototype.git` +2. Go to the project folder +`cd redoc-prototype` +3. Install node modules +`npm install` +4. _(optional)_ Replace `demo/swagger.json` with your own schema +5. Start the server +`npm start` +6. Open `http://localhost:9000` From 99e515c2aaecdfa5d9dbaf7f3ef95b5497a9710c Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 14 Oct 2015 23:59:39 +0300 Subject: [PATCH 29/97] Added zone.js to build --- build/paths.js | 1 + build/tasks/build.js | 23 ++++++++++++++++++++--- build/tasks/watch.js | 2 +- package.json | 6 +++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/build/paths.js b/build/paths.js index f5210ba7..3ebd0639 100644 --- a/build/paths.js +++ b/build/paths.js @@ -3,6 +3,7 @@ module.exports = { html: 'lib/**/*.html', css: 'lib/**/*.css', sourceEntryPoint: 'lib/index.js', + outputName: 'redoc.full.js', output: 'dist/', tmp: '.tmp/', demo: 'demo/**/*' diff --git a/build/tasks/build.js b/build/tasks/build.js index aa87df19..4d52b175 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -3,29 +3,46 @@ var runSequence = require('run-sequence'); var Builder = require('systemjs-builder'); var inlineNg2Template = require('gulp-inline-ng2-template'); var path = require('path'); - +var sourcemaps = require('gulp-sourcemaps'); var paths = require('../paths'); var fs= require('fs'); +var concat = require('gulp-concat'); +paths.redocBuilt = path.join(paths.output, paths.outputName); gulp.task('build', function (callback) { return runSequence( 'clean', - 'bundleSfx', + 'bundle', callback ); }); +gulp.task('bundle', ['bundleSfx', 'concatDeps']); + gulp.task('inlineTemplates', function() { return gulp.src(paths.source, { base: './' }) .pipe(inlineNg2Template({ base: '/' })) .pipe(gulp.dest(paths.tmp)); }); +var JS_DEV_DEPS = [ + 'node_modules/zone.js/dist/zone-microtask.js' +]; + +// concatenate angular2 deps +gulp.task('concatDeps', ['bundleSfx'], function() { + gulp.src(JS_DEV_DEPS.concat([paths.redocBuilt])) + .pipe(sourcemaps.init({loadMaps: true})) + .pipe(concat(paths.outputName)) + .pipe(sourcemaps.write()) + .pipe(gulp.dest(paths.output)) +}); + gulp.task('bundleSfx', ['inlineTemplates'], function(cb) { var builder = new Builder('./', 'system.config.js'); builder .buildStatic(path.join(paths.tmp, paths.sourceEntryPoint), - path.join(paths.output, 'redoc.full.js'), + paths.redocBuilt, { globalName: 'Redoc', sourceMaps: true } ) .then(function() { diff --git a/build/tasks/watch.js b/build/tasks/watch.js index ee6e9100..ba69bc83 100644 --- a/build/tasks/watch.js +++ b/build/tasks/watch.js @@ -6,7 +6,7 @@ function changed(event) { console.log('File ' + event.path + ' was ' + event.type + ', running tasks...'); } -gulp.task('watch', ['build'], function () { +gulp.task('watch', ['bundle'], function () { gulp.watch([ paths.source ], [ 'bundleSfx', browserSync.reload ]).on('change', changed); gulp.watch([ paths.html ], [ 'bundleSfx', browserSync.reload]).on('change', changed); gulp.watch([ paths.css ], [ 'bundleSfx', browserSync.reload]).on('change', changed); diff --git a/package.json b/package.json index 0c04eb94..6078350b 100644 --- a/package.json +++ b/package.json @@ -41,14 +41,18 @@ "browser-sync": "^2.9.8", "del": "^2.0.2", "gulp": "^3.9.0", + "gulp-concat": "^2.6.0", "gulp-eslint": "^1.0.0", "gulp-inline-ng2-template": "0.0.7", "gulp-jshint": "^1.11.2", + "gulp-replace": "^0.5.4", + "gulp-sourcemaps": "^1.6.0", "jshint-stylish": "^2.0.1", "jspm": "^0.16.11", "require-dir": "^0.3.0", "run-sequence": "^1.1.4", "systemjs-builder": "^0.14.7", - "vinyl-paths": "^2.0.0" + "vinyl-paths": "^2.0.0", + "zone.js": "^0.5.8" } } From bb5eb498feff25d8a600c46aa7d46ee48132c39d Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 15 Oct 2015 19:57:47 +0300 Subject: [PATCH 30/97] fixed watch task issue --- build/tasks/watch.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/tasks/watch.js b/build/tasks/watch.js index ba69bc83..dea14127 100644 --- a/build/tasks/watch.js +++ b/build/tasks/watch.js @@ -7,8 +7,8 @@ function changed(event) { } gulp.task('watch', ['bundle'], function () { - gulp.watch([ paths.source ], [ 'bundleSfx', browserSync.reload ]).on('change', changed); - gulp.watch([ paths.html ], [ 'bundleSfx', browserSync.reload]).on('change', changed); - gulp.watch([ paths.css ], [ 'bundleSfx', browserSync.reload]).on('change', changed); + gulp.watch([ paths.source ], [ 'bundle', browserSync.reload ]).on('change', changed); + gulp.watch([ paths.html ], [ 'bundle', browserSync.reload]).on('change', changed); + gulp.watch([ paths.css ], [ 'bundle', browserSync.reload]).on('change', changed); gulp.watch([ paths.demo ], [ '', browserSync.reload ]).on('change', changed); }); From 72795c6431e3f1eafebcc09973bd2d51b47f74ed Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 15 Oct 2015 20:06:16 +0300 Subject: [PATCH 31/97] Implemented side-menu component --- lib/components/MethodsList/methods-list.css | 2 +- lib/components/MethodsList/methods-list.html | 2 +- lib/components/SideMenu/side-menu.html | 4 + lib/components/SideMenu/side-menu.js | 125 ++++++++++++++++++ lib/components/SideMenuCat/side-menu-cat.css | 23 ++++ lib/components/SideMenuCat/side-menu-cat.html | 6 + lib/components/SideMenuCat/side-menu-cat.js | 19 +++ lib/components/index.js | 1 + 8 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 lib/components/SideMenu/side-menu.html create mode 100644 lib/components/SideMenu/side-menu.js create mode 100644 lib/components/SideMenuCat/side-menu-cat.css create mode 100644 lib/components/SideMenuCat/side-menu-cat.html create mode 100644 lib/components/SideMenuCat/side-menu-cat.js diff --git a/lib/components/MethodsList/methods-list.css b/lib/components/MethodsList/methods-list.css index 35b9afdf..e4b8f554 100644 --- a/lib/components/MethodsList/methods-list.css +++ b/lib/components/MethodsList/methods-list.css @@ -1,5 +1,5 @@ method { - padding-bottom: 50px; + padding-bottom: 100px; display: block; border-bottom: 1px solid silver; } diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html index 37846147..67327ac0 100644 --- a/lib/components/MethodsList/methods-list.html +++ b/lib/components/MethodsList/methods-list.html @@ -1,3 +1,3 @@
- +
diff --git a/lib/components/SideMenu/side-menu.html b/lib/components/SideMenu/side-menu.html new file mode 100644 index 00000000..fa462571 --- /dev/null +++ b/lib/components/SideMenu/side-menu.html @@ -0,0 +1,4 @@ +

Api reference

+
+ +
diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js new file mode 100644 index 00000000..a244231f --- /dev/null +++ b/lib/components/SideMenu/side-menu.js @@ -0,0 +1,125 @@ +'use strict'; + +import {RedocComponent, BaseComponent} from '../base'; +import {SchemaManager} from '../../utils/SchemaManager'; +import {methods as swaggerMethods} from '../../utils/swagger-defs'; +import {JsonPointer} from '../../utils/JsonPointer'; +import {SideMenuCat} from '../SideMenuCat/side-menu-cat'; +import {NgZone} from 'angular2/angular2'; + +@RedocComponent({ + selector: 'side-menu', + bindings: [SchemaManager], + templateUrl: './lib/components/SideMenu/side-menu.html', + directives: [SideMenuCat] +}) +export class SideMenu extends BaseComponent { + constructor(schemaMgr, zone) { + super(schemaMgr); + this.zone = zone; + this.zone.run(() => { + this.bindScroll(); + }); + + this.activeCatIdx = 0; + this.activeMethodIdx = 0; + this.prevOffsetY = null; + } + + changeActiveMethod(offset) { + let menu = this.data.menu; + let catCount = menu.length; + let catLength = menu[this.activeCatIdx].methods.length; + this.activeMethodIdx += offset; + + if (this.activeMethodIdx > catLength - 1) { + this.activeCatIdx++; + this.activeMethodIdx = 0; + } + if (this.activeMethodIdx < 0) { + let prevCatIdx = --this.activeCatIdx; + catLength = menu[Math.max(prevCatIdx, 0)].methods.length; + this.activeMethodIdx = catLength - 1; + } + if (this.activeCatIdx > catCount - 1) { + this.activeCatIdx = catCount - 1; + this.activeMethodIdx = catLength - 1; + } + if (this.activeCatIdx < 0) { + this.activeCatIdx = 0; + this.activeMethodIdx = 0; + } + } + activateNext(offset = 1) { + let menu = this.data.menu; + menu[this.activeCatIdx].methods[this.activeMethodIdx].active = false; + menu[this.activeCatIdx].active = false; + + this.changeActiveMethod(offset); + + menu[this.activeCatIdx].active = true; + let currentItem = menu[this.activeCatIdx].methods[this.activeMethodIdx]; + currentItem.active = true; + this.activeMethodPtr = currentItem.pointer; + } + + scrollHandler() { + let isScrolledDown = (window.scrollY - this.prevOffsetY > 0); + this.prevOffsetY = window.scrollY; + let ptr = this.activeMethodPtr; + var activeMethodHost = document.querySelector(`[pointer="${ptr}"]`); + if (!activeMethodHost) return; + + if(isScrolledDown && activeMethodHost.getBoundingClientRect().bottom <= 0 ) { + this.activateNext(1); + return; + } + if(!isScrolledDown && activeMethodHost.getBoundingClientRect().top > 0 ) { + this.activateNext(-1); + return; + } + } + + bindScroll() { + this.prevOffsetY = window.scrollY; + window.addEventListener('scroll', () => this.scrollHandler()); + } + + prepareModel() { + this.data = {}; + this.data.menu = Array.from(this.buildMenuTree().entries()).map( + el => ({name: el[0], methods: el[1]}) + ); + this.activateNext(0); + } + + buildMenuTree() { + let tag2MethodMapping = new Map(); + let paths = this.componentSchema.paths; + for (let path of Object.keys(paths)) { + let methods = Object.keys(paths[path]).filter((k) => swaggerMethods.has(k)); + for (let method of methods) { + let methodInfo = paths[path][method]; + let tags = methodInfo.tags; + + //TODO: mb need to do something cleverer + if (!tags || !tags.length) { + tags = ['[Other]']; + } + let methodPointer = JsonPointer.compile(['paths', path, method]); + let methodSummary = methodInfo.summary; + for (let tag of tags) { + let tagMethods = tag2MethodMapping.get(tag); + if (!tagMethods) { + tagMethods = []; + tag2MethodMapping.set(tag, tagMethods); + } + + tagMethods.push({pointer: methodPointer, summary: methodSummary}); + } + } + } + return tag2MethodMapping; + } +} +SideMenu.parameters.push([NgZone]); diff --git a/lib/components/SideMenuCat/side-menu-cat.css b/lib/components/SideMenuCat/side-menu-cat.css new file mode 100644 index 00000000..23a88309 --- /dev/null +++ b/lib/components/SideMenuCat/side-menu-cat.css @@ -0,0 +1,23 @@ +label { + font-weight: bold; + font-size: 18px; +} + +ul { + padding-left: 20px; + margin: 0; + display: none; +} + +ul.active { + display: block; +} + +li { + list-style: none inside none; + padding: 5px 0; +} + +li.active { + color: #1976D3; +} diff --git a/lib/components/SideMenuCat/side-menu-cat.html b/lib/components/SideMenuCat/side-menu-cat.html new file mode 100644 index 00000000..aadeb1b3 --- /dev/null +++ b/lib/components/SideMenuCat/side-menu-cat.html @@ -0,0 +1,6 @@ + +
    +
  • + {{method.summary}} +
  • +
diff --git a/lib/components/SideMenuCat/side-menu-cat.js b/lib/components/SideMenuCat/side-menu-cat.js new file mode 100644 index 00000000..b9b5ae77 --- /dev/null +++ b/lib/components/SideMenuCat/side-menu-cat.js @@ -0,0 +1,19 @@ +'use strict'; + +import {RedocComponent, BaseComponent} from '../base'; + +@RedocComponent({ + selector: 'side-menu-cat', + inputs: ['catDetails'], + styleUrls: ['./lib/components/SideMenuCat/side-menu-cat.css'], + templateUrl: './lib/components/SideMenuCat/side-menu-cat.html' +}) +export class SideMenuCat extends BaseComponent { + constructor(schemaMgr) { + super(schemaMgr); + } + + prepareModel() { + this.data = this.catDetails; + } +} diff --git a/lib/components/index.js b/lib/components/index.js index bf07f4c9..8b6de80d 100644 --- a/lib/components/index.js +++ b/lib/components/index.js @@ -1,4 +1,5 @@ 'use strict'; export * from './Redoc/redoc'; +export * from './SideMenu/side-menu'; export * from './ApiInfo/api-info'; From cb16c5d8d3f7a746bb86e6f291a45ddb2594b6f8 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 15 Oct 2015 20:06:33 +0300 Subject: [PATCH 32/97] Added side-menu to demo page --- demo/index.html | 2 ++ demo/main.css | 19 ++++++++++++++++++- lib/components/SideMenu/side-menu.js | 21 ++++++++++++++------- lib/index.js | 7 +++++-- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/demo/index.html b/demo/index.html index dce8c797..1351e01a 100644 --- a/demo/index.html +++ b/demo/index.html @@ -5,6 +5,8 @@ + + Loading... diff --git a/demo/main.css b/demo/main.css index bd7110a3..50c3f0a7 100644 --- a/demo/main.css +++ b/demo/main.css @@ -1,6 +1,23 @@ body { font-family: Verdana, Geneva, sans-serif; font-size: 14px; - padding: 10px 20px; color: #333; + margin: 0; +} + +side-menu, redoc { + display: block; + padding: 10px 20px; + box-sizing: border-box; +} + +side-menu { + position: fixed; + width: 260px; + height: 100%; + overflow-y: auto; +} + +redoc { + margin-left: 260px; } diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index a244231f..99934df5 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -7,6 +7,12 @@ import {JsonPointer} from '../../utils/JsonPointer'; import {SideMenuCat} from '../SideMenuCat/side-menu-cat'; import {NgZone} from 'angular2/angular2'; +const CHANGE = { + NEXT : 1, + BACK : -1, + HOLD : 0 +}; + @RedocComponent({ selector: 'side-menu', bindings: [SchemaManager], @@ -26,7 +32,7 @@ export class SideMenu extends BaseComponent { this.prevOffsetY = null; } - changeActiveMethod(offset) { + _updateActiveMethod(offset) { let menu = this.data.menu; let catCount = menu.length; let catLength = menu[this.activeCatIdx].methods.length; @@ -50,12 +56,13 @@ export class SideMenu extends BaseComponent { this.activeMethodIdx = 0; } } - activateNext(offset = 1) { + + changeActive(offset = 1) { let menu = this.data.menu; menu[this.activeCatIdx].methods[this.activeMethodIdx].active = false; menu[this.activeCatIdx].active = false; - - this.changeActiveMethod(offset); + + this._updateActiveMethod(offset); menu[this.activeCatIdx].active = true; let currentItem = menu[this.activeCatIdx].methods[this.activeMethodIdx]; @@ -71,11 +78,11 @@ export class SideMenu extends BaseComponent { if (!activeMethodHost) return; if(isScrolledDown && activeMethodHost.getBoundingClientRect().bottom <= 0 ) { - this.activateNext(1); + this.changeActive(CHANGE.NEXT); return; } if(!isScrolledDown && activeMethodHost.getBoundingClientRect().top > 0 ) { - this.activateNext(-1); + this.changeActive(CHANGE.BACK); return; } } @@ -90,7 +97,7 @@ export class SideMenu extends BaseComponent { this.data.menu = Array.from(this.buildMenuTree().entries()).map( el => ({name: el[0], methods: el[1]}) ); - this.activateNext(0); + this.changeActive(CHANGE.HOLD); } buildMenuTree() { diff --git a/lib/index.js b/lib/index.js index 2a8a0b02..c6056a8b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,7 +2,7 @@ import 'reflect-metadata'; import { bootstrap } from 'angular2/angular2'; -import { Redoc } from './components/Redoc/redoc'; +import { Redoc, SideMenu } from './components/index'; import { SchemaManager} from './utils/SchemaManager'; export * from './components/index'; @@ -12,8 +12,11 @@ export function init(schemaUrl) { () => { return bootstrap(Redoc); } - ).then( + ).then(() => bootstrap(SideMenu)) + .then( () => console.log('ReDoc bootstrapped!'), error => console.log(error) ); } + +window.Redoc = Redoc; From b98cfa82809acf7a27a23f53d4c9eb6810d93757 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 15 Oct 2015 21:35:05 +0300 Subject: [PATCH 33/97] Added side-menu click actions --- lib/components/SideMenu/side-menu.html | 6 +- lib/components/SideMenu/side-menu.js | 86 ++++++++++++------- lib/components/SideMenuCat/side-menu-cat.css | 7 +- lib/components/SideMenuCat/side-menu-cat.html | 6 +- lib/components/SideMenuCat/side-menu-cat.js | 12 +++ lib/components/base.js | 1 + 6 files changed, 82 insertions(+), 36 deletions(-) diff --git a/lib/components/SideMenu/side-menu.html b/lib/components/SideMenu/side-menu.html index fa462571..ea64d88b 100644 --- a/lib/components/SideMenu/side-menu.html +++ b/lib/components/SideMenu/side-menu.html @@ -1,4 +1,6 @@

Api reference

-
- +
+ +
diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index 99934df5..1129f103 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -23,6 +23,9 @@ export class SideMenu extends BaseComponent { constructor(schemaMgr, zone) { super(schemaMgr); this.zone = zone; + + // for some reason constructor is not run inside zone + // as workaround running it manually this.zone.run(() => { this.bindScroll(); }); @@ -32,49 +35,77 @@ export class SideMenu extends BaseComponent { this.prevOffsetY = null; } - _updateActiveMethod(offset) { + bindScroll() { + this.prevOffsetY = window.scrollY; + window.addEventListener('scroll', () => this.scrollHandler()); + } + + + activateAndScroll(idx, methodIdx) { + this.activate(idx, methodIdx); + this.scrollToActive(); + } + + scrollToActive() { + window.scrollTo(0, this.getMethodEl().offsetTop); + } + + activate(catIdx, methodIdx) { + let menu = this.data.menu; + menu[this.activeCatIdx].active = false; + menu[this.activeCatIdx].methods[this.activeMethodIdx].active = false; + + this.activeCatIdx = catIdx; + this.activeMethodIdx = methodIdx; + menu[catIdx].active = true; + let currentItem = menu[catIdx].methods[methodIdx]; + currentItem.active = true; + this.activeMethodPtr = currentItem.pointer; + } + + _calcActiveIndexes(offset) { let menu = this.data.menu; let catCount = menu.length; let catLength = menu[this.activeCatIdx].methods.length; - this.activeMethodIdx += offset; - if (this.activeMethodIdx > catLength - 1) { - this.activeCatIdx++; - this.activeMethodIdx = 0; + let resMethodIdx = this.activeMethodIdx + offset; + let resCatIdx = this.activeCatIdx; + + if (resMethodIdx > catLength - 1) { + resCatIdx++; + resMethodIdx = 0; } - if (this.activeMethodIdx < 0) { - let prevCatIdx = --this.activeCatIdx; + if (resMethodIdx < 0) { + let prevCatIdx = --resCatIdx; catLength = menu[Math.max(prevCatIdx, 0)].methods.length; - this.activeMethodIdx = catLength - 1; + resMethodIdx = catLength - 1; } - if (this.activeCatIdx > catCount - 1) { - this.activeCatIdx = catCount - 1; - this.activeMethodIdx = catLength - 1; + if (resCatIdx > catCount - 1) { + resCatIdx = catCount - 1; + resMethodIdx = catLength - 1; } - if (this.activeCatIdx < 0) { - this.activeCatIdx = 0; - this.activeMethodIdx = 0; + if (resCatIdx < 0) { + resCatIdx = 0; + resMethodIdx = 0; } + + return [resCatIdx, resMethodIdx]; } changeActive(offset = 1) { - let menu = this.data.menu; - menu[this.activeCatIdx].methods[this.activeMethodIdx].active = false; - menu[this.activeCatIdx].active = false; + let [catIdx, methodIdx] = this._calcActiveIndexes(offset); + this.activate(catIdx, methodIdx); + } - this._updateActiveMethod(offset); - - menu[this.activeCatIdx].active = true; - let currentItem = menu[this.activeCatIdx].methods[this.activeMethodIdx]; - currentItem.active = true; - this.activeMethodPtr = currentItem.pointer; + getMethodEl() { + let ptr = this.activeMethodPtr; + return document.querySelector(`[pointer="${ptr}"]`); } scrollHandler() { let isScrolledDown = (window.scrollY - this.prevOffsetY > 0); this.prevOffsetY = window.scrollY; - let ptr = this.activeMethodPtr; - var activeMethodHost = document.querySelector(`[pointer="${ptr}"]`); + var activeMethodHost = this.getMethodEl(); if (!activeMethodHost) return; if(isScrolledDown && activeMethodHost.getBoundingClientRect().bottom <= 0 ) { @@ -87,11 +118,6 @@ export class SideMenu extends BaseComponent { } } - bindScroll() { - this.prevOffsetY = window.scrollY; - window.addEventListener('scroll', () => this.scrollHandler()); - } - prepareModel() { this.data = {}; this.data.menu = Array.from(this.buildMenuTree().entries()).map( diff --git a/lib/components/SideMenuCat/side-menu-cat.css b/lib/components/SideMenuCat/side-menu-cat.css index 23a88309..29c08230 100644 --- a/lib/components/SideMenuCat/side-menu-cat.css +++ b/lib/components/SideMenuCat/side-menu-cat.css @@ -1,21 +1,24 @@ label { font-weight: bold; font-size: 18px; + cursor: pointer; } ul { padding-left: 20px; margin: 0; - display: none; + height: 0; + overflow: hidden; } ul.active { - display: block; + height: auto; } li { list-style: none inside none; padding: 5px 0; + cursor: pointer; } li.active { diff --git a/lib/components/SideMenuCat/side-menu-cat.html b/lib/components/SideMenuCat/side-menu-cat.html index aadeb1b3..087a96a5 100644 --- a/lib/components/SideMenuCat/side-menu-cat.html +++ b/lib/components/SideMenuCat/side-menu-cat.html @@ -1,6 +1,8 @@ - +
    -
  • +
  • {{method.summary}}
diff --git a/lib/components/SideMenuCat/side-menu-cat.js b/lib/components/SideMenuCat/side-menu-cat.js index b9b5ae77..9cfb9a77 100644 --- a/lib/components/SideMenuCat/side-menu-cat.js +++ b/lib/components/SideMenuCat/side-menu-cat.js @@ -1,16 +1,28 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; +import {EventEmitter} from 'angular2/angular2'; @RedocComponent({ selector: 'side-menu-cat', inputs: ['catDetails'], + outputs: ['expand', 'activate'], styleUrls: ['./lib/components/SideMenuCat/side-menu-cat.css'], templateUrl: './lib/components/SideMenuCat/side-menu-cat.html' }) export class SideMenuCat extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); + this.expand = new EventEmitter(); + this.activate = new EventEmitter(); + } + + expandCat() { + this.expand.next(); + } + + activateMethod(methodIdx) { + this.activate.next({methodIdx: methodIdx}); } prepareModel() { diff --git a/lib/components/base.js b/lib/components/base.js index 030da682..e4550ecc 100644 --- a/lib/components/base.js +++ b/lib/components/base.js @@ -38,6 +38,7 @@ export function RedocComponent(options) { let componentDecorator = Component({ selector: options.selector, inputs: inputs, + outputs: options.outputs, lifecycle: [OnInit], bindings: options.bindings }); From aa04a7c01c8ca802e32e94d3c5831d51d4d94952 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 17 Oct 2015 21:03:08 +0300 Subject: [PATCH 34/97] Added JsonSchemaView component --- .../JsonSchemaView/json-schema-view.js | 51 ++++++++++++++++++ package.json | 6 ++- system.config.js | 52 +++++++++++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 lib/components/JsonSchemaView/json-schema-view.js diff --git a/lib/components/JsonSchemaView/json-schema-view.js b/lib/components/JsonSchemaView/json-schema-view.js new file mode 100644 index 00000000..ba89fa77 --- /dev/null +++ b/lib/components/JsonSchemaView/json-schema-view.js @@ -0,0 +1,51 @@ +'use strict'; + +import {RedocComponent, BaseComponent} from '../base'; + +/* temporarily this component uses json-schema-view-js lib */ +import 'json-formatter-js/src/index'; +import 'json-formatter-js/dist/style.css!'; +import JSONSchemaView from 'json-schema-view-js/src/index'; +import 'json-schema-view-js/dist/style.css!'; + +import {ElementRef} from 'angular2/angular2'; + +@RedocComponent({ + selector: 'schema', + template: '', + inputs: ['title', 'description'] +}) +export class JsonSchemaView extends BaseComponent { + constructor(schemaMgr, elementRef) { + super(schemaMgr); + this.element = elementRef.nativeElement; + } + + dereference(schema = this.componentSchema) { + // simple in-place schema dereferencing. Schema is already bundled so no need in + // global dereferencing. + // TODO: doesn't support circular references + if (schema && schema.$ref) { + let resolved = this.schemaMgr.byPointer(schema.$ref); + Object.assign(schema, resolved); + delete schema.$ref; + } + + Object.keys(schema).forEach((key) => { + let value = schema[key]; + if (value && typeof value === 'object') { + this.dereference(value); + } + }); + } + + init() { + this.dereference(); + const formatter = new JSONSchemaView(this.componentSchema); + this.componentSchema.title = this.componentSchema.title || this.title; + this.componentSchema.description = this.componentSchema.description || this.description; + this.element.appendChild(formatter.render()); + } +} + +JsonSchemaView.parameters = JsonSchemaView.parameters.concat([[ElementRef]]); diff --git a/package.json b/package.json index 6078350b..db0f4670 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "@reactivex/rxjs": "npm:@reactivex/rxjs@^5.0.0-alpha.2", "angular2": "npm:angular2@^2.0.0-alpha.39", "es6-shim": "github:es-shims/es6-shim@^0.33.6", + "json-formatter-js": "npm:json-formatter-js@^0.2.0", "json-pointer": "npm:json-pointer@^0.3.0", + "json-schema-view-js": "npm:json-schema-view-js@^0.2.0", "reflect-metadata": "npm:reflect-metadata@^0.1.2", "swagger-parser": "npm:swagger-parser@^3.3.0", "zone.js": "npm:zone.js@^0.5.7" @@ -33,7 +35,9 @@ "babel": "npm:babel-core@^5.8.24", "babel-runtime": "npm:babel-runtime@^5.8.24", "core-js": "npm:core-js@^1.1.4", - "systemjs/plugin-json": "github:systemjs/plugin-json@^0.1.0" + "css": "github:systemjs/plugin-css@^0.1.18", + "systemjs/plugin-json": "github:systemjs/plugin-json@^0.1.0", + "clean-css": "npm:clean-css@^3.4.6" } }, "devDependencies": { diff --git a/system.config.js b/system.config.js index c79aba03..295bd0d8 100644 --- a/system.config.js +++ b/system.config.js @@ -27,15 +27,28 @@ System.config({ } }, + meta: { + "jspm_packages/npm/json-formatter-js@0.2.0/src/*": { + "format": "es6" + }, + "jspm_packages/npm/json-schema-view-js@0.2.0/src/*": { + "format": "es6" + } + }, + map: { "@reactivex/rxjs": "npm:@reactivex/rxjs@5.0.0-alpha.2", "angular2": "npm:angular2@2.0.0-alpha.39", "babel": "npm:babel-core@5.8.25", "babel-runtime": "npm:babel-runtime@5.8.25", + "clean-css": "npm:clean-css@3.4.6", "core-js": "npm:core-js@1.2.0", + "css": "github:systemjs/plugin-css@0.1.18", "es6-shim": "github:es-shims/es6-shim@0.33.6", "json": "github:systemjs/plugin-json@0.1.0", + "json-formatter-js": "npm:json-formatter-js@0.2.0", "json-pointer": "npm:json-pointer@0.3.0", + "json-schema-view-js": "npm:json-schema-view-js@0.2.0", "reflect-metadata": "npm:reflect-metadata@0.1.2", "swagger-parser": "npm:swagger-parser@3.3.0", "systemjs/plugin-json": "github:systemjs/plugin-json@0.1.0", @@ -76,6 +89,9 @@ System.config({ "timers": "github:jspm/nodelibs-timers@0.1.0", "util": "github:jspm/nodelibs-util@0.1.0" }, + "github:jspm/nodelibs-os@0.1.0": { + "os-browserify": "npm:os-browserify@0.1.2" + }, "github:jspm/nodelibs-path@0.1.0": { "path-browserify": "npm:path-browserify@0.0.0" }, @@ -116,6 +132,12 @@ System.config({ "buffer": "github:jspm/nodelibs-buffer@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" }, + "npm:amdefine@1.0.0": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "module": "github:jspm/nodelibs-module@0.1.0", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, "npm:angular2@2.0.0-alpha.39": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", @@ -259,6 +281,19 @@ System.config({ "stream": "github:jspm/nodelibs-stream@0.1.0", "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0" }, + "npm:clean-css@3.4.6": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "commander": "npm:commander@2.8.1", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "http": "github:jspm/nodelibs-http@1.7.1", + "https": "github:jspm/nodelibs-https@0.1.0", + "os": "github:jspm/nodelibs-os@0.1.0", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "source-map": "npm:source-map@0.4.4", + "url": "github:jspm/nodelibs-url@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, "npm:combined-stream@1.0.5": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "delayed-stream": "npm:delayed-stream@1.0.0", @@ -466,6 +501,11 @@ System.config({ "systemjs-json": "github:systemjs/plugin-json@0.1.0", "util": "github:jspm/nodelibs-util@0.1.0" }, + "npm:json-formatter-js@0.2.0": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.2", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, "npm:json-pointer@0.3.0": { "foreach": "npm:foreach@2.0.5" }, @@ -488,6 +528,11 @@ System.config({ "url": "github:jspm/nodelibs-url@0.1.0", "util": "github:jspm/nodelibs-util@0.1.0" }, + "npm:json-schema-view-js@0.2.0": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.2", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, "npm:jsonpointer@2.0.0": { "assert": "github:jspm/nodelibs-assert@0.1.0" }, @@ -529,6 +574,9 @@ System.config({ "process": "github:jspm/nodelibs-process@0.1.2", "util": "github:jspm/nodelibs-util@0.1.0" }, + "npm:os-browserify@0.1.2": { + "os": "github:jspm/nodelibs-os@0.1.0" + }, "npm:pako@0.2.8": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" @@ -654,6 +702,10 @@ System.config({ "hoek": "npm:hoek@2.16.3", "process": "github:jspm/nodelibs-process@0.1.2" }, + "npm:source-map@0.4.4": { + "amdefine": "npm:amdefine@1.0.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, "npm:stream-browserify@1.0.0": { "events": "github:jspm/nodelibs-events@0.1.1", "inherits": "npm:inherits@2.0.1", From 094c42f07a4e1a108bd2d33b51995a51c0c0acb2 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 17 Oct 2015 21:12:46 +0300 Subject: [PATCH 35/97] Displaying in-body param schema --- lib/components/ParamsList/params-list.css | 9 ++++++-- lib/components/ParamsList/params-list.html | 15 ++++++++------ lib/components/ParamsList/params-list.js | 24 ++++++++++++++++------ lib/components/base.js | 7 +++++++ lib/utils/JsonPointer.js | 14 +++++++++++++ 5 files changed, 55 insertions(+), 14 deletions(-) diff --git a/lib/components/ParamsList/params-list.css b/lib/components/ParamsList/params-list.css index febf6df3..1138f3e6 100644 --- a/lib/components/ParamsList/params-list.css +++ b/lib/components/ParamsList/params-list.css @@ -10,7 +10,7 @@ h4 { .param > span { padding: 5px 10px; - vertical-align: middle; + vertical-align: top; } .param-name { @@ -18,7 +18,12 @@ h4 { } .param-type { - padding: 2px 10px; background-color: #EAEAEA; border: silver 1px solid; } + +.body-schema { + display: inline-block; + vertical-align: top; + padding: 0 10px; +} diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 8750f4a8..13b1114b 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -1,5 +1,6 @@

Parameters

No parameters +
{{param.name}} @@ -7,12 +8,14 @@ {{param.description}}
+
{{data.bodyParam.name}} - {{data.bodyParam.type}} - - {{data.bodyParam.description}} - - Body Schema would be somewhere here (unimplemented yet) +
+ + +
diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index f3036d4a..c613fd7c 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -2,11 +2,22 @@ import {JsonPointer} from '../../utils/JsonPointer'; import {RedocComponent, BaseComponent} from '../base'; +import {JsonSchemaView} from '../JsonSchemaView/json-schema-view'; + +/* inject JsonPointer into array elements */ +function injectPointers(array, root) { + if (!array) return array; + return array.map((element, idx) => { + element.$$pointer = JsonPointer.join(root, idx); + return element; + }); +} @RedocComponent({ selector: 'params-list', templateUrl: './lib/components/ParamsList/params-list.html', - styleUrls: ['./lib/components/ParamsList/params-list.css'] + styleUrls: ['./lib/components/ParamsList/params-list.css'], + directives: [JsonSchemaView] }) export class ParamsList extends BaseComponent { constructor(schemaMgr) { @@ -15,17 +26,18 @@ export class ParamsList extends BaseComponent { prepareModel() { this.data = {}; - let params = this.componentSchema || []; + let params = injectPointers(this.componentSchema, this.pointer) || []; let pathParams = this.getPathParams() || []; params = params.concat(pathParams); params = this.resolveRefs(params); this.sortParams(params); - // temporary hanlde body param + // temporary handle body param if (params.length && params[params.length - 1].in === 'body') { let bodyParam = params.pop(); bodyParam.type = bodyParam.schema.type - || `Object(${JsonPointer.baseName(bodyParam.schema.$ref)})`; + || JsonPointer.baseName(bodyParam.schema.$ref); + bodyParam.pointer = bodyParam.$$pointer; this.data.bodyParam = bodyParam; } @@ -37,10 +49,10 @@ export class ParamsList extends BaseComponent { let ptr = JsonPointer.dirName(this.pointer, 2) + '/parameters'; let pathParams = this.schemaMgr.byPointer(ptr); if (Array.isArray(pathParams)) { - return pathParams; + return injectPointers(pathParams, ptr); } if (pathParams && pathParams.$ref) { - return this.schemaMgr.byPointer(pathParams.$ref); + return injectPointers(this.schemaMgr.byPointer(pathParams.$ref), pathParams.$ref); } return []; diff --git a/lib/components/base.js b/lib/components/base.js index e4550ecc..2f4444d2 100644 --- a/lib/components/base.js +++ b/lib/components/base.js @@ -71,6 +71,7 @@ export class BaseComponent { onInit() { this.componentSchema = this.schemaMgr.byPointer(this.pointer || ''); this.prepareModel(); + this.init(); } /** @@ -78,5 +79,11 @@ export class BaseComponent { * @abstract */ prepareModel() {} + + /** + * Used to initialize component. Run after prepareModel + * @abstract + */ + init() {} } BaseComponent.parameters = [[SchemaManager]]; diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.js index bd5851cd..165bcffd 100644 --- a/lib/utils/JsonPointer.js +++ b/lib/utils/JsonPointer.js @@ -44,6 +44,20 @@ export class JsonPointer extends JsonPointerLib { } return JsonPointerLib._origParse(ptr); } + + /** + * Creates a JSON pointer path, by joining one or more tokens to a base path. + * + * @param {string} base - The base path + * @param {string|string[]} tokens - The token(s) to append (e.g. ["name", "first"]) + * @returns {string} + */ + static join(base, tokens) { + // TODO: optimize + let baseTokens = JsonPointer.parse(base); + let resTokens = baseTokens.concat(tokens); + return JsonPointer.compile(resTokens); + } } JsonPointerLib._origParse = JsonPointerLib.parse; From c8652f7f6d7b99595cbd5c9c5fd5f93a6a0bbbe6 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 17 Oct 2015 21:40:04 +0300 Subject: [PATCH 36/97] Upgraded angular to the latest alpha --- package.json | 7 +++---- system.config.js | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index db0f4670..1fdd510f 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,7 @@ "jspm": { "configFile": "system.config.js", "dependencies": { - "@reactivex/rxjs": "npm:@reactivex/rxjs@^5.0.0-alpha.2", - "angular2": "npm:angular2@^2.0.0-alpha.39", + "angular2": "npm:angular2@^2.0.0-alpha.44", "es6-shim": "github:es-shims/es6-shim@^0.33.6", "json-formatter-js": "npm:json-formatter-js@^0.2.0", "json-pointer": "npm:json-pointer@^0.3.0", @@ -34,10 +33,10 @@ "devDependencies": { "babel": "npm:babel-core@^5.8.24", "babel-runtime": "npm:babel-runtime@^5.8.24", + "clean-css": "npm:clean-css@^3.4.6", "core-js": "npm:core-js@^1.1.4", "css": "github:systemjs/plugin-css@^0.1.18", - "systemjs/plugin-json": "github:systemjs/plugin-json@^0.1.0", - "clean-css": "npm:clean-css@^3.4.6" + "systemjs/plugin-json": "github:systemjs/plugin-json@^0.1.0" } }, "devDependencies": { diff --git a/system.config.js b/system.config.js index 295bd0d8..25cbd9f6 100644 --- a/system.config.js +++ b/system.config.js @@ -37,8 +37,7 @@ System.config({ }, map: { - "@reactivex/rxjs": "npm:@reactivex/rxjs@5.0.0-alpha.2", - "angular2": "npm:angular2@2.0.0-alpha.39", + "angular2": "npm:angular2@2.0.0-alpha.44", "babel": "npm:babel-core@5.8.25", "babel-runtime": "npm:babel-runtime@5.8.25", "clean-css": "npm:clean-css@3.4.6", @@ -128,8 +127,9 @@ System.config({ "github:jspm/nodelibs-zlib@0.1.0": { "browserify-zlib": "npm:browserify-zlib@0.1.4" }, - "npm:@reactivex/rxjs@5.0.0-alpha.2": { + "npm:@reactivex/rxjs@5.0.0-alpha.4": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:amdefine@1.0.0": { @@ -138,14 +138,14 @@ System.config({ "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" }, - "npm:angular2@2.0.0-alpha.39": { + "npm:angular2@2.0.0-alpha.44": { + "@reactivex/rxjs": "npm:@reactivex/rxjs@5.0.0-alpha.4", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", "fs": "github:jspm/nodelibs-fs@0.1.2", "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2", - "reflect-metadata": "npm:reflect-metadata@0.1.2", - "rx": "npm:rx@2.5.1", + "reflect-metadata": "npm:reflect-metadata@0.1.1", "zone.js": "npm:zone.js@0.5.8" }, "npm:argparse@1.0.2": { @@ -646,6 +646,10 @@ System.config({ "string_decoder": "npm:string_decoder@0.10.31", "util-deprecate": "npm:util-deprecate@1.0.1" }, + "npm:reflect-metadata@0.1.1": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, "npm:reflect-metadata@0.1.2": { "assert": "github:jspm/nodelibs-assert@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" @@ -686,9 +690,6 @@ System.config({ "buffer": "github:jspm/nodelibs-buffer@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" }, - "npm:rx@2.5.1": { - "process": "github:jspm/nodelibs-process@0.1.2" - }, "npm:sha.js@2.4.4": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "fs": "github:jspm/nodelibs-fs@0.1.2", From 3a61d252d3a6172dd93337a7ab8c5622a07dc8a5 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 17 Oct 2015 21:56:24 +0300 Subject: [PATCH 37/97] Renamed bindings into providers --- lib/components/Redoc/redoc.js | 2 +- lib/components/SideMenu/side-menu.js | 2 +- lib/components/base.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index 0f9c44b9..52861bbb 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -7,7 +7,7 @@ import {PathsList} from '../PathsList/paths-list'; @RedocComponent({ selector: 'redoc', - bindings: [SchemaManager], + providers: [SchemaManager], templateUrl: './lib/components/Redoc/redoc.html', directives: [ApiInfo, PathsList] }) diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index 1129f103..4f410768 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -15,7 +15,7 @@ const CHANGE = { @RedocComponent({ selector: 'side-menu', - bindings: [SchemaManager], + providers: [SchemaManager], templateUrl: './lib/components/SideMenu/side-menu.html', directives: [SideMenuCat] }) diff --git a/lib/components/base.js b/lib/components/base.js index 2f4444d2..338b22e0 100644 --- a/lib/components/base.js +++ b/lib/components/base.js @@ -23,7 +23,7 @@ function safeConcat(a, b) { * @param {*[]} options.directives - directives used by component * (except CORE_DIRECTIVES) * @param {*[]} options.pipes - pipes used by component - * @param {*[]} options.bindings - component bindings + * @param {*[]} options.providers - component providers * @param {string} options.templateUrl - path to component template * @param {string} options.template - component template html * @param {string} options.styles - component css styles @@ -40,7 +40,7 @@ export function RedocComponent(options) { inputs: inputs, outputs: options.outputs, lifecycle: [OnInit], - bindings: options.bindings + providers: options.providers }); let viewDecorator = View({ templateUrl: options.templateUrl, From 55d05b3e036ba5ada0cc973132c526e298a2a506 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 17 Oct 2015 23:31:01 +0300 Subject: [PATCH 38/97] Open only first level of schema --- lib/components/JsonSchemaView/json-schema-view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/JsonSchemaView/json-schema-view.js b/lib/components/JsonSchemaView/json-schema-view.js index ba89fa77..47f46326 100644 --- a/lib/components/JsonSchemaView/json-schema-view.js +++ b/lib/components/JsonSchemaView/json-schema-view.js @@ -41,9 +41,9 @@ export class JsonSchemaView extends BaseComponent { init() { this.dereference(); - const formatter = new JSONSchemaView(this.componentSchema); this.componentSchema.title = this.componentSchema.title || this.title; this.componentSchema.description = this.componentSchema.description || this.description; + const formatter = new JSONSchemaView(this.componentSchema, 1); this.element.appendChild(formatter.render()); } } From afd42a955a27c95a9d88286a7c09a3b308b8ac21 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 18 Oct 2015 12:28:48 +0300 Subject: [PATCH 39/97] Add missing title injecting to Schema --- lib/components/JsonSchemaView/json-schema-view.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/components/JsonSchemaView/json-schema-view.js b/lib/components/JsonSchemaView/json-schema-view.js index 47f46326..a75cdf68 100644 --- a/lib/components/JsonSchemaView/json-schema-view.js +++ b/lib/components/JsonSchemaView/json-schema-view.js @@ -9,11 +9,11 @@ import JSONSchemaView from 'json-schema-view-js/src/index'; import 'json-schema-view-js/dist/style.css!'; import {ElementRef} from 'angular2/angular2'; +import {JsonPointer} from '../../utils/JsonPointer'; @RedocComponent({ selector: 'schema', - template: '', - inputs: ['title', 'description'] + template: '' }) export class JsonSchemaView extends BaseComponent { constructor(schemaMgr, elementRef) { @@ -27,8 +27,11 @@ export class JsonSchemaView extends BaseComponent { // TODO: doesn't support circular references if (schema && schema.$ref) { let resolved = this.schemaMgr.byPointer(schema.$ref); + let baseName = JsonPointer.baseName(schema.$ref); + // if resolved schema doesn't have title use name from ref + resolved.title = resolved.title || baseName; Object.assign(schema, resolved); - delete schema.$ref; + schema.$ref = null; } Object.keys(schema).forEach((key) => { @@ -41,8 +44,6 @@ export class JsonSchemaView extends BaseComponent { init() { this.dereference(); - this.componentSchema.title = this.componentSchema.title || this.title; - this.componentSchema.description = this.componentSchema.description || this.description; const formatter = new JSONSchemaView(this.componentSchema, 1); this.element.appendChild(formatter.render()); } From 211cf2c38a5f4981614a7751badeb2237415f020 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 18 Oct 2015 12:29:18 +0300 Subject: [PATCH 40/97] Change param-list to a table --- lib/components/ParamsList/params-list.css | 26 ++++++++++--- lib/components/ParamsList/params-list.html | 45 +++++++++++++--------- lib/components/ParamsList/params-list.js | 2 - 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/lib/components/ParamsList/params-list.css b/lib/components/ParamsList/params-list.css index 1138f3e6..f237a84a 100644 --- a/lib/components/ParamsList/params-list.css +++ b/lib/components/ParamsList/params-list.css @@ -4,13 +4,26 @@ h4 { color: black; } -.param { - padding: 10px 0; +table { + border-collapse: collapse; } -.param > span { - padding: 5px 10px; +td, th { vertical-align: top; + padding: 10px 15px; + font-size: 12px; +} + +th { + background-color: #DCDCDC; + color: black; + padding: 5px 15px; + text-align: left; + border-bottom: 2px solid #afafaf; +} + +td { + border-bottom: 1px solid #afafaf; } .param-name { @@ -20,10 +33,11 @@ h4 { .param-type { background-color: #EAEAEA; border: silver 1px solid; + padding: 5px 10px; + line-height: 14px; + font-family: monospace; } .body-schema { display: inline-block; - vertical-align: top; - padding: 0 10px; } diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 13b1114b..a58adefe 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -1,21 +1,30 @@

Parameters

No parameters -
-
- {{param.name}} - {{param.type}} - {{param.description}} -
-
- -
- {{data.bodyParam.name}} -
- - -
-
+ + + + + + + + + + + + + + + + + + + + + +
Name Type Description
{{param.name}} + {{param.type}} + {{param.description}}
{{data.bodyParam.name}} + + + {{data.bodyParam.description}}
diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index c613fd7c..f8adaf12 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -35,8 +35,6 @@ export class ParamsList extends BaseComponent { // temporary handle body param if (params.length && params[params.length - 1].in === 'body') { let bodyParam = params.pop(); - bodyParam.type = bodyParam.schema.type - || JsonPointer.baseName(bodyParam.schema.$ref); bodyParam.pointer = bodyParam.$$pointer; this.data.bodyParam = bodyParam; } From e9c32993a774ecf345966d5ef66789cb29ef8682 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 18 Oct 2015 12:53:16 +0300 Subject: [PATCH 41/97] fix watch task --- build/tasks/watch.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/tasks/watch.js b/build/tasks/watch.js index dea14127..a806c0da 100644 --- a/build/tasks/watch.js +++ b/build/tasks/watch.js @@ -6,9 +6,9 @@ function changed(event) { console.log('File ' + event.path + ' was ' + event.type + ', running tasks...'); } -gulp.task('watch', ['bundle'], function () { - gulp.watch([ paths.source ], [ 'bundle', browserSync.reload ]).on('change', changed); - gulp.watch([ paths.html ], [ 'bundle', browserSync.reload]).on('change', changed); - gulp.watch([ paths.css ], [ 'bundle', browserSync.reload]).on('change', changed); +gulp.task('watch', ['build'], function () { + gulp.watch([ paths.source ], [ 'build', browserSync.reload ]).on('change', changed); + gulp.watch([ paths.html ], [ 'build', browserSync.reload]).on('change', changed); + gulp.watch([ paths.css ], [ 'build', browserSync.reload]).on('change', changed); gulp.watch([ paths.demo ], [ '', browserSync.reload ]).on('change', changed); }); From 753cfdb8fd43e505b5a2ff5a113965579b8ec636 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 18 Oct 2015 19:32:11 +0300 Subject: [PATCH 42/97] Fix menu for cases method has more than one tag --- lib/components/MethodsList/methods-list.html | 3 +- lib/components/MethodsList/methods-list.js | 18 +++++++-- lib/components/PathsList/paths-list.html | 3 -- lib/components/PathsList/paths-list.js | 20 ---------- lib/components/Redoc/redoc.html | 2 +- lib/components/Redoc/redoc.js | 4 +- lib/components/SideMenu/side-menu.js | 39 +++----------------- lib/utils/SchemaManager.js | 31 ++++++++++++++++ 8 files changed, 57 insertions(+), 63 deletions(-) delete mode 100644 lib/components/PathsList/paths-list.html delete mode 100644 lib/components/PathsList/paths-list.js diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html index 67327ac0..ca0122c4 100644 --- a/lib/components/MethodsList/methods-list.html +++ b/lib/components/MethodsList/methods-list.html @@ -1,3 +1,4 @@
- +
diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index 60364f56..1f743413 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -1,7 +1,6 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {methods as swaggerMethods} from '../../utils/swagger-defs'; import {Method} from '../Method/method'; @RedocComponent({ @@ -18,9 +17,22 @@ export class MethodsList extends BaseComponent { prepareModel() { this.data = {}; - let pathInfo = this.componentSchema; + // follow SwaggerUI behavior for cases when one method has more than one tag: + // duplicate methods - this.data.methods = Object.keys(pathInfo).filter((k) => swaggerMethods.has(k)); + let menuStructure = this.schemaMgr.buildMenuTree(); + let methods = Array.from(menuStructure.entries()) + .map((entry) => { + let [tag, methods] = entry; + // inject tag name into method info + methods.forEach(method => { + method.tag = tag; + }); + return methods; + }) + // join arrays + .reduce((a, b) => a.concat(b)); + this.data.methods = methods; // TODO: check $ref field } } diff --git a/lib/components/PathsList/paths-list.html b/lib/components/PathsList/paths-list.html deleted file mode 100644 index 3f316095..00000000 --- a/lib/components/PathsList/paths-list.html +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/lib/components/PathsList/paths-list.js b/lib/components/PathsList/paths-list.js deleted file mode 100644 index ba3ab03c..00000000 --- a/lib/components/PathsList/paths-list.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -import {RedocComponent, BaseComponent} from '../base'; -import {MethodsList} from '../MethodsList/methods-list'; - -@RedocComponent({ - selector: 'paths-list', - templateUrl: './lib/components/PathsList/paths-list.html', - directives: [MethodsList] -}) -export class PathsList extends BaseComponent { - constructor(schemaMgr) { - super(schemaMgr); - } - - prepareModel() { - this.data = {}; - this.data.paths = Object.keys(this.componentSchema.paths); - } -} diff --git a/lib/components/Redoc/redoc.html b/lib/components/Redoc/redoc.html index 5509bc31..cae6ce5d 100644 --- a/lib/components/Redoc/redoc.html +++ b/lib/components/Redoc/redoc.html @@ -1,2 +1,2 @@ - + diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index 52861bbb..44f336bc 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -3,13 +3,13 @@ import {RedocComponent, BaseComponent} from '../base'; import {SchemaManager} from '../../utils/SchemaManager'; import {ApiInfo} from '../ApiInfo/api-info'; -import {PathsList} from '../PathsList/paths-list'; +import {MethodsList} from '../MethodsList/methods-list'; @RedocComponent({ selector: 'redoc', providers: [SchemaManager], templateUrl: './lib/components/Redoc/redoc.html', - directives: [ApiInfo, PathsList] + directives: [ApiInfo, MethodsList] }) export class Redoc extends BaseComponent { constructor(schemaMgr) { diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index 4f410768..33fe1d6e 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -2,15 +2,13 @@ import {RedocComponent, BaseComponent} from '../base'; import {SchemaManager} from '../../utils/SchemaManager'; -import {methods as swaggerMethods} from '../../utils/swagger-defs'; -import {JsonPointer} from '../../utils/JsonPointer'; import {SideMenuCat} from '../SideMenuCat/side-menu-cat'; import {NgZone} from 'angular2/angular2'; const CHANGE = { NEXT : 1, BACK : -1, - HOLD : 0 + INITIAL : 0 }; @RedocComponent({ @@ -99,7 +97,8 @@ export class SideMenu extends BaseComponent { getMethodEl() { let ptr = this.activeMethodPtr; - return document.querySelector(`[pointer="${ptr}"]`); + let tag = this.data.menu[this.activeCatIdx].name; + return document.querySelector(`[pointer="${ptr}"][tag="${tag}"]`); } scrollHandler() { @@ -120,39 +119,13 @@ export class SideMenu extends BaseComponent { prepareModel() { this.data = {}; - this.data.menu = Array.from(this.buildMenuTree().entries()).map( + this.data.menu = Array.from(this.schemaMgr.buildMenuTree().entries()).map( el => ({name: el[0], methods: el[1]}) ); - this.changeActive(CHANGE.HOLD); } - buildMenuTree() { - let tag2MethodMapping = new Map(); - let paths = this.componentSchema.paths; - for (let path of Object.keys(paths)) { - let methods = Object.keys(paths[path]).filter((k) => swaggerMethods.has(k)); - for (let method of methods) { - let methodInfo = paths[path][method]; - let tags = methodInfo.tags; - - //TODO: mb need to do something cleverer - if (!tags || !tags.length) { - tags = ['[Other]']; - } - let methodPointer = JsonPointer.compile(['paths', path, method]); - let methodSummary = methodInfo.summary; - for (let tag of tags) { - let tagMethods = tag2MethodMapping.get(tag); - if (!tagMethods) { - tagMethods = []; - tag2MethodMapping.set(tag, tagMethods); - } - - tagMethods.push({pointer: methodPointer, summary: methodSummary}); - } - } - } - return tag2MethodMapping; + init() { + this.changeActive(CHANGE.INITIAL); } } SideMenu.parameters.push([NgZone]); diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index 33f6ed3c..fa910443 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -1,6 +1,7 @@ 'use strict'; import SwaggerParser from 'swagger-parser'; import JsonPointer from './JsonPointer'; +import {methods as swaggerMethods} from './swagger-defs'; export class SchemaManager { constructor() { @@ -47,4 +48,34 @@ export class SchemaManager { return res; } + /* returns ES6 Map */ + buildMenuTree() { + let tag2MethodMapping = new Map(); + let paths = this._schema.paths; + for (let path of Object.keys(paths)) { + let methods = Object.keys(paths[path]).filter((k) => swaggerMethods.has(k)); + for (let method of methods) { + let methodInfo = paths[path][method]; + let tags = methodInfo.tags; + + //TODO: mb need to do something cleverer + if (!tags || !tags.length) { + tags = ['[Other]']; + } + let methodPointer = JsonPointer.compile(['paths', path, method]); + let methodSummary = methodInfo.summary; + for (let tag of tags) { + let tagMethods = tag2MethodMapping.get(tag); + if (!tagMethods) { + tagMethods = []; + tag2MethodMapping.set(tag, tagMethods); + } + + tagMethods.push({pointer: methodPointer, summary: methodSummary}); + } + } + } + return tag2MethodMapping; + } + } From bcb2fdaea88b9b76ac5af99eb79c46febf42e9e3 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 18 Oct 2015 19:46:21 +0300 Subject: [PATCH 43/97] Updated menu styling --- demo/main.css | 2 ++ lib/components/SideMenu/side-menu.css | 4 ++++ lib/components/SideMenu/side-menu.js | 1 + lib/components/SideMenuCat/side-menu-cat.css | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 lib/components/SideMenu/side-menu.css diff --git a/demo/main.css b/demo/main.css index 50c3f0a7..ca05c070 100644 --- a/demo/main.css +++ b/demo/main.css @@ -16,6 +16,8 @@ side-menu { width: 260px; height: 100%; overflow-y: auto; + overflow-x: hidden;; + background-color: #E9E9F9; } redoc { diff --git a/lib/components/SideMenu/side-menu.css b/lib/components/SideMenu/side-menu.css new file mode 100644 index 00000000..8ea12bb4 --- /dev/null +++ b/lib/components/SideMenu/side-menu.css @@ -0,0 +1,4 @@ +h2 { + text-transform: uppercase; + color: #1976D3; +} diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index 33fe1d6e..8f84737c 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -15,6 +15,7 @@ const CHANGE = { selector: 'side-menu', providers: [SchemaManager], templateUrl: './lib/components/SideMenu/side-menu.html', + styleUrls: ['./lib/components/SideMenu/side-menu.css'], directives: [SideMenuCat] }) export class SideMenu extends BaseComponent { diff --git a/lib/components/SideMenuCat/side-menu-cat.css b/lib/components/SideMenuCat/side-menu-cat.css index 29c08230..c6a02198 100644 --- a/lib/components/SideMenuCat/side-menu-cat.css +++ b/lib/components/SideMenuCat/side-menu-cat.css @@ -1,7 +1,8 @@ label { font-weight: bold; - font-size: 18px; + font-size: 15px; cursor: pointer; + color: #666; } ul { From 8c54d83ee8e7898bbd6ce072cf92911774fedc3a Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 18 Oct 2015 20:16:40 +0300 Subject: [PATCH 44/97] Minor styling --- demo/main.css | 2 +- lib/components/Method/method.css | 4 +++ lib/components/Method/method.html | 2 +- lib/components/ParamsList/params-list.css | 32 ++++++++++-------- lib/components/ParamsList/params-list.html | 38 ++++++++++++---------- 5 files changed, 46 insertions(+), 32 deletions(-) diff --git a/demo/main.css b/demo/main.css index ca05c070..2d6aac64 100644 --- a/demo/main.css +++ b/demo/main.css @@ -17,7 +17,7 @@ side-menu { height: 100%; overflow-y: auto; overflow-x: hidden;; - background-color: #E9E9F9; + background-color: #f2f2f2; } redoc { diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css index 32e768e2..a7eaef25 100644 --- a/lib/components/Method/method.css +++ b/lib/components/Method/method.css @@ -13,6 +13,10 @@ h3 > span { vertical-align: middle; } +.method-description { + padding: 30px 0; +} + .http-method { font-size: 13px; color: white; diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index bf378160..52818d37 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -3,7 +3,7 @@ {{data.method}} {{data.path}} -

+

{{data.methodInfo.description}}

diff --git a/lib/components/ParamsList/params-list.css b/lib/components/ParamsList/params-list.css index f237a84a..66aa56c4 100644 --- a/lib/components/ParamsList/params-list.css +++ b/lib/components/ParamsList/params-list.css @@ -5,7 +5,25 @@ h4 { } table { - border-collapse: collapse; + border-spacing: 0; + border: 2px solid #1976D3; +} + +thead tr:first-child { + background: #1976D3; + color: #fff; + border: none; +} + +thead tr:last-child th { + border-bottom: 3px solid #ddd; +} + +tbody tr:last-child td { + border: none; +} +tbody td { + border-bottom: 1px solid #ddd; } td, th { @@ -15,19 +33,7 @@ td, th { } th { - background-color: #DCDCDC; - color: black; - padding: 5px 15px; text-align: left; - border-bottom: 2px solid #afafaf; -} - -td { - border-bottom: 1px solid #afafaf; -} - -.param-name { - font-weight: bold; } .param-type { diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index a58adefe..9dc431b2 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -1,30 +1,34 @@ -

Parameters

No parameters + + + - - - + + + + + + + + + + + - - - - - - - - - + + +
Parameters
Name Type Description
{{param.name}}
{{param.name}} + {{param.type}} + {{param.description}}
{{data.bodyParam.name}} - {{param.type}} + + {{param.description}}
{{data.bodyParam.name}} - - - {{data.bodyParam.description}}
{{data.bodyParam.description}}
From 93d7d98ad77d3ae01a62214240a02c0dff44787b Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 12:20:14 +0300 Subject: [PATCH 45/97] Added responses list --- lib/components/Method/method.css | 4 ++ lib/components/Method/method.html | 2 + lib/components/Method/method.js | 3 +- lib/components/ParamsList/params-list.css | 1 + lib/components/ParamsList/params-list.html | 10 ++--- .../ResponsesList/responses-list.css | 32 ++++++++++++++ .../ResponsesList/responses-list.html | 22 ++++++++++ .../ResponsesList/responses-list.js | 42 +++++++++++++++++++ 8 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 lib/components/ResponsesList/responses-list.css create mode 100644 lib/components/ResponsesList/responses-list.html create mode 100644 lib/components/ResponsesList/responses-list.js diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css index a7eaef25..2a61ce42 100644 --- a/lib/components/Method/method.css +++ b/lib/components/Method/method.css @@ -1,3 +1,7 @@ +responses-list, params-list { + display: block; +} + h2 { font-size: 32px; font-weight: 200; diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index 52818d37..1037f3e3 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -7,3 +7,5 @@ {{data.methodInfo.description}}

+
+ diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 58e29f9f..b0798da3 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -3,12 +3,13 @@ import {JsonPointer} from '../../utils/JsonPointer'; import {RedocComponent, BaseComponent} from '../base'; import {ParamsList} from '../ParamsList/params-list'; +import {ResponsesList} from '../ResponsesList/responses-list'; @RedocComponent({ selector: 'method', templateUrl: './lib/components/Method/method.html', styleUrls: ['./lib/components/Method/method.css'], - directives: [ParamsList] + directives: [ParamsList, ResponsesList] }) export class Method extends BaseComponent { constructor(schemaMgr) { diff --git a/lib/components/ParamsList/params-list.css b/lib/components/ParamsList/params-list.css index 66aa56c4..a7af38cb 100644 --- a/lib/components/ParamsList/params-list.css +++ b/lib/components/ParamsList/params-list.css @@ -5,6 +5,7 @@ h4 { } table { + width: 100%; border-spacing: 0; border: 2px solid #1976D3; } diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 9dc431b2..358f82ac 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -1,24 +1,24 @@ No parameters - +
- + - + diff --git a/lib/components/ResponsesList/responses-list.css b/lib/components/ResponsesList/responses-list.css new file mode 100644 index 00000000..f2c90766 --- /dev/null +++ b/lib/components/ResponsesList/responses-list.css @@ -0,0 +1,32 @@ +table { + width: 100%; + border-spacing: 0; + border: 2px solid green; +} + +thead tr:first-child { + background: green; + color: #fff; + border: none; +} + +thead tr:last-child th { + border-bottom: 3px solid #ddd; +} + +tbody tr:last-child td { + border: none; +} +tbody td { + border-bottom: 1px solid #ddd; +} + +td, th { + vertical-align: top; + padding: 10px 15px; + font-size: 12px; +} + +th { + text-align: left; +} diff --git a/lib/components/ResponsesList/responses-list.html b/lib/components/ResponsesList/responses-list.html new file mode 100644 index 00000000..53b0fd50 --- /dev/null +++ b/lib/components/ResponsesList/responses-list.html @@ -0,0 +1,22 @@ +
Parameters
Name Type Description Type
{{param.name}} - {{param.type}} - {{param.description}} + {{param.type}} +
+ + + + + + + + + + + + + + + + + +
Responses
Response code Description Response schema
{{response.code}}{{response.description}} + + +
diff --git a/lib/components/ResponsesList/responses-list.js b/lib/components/ResponsesList/responses-list.js new file mode 100644 index 00000000..1dcdb159 --- /dev/null +++ b/lib/components/ResponsesList/responses-list.js @@ -0,0 +1,42 @@ +'use strict'; + +import {RedocComponent, BaseComponent} from '../base'; +import {JsonPointer} from '../../utils/JsonPointer'; +import {JsonSchemaView} from '../JsonSchemaView/json-schema-view'; + +function isNumeric(n) { + return (!isNaN(parseFloat(n)) && isFinite(n)); +} + +@RedocComponent({ + selector: 'responses-list', + templateUrl: './lib/components/ResponsesList/responses-list.html', + styleUrls: ['./lib/components/ResponsesList/responses-list.css'], + directives: [JsonSchemaView] +}) +export class ResponsesList extends BaseComponent { + constructor(schemaMgr) { + super(schemaMgr); + } + + prepareModel() { + this.data = {}; + let responses = this.componentSchema; + responses = Object.keys(responses).filter(respCode => { + // only response-codes and "default" + return ( isNumeric(respCode) || (respCode === 'default')); + }).map(respCode => { + let resp = responses[respCode]; + resp.pointer = JsonPointer.join(this.pointer, respCode); + if (resp.$ref) { + let ref = resp.$ref; + resp = this.schemaMgr.byPointer(resp.$ref); + resp.pointer = ref; + } + + resp.code = respCode; + return resp; + }); + this.data.responses = responses; + } +} From 5c49fc49f04148efb14a38a95d85da1dfe1f0d37 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 12:25:51 +0300 Subject: [PATCH 46/97] Unify params table for no-params case --- lib/components/ParamsList/params-list.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 358f82ac..940f13be 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -1,17 +1,23 @@ - No parameters - - +
+ + + + + - + + From 2d039f57405e8579318985d4b6e4de6847288e9a Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 12:35:20 +0300 Subject: [PATCH 47/97] Minor ui fix --- lib/components/Method/method.html | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index 1037f3e3..0124cde2 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -6,6 +6,7 @@

{{data.methodInfo.description}}

+

From 1ac727290f2969fcde23d1dd85533f6a516da24c Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 14:07:22 +0300 Subject: [PATCH 48/97] Added rigth panel --- demo/main.css | 6 +++- lib/components/Method/method.css | 15 ++++++++++ lib/components/Method/method.html | 31 ++++++++++++-------- lib/components/MethodsList/methods-list.css | 18 +++++++++++- lib/components/MethodsList/methods-list.html | 4 +-- 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/demo/main.css b/demo/main.css index 2d6aac64..1ee1eaf5 100644 --- a/demo/main.css +++ b/demo/main.css @@ -7,10 +7,14 @@ body { side-menu, redoc { display: block; - padding: 10px 20px; box-sizing: border-box; } +api-info, side-menu { + display: block; + padding: 10px 20px; +} + side-menu { position: fixed; width: 260px; diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css index 2a61ce42..459c3577 100644 --- a/lib/components/Method/method.css +++ b/lib/components/Method/method.css @@ -17,6 +17,21 @@ h3 > span { vertical-align: middle; } +.content, .samples { + display: block; + box-sizing: border-box; + width: 50%; + float: left; + padding: 0 20px; +} + + +.method:after { + content: ""; + display: table; + clear:both; +} + .method-description { padding: 30px 0; } diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index 0124cde2..9554697c 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -1,12 +1,19 @@ -

{{data.methodInfo.summary}}

-

- {{data.method}} - {{data.path}} -

-

- {{data.methodInfo.description}} -

-
- -
- +
+
+

{{data.methodInfo.summary}}

+

+ {{data.method}} + {{data.path}} +

+

+ {{data.methodInfo.description}} +

+
+ +
+ +
+
+ +
+
diff --git a/lib/components/MethodsList/methods-list.css b/lib/components/MethodsList/methods-list.css index e4b8f554..ed203fec 100644 --- a/lib/components/MethodsList/methods-list.css +++ b/lib/components/MethodsList/methods-list.css @@ -1,5 +1,21 @@ method { padding-bottom: 100px; display: block; - border-bottom: 1px solid silver; + border-bottom: 1px solid rgba(0, 0, 0, 0.1); +} + +.methods { + display: block; + position: relative;; +} + +.methods:before { + content: ""; + background: rgb(59, 59, 105); + height: 100%; + width: 50%; + top: 0; + right: 0; + position: absolute; + z-index: -1; } diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html index ca0122c4..0a067862 100644 --- a/lib/components/MethodsList/methods-list.html +++ b/lib/components/MethodsList/methods-list.html @@ -1,4 +1,4 @@ -
- +
From 1892ac4b0042f06f37c0583dbc2edaa98800552f Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 14:11:35 +0300 Subject: [PATCH 49/97] n/a label for missing response schema --- lib/components/ResponsesList/responses-list.css | 4 ++++ lib/components/ResponsesList/responses-list.html | 1 + 2 files changed, 5 insertions(+) diff --git a/lib/components/ResponsesList/responses-list.css b/lib/components/ResponsesList/responses-list.css index f2c90766..9099b038 100644 --- a/lib/components/ResponsesList/responses-list.css +++ b/lib/components/ResponsesList/responses-list.css @@ -1,3 +1,7 @@ +small { + color: #999; +} + table { width: 100%; border-spacing: 0; diff --git a/lib/components/ResponsesList/responses-list.html b/lib/components/ResponsesList/responses-list.html index 53b0fd50..849de725 100644 --- a/lib/components/ResponsesList/responses-list.html +++ b/lib/components/ResponsesList/responses-list.html @@ -16,6 +16,7 @@
From 99c578efcc1cf989d2e210f9a92afc6604e7f496 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 14:29:49 +0300 Subject: [PATCH 50/97] Changed order component bootstrapping --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index c6056a8b..42e485d1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,9 +10,9 @@ export * from './components/index'; export function init(schemaUrl) { SchemaManager.instance().load(schemaUrl).then( () => { - return bootstrap(Redoc); + return bootstrap(SideMenu); } - ).then(() => bootstrap(SideMenu)) + ).then(() => bootstrap(Redoc)) .then( () => console.log('ReDoc bootstrapped!'), error => console.log(error) From c3efcf6756b6729c78a4fc972122f8cd4fdf4651 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 14:46:15 +0300 Subject: [PATCH 51/97] right panel width 50% -> 40% --- lib/components/Method/method.css | 8 +++++++- lib/components/MethodsList/methods-list.css | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css index 459c3577..bc105b39 100644 --- a/lib/components/Method/method.css +++ b/lib/components/Method/method.css @@ -20,11 +20,17 @@ h3 > span { .content, .samples { display: block; box-sizing: border-box; - width: 50%; float: left; padding: 0 20px; } +.content { + width: 60%; +} + +.samples { + width: 40%; +} .method:after { content: ""; diff --git a/lib/components/MethodsList/methods-list.css b/lib/components/MethodsList/methods-list.css index ed203fec..c07d19ae 100644 --- a/lib/components/MethodsList/methods-list.css +++ b/lib/components/MethodsList/methods-list.css @@ -13,7 +13,7 @@ method { content: ""; background: rgb(59, 59, 105); height: 100%; - width: 50%; + width: 40%; top: 0; right: 0; position: absolute; From 5e207b343c60d72393eaf627ad5c3b1c461637e5 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 17:22:22 +0300 Subject: [PATCH 52/97] Moved dereference to base class --- .../JsonSchemaView/json-schema-view.js | 22 ------------------ lib/components/base.js | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/lib/components/JsonSchemaView/json-schema-view.js b/lib/components/JsonSchemaView/json-schema-view.js index a75cdf68..0c2063a4 100644 --- a/lib/components/JsonSchemaView/json-schema-view.js +++ b/lib/components/JsonSchemaView/json-schema-view.js @@ -9,7 +9,6 @@ import JSONSchemaView from 'json-schema-view-js/src/index'; import 'json-schema-view-js/dist/style.css!'; import {ElementRef} from 'angular2/angular2'; -import {JsonPointer} from '../../utils/JsonPointer'; @RedocComponent({ selector: 'schema', @@ -21,27 +20,6 @@ export class JsonSchemaView extends BaseComponent { this.element = elementRef.nativeElement; } - dereference(schema = this.componentSchema) { - // simple in-place schema dereferencing. Schema is already bundled so no need in - // global dereferencing. - // TODO: doesn't support circular references - if (schema && schema.$ref) { - let resolved = this.schemaMgr.byPointer(schema.$ref); - let baseName = JsonPointer.baseName(schema.$ref); - // if resolved schema doesn't have title use name from ref - resolved.title = resolved.title || baseName; - Object.assign(schema, resolved); - schema.$ref = null; - } - - Object.keys(schema).forEach((key) => { - let value = schema[key]; - if (value && typeof value === 'object') { - this.dereference(value); - } - }); - } - init() { this.dereference(); const formatter = new JSONSchemaView(this.componentSchema, 1); diff --git a/lib/components/base.js b/lib/components/base.js index 338b22e0..6676a394 100644 --- a/lib/components/base.js +++ b/lib/components/base.js @@ -2,6 +2,7 @@ import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2'; import {SchemaManager} from '../utils/SchemaManager'; import {JsonPointerEscapePipe} from '../utils/pipes'; +import {JsonPointer} from '../utils/JsonPointer'; // common inputs for all components let commonInputs = ['pointer']; // json pointer to the schema chunk @@ -74,6 +75,28 @@ export class BaseComponent { this.init(); } + /** + * simple in-place schema dereferencing. Schema is already bundled so no need in global dereferencing. + * TODO: doesn't support circular references + */ + dereference(schema = this.componentSchema) { + if (schema && schema.$ref) { + let resolved = this.schemaMgr.byPointer(schema.$ref); + let baseName = JsonPointer.baseName(schema.$ref); + // if resolved schema doesn't have title use name from ref + resolved.title = resolved.title || baseName; + Object.assign(schema, resolved); + delete schema.$ref; + } + + Object.keys(schema).forEach((key) => { + let value = schema[key]; + if (value && typeof value === 'object') { + this.dereference(value); + } + }); + } + /** * Used to prepare model based on component schema * @abstract From 25412953df278d50af43404ece1818c7c84a025b Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 17:23:00 +0300 Subject: [PATCH 53/97] installed json-schema-instantiator --- package.json | 1 + system.config.js | 1 + 2 files changed, 2 insertions(+) diff --git a/package.json b/package.json index 1fdd510f..9a7c59a8 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "es6-shim": "github:es-shims/es6-shim@^0.33.6", "json-formatter-js": "npm:json-formatter-js@^0.2.0", "json-pointer": "npm:json-pointer@^0.3.0", + "json-schema-instantiator": "npm:json-schema-instantiator@^0.2.2", "json-schema-view-js": "npm:json-schema-view-js@^0.2.0", "reflect-metadata": "npm:reflect-metadata@^0.1.2", "swagger-parser": "npm:swagger-parser@^3.3.0", diff --git a/system.config.js b/system.config.js index 25cbd9f6..5dc162af 100644 --- a/system.config.js +++ b/system.config.js @@ -47,6 +47,7 @@ System.config({ "json": "github:systemjs/plugin-json@0.1.0", "json-formatter-js": "npm:json-formatter-js@0.2.0", "json-pointer": "npm:json-pointer@0.3.0", + "json-schema-instantiator": "npm:json-schema-instantiator@0.2.2", "json-schema-view-js": "npm:json-schema-view-js@0.2.0", "reflect-metadata": "npm:reflect-metadata@0.1.2", "swagger-parser": "npm:swagger-parser@3.3.0", From d8e406367750ccc1ba292b22da4089dc0f0f97ed Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 17:24:04 +0300 Subject: [PATCH 54/97] Add 200 response schema sample --- lib/components/Method/method.css | 13 +++++++++- lib/components/Method/method.html | 5 +++- lib/components/Method/method.js | 3 ++- lib/components/MethodsList/methods-list.css | 2 +- .../SchemaSample/schema-sample.html | 3 +++ lib/components/SchemaSample/schema-sample.js | 26 +++++++++++++++++++ 6 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 lib/components/SchemaSample/schema-sample.html create mode 100644 lib/components/SchemaSample/schema-sample.js diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css index bc105b39..a7997e4e 100644 --- a/lib/components/Method/method.css +++ b/lib/components/Method/method.css @@ -21,17 +21,28 @@ h3 > span { display: block; box-sizing: border-box; float: left; - padding: 0 20px; } .content { width: 60%; + padding: 0 20px; } .samples { + color: white; width: 40%; } +.samples header { + padding: 10px 20px; + font-size: 20px; + background-color: #231416; +} + +.samples .snippet { + padding: 10px 20px; +} + .method:after { content: ""; display: table; diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index 9554697c..a77929da 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -14,6 +14,9 @@
- +
Response sample
+
+ +
diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index b0798da3..5243ecf5 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -4,12 +4,13 @@ import {JsonPointer} from '../../utils/JsonPointer'; import {RedocComponent, BaseComponent} from '../base'; import {ParamsList} from '../ParamsList/params-list'; import {ResponsesList} from '../ResponsesList/responses-list'; +import {SchemaSample} from '../SchemaSample/schema-sample'; @RedocComponent({ selector: 'method', templateUrl: './lib/components/Method/method.html', styleUrls: ['./lib/components/Method/method.css'], - directives: [ParamsList, ResponsesList] + directives: [ParamsList, ResponsesList, SchemaSample] }) export class Method extends BaseComponent { constructor(schemaMgr) { diff --git a/lib/components/MethodsList/methods-list.css b/lib/components/MethodsList/methods-list.css index c07d19ae..e9debf09 100644 --- a/lib/components/MethodsList/methods-list.css +++ b/lib/components/MethodsList/methods-list.css @@ -11,7 +11,7 @@ method { .methods:before { content: ""; - background: rgb(59, 59, 105); + background: rgb(64, 33, 37); height: 100%; width: 40%; top: 0; diff --git a/lib/components/SchemaSample/schema-sample.html b/lib/components/SchemaSample/schema-sample.html new file mode 100644 index 00000000..d09cffcf --- /dev/null +++ b/lib/components/SchemaSample/schema-sample.html @@ -0,0 +1,3 @@ +
+
{{data.sample | json}}
+
diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js new file mode 100644 index 00000000..4f02294a --- /dev/null +++ b/lib/components/SchemaSample/schema-sample.js @@ -0,0 +1,26 @@ +'use strict'; + +import {RedocComponent, BaseComponent} from '../base'; + +import SchemaSampler from 'json-schema-instantiator'; + +@RedocComponent({ + selector: 'schema-sample', + templateUrl: './lib/components/SchemaSample/schema-sample.html' +}) +export class SchemaSample extends BaseComponent { + constructor(schemaMgr) { + super(schemaMgr); + } + + init() { + this.data = {}; + if (!this.componentSchema || !this.pointer) { + console.log(this.pointer); + return; + } + this.dereference(); + let sample = SchemaSampler.instantiate(this.componentSchema); + this.data.sample = sample; + } +} From e46eca92b60d43fc6e6c6b007dcf05b2e013c119 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 21 Oct 2015 17:26:06 +0300 Subject: [PATCH 55/97] fix incorrect cell order body-param --- lib/components/ParamsList/params-list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 940f13be..2e5cb03e 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -30,11 +30,11 @@
+ -
+ No parameters +
Parameters
Name Description Type
{{param.name}} + N/A
{{data.bodyParam.name}}{{data.bodyParam.description}} {{data.bodyParam.description}}
From c265e724e26b8a5cba7fb6768573d26edbbea403 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 22 Oct 2015 20:52:03 +0300 Subject: [PATCH 56/97] Add tabs common component --- lib/common-components/Tabs/tabs.css | 20 ++++++++++ lib/common-components/Tabs/tabs.js | 61 +++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 lib/common-components/Tabs/tabs.css create mode 100644 lib/common-components/Tabs/tabs.js diff --git a/lib/common-components/Tabs/tabs.css b/lib/common-components/Tabs/tabs.css new file mode 100644 index 00000000..57f2c472 --- /dev/null +++ b/lib/common-components/Tabs/tabs.css @@ -0,0 +1,20 @@ +ul { + display: block; + margin: 0; + padding: 10px 0px 0 0; +} + +li { + list-style: none; + margin: 0; + display: inline-block; + padding: 5px 15px; + background-color: #8F1B1B; + border-left: 1px solid #771D1D; + border-bottom: 2px solid transparent; + cursor: pointer; +} + +li.active { + border-bottom: 2px solid red; +} diff --git a/lib/common-components/Tabs/tabs.js b/lib/common-components/Tabs/tabs.js new file mode 100644 index 00000000..e9d27e81 --- /dev/null +++ b/lib/common-components/Tabs/tabs.js @@ -0,0 +1,61 @@ +'use strict'; + +import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2'; + +@Component({ + selector: 'tabs' +}) +@View({ + template: ` +
    +
  • {{tab.tabTitle}}
  • +
+ + `, + directives: [CORE_DIRECTIVES], + styleUrls: ['./lib/common-components/Tabs/tabs.css'] +}) +export class Tabs { + constructor() { + this.tabs = []; + } + + selectTab(tab) { + this.tabs.forEach((tab) => { + tab.active = false; + }); + tab.active = true; + } + + addTab(tab: Tab) { + if (this.tabs.length === 0) { + tab.active = true; + } + this.tabs.push(tab); + } +} + +@Component({ + selector: 'tab', + inputs: ['tabTitle: tab-title'] +}) +@View({ + template: ` +
+ +
+ `, + styles: [` + .tab-wrap { + padding: 5px; + background-color: #771D1D; + } + `] +}) +export class Tab { + constructor(tabs) { + tabs.addTab(this); + } +} + +Tab.parameters = [ [ Tabs ] ]; From 258a64daf8d4e4d2ee21c6a289c7b2e501e3a69d Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 22 Oct 2015 20:53:07 +0300 Subject: [PATCH 57/97] Added responses samples component --- .../ResponsesSamples/responses-samples.css | 11 +++++ .../ResponsesSamples/responses-samples.html | 6 +++ .../ResponsesSamples/responses-samples.js | 44 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 lib/components/ResponsesSamples/responses-samples.css create mode 100644 lib/components/ResponsesSamples/responses-samples.html create mode 100644 lib/components/ResponsesSamples/responses-samples.js diff --git a/lib/components/ResponsesSamples/responses-samples.css b/lib/components/ResponsesSamples/responses-samples.css new file mode 100644 index 00000000..ad8a31a2 --- /dev/null +++ b/lib/components/ResponsesSamples/responses-samples.css @@ -0,0 +1,11 @@ +header { + font-size: 20px; +} + +tab, tabs { + display: block; +} + +schema-sample { + display: block; +} diff --git a/lib/components/ResponsesSamples/responses-samples.html b/lib/components/ResponsesSamples/responses-samples.html new file mode 100644 index 00000000..4c540c7b --- /dev/null +++ b/lib/components/ResponsesSamples/responses-samples.html @@ -0,0 +1,6 @@ +
Responses samples
+ + + + + diff --git a/lib/components/ResponsesSamples/responses-samples.js b/lib/components/ResponsesSamples/responses-samples.js new file mode 100644 index 00000000..dec82e39 --- /dev/null +++ b/lib/components/ResponsesSamples/responses-samples.js @@ -0,0 +1,44 @@ +'use strict'; + +import {RedocComponent, BaseComponent} from '../base'; +import {JsonPointer} from '../../utils/JsonPointer'; +import {Tabs, Tab} from '../../common-components/Tabs/tabs'; +import {SchemaSample} from '../SchemaSample/schema-sample'; + + +function isNumeric(n) { + return (!isNaN(parseFloat(n)) && isFinite(n)); +} + +@RedocComponent({ + selector: 'responses-samples', + templateUrl: './lib/components/ResponsesSamples/responses-samples.html', + styleUrls: ['./lib/components/ResponsesSamples/responses-samples.css'], + directives: [SchemaSample, Tabs, Tab] +}) +export class ResponsesSamples extends BaseComponent { + constructor(schemaMgr) { + super(schemaMgr); + } + + prepareModel() { + this.data = {}; + let responses = this.componentSchema; + responses = Object.keys(responses).filter(respCode => { + // only response-codes and "default" + return ( isNumeric(respCode) || (respCode === 'default')); + }).map(respCode => { + let resp = responses[respCode]; + resp.pointer = JsonPointer.join(this.pointer, respCode); + if (resp.$ref) { + let ref = resp.$ref; + resp = this.schemaMgr.byPointer(resp.$ref); + resp.pointer = ref; + } + + resp.code = respCode; + return resp; + }); + this.data.responses = responses; + } +} From d6defae7e7cc5a5a794ef2153cc5bae62ad8748a Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 22 Oct 2015 20:54:26 +0300 Subject: [PATCH 58/97] Add responses samples to method --- lib/components/Method/method.css | 9 ++------- lib/components/Method/method.html | 5 +---- lib/components/Method/method.js | 4 ++-- lib/components/MethodsList/methods-list.css | 2 +- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css index a7997e4e..a147de73 100644 --- a/lib/components/Method/method.css +++ b/lib/components/Method/method.css @@ -33,13 +33,8 @@ h3 > span { width: 40%; } -.samples header { - padding: 10px 20px; - font-size: 20px; - background-color: #231416; -} - -.samples .snippet { +responses-samples { + display: block; padding: 10px 20px; } diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index a77929da..18970420 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -14,9 +14,6 @@
-
Response sample
-
- -
+
diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 5243ecf5..832acdcf 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -4,13 +4,13 @@ import {JsonPointer} from '../../utils/JsonPointer'; import {RedocComponent, BaseComponent} from '../base'; import {ParamsList} from '../ParamsList/params-list'; import {ResponsesList} from '../ResponsesList/responses-list'; -import {SchemaSample} from '../SchemaSample/schema-sample'; +import {ResponsesSamples} from '../ResponsesSamples/responses-samples'; @RedocComponent({ selector: 'method', templateUrl: './lib/components/Method/method.html', styleUrls: ['./lib/components/Method/method.css'], - directives: [ParamsList, ResponsesList, SchemaSample] + directives: [ParamsList, ResponsesList, ResponsesSamples] }) export class Method extends BaseComponent { constructor(schemaMgr) { diff --git a/lib/components/MethodsList/methods-list.css b/lib/components/MethodsList/methods-list.css index e9debf09..e2f39cda 100644 --- a/lib/components/MethodsList/methods-list.css +++ b/lib/components/MethodsList/methods-list.css @@ -11,7 +11,7 @@ method { .methods:before { content: ""; - background: rgb(64, 33, 37); + background: #48040D; height: 100%; width: 40%; top: 0; From 823add877b5c1d5a24b92f8e6bbf71ae24b279c3 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 22 Oct 2015 21:30:20 +0300 Subject: [PATCH 59/97] display temp error message for unsupported schema --- lib/components/SchemaSample/schema-sample.html | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/components/SchemaSample/schema-sample.html b/lib/components/SchemaSample/schema-sample.html index d09cffcf..932df1bf 100644 --- a/lib/components/SchemaSample/schema-sample.html +++ b/lib/components/SchemaSample/schema-sample.html @@ -1,3 +1,4 @@
+
 Not supported yet (any-of)
{{data.sample | json}}
From b07fd2664756b88fbb8ccb16a5e58122d4ee2910 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 22 Oct 2015 21:31:12 +0300 Subject: [PATCH 60/97] response samples only for responses with samples or schema --- .../ResponsesSamples/responses-samples.html | 2 +- .../ResponsesSamples/responses-samples.js | 8 +++++++- lib/components/SchemaSample/schema-sample.html | 3 ++- lib/components/SchemaSample/schema-sample.js | 14 +++++++++++--- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/components/ResponsesSamples/responses-samples.html b/lib/components/ResponsesSamples/responses-samples.html index 4c540c7b..c143b6e0 100644 --- a/lib/components/ResponsesSamples/responses-samples.html +++ b/lib/components/ResponsesSamples/responses-samples.html @@ -1,6 +1,6 @@
Responses samples
- + diff --git a/lib/components/ResponsesSamples/responses-samples.js b/lib/components/ResponsesSamples/responses-samples.js index dec82e39..41420127 100644 --- a/lib/components/ResponsesSamples/responses-samples.js +++ b/lib/components/ResponsesSamples/responses-samples.js @@ -10,6 +10,11 @@ function isNumeric(n) { return (!isNaN(parseFloat(n)) && isFinite(n)); } +function hasExample(response) { + return ((response.examples && response.examples['application/json']) || + response.schema); +} + @RedocComponent({ selector: 'responses-samples', templateUrl: './lib/components/ResponsesSamples/responses-samples.html', @@ -38,7 +43,8 @@ export class ResponsesSamples extends BaseComponent { resp.code = respCode; return resp; - }); + }) + .filter(response => hasExample(response)); this.data.responses = responses; } } diff --git a/lib/components/SchemaSample/schema-sample.html b/lib/components/SchemaSample/schema-sample.html index 932df1bf..71a7b47c 100644 --- a/lib/components/SchemaSample/schema-sample.html +++ b/lib/components/SchemaSample/schema-sample.html @@ -1,4 +1,5 @@
-
 Not supported yet (any-of)
+ +
 Sample unavailable 
{{data.sample | json}}
diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js index 4f02294a..e10bd446 100644 --- a/lib/components/SchemaSample/schema-sample.js +++ b/lib/components/SchemaSample/schema-sample.js @@ -15,12 +15,20 @@ export class SchemaSample extends BaseComponent { init() { this.data = {}; + + // sometimes for some reason this method is called without resolved pointer + // TODO: fix it and remove the following workaround if (!this.componentSchema || !this.pointer) { - console.log(this.pointer); return; } - this.dereference(); - let sample = SchemaSampler.instantiate(this.componentSchema); + let sample; + if (this.componentSchema.examples && this.componentSchema.examples['application/json']) { + sample = this.componentSchema.examples['application/json']; + } else { + this.dereference(this.componentSchema.schema); + sample = SchemaSampler.instantiate(this.componentSchema.schema); + } + this.data.sample = sample; } } From f7958644cbd467ec6ad4f3355bac047d950c563e Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 22 Oct 2015 21:50:26 +0300 Subject: [PATCH 61/97] Table sizing minor fixes --- lib/components/ParamsList/params-list.css | 10 +++++++++- lib/components/ResponsesList/responses-list.css | 10 +++++++++- lib/components/ResponsesList/responses-list.html | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/components/ParamsList/params-list.css b/lib/components/ParamsList/params-list.css index a7af38cb..d8ae1808 100644 --- a/lib/components/ParamsList/params-list.css +++ b/lib/components/ParamsList/params-list.css @@ -10,6 +10,14 @@ table { border: 2px solid #1976D3; } +td.param-name { + width: 20%; +} + +td.param-description { + width: 30%; +} + thead tr:first-child { background: #1976D3; color: #fff; @@ -29,7 +37,7 @@ tbody td { td, th { vertical-align: top; - padding: 10px 15px; + padding: 10px 10px; font-size: 12px; } diff --git a/lib/components/ResponsesList/responses-list.css b/lib/components/ResponsesList/responses-list.css index 9099b038..74fc76a5 100644 --- a/lib/components/ResponsesList/responses-list.css +++ b/lib/components/ResponsesList/responses-list.css @@ -8,6 +8,14 @@ table { border: 2px solid green; } +th.response-code { + width: 10%; +} + +th.response-description { + width: 30%; +} + thead tr:first-child { background: green; color: #fff; @@ -27,7 +35,7 @@ tbody td { td, th { vertical-align: top; - padding: 10px 15px; + padding: 10px 10px; font-size: 12px; } diff --git a/lib/components/ResponsesList/responses-list.html b/lib/components/ResponsesList/responses-list.html index 849de725..741ebb31 100644 --- a/lib/components/ResponsesList/responses-list.html +++ b/lib/components/ResponsesList/responses-list.html @@ -4,8 +4,8 @@ Responses - Response code - Description + Code + Description Response schema From 9523f77f1c72bca40a6df0946f2da5525c176e2d Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 22 Oct 2015 21:55:17 +0300 Subject: [PATCH 62/97] no sample message removed for falsy objects --- lib/components/SchemaSample/schema-sample.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/SchemaSample/schema-sample.html b/lib/components/SchemaSample/schema-sample.html index 71a7b47c..fd02ae08 100644 --- a/lib/components/SchemaSample/schema-sample.html +++ b/lib/components/SchemaSample/schema-sample.html @@ -1,5 +1,5 @@
-
 Sample unavailable 
+
 Sample unavailable 
{{data.sample | json}}
From 87dd150a934063d97cc7068fc9ed29de5d1bcb90 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Thu, 22 Oct 2015 22:45:04 +0300 Subject: [PATCH 63/97] Change ugly side-panel color-schema --- lib/common-components/Tabs/tabs.css | 6 +++--- lib/common-components/Tabs/tabs.js | 2 +- lib/components/MethodsList/methods-list.css | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/common-components/Tabs/tabs.css b/lib/common-components/Tabs/tabs.css index 57f2c472..b977de5c 100644 --- a/lib/common-components/Tabs/tabs.css +++ b/lib/common-components/Tabs/tabs.css @@ -9,12 +9,12 @@ li { margin: 0; display: inline-block; padding: 5px 15px; - background-color: #8F1B1B; - border-left: 1px solid #771D1D; + background-color: #262673; + border-left: 1px solid #1C1C50; border-bottom: 2px solid transparent; cursor: pointer; } li.active { - border-bottom: 2px solid red; + border-bottom: 2px solid blue; } diff --git a/lib/common-components/Tabs/tabs.js b/lib/common-components/Tabs/tabs.js index e9d27e81..422ce138 100644 --- a/lib/common-components/Tabs/tabs.js +++ b/lib/common-components/Tabs/tabs.js @@ -48,7 +48,7 @@ export class Tabs { styles: [` .tab-wrap { padding: 5px; - background-color: #771D1D; + background-color: #121427; } `] }) diff --git a/lib/components/MethodsList/methods-list.css b/lib/components/MethodsList/methods-list.css index e2f39cda..b3f32bcd 100644 --- a/lib/components/MethodsList/methods-list.css +++ b/lib/components/MethodsList/methods-list.css @@ -11,7 +11,7 @@ method { .methods:before { content: ""; - background: #48040D; + background: #2C2E3E; height: 100%; width: 40%; top: 0; From 1f3cd3d85be65b4911a8242a10997e97599974cc Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 23 Oct 2015 11:35:13 +0300 Subject: [PATCH 64/97] Added marked markdown parser --- package.json | 1 + system.config.js | 1 + 2 files changed, 2 insertions(+) diff --git a/package.json b/package.json index 9a7c59a8..ace44c42 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "json-pointer": "npm:json-pointer@^0.3.0", "json-schema-instantiator": "npm:json-schema-instantiator@^0.2.2", "json-schema-view-js": "npm:json-schema-view-js@^0.2.0", + "marked": "npm:marked@^0.3.5", "reflect-metadata": "npm:reflect-metadata@^0.1.2", "swagger-parser": "npm:swagger-parser@^3.3.0", "zone.js": "npm:zone.js@^0.5.7" diff --git a/system.config.js b/system.config.js index 5dc162af..23f8e509 100644 --- a/system.config.js +++ b/system.config.js @@ -49,6 +49,7 @@ System.config({ "json-pointer": "npm:json-pointer@0.3.0", "json-schema-instantiator": "npm:json-schema-instantiator@0.2.2", "json-schema-view-js": "npm:json-schema-view-js@0.2.0", + "marked": "npm:marked@0.3.5", "reflect-metadata": "npm:reflect-metadata@0.1.2", "swagger-parser": "npm:swagger-parser@3.3.0", "systemjs/plugin-json": "github:systemjs/plugin-json@0.1.0", From 90f304304c0f321f79f5081203be2a7f62d57703 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 23 Oct 2015 12:03:47 +0300 Subject: [PATCH 65/97] Display descriptions as GFM (closes #2) --- lib/components/ApiInfo/api-info.html | 2 +- lib/components/Method/method.html | 4 ++-- lib/components/ParamsList/params-list.html | 4 ++-- .../ResponsesList/responses-list.html | 2 +- lib/components/base.js | 3 ++- lib/utils/pipes.js | 23 +++++++++++++++++++ 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/lib/components/ApiInfo/api-info.html b/lib/components/ApiInfo/api-info.html index e596009e..65c835ae 100644 --- a/lib/components/ApiInfo/api-info.html +++ b/lib/components/ApiInfo/api-info.html @@ -1,5 +1,5 @@

{{data.title}} ({{data.version}})

-

{{data.description}}

+

Contact: diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index 18970420..9f43e50b 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -5,8 +5,8 @@ {{data.method}} {{data.path}} -

- {{data.methodInfo.description}} +


diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 2e5cb03e..915cc906 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -21,7 +21,7 @@ {{param.name}} - {{param.description}} + {{param.type}} @@ -30,7 +30,7 @@ {{data.bodyParam.name}} - {{data.bodyParam.description}} + diff --git a/lib/components/ResponsesList/responses-list.html b/lib/components/ResponsesList/responses-list.html index 741ebb31..c2581163 100644 --- a/lib/components/ResponsesList/responses-list.html +++ b/lib/components/ResponsesList/responses-list.html @@ -12,7 +12,7 @@ {{response.code}} - {{response.description}} + diff --git a/lib/components/base.js b/lib/components/base.js index 6676a394..e512b29a 100644 --- a/lib/components/base.js +++ b/lib/components/base.js @@ -3,6 +3,7 @@ import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2'; import {SchemaManager} from '../utils/SchemaManager'; import {JsonPointerEscapePipe} from '../utils/pipes'; import {JsonPointer} from '../utils/JsonPointer'; +import {MarkedPipe} from '../utils/pipes'; // common inputs for all components let commonInputs = ['pointer']; // json pointer to the schema chunk @@ -32,7 +33,7 @@ function safeConcat(a, b) { export function RedocComponent(options) { let inputs = safeConcat(options.inputs, commonInputs); let directives = safeConcat(options.directives, CORE_DIRECTIVES); - let pipes = safeConcat(options.pipes, [JsonPointerEscapePipe]); + let pipes = safeConcat(options.pipes, [JsonPointerEscapePipe, MarkedPipe]); return function decorator(target) { diff --git a/lib/utils/pipes.js b/lib/utils/pipes.js index ed3c8ab8..6ca8d5a7 100644 --- a/lib/utils/pipes.js +++ b/lib/utils/pipes.js @@ -2,6 +2,19 @@ import {Pipe} from 'angular2/angular2'; import {JsonPointer} from './JsonPointer'; +import marked from 'marked'; + +marked.setOptions({ + renderer: new marked.Renderer(), + gfm: true, + tables: true, + breaks: false, + pedantic: false, + sanitize: true, + smartLists: true, + smartypants: false +}); + @Pipe({ name: 'keys' @@ -29,3 +42,13 @@ export class JsonPointerEscapePipe { return JsonPointer.escape(str); } } + +@Pipe({ + name: 'marked' +}) +export class MarkedPipe { + transform(str) { + if (!str) return str; + return marked(str); + } +} From c7bc6ff391a67ca08a2adaf7dee78aba1146bf6c Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 25 Oct 2015 13:26:38 +0200 Subject: [PATCH 66/97] Add body sample to the right panel --- lib/components/Method/method.css | 13 +++++- lib/components/Method/method.html | 9 ++++- lib/components/Method/method.js | 10 ++++- lib/components/ParamsList/params-list.js | 40 +------------------ .../ResponsesSamples/responses-samples.css | 4 -- .../ResponsesSamples/responses-samples.html | 4 +- lib/components/SchemaSample/schema-sample.js | 16 ++++++-- lib/utils/SchemaManager.js | 37 +++++++++++++++++ 8 files changed, 82 insertions(+), 51 deletions(-) diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css index a147de73..4b8dedc7 100644 --- a/lib/components/Method/method.css +++ b/lib/components/Method/method.css @@ -31,11 +31,22 @@ h3 > span { .samples { color: white; width: 40%; + padding: 10px 20px; } responses-samples { display: block; - padding: 10px 20px; +} + +.samples header { + font-size: 20px; + margin: 5px 0; +} + +.samples schema-sample { + display: block; + padding: 5px; + background-color: rgb(18, 20, 39); } .method:after { diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index 9f43e50b..3619cc29 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -14,6 +14,13 @@
- +
+
Body sample
+ +
+
+
Responses samples
+ +
diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 832acdcf..111fdc9e 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -5,12 +5,13 @@ import {RedocComponent, BaseComponent} from '../base'; import {ParamsList} from '../ParamsList/params-list'; import {ResponsesList} from '../ResponsesList/responses-list'; import {ResponsesSamples} from '../ResponsesSamples/responses-samples'; +import {SchemaSample} from '../SchemaSample/schema-sample'; @RedocComponent({ selector: 'method', templateUrl: './lib/components/Method/method.html', styleUrls: ['./lib/components/Method/method.css'], - directives: [ParamsList, ResponsesList, ResponsesSamples] + directives: [ParamsList, ResponsesList, ResponsesSamples, SchemaSample] }) export class Method extends BaseComponent { constructor(schemaMgr) { @@ -22,5 +23,12 @@ export class Method extends BaseComponent { this.data.method = JsonPointer.baseName(this.pointer); this.data.path = JsonPointer.baseName(this.pointer, 2); this.data.methodInfo = this.componentSchema; + this.data.bodyParam = this.findBodyParam(); + } + + findBodyParam() { + let pathParams = this.schemaMgr.getMethodParams(JsonPointer.join(this.pointer, 'parameters'), true); + let bodyParam = pathParams.find(param => param.in === 'body'); + return bodyParam; } } diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index f8adaf12..b8b5d83c 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -1,18 +1,8 @@ 'use strict'; -import {JsonPointer} from '../../utils/JsonPointer'; import {RedocComponent, BaseComponent} from '../base'; import {JsonSchemaView} from '../JsonSchemaView/json-schema-view'; -/* inject JsonPointer into array elements */ -function injectPointers(array, root) { - if (!array) return array; - return array.map((element, idx) => { - element.$$pointer = JsonPointer.join(root, idx); - return element; - }); -} - @RedocComponent({ selector: 'params-list', templateUrl: './lib/components/ParamsList/params-list.html', @@ -26,16 +16,13 @@ export class ParamsList extends BaseComponent { prepareModel() { this.data = {}; - let params = injectPointers(this.componentSchema, this.pointer) || []; - let pathParams = this.getPathParams() || []; - params = params.concat(pathParams); - params = this.resolveRefs(params); + let params = this.schemaMgr.getMethodParams(this.pointer, true); this.sortParams(params); // temporary handle body param if (params.length && params[params.length - 1].in === 'body') { let bodyParam = params.pop(); - bodyParam.pointer = bodyParam.$$pointer; + bodyParam.pointer = bodyParam._pointer; this.data.bodyParam = bodyParam; } @@ -43,29 +30,6 @@ export class ParamsList extends BaseComponent { this.data.params = params; } - getPathParams() { - let ptr = JsonPointer.dirName(this.pointer, 2) + '/parameters'; - let pathParams = this.schemaMgr.byPointer(ptr); - if (Array.isArray(pathParams)) { - return injectPointers(pathParams, ptr); - } - if (pathParams && pathParams.$ref) { - return injectPointers(this.schemaMgr.byPointer(pathParams.$ref), pathParams.$ref); - } - - return []; - } - - resolveRefs(params) { - return params.map(param => { - if (param.$ref) { - return this.schemaMgr.byPointer(param.$ref); - } else { - return param; - } - }); - } - sortParams(params) { const sortOrder = { 'path' : 0, diff --git a/lib/components/ResponsesSamples/responses-samples.css b/lib/components/ResponsesSamples/responses-samples.css index ad8a31a2..895f3253 100644 --- a/lib/components/ResponsesSamples/responses-samples.css +++ b/lib/components/ResponsesSamples/responses-samples.css @@ -1,7 +1,3 @@ -header { - font-size: 20px; -} - tab, tabs { display: block; } diff --git a/lib/components/ResponsesSamples/responses-samples.html b/lib/components/ResponsesSamples/responses-samples.html index c143b6e0..2581ca06 100644 --- a/lib/components/ResponsesSamples/responses-samples.html +++ b/lib/components/ResponsesSamples/responses-samples.html @@ -1,5 +1,5 @@ -
Responses samples
- + No samples + diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js index e10bd446..dc87d8a0 100644 --- a/lib/components/SchemaSample/schema-sample.js +++ b/lib/components/SchemaSample/schema-sample.js @@ -21,12 +21,20 @@ export class SchemaSample extends BaseComponent { if (!this.componentSchema || !this.pointer) { return; } + let base = {}; let sample; - if (this.componentSchema.examples && this.componentSchema.examples['application/json']) { - sample = this.componentSchema.examples['application/json']; + + // got pointer not directly to the schema but e.g. to response obj + if (this.componentSchema.schema) { + base = this.componentSchema; + this.componentSchema = this.componentSchema.schema; + } + + if (base.examples && base.examples['application/json']) { + sample = base.examples['application/json']; } else { - this.dereference(this.componentSchema.schema); - sample = SchemaSampler.instantiate(this.componentSchema.schema); + this.dereference(this.componentSchema); + sample = SchemaSampler.instantiate(this.componentSchema); } this.data.sample = sample; diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index fa910443..75b47b01 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -48,6 +48,43 @@ export class SchemaManager { return res; } + resolveRefs(obj) { + Object.keys(obj).forEach(key => { + if (obj[key].$ref) { + obj[key] = this.byPointer(obj[key].$ref); + } + }); + return obj; + } + + getMethodParams(methodPtr, resolveRefs) { + /* inject JsonPointer into array elements */ + function injectPointers(array, root) { + if (!array) return array; + return array.map((element, idx) => { + element._pointer = JsonPointer.join(root, idx); + return element; + }); + } + + //get path params + let ptr = JsonPointer.dirName(methodPtr, 2) + '/parameters'; + let pathParams = this.byPointer(ptr); + if (Array.isArray(pathParams)) { + pathParams = injectPointers(pathParams, ptr); + } else if (pathParams && pathParams.$ref) { + pathParams = injectPointers(this.byPointer(pathParams.$ref), pathParams.$ref); + } else { + pathParams = []; + } + + let methodParams = injectPointers(this.byPointer(methodPtr), methodPtr) || []; + if (resolveRefs) { + methodParams = this.resolveRefs(methodParams); + } + return methodParams.concat(pathParams); + } + /* returns ES6 Map */ buildMenuTree() { let tag2MethodMapping = new Map(); From 2d831f7a460df07c92ba08afb8e86305bcd2bbfb Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Mon, 26 Oct 2015 20:21:09 +0200 Subject: [PATCH 67/97] Serve task: fixed issue with reload --- build/tasks/serve.js | 8 ++++++-- build/tasks/watch.js | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/build/tasks/serve.js b/build/tasks/serve.js index 4c28ef26..93105d83 100644 --- a/build/tasks/serve.js +++ b/build/tasks/serve.js @@ -7,7 +7,11 @@ gulp.task('serve', ['watch'], function (done) { notify: false, port: 9000, server: { - baseDir: ['./demo', '.'] - } + baseDir: './demo', + routes: { + '/dist': './dist' + }, + }, + reloadDelay: 500 }, done); }); diff --git a/build/tasks/watch.js b/build/tasks/watch.js index a806c0da..4358c1cc 100644 --- a/build/tasks/watch.js +++ b/build/tasks/watch.js @@ -7,8 +7,8 @@ function changed(event) { } gulp.task('watch', ['build'], function () { - gulp.watch([ paths.source ], [ 'build', browserSync.reload ]).on('change', changed); - gulp.watch([ paths.html ], [ 'build', browserSync.reload]).on('change', changed); - gulp.watch([ paths.css ], [ 'build', browserSync.reload]).on('change', changed); + gulp.watch([ paths.source ], [ 'bundle', browserSync.reload ]).on('change', changed); + gulp.watch([ paths.html ], [ 'bundle', browserSync.reload]).on('change', changed); + gulp.watch([ paths.css ], [ 'bundle', browserSync.reload]).on('change', changed); gulp.watch([ paths.demo ], [ '', browserSync.reload ]).on('change', changed); }); From 53ea1008eb132ad1465eb013dc3c214587a8de92 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Mon, 26 Oct 2015 21:17:26 +0200 Subject: [PATCH 68/97] Fix source map appended as base64 --- build/tasks/build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index 4d52b175..16d17aff 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -34,7 +34,7 @@ gulp.task('concatDeps', ['bundleSfx'], function() { gulp.src(JS_DEV_DEPS.concat([paths.redocBuilt])) .pipe(sourcemaps.init({loadMaps: true})) .pipe(concat(paths.outputName)) - .pipe(sourcemaps.write()) + .pipe(sourcemaps.write('.')) .pipe(gulp.dest(paths.output)) }); @@ -43,7 +43,7 @@ gulp.task('bundleSfx', ['inlineTemplates'], function(cb) { builder .buildStatic(path.join(paths.tmp, paths.sourceEntryPoint), paths.redocBuilt, - { globalName: 'Redoc', sourceMaps: true } + { globalName: 'Redoc', sourceMaps: true, lowResSourceMaps: true } ) .then(function() { cb(); From 01328bce19a128205b17c8d0446ca8171882ab4b Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Mon, 26 Oct 2015 21:34:32 +0200 Subject: [PATCH 69/97] Build imported css into separate file --- build/tasks/build.js | 5 +++++ demo/index.html | 1 + 2 files changed, 6 insertions(+) diff --git a/build/tasks/build.js b/build/tasks/build.js index 16d17aff..7c585bf4 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -39,7 +39,12 @@ gulp.task('concatDeps', ['bundleSfx'], function() { }); gulp.task('bundleSfx', ['inlineTemplates'], function(cb) { + fs.existsSync('dist') || fs.mkdirSync('dist'); var builder = new Builder('./', 'system.config.js'); + builder.config({ + separateCSS: true + }); + builder .buildStatic(path.join(paths.tmp, paths.sourceEntryPoint), paths.redocBuilt, diff --git a/demo/index.html b/demo/index.html index 1351e01a..28f0293c 100644 --- a/demo/index.html +++ b/demo/index.html @@ -3,6 +3,7 @@ ReDoc prototype + From 98f0cdd1ecd37c0c2b93cc49d937f6c20b472cff Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Tue, 27 Oct 2015 14:08:38 +0200 Subject: [PATCH 70/97] Update travis not to use global gulp --- .travis.yml | 4 +--- package.json | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 47de63f6..16a93a6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,8 @@ cache: before_install: - npm install -g jspm - jspm config registries.github.auth $JSPM_GITHUB_AUTH_TOKEN -before_script: -- npm install -g gulp before_deploy: -- gulp build +- npm run build deploy: skip_cleanup: true provider: script diff --git a/package.json b/package.json index ace44c42..7abf0d70 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "scripts": { "test": "gulp lint", "postinstall": "jspm install", - "start": "gulp serve" + "start": "gulp serve", + "build": "gulp build" }, "keywords": [ "Swagger", From f8590bb4dd5a3fd9a98b4837f0baa65bde9aa6e2 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Tue, 27 Oct 2015 19:44:08 +0200 Subject: [PATCH 71/97] default es6 export + REDOC_COMPONENTS --- lib/components/ApiInfo/api-info.js | 2 +- .../JsonSchemaView/json-schema-view.js | 2 +- lib/components/Method/method.js | 10 ++--- lib/components/MethodsList/methods-list.js | 4 +- lib/components/ParamsList/params-list.js | 4 +- lib/components/Redoc/redoc.js | 8 ++-- .../ResponsesList/responses-list.js | 6 +-- .../ResponsesSamples/responses-samples.js | 6 +-- lib/components/SchemaSample/schema-sample.js | 2 +- lib/components/SideMenu/side-menu.js | 10 ++--- lib/components/SideMenuCat/side-menu-cat.js | 2 +- lib/components/base.js | 7 ++- lib/components/index.js | 43 +++++++++++++++++-- lib/index.js | 6 +-- lib/utils/SchemaManager.js | 2 +- 15 files changed, 75 insertions(+), 39 deletions(-) diff --git a/lib/components/ApiInfo/api-info.js b/lib/components/ApiInfo/api-info.js index e1cf1cc1..d179dae9 100644 --- a/lib/components/ApiInfo/api-info.js +++ b/lib/components/ApiInfo/api-info.js @@ -7,7 +7,7 @@ import {RedocComponent, BaseComponent} from '../base'; styleUrls: ['./lib/components/ApiInfo/api-info.css'], templateUrl: './lib/components/ApiInfo/api-info.html' }) -export class ApiInfo extends BaseComponent { +export default class ApiInfo extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/JsonSchemaView/json-schema-view.js b/lib/components/JsonSchemaView/json-schema-view.js index 0c2063a4..3341c8cb 100644 --- a/lib/components/JsonSchemaView/json-schema-view.js +++ b/lib/components/JsonSchemaView/json-schema-view.js @@ -14,7 +14,7 @@ import {ElementRef} from 'angular2/angular2'; selector: 'schema', template: '' }) -export class JsonSchemaView extends BaseComponent { +export default class JsonSchemaView extends BaseComponent { constructor(schemaMgr, elementRef) { super(schemaMgr); this.element = elementRef.nativeElement; diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 111fdc9e..2f660359 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -2,10 +2,10 @@ import {JsonPointer} from '../../utils/JsonPointer'; import {RedocComponent, BaseComponent} from '../base'; -import {ParamsList} from '../ParamsList/params-list'; -import {ResponsesList} from '../ResponsesList/responses-list'; -import {ResponsesSamples} from '../ResponsesSamples/responses-samples'; -import {SchemaSample} from '../SchemaSample/schema-sample'; +import ParamsList from '../ParamsList/params-list'; +import ResponsesList from '../ResponsesList/responses-list'; +import ResponsesSamples from '../ResponsesSamples/responses-samples'; +import SchemaSample from '../SchemaSample/schema-sample'; @RedocComponent({ selector: 'method', @@ -13,7 +13,7 @@ import {SchemaSample} from '../SchemaSample/schema-sample'; styleUrls: ['./lib/components/Method/method.css'], directives: [ParamsList, ResponsesList, ResponsesSamples, SchemaSample] }) -export class Method extends BaseComponent { +export default class Method extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index 1f743413..dc04f4cf 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -1,7 +1,7 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {Method} from '../Method/method'; +import Method from '../Method/method'; @RedocComponent({ selector: 'methods-list', @@ -9,7 +9,7 @@ import {Method} from '../Method/method'; styleUrls: ['./lib/components/MethodsList/methods-list.css'], directives: [Method] }) -export class MethodsList extends BaseComponent { +export default class MethodsList extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index b8b5d83c..47e3d9f2 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -1,7 +1,7 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {JsonSchemaView} from '../JsonSchemaView/json-schema-view'; +import JsonSchemaView from '../JsonSchemaView/json-schema-view'; @RedocComponent({ selector: 'params-list', @@ -9,7 +9,7 @@ import {JsonSchemaView} from '../JsonSchemaView/json-schema-view'; styleUrls: ['./lib/components/ParamsList/params-list.css'], directives: [JsonSchemaView] }) -export class ParamsList extends BaseComponent { +export default class ParamsList extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index 44f336bc..08f562d6 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -1,9 +1,9 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {SchemaManager} from '../../utils/SchemaManager'; -import {ApiInfo} from '../ApiInfo/api-info'; -import {MethodsList} from '../MethodsList/methods-list'; +import SchemaManager from '../../utils/SchemaManager'; +import ApiInfo from '../ApiInfo/api-info'; +import MethodsList from '../MethodsList/methods-list'; @RedocComponent({ selector: 'redoc', @@ -11,7 +11,7 @@ import {MethodsList} from '../MethodsList/methods-list'; templateUrl: './lib/components/Redoc/redoc.html', directives: [ApiInfo, MethodsList] }) -export class Redoc extends BaseComponent { +export default class Redoc extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/ResponsesList/responses-list.js b/lib/components/ResponsesList/responses-list.js index 1dcdb159..a03bf31b 100644 --- a/lib/components/ResponsesList/responses-list.js +++ b/lib/components/ResponsesList/responses-list.js @@ -1,8 +1,8 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {JsonPointer} from '../../utils/JsonPointer'; -import {JsonSchemaView} from '../JsonSchemaView/json-schema-view'; +import JsonPointer from '../../utils/JsonPointer'; +import JsonSchemaView from '../JsonSchemaView/json-schema-view'; function isNumeric(n) { return (!isNaN(parseFloat(n)) && isFinite(n)); @@ -14,7 +14,7 @@ function isNumeric(n) { styleUrls: ['./lib/components/ResponsesList/responses-list.css'], directives: [JsonSchemaView] }) -export class ResponsesList extends BaseComponent { +export default class ResponsesList extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/ResponsesSamples/responses-samples.js b/lib/components/ResponsesSamples/responses-samples.js index 41420127..1901605d 100644 --- a/lib/components/ResponsesSamples/responses-samples.js +++ b/lib/components/ResponsesSamples/responses-samples.js @@ -1,9 +1,9 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {JsonPointer} from '../../utils/JsonPointer'; +import JsonPointer from '../../utils/JsonPointer'; import {Tabs, Tab} from '../../common-components/Tabs/tabs'; -import {SchemaSample} from '../SchemaSample/schema-sample'; +import SchemaSample from '../SchemaSample/schema-sample'; function isNumeric(n) { @@ -21,7 +21,7 @@ function hasExample(response) { styleUrls: ['./lib/components/ResponsesSamples/responses-samples.css'], directives: [SchemaSample, Tabs, Tab] }) -export class ResponsesSamples extends BaseComponent { +export default class ResponsesSamples extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js index dc87d8a0..38234655 100644 --- a/lib/components/SchemaSample/schema-sample.js +++ b/lib/components/SchemaSample/schema-sample.js @@ -8,7 +8,7 @@ import SchemaSampler from 'json-schema-instantiator'; selector: 'schema-sample', templateUrl: './lib/components/SchemaSample/schema-sample.html' }) -export class SchemaSample extends BaseComponent { +export default class SchemaSample extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index 8f84737c..8df9c563 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -1,8 +1,8 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {SchemaManager} from '../../utils/SchemaManager'; -import {SideMenuCat} from '../SideMenuCat/side-menu-cat'; +import SchemaManager from '../../utils/SchemaManager'; +import SideMenuCat from '../SideMenuCat/side-menu-cat'; import {NgZone} from 'angular2/angular2'; const CHANGE = { @@ -15,10 +15,10 @@ const CHANGE = { selector: 'side-menu', providers: [SchemaManager], templateUrl: './lib/components/SideMenu/side-menu.html', - styleUrls: ['./lib/components/SideMenu/side-menu.css'], + styleUrls: ['./lib/components/SideMenu/side-menu.css'], directives: [SideMenuCat] }) -export class SideMenu extends BaseComponent { +export default class SideMenu extends BaseComponent { constructor(schemaMgr, zone) { super(schemaMgr); this.zone = zone; @@ -129,4 +129,4 @@ export class SideMenu extends BaseComponent { this.changeActive(CHANGE.INITIAL); } } -SideMenu.parameters.push([NgZone]); +SideMenu.parameters = SideMenu.parameters.concat([NgZone]); diff --git a/lib/components/SideMenuCat/side-menu-cat.js b/lib/components/SideMenuCat/side-menu-cat.js index 9cfb9a77..e9780c9d 100644 --- a/lib/components/SideMenuCat/side-menu-cat.js +++ b/lib/components/SideMenuCat/side-menu-cat.js @@ -10,7 +10,7 @@ import {EventEmitter} from 'angular2/angular2'; styleUrls: ['./lib/components/SideMenuCat/side-menu-cat.css'], templateUrl: './lib/components/SideMenuCat/side-menu-cat.html' }) -export class SideMenuCat extends BaseComponent { +export default class SideMenuCat extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); this.expand = new EventEmitter(); diff --git a/lib/components/base.js b/lib/components/base.js index e512b29a..844358ac 100644 --- a/lib/components/base.js +++ b/lib/components/base.js @@ -1,9 +1,8 @@ 'use strict'; import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2'; -import {SchemaManager} from '../utils/SchemaManager'; -import {JsonPointerEscapePipe} from '../utils/pipes'; -import {JsonPointer} from '../utils/JsonPointer'; -import {MarkedPipe} from '../utils/pipes'; +import SchemaManager from '../utils/SchemaManager'; +import JsonPointer from '../utils/JsonPointer'; +import {MarkedPipe, JsonPointerEscapePipe} from '../utils/pipes'; // common inputs for all components let commonInputs = ['pointer']; // json pointer to the schema chunk diff --git a/lib/components/index.js b/lib/components/index.js index 8b6de80d..66ce6b93 100644 --- a/lib/components/index.js +++ b/lib/components/index.js @@ -1,5 +1,42 @@ 'use strict'; -export * from './Redoc/redoc'; -export * from './SideMenu/side-menu'; -export * from './ApiInfo/api-info'; +import ApiInfo from './ApiInfo/api-info'; +import JsonSchemaView from './JsonSchemaView/json-schema-view'; +import Method from './Method/method.js'; +import MethodsList from './MethodsList/methods-list'; +import ParamsList from './ParamsList/params-list'; +import Redoc from './Redoc/redoc'; +import ResponsesList from './ResponsesList/responses-list'; +import ResponsesSamples from './ResponsesSamples/responses-samples'; +import SchemaSample from './SchemaSample/schema-sample'; +import SideMenu from './SideMenu/side-menu'; +import SideMenuCat from './SideMenuCat/side-menu-cat'; + +const REDOC_COMPONENTS = [ + ApiInfo, + JsonSchemaView, + Method, + MethodsList, + ParamsList, + Redoc, + ResponsesList, + ResponsesSamples, + SchemaSample, + SideMenu, + SideMenuCat +]; + +export { + ApiInfo, + JsonSchemaView, + Method, + MethodsList, + ParamsList, + Redoc, + ResponsesList, + ResponsesSamples, + SchemaSample, + SideMenu, + SideMenuCat, + REDOC_COMPONENTS +}; diff --git a/lib/index.js b/lib/index.js index 42e485d1..7b517747 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,9 +1,9 @@ 'use strict'; import 'reflect-metadata'; -import { bootstrap } from 'angular2/angular2'; -import { Redoc, SideMenu } from './components/index'; -import { SchemaManager} from './utils/SchemaManager'; +import {bootstrap} from 'angular2/angular2'; +import {Redoc, SideMenu} from './components/index'; +import SchemaManager from './utils/SchemaManager'; export * from './components/index'; diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index 75b47b01..87f7524f 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -3,7 +3,7 @@ import SwaggerParser from 'swagger-parser'; import JsonPointer from './JsonPointer'; import {methods as swaggerMethods} from './swagger-defs'; -export class SchemaManager { +export default class SchemaManager { constructor() { if (SchemaManager.prototype._instance) { return SchemaManager.prototype._instance; From 5595247c3c0c313134b4da5400e519e9d705dd9d Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 28 Oct 2015 09:57:05 +0200 Subject: [PATCH 72/97] add travis_retry to install jsmp --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 16a93a6b..3151fec6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ cache: directories: - node_modules before_install: -- npm install -g jspm +- travis_retry npm install -g jspm - jspm config registries.github.auth $JSPM_GITHUB_AUTH_TOKEN before_deploy: - npm run build From 0bfeafb2a8a7f2dc2712c83c92ec0af5285ac922 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 28 Oct 2015 10:01:35 +0200 Subject: [PATCH 73/97] Remove global jspm install --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3151fec6..0ffdc882 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ cache: directories: - node_modules before_install: -- travis_retry npm install -g jspm +- travis_retry npm install jspm - jspm config registries.github.auth $JSPM_GITHUB_AUTH_TOKEN before_deploy: - npm run build From 40ec886f7d1eac5ff063e73eacba7ca744ebfaee Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 28 Oct 2015 23:22:12 +0200 Subject: [PATCH 74/97] Group methods by tag; add tag and description --- lib/components/MethodsList/methods-list.html | 8 ++++++-- lib/components/MethodsList/methods-list.js | 16 +++++++++------- lib/components/SideMenu/side-menu.js | 2 +- lib/utils/SchemaManager.js | 19 +++++++++++++------ 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html index 0a067862..1e2fe5b2 100644 --- a/lib/components/MethodsList/methods-list.html +++ b/lib/components/MethodsList/methods-list.html @@ -1,4 +1,8 @@
- +
+

{{tag.name}}

+

+ +
diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index dc04f4cf..72ee2545 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -21,18 +21,20 @@ export default class MethodsList extends BaseComponent { // duplicate methods let menuStructure = this.schemaMgr.buildMenuTree(); - let methods = Array.from(menuStructure.entries()) + let tags = Array.from(menuStructure.entries()) .map((entry) => { - let [tag, methods] = entry; + let [tag, {description, methods}] = entry; // inject tag name into method info methods.forEach(method => { method.tag = tag; }); - return methods; - }) - // join arrays - .reduce((a, b) => a.concat(b)); - this.data.methods = methods; + return { + name: tag, + description: description, + methods: methods + }; + }); + this.data.tags = tags; // TODO: check $ref field } } diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index 8df9c563..a4d70a48 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -121,7 +121,7 @@ export default class SideMenu extends BaseComponent { prepareModel() { this.data = {}; this.data.menu = Array.from(this.schemaMgr.buildMenuTree().entries()).map( - el => ({name: el[0], methods: el[1]}) + el => ({name: el[0], description: el[1].description, methods: el[1].methods}) ); } diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index 87f7524f..1c6d750a 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -88,6 +88,13 @@ export default class SchemaManager { /* returns ES6 Map */ buildMenuTree() { let tag2MethodMapping = new Map(); + + let definedTags = this._schema.tags; + // add tags into map to preserve order + for (let tag of definedTags) { + tag2MethodMapping.set(tag.name, {description: tag.description}); + } + let paths = this._schema.paths; for (let path of Object.keys(paths)) { let methods = Object.keys(paths[path]).filter((k) => swaggerMethods.has(k)); @@ -102,13 +109,13 @@ export default class SchemaManager { let methodPointer = JsonPointer.compile(['paths', path, method]); let methodSummary = methodInfo.summary; for (let tag of tags) { - let tagMethods = tag2MethodMapping.get(tag); - if (!tagMethods) { - tagMethods = []; - tag2MethodMapping.set(tag, tagMethods); + let tagDetails = tag2MethodMapping.get(tag); + if (!tagDetails) { + tagDetails = {}; + tag2MethodMapping.set(tag, tagDetails); } - - tagMethods.push({pointer: methodPointer, summary: methodSummary}); + if (!tagDetails.methods) tagDetails.methods = []; + tagDetails.methods.push({pointer: methodPointer, summary: methodSummary}); } } } From b56c170d3a4bc2e75fbbb1f89e6478aea2f8d087 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 28 Oct 2015 23:37:16 +0200 Subject: [PATCH 75/97] Styling for tags --- lib/components/Method/method.css | 3 ++- lib/components/MethodsList/methods-list.css | 13 +++++++++++++ lib/components/MethodsList/methods-list.html | 6 ++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css index 4b8dedc7..81572c33 100644 --- a/lib/components/Method/method.css +++ b/lib/components/Method/method.css @@ -3,8 +3,9 @@ responses-list, params-list { } h2 { - font-size: 32px; + font-size: 25px; font-weight: 200; + color: #666; } h3 { diff --git a/lib/components/MethodsList/methods-list.css b/lib/components/MethodsList/methods-list.css index b3f32bcd..7411eb65 100644 --- a/lib/components/MethodsList/methods-list.css +++ b/lib/components/MethodsList/methods-list.css @@ -4,6 +4,19 @@ method { border-bottom: 1px solid rgba(0, 0, 0, 0.1); } +.tag-info { + padding: 0 20px; + width: 60%; + box-sizing: border-box; +} + +.tag-info h1 { + color: rgb(102, 102, 102); + text-transform: capitalize; + padding-left: 10px; + border-left: 5px solid green; +} + .methods { display: block; position: relative;; diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html index 1e2fe5b2..5b723908 100644 --- a/lib/components/MethodsList/methods-list.html +++ b/lib/components/MethodsList/methods-list.html @@ -1,7 +1,9 @@
-

{{tag.name}}

-

+
+

{{tag.name}}

+

+
From 37030ecbc1c94b1ab558a5a695fc1c9352962995 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 28 Oct 2015 23:49:31 +0200 Subject: [PATCH 76/97] Handle tags without methods --- lib/components/MethodsList/methods-list.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index 72ee2545..4cf2d7c8 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -25,6 +25,7 @@ export default class MethodsList extends BaseComponent { .map((entry) => { let [tag, {description, methods}] = entry; // inject tag name into method info + methods = methods || []; methods.forEach(method => { method.tag = tag; }); From f403487be9fd237f00bd4468701e33367f76d628 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 29 Oct 2015 16:49:40 +0200 Subject: [PATCH 77/97] Add Instagram demo --- demo/instagram.yaml | 1057 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1057 insertions(+) create mode 100644 demo/instagram.yaml diff --git a/demo/instagram.yaml b/demo/instagram.yaml new file mode 100644 index 00000000..6b62e710 --- /dev/null +++ b/demo/instagram.yaml @@ -0,0 +1,1057 @@ +--- +swagger: '2.0' + +################################################################################ +# API Information # +################################################################################ +info: + version: v1 + title: Instagram API + description: | + The first version of the Instagram API is an exciting step forward towards + making it easier for users to have open access to their data. We created it + so that you can surface the amazing content Instagram users share every + second, in fun and innovative ways. + + Build something great! + + Once you've + [registered your client](http://instagram.com/developer/register/) it's easy + to start requesting data from Instagram. + + termsOfService: http://instagram.com/about/legal/terms/api + +################################################################################ +# Host, Base Path, Schemes and Content Types # +################################################################################ +host: api.instagram.com +basePath: /v1 +schemes: + - https +produces: + - application/json +consumes: + - application/json + +################################################################################ +# Tags # +################################################################################ +tags: + - name: JSONP + x-secondaryTag: true + description: | + If you're writing an AJAX application, and you'd like to wrap our response + with a callback, all you have to do is specify a callback parameter with + any API call: + ``` + https://api.instagram.com/v1/tags/coffee/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&callback=callbackFunction + ``` + Would respond with: + ```js + callbackFunction({ + ... + }); + ``` + - name: Pagination + x-secondaryTag: true + description: | + Sometimes you just can't get enough. For this reason, we've provided a + convenient way to access more data in any request for sequential data. + Simply call the url in the next_url parameter and we'll respond with the + next set of data. + ```json + { + ... + "pagination": { + "next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296", + "next_max_id": "13872296" + } + } + ``` + On views where pagination is present, we also support the "count" parameter. + Simply set this to the number of items you'd like to receive. Note that the + default values should be fine for most applications - but if you decide to + increase this number there is a maximum value defined on each endpoint. + - name: PUT & DELETE in old browsers + x-secondaryTag: true + description: | + We do our best to have all our URLs be + [RESTful](http://en.wikipedia.org/wiki/Representational_state_transfer). + Every endpoint (URL) may support one of four different http verbs. GET + requests fetch information about an object, POST requests create objects, + PUT requests update objects, and finally DELETE requests will delete + objects. + + Since many old browsers don't support PUT or DELETE, we've made it easy to + fake PUTs and DELETEs. All you have to do is do a POST with _method=PUT or + _method=DELETE as a parameter and we will treat it as if you used PUT or + DELETE respectively. + - name: Users + - name: Relationships + description: | + Relationships are expressed using the following terms: + + **outgoing_status**: Your relationship to the user. Can be "follows", + "requested", "none". + **incoming_status**: A user's relationship to you. Can be "followed_by", + "requested_by", "blocked_by_you", "none". + - name: Media + description: | + At this time, uploading via the API is not possible. We made a conscious + choice not to add this for the following reasons: + + * Instagram is about your life on the go – we hope to encourage photos + from within the app. + * We want to fight spam & low quality photos. Once we allow uploading + from other sources, it's harder to control what comes into the Instagram + ecosystem. All this being said, we're working on ways to ensure users + have a consistent and high-quality experience on our platform. + - name: Commnts + - name: Likes + - name: Tags + - name: Location + - name: Subscribtions + +################################################################################ +# Security # +################################################################################ +securityDefinitions: + oauth: + type: oauth2 + flow: implicit + authorizationUrl: https://instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token + scopes: + basic: | + to read any and all data related to a user (e.g. following/followed-by + lists, photos, etc.) (granted by default) + comments: to create or delete comments on a user’s behalf + relationships: to follow and unfollow users on a user’s behalf + likes: to like and unlike items on a user’s behalf + key: + type: apiKey + in: query + name: access_token +security: + - oauth: + - basic + - comments + - relationships + - likes + - key: [] + +################################################################################ +# Parameters # +################################################################################ +parameters: + user-id: + name: user-id + in: path + description: The user identifier number + type: number + required: true + tag-name: + name: tag-name + in: path + description: Tag name + type: string + required: true + +################################################################################ +# Paths # +################################################################################ +paths: + /users/{user-id}: + parameters: + - $ref: '#/parameters/user-id' + get: + security: + - key: [] + - oauth: + - basic + tags: + - Users + - JSONP + - Pagination + description: Get basic information about a user. + responses: + 200: + description: The user object + schema: + type: object + properties: + data: + $ref: '#/definitions/User' + + /users/self/feed: + get: + tags: + - Users + - JSONP + - Pagination + description: See the authenticated user's feed. + parameters: + - name: count + in: query + description: Count of media to return. + type: integer + - name: max_id + in: query + description: Return media earlier than this max_id.s + type: integer + - name: min_id + in: query + description: Return media later than this min_id. + + type: integer + responses: + 200: + description: OK + schema: + type: object + properties: + data: + type: array + items: + $ref: '#/definitions/Media' + + /users/{user-id}/media/recent: + parameters: + - $ref: '#/parameters/user-id' + get: + tags: + - Users + - JSONP + - Pagination + responses: + 200: + description: | + Get the most recent media published by a user. To get the most recent + media published by the owner of the access token, you can use `self` + instead of the `user-id`. + schema: + type: object + properties: + data: + type: array + items: + $ref: '#/definitions/Media' + parameters: + - name: count + in: query + description: Count of media to return. + type: integer + - name: max_timestamp + in: query + description: Return media before this UNIX timestamp. + type: integer + - name: min_timestamp + in: query + description: Return media after this UNIX timestamp. + type: integer + - name: min_id + in: query + description: Return media later than this min_id. + type: string + - name: max_id + in: query + description: Return media earlier than this max_id. + type: string + + /users/self/media/liked: + get: + tags: + - Users + - JSONP + - Pagination + description: | + See the list of media liked by the authenticated user. + Private media is returned as long as the authenticated user + has permissionto view that media. Liked media lists are only + available for the currently authenticated user. + responses: + 200: + description: OK + schema: + type: object + properties: + data: + type: array + items: + $ref: '#/definitions/Media' + parameters: + - name: count + in: query + description: Count of media to return. + type: integer + - name: max_like_id + in: query + description: Return media liked before this id. + type: integer + + /users/search: + get: + tags: + - Users + - JSONP + - Pagination + description: Search for a user by name. + parameters: + - name: q + in: query + description: A query string + type: string + required: true + - name: count + in: query + description: Number of users to return. + type: string + responses: + 200: + description: OK + schema: + type: object + properties: + data: + type: array + items: + $ref: '#/definitions/MiniProfile' + + /users/{user-id}/follows: + parameters: + - $ref: '#/parameters/user-id' + get: + tags: + - Relationships + - JSONP + - Pagination + description: Get the list of users this user follows. + responses: + 200: + description: OK + schema: + properties: + data: + type: array + items: + $ref: '#/definitions/MiniProfile' + + /users/{user-id}/followed-by: + parameters: + - $ref: '#/parameters/user-id' + get: + tags: + - Relationships + - JSONP + - Pagination + description: Get the list of users this user is followed by. + responses: + 200: + description: OK + schema: + properties: + data: + type: array + items: + $ref: '#/definitions/MiniProfile' + + /users/self/requested-by: + get: + tags: + - Relationships + - JSONP + - Pagination + description: | + List the users who have requested this user's permission to follow. + responses: + 200: + description: OK + schema: + properties: + meta: + properties: + code: + type: integer + data: + type: array + items: + $ref: '#/definitions/MiniProfile' + + /users/{user-id}/relationship: + parameters: + - $ref: '#/parameters/user-id' + post: + tags: + - Relationships + - JSONP + description: | + Modify the relationship between the current user and thetarget user. + security: + - oauth: + - relationships + parameters: + - name: action + in: body + description: One of follow/unfollow/block/unblock/approve/ignore. + schema: + type: string + enum: + - follow + - unfollow + - block + - unblock + - approve + + responses: + 200: + description: OK + schema: + properties: + data: + type: array + items: + $ref: '#/definitions/MiniProfile' + + /media/{media-id}: + parameters: + - name: media-id + in: path + description: The media ID + type: integer + required: true + get: + tags: + - Media + - JSONP + - Pagination + description: | + Get information about a media object. + The returned type key will allow you to differentiate between `image` + and `video` media. + + Note: if you authenticate with an OAuth Token, you will receive the + `user_has_liked` key which quickly tells you whether the current user + has liked this media item. + responses: + 200: + description: OK + schema: + $ref: '#/definitions/Media' + + /media1/{shortcode}: #FIXME: correct path is /media/{shortcode} + parameters: + - name: shortcode + in: path + description: The media shortcode + type: string + required: true + get: + tags: + - Media + - JSONP + - Pagination + description: | + This endpoint returns the same response as **GET** `/media/media-id`. + + A media object's shortcode can be found in its shortlink URL. + An example shortlink is `http://instagram.com/p/D/` + Its corresponding shortcode is D. + + responses: + 200: + description: OK + schema: + $ref: '#/definitions/Media' + + /media/search: + get: + tags: + - Media + - JSONP + - Pagination + description: | + Search for media in a given area. The default time span is set to 5 + days. The time span must not exceed 7 days. Defaults time stamps cover + the last 5 days. Can return mix of image and video types. + + parameters: + - name: LAT + description: | + Latitude of the center search coordinate. If used, lng is required. + type: number + in: query + - name: MIN_TIMESTAMP + description: | + A unix timestamp. All media returned will be taken later than + this timestamp. + type: integer + in: query + - name: LNG + description: | + Longitude of the center search coordinate. If used, lat is required. + type: number + in: query + - name: MAX_TIMESTAMP + description: | + A unix timestamp. All media returned will be taken earlier than this + timestamp. + type: integer + in: query + - name: DISTANCE + description: Default is 1km (distance=1000), max distance is 5km. + type: integer + maximum: 5000 + default: 1000 + in: query + responses: + 200: + description: OK + schema: + type: object + description: List of all media with added `distance` property + properties: + data: + type: array + items: + allOf: + - $ref: '#/definitions/Media' + - + properties: + distance: + type: number + + /media/popular: + get: + tags: + - Media + - JSONP + - Pagination + description: | + Get a list of what media is most popular at the moment. + Can return mix of image and video types. + responses: + 200: + description: OK + schema: + type: object + properties: + data: + type: array + items: + $ref: '#/definitions/Media' + + /media/{media-id}/comments: + parameters: + - name: media-id + in: path + description: Media ID + type: integer + required: true + get: + tags: + - Comments + - JSONP + - Pagination + description: | + Get a list of recent comments on a media object. + responses: + 200: + description: OK + schema: + properties: + meta: + properties: + code: + type: number + data: + type: array + items: + $ref: '#/definitions/Comment' + post: + tags: + - Comments + - Media + - JSONP + description: | + Create a comment on a media object with the following rules: + + * The total length of the comment cannot exceed 300 characters. + * The comment cannot contain more than 4 hashtags. + * The comment cannot contain more than 1 URL. + * The comment cannot consist of all capital letters. + security: + - oauth: + - comments + parameters: + - name: TEXT + description: | + Text to post as a comment on the media object as specified in + media-id. + in: body + schema: + type: number + responses: + 200: + description: OK + schema: + type: object + properties: + meta: + properties: + code: + type: number + data: + type: object + delete: + tags: + - Comments + - PUT & DELETE in old browsers + description: | + Remove a comment either on the authenticated user's media object or + authored by the authenticated user. + responses: + 200: + description: OK + schema: + type: object + properties: + meta: + properties: + code: + type: number + data: + type: object + + /media/{media-id}/likes: + parameters: + - name: media-id + in: path + description: Media ID + type: integer + required: true + get: + tags: + - Likes + - Media + - JSONP + - Pagination + description: | + Get a list of users who have liked this media. + responses: + 200: + description: OK + schema: + properties: + meta: + properties: + code: + type: number + data: + type: array + items: + $ref: '#/definitions/Like' + post: + tags: + - Likes + description: Set a like on this media by the currently authenticated user. + security: + - oauth: + - comments + responses: + 200: + description: OK + schema: + type: object + properties: + meta: + properties: + code: + type: number + data: + type: object + delete: + tags: + - Likes + - PUT & DELETE in old browsers + description: | + Remove a like on this media by the currently authenticated user. + responses: + 200: + description: OK + schema: + type: object + properties: + meta: + properties: + code: + type: number + data: + type: object + + /tags/{tag-name}: + parameters: + - $ref: '#/parameters/tag-name' + get: + tags: + - Tags + - JSONP + - Pagination + description: Get information about a tag object. + responses: + 200: + description: OK + schema: + $ref: '#/definitions/Tag' + + /tags/{tag-name}/media/recent: + parameters: + - $ref: '#/parameters/tag-name' + get: + tags: + - Tags + - JSONP + - Pagination + description: | + Get a list of recently tagged media. Use the `max_tag_id` and + `min_tag_id` parameters in the pagination response to paginate through + these objects. + responses: + 200: + description: OK + schema: + properties: + data: + type: array + items: + $ref: '#/definitions/Tag' + + /tags/search: + get: + tags: + - Tags + - JSONP + - Pagination + parameters: + - name: q + description: | + A valid tag name without a leading #. (eg. snowy, nofilter) + in: query + type: string + responses: + 200: + description: OK + schema: + type: object + properties: + meta: + properties: + code: + type: integer + data: + type: array + items: + $ref: '#/definitions/Tag' + + /locations/{location-id}: + parameters: + - name: location-id + description: Location ID + in: path + type: integer + required: true + get: + tags: + - Location + - JSONP + - Pagination + description: Get information about a location. + responses: + 200: + description: OK + schema: + type: object + properties: + data: + $ref: '#/definitions/Location' + + /locations/{location-id}/media/recent: + parameters: + - name: location-id + description: Location ID + in: path + type: integer + required: true + get: + tags: + - Location + - Media + - JSONP + - Pagination + description: Get a list of recent media objects from a given location. + parameters: + - name: max_timestamp + in: query + description: Return media before this UNIX timestamp. + type: integer + - name: min_timestamp + in: query + description: Return media after this UNIX timestamp. + type: integer + - name: min_id + in: query + description: Return media later than this min_id. + type: string + - name: max_id + in: query + description: Return media earlier than this max_id. + type: string + responses: + 200: + description: OK + schema: + type: object + properties: + data: + type: array + items: + $ref: '#/definitions/Media' + + /locations/search: + get: + tags: + - Location + - JSONP + - Pagination + description: Search for a location by geographic coordinate. + parameters: + - name: distance + in: query + description: Default is 1000m (distance=1000), max distance is 5000. + type: integer + + - name: facebook_places_id + in: query + description: | + Returns a location mapped off of a Facebook places id. If used, a + Foursquare id and lat, lng are not required. + type: integer + + - name: foursquare_id + in: query + description: | + returns a location mapped off of a foursquare v1 api location id. + If used, you are not required to use lat and lng. Note that this + method is deprecated; you should use the new foursquare IDs with V2 + of their API. + type: integer + + - name: lat + in: query + description: | + atitude of the center search coordinate. If used, lng is required. + type: number + + - name: lng + in: query + description: | + ongitude of the center search coordinate. If used, lat is required. + type: number + + - name: foursquare_v2_id + in: query + description: | + Returns a location mapped off of a foursquare v2 api location id. If + used, you are not required to use lat and lng. + type: integer + responses: + 200: + description: OK + schema: + type: object + properties: + data: + type: array + items: + $ref: '#/definitions/Location' + + /geographies/{geo-id}/media/recent: + parameters: + - name: geo-id + in: path + description: Geolocation ID + type: integer + required: true + get: + tags: + - Media + - JSONP + - Pagination + description: | + Get recent media from a geography subscription that you created. + **Note**: You can only access Geographies that were explicitly created + by your OAuth client. Check the Geography Subscriptions section of the + [real-time updates page](https://instagram.com/developer/realtime/). + When you create a subscription to some geography + that you define, you will be returned a unique geo-id that can be used + in this query. To backfill photos from the location covered by this + geography, use the [media search endpoint + ](https://instagram.com/developer/endpoints/media/). + parameters: + - name: count + in: query + description: Max number of media to return. + type: integer + - name: min_id + in: query + description: Return media before this `min_id`. + type: integer + responses: + 200: + description: OK + +################################################################################ +# Definitions # +################################################################################ +definitions: + User: + type: object + properties: + id: + type: integer + username: + type: string + full_name: + type: string + profile_picture: + type: string + bio: + type: string + website: + type: string + counts: + type: object + properties: + media: + type: integer + follows: + type: integer + follwed_by: + type: integer + Media: + type: object + properties: + created_time: + description: Epoc time (ms) + type: integer + type: + type: string + filter: + type: string + tags: + type: array + items: + $ref: '#/definitions/Tag' + id: + type: integer + user: + $ref: '#/definitions/MiniProfile' + users_in_photo: + type: array + items: + $ref: '#/definitions/MiniProfile' + location: + $ref: '#/definitions/Location' + comments:: + type: object + properties: + count: + type: integer + data: + type: array + items: + $ref: '#/definitions/Comment' + likes: + type: object + properties: + count: + type: integer + data: + type: array + items: + $ref: '#/definitions/MiniProfile' + images: + properties: + low_resolution: + $ref: '#/definitions/Image' + thumbnail: + $ref: '#/definitions/Image' + standard_resolution: + $ref: '#/definitions/Image' + videos: + properties: + low_resolution: + $ref: '#/definitions/Image' + standard_resolution: + $ref: '#/definitions/Image' + Location: + type: object + properties: + id: + type: string + name: + type: string + latitude: + type: number + longitude: + type: number + Comment: + type: object + properties: + id: + type: string + created_time: + type: string + text: + type: string + from: + $ref: '#/definitions/MiniProfile' + Like: + type: object + properties: + user_name: + type: string + first_name: + type: string + last_name: + type: string + type: + type: string + id: + type: string + Tag: + type: object + properties: + media_count: + type: integer + name: + type: string + Image: + type: object + properties: + width: + type: integer + height: + type: integer + url: + type: string + MiniProfile: + type: object + description: A shorter version of User for likes array + properties: + user_name: + type: string + full_name: + type: string + id: + type: integer + profile_picture: + type: string From ab104f3d48385fe09e2518766caa04290d55c53f Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 30 Oct 2015 09:41:42 +0200 Subject: [PATCH 78/97] Handle x-secondaryTag in menu generation --- lib/utils/SchemaManager.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index 1c6d750a..e70109f6 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -92,7 +92,11 @@ export default class SchemaManager { let definedTags = this._schema.tags; // add tags into map to preserve order for (let tag of definedTags) { - tag2MethodMapping.set(tag.name, {description: tag.description}); + tag2MethodMapping.set(tag.name, { + 'description': tag.description, + 'x-secondaryTag': tag['x-secondaryTag'], + 'methods': [] + }); } let paths = this._schema.paths; @@ -114,7 +118,7 @@ export default class SchemaManager { tagDetails = {}; tag2MethodMapping.set(tag, tagDetails); } - if (!tagDetails.methods) tagDetails.methods = []; + if (tagDetails['x-secondaryTag']) continue; tagDetails.methods.push({pointer: methodPointer, summary: methodSummary}); } } From 29677bbd643fa248d4109b98ce580b80595dcb6d Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 30 Oct 2015 10:26:23 +0200 Subject: [PATCH 79/97] x-secondaryTag and menu-sync --- lib/common-components/Tabs/tabs.js | 8 +----- lib/components/MethodsList/methods-list.html | 2 +- lib/components/SchemaSample/schema-sample.js | 7 ++++- lib/components/SideMenu/side-menu.js | 28 +++++++++++++------ lib/components/SideMenuCat/side-menu-cat.css | 2 +- lib/components/SideMenuCat/side-menu-cat.html | 2 +- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/lib/common-components/Tabs/tabs.js b/lib/common-components/Tabs/tabs.js index 422ce138..4f527f67 100644 --- a/lib/common-components/Tabs/tabs.js +++ b/lib/common-components/Tabs/tabs.js @@ -44,13 +44,7 @@ export class Tabs {
- `, - styles: [` - .tab-wrap { - padding: 5px; - background-color: #121427; - } - `] + ` }) export class Tab { constructor(tabs) { diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html index 5b723908..e51bccdf 100644 --- a/lib/components/MethodsList/methods-list.html +++ b/lib/components/MethodsList/methods-list.html @@ -1,6 +1,6 @@
-
+

{{tag.name}}

diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js index 38234655..5193e3f8 100644 --- a/lib/components/SchemaSample/schema-sample.js +++ b/lib/components/SchemaSample/schema-sample.js @@ -6,7 +6,12 @@ import SchemaSampler from 'json-schema-instantiator'; @RedocComponent({ selector: 'schema-sample', - templateUrl: './lib/components/SchemaSample/schema-sample.html' + templateUrl: './lib/components/SchemaSample/schema-sample.html', + styles: [` + pre { + background-color: #121427; + } + `] }) export default class SchemaSample extends BaseComponent { constructor(schemaMgr) { diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index a4d70a48..75a89e43 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -30,7 +30,7 @@ export default class SideMenu extends BaseComponent { }); this.activeCatIdx = 0; - this.activeMethodIdx = 0; + this.activeMethodIdx = -1; this.prevOffsetY = null; } @@ -46,20 +46,29 @@ export default class SideMenu extends BaseComponent { } scrollToActive() { - window.scrollTo(0, this.getMethodEl().offsetTop); + let subjRect = this.getMethodEl().getBoundingClientRect(); + let offset = window.scrollY + subjRect.top; + window.scrollTo(0, offset); } activate(catIdx, methodIdx) { let menu = this.data.menu; menu[this.activeCatIdx].active = false; - menu[this.activeCatIdx].methods[this.activeMethodIdx].active = false; + if (menu[this.activeCatIdx].methods.length) { + if (this.activeMethodIdx >= 0) { + menu[this.activeCatIdx].methods[this.activeMethodIdx].active = false; + } + } this.activeCatIdx = catIdx; this.activeMethodIdx = methodIdx; menu[catIdx].active = true; - let currentItem = menu[catIdx].methods[methodIdx]; - currentItem.active = true; - this.activeMethodPtr = currentItem.pointer; + this.activeMethodPtr = null; + if (menu[catIdx].methods.length && (methodIdx > -1)) { + let currentItem = menu[catIdx].methods[methodIdx]; + currentItem.active = true; + this.activeMethodPtr = currentItem.pointer; + } } _calcActiveIndexes(offset) { @@ -72,9 +81,9 @@ export default class SideMenu extends BaseComponent { if (resMethodIdx > catLength - 1) { resCatIdx++; - resMethodIdx = 0; + resMethodIdx = -1; } - if (resMethodIdx < 0) { + if (resMethodIdx < -1) { let prevCatIdx = --resCatIdx; catLength = menu[Math.max(prevCatIdx, 0)].methods.length; resMethodIdx = catLength - 1; @@ -99,7 +108,8 @@ export default class SideMenu extends BaseComponent { getMethodEl() { let ptr = this.activeMethodPtr; let tag = this.data.menu[this.activeCatIdx].name; - return document.querySelector(`[pointer="${ptr}"][tag="${tag}"]`); + let selector = ptr ? `[pointer="${ptr}"][tag="${tag}"]` : `[tag="${tag}"]`; + return document.querySelector(selector); } scrollHandler() { diff --git a/lib/components/SideMenuCat/side-menu-cat.css b/lib/components/SideMenuCat/side-menu-cat.css index c6a02198..1a851b83 100644 --- a/lib/components/SideMenuCat/side-menu-cat.css +++ b/lib/components/SideMenuCat/side-menu-cat.css @@ -22,6 +22,6 @@ li { cursor: pointer; } -li.active { +label.active, li.active { color: #1976D3; } diff --git a/lib/components/SideMenuCat/side-menu-cat.html b/lib/components/SideMenuCat/side-menu-cat.html index 087a96a5..ed47f6b7 100644 --- a/lib/components/SideMenuCat/side-menu-cat.html +++ b/lib/components/SideMenuCat/side-menu-cat.html @@ -1,4 +1,4 @@ - +
  • Date: Fri, 30 Oct 2015 10:27:02 +0200 Subject: [PATCH 80/97] pre styling --- demo/main.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/demo/main.css b/demo/main.css index 1ee1eaf5..27d300b2 100644 --- a/demo/main.css +++ b/demo/main.css @@ -27,3 +27,10 @@ side-menu { redoc { margin-left: 260px; } + +pre { + white-space: pre-wrap; + background-color: #f2f2f2; + padding: 10px; + overflow-x: auto; +} From 7783d8dc17461cea0e523877afcf9832aded5e57 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 30 Oct 2015 11:43:51 +0200 Subject: [PATCH 81/97] Add tag list to method --- lib/components/Method/method.css | 14 ++++++++++++++ lib/components/Method/method.html | 3 +++ lib/components/MethodsList/methods-list.html | 1 + 3 files changed, 18 insertions(+) diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css index 81572c33..87016e93 100644 --- a/lib/components/Method/method.css +++ b/lib/components/Method/method.css @@ -18,6 +18,20 @@ h3 > span { vertical-align: middle; } +.method-tags { + margin-top: 10px; + color: #666; + font-weight: bold; +} + +.method-tags a { + color: #666; + font-weight: bold; + display: inline-block; + padding: 0 5px; + font-style: italic; +} + .content, .samples { display: block; box-sizing: border-box; diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index 3619cc29..6d3a4e3c 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -5,6 +5,9 @@ {{data.method}} {{data.path}} +
    Tags: + {{tag}} +

    diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html index e51bccdf..5e610f26 100644 --- a/lib/components/MethodsList/methods-list.html +++ b/lib/components/MethodsList/methods-list.html @@ -1,6 +1,7 @@
    +

    {{tag.name}}

    From e6a1fde2e47bb4ba447fd440b817e8603fea317e Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 30 Oct 2015 11:44:40 +0200 Subject: [PATCH 82/97] Improve side-menu sync --- lib/components/SideMenu/side-menu.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index 75a89e43..e49f451e 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -103,6 +103,7 @@ export default class SideMenu extends BaseComponent { changeActive(offset = 1) { let [catIdx, methodIdx] = this._calcActiveIndexes(offset); this.activate(catIdx, methodIdx); + return (methodIdx === 0 && catIdx === 0); } getMethodEl() { @@ -115,16 +116,20 @@ export default class SideMenu extends BaseComponent { scrollHandler() { let isScrolledDown = (window.scrollY - this.prevOffsetY > 0); this.prevOffsetY = window.scrollY; - var activeMethodHost = this.getMethodEl(); - if (!activeMethodHost) return; + let stable = false; + while(!stable) { + let activeMethodHost = this.getMethodEl(); + if (!activeMethodHost) return; - if(isScrolledDown && activeMethodHost.getBoundingClientRect().bottom <= 0 ) { - this.changeActive(CHANGE.NEXT); - return; - } - if(!isScrolledDown && activeMethodHost.getBoundingClientRect().top > 0 ) { - this.changeActive(CHANGE.BACK); - return; + if(isScrolledDown && activeMethodHost.getBoundingClientRect().bottom <= 0 ) { + stable = this.changeActive(CHANGE.NEXT); + continue; + } + if(!isScrolledDown && Math.floor(activeMethodHost.getBoundingClientRect().top) > 0 ) { + stable = this.changeActive(CHANGE.BACK); + continue; + } + stable = true; } } From cc707b50fbd5f0847066f419be768afdcce04e75 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 30 Oct 2015 11:48:18 +0200 Subject: [PATCH 83/97] Removed instagram example --- demo/instagram.yaml | 1057 ------------------------------------------- 1 file changed, 1057 deletions(-) delete mode 100644 demo/instagram.yaml diff --git a/demo/instagram.yaml b/demo/instagram.yaml deleted file mode 100644 index 6b62e710..00000000 --- a/demo/instagram.yaml +++ /dev/null @@ -1,1057 +0,0 @@ ---- -swagger: '2.0' - -################################################################################ -# API Information # -################################################################################ -info: - version: v1 - title: Instagram API - description: | - The first version of the Instagram API is an exciting step forward towards - making it easier for users to have open access to their data. We created it - so that you can surface the amazing content Instagram users share every - second, in fun and innovative ways. - - Build something great! - - Once you've - [registered your client](http://instagram.com/developer/register/) it's easy - to start requesting data from Instagram. - - termsOfService: http://instagram.com/about/legal/terms/api - -################################################################################ -# Host, Base Path, Schemes and Content Types # -################################################################################ -host: api.instagram.com -basePath: /v1 -schemes: - - https -produces: - - application/json -consumes: - - application/json - -################################################################################ -# Tags # -################################################################################ -tags: - - name: JSONP - x-secondaryTag: true - description: | - If you're writing an AJAX application, and you'd like to wrap our response - with a callback, all you have to do is specify a callback parameter with - any API call: - ``` - https://api.instagram.com/v1/tags/coffee/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&callback=callbackFunction - ``` - Would respond with: - ```js - callbackFunction({ - ... - }); - ``` - - name: Pagination - x-secondaryTag: true - description: | - Sometimes you just can't get enough. For this reason, we've provided a - convenient way to access more data in any request for sequential data. - Simply call the url in the next_url parameter and we'll respond with the - next set of data. - ```json - { - ... - "pagination": { - "next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296", - "next_max_id": "13872296" - } - } - ``` - On views where pagination is present, we also support the "count" parameter. - Simply set this to the number of items you'd like to receive. Note that the - default values should be fine for most applications - but if you decide to - increase this number there is a maximum value defined on each endpoint. - - name: PUT & DELETE in old browsers - x-secondaryTag: true - description: | - We do our best to have all our URLs be - [RESTful](http://en.wikipedia.org/wiki/Representational_state_transfer). - Every endpoint (URL) may support one of four different http verbs. GET - requests fetch information about an object, POST requests create objects, - PUT requests update objects, and finally DELETE requests will delete - objects. - - Since many old browsers don't support PUT or DELETE, we've made it easy to - fake PUTs and DELETEs. All you have to do is do a POST with _method=PUT or - _method=DELETE as a parameter and we will treat it as if you used PUT or - DELETE respectively. - - name: Users - - name: Relationships - description: | - Relationships are expressed using the following terms: - - **outgoing_status**: Your relationship to the user. Can be "follows", - "requested", "none". - **incoming_status**: A user's relationship to you. Can be "followed_by", - "requested_by", "blocked_by_you", "none". - - name: Media - description: | - At this time, uploading via the API is not possible. We made a conscious - choice not to add this for the following reasons: - - * Instagram is about your life on the go – we hope to encourage photos - from within the app. - * We want to fight spam & low quality photos. Once we allow uploading - from other sources, it's harder to control what comes into the Instagram - ecosystem. All this being said, we're working on ways to ensure users - have a consistent and high-quality experience on our platform. - - name: Commnts - - name: Likes - - name: Tags - - name: Location - - name: Subscribtions - -################################################################################ -# Security # -################################################################################ -securityDefinitions: - oauth: - type: oauth2 - flow: implicit - authorizationUrl: https://instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token - scopes: - basic: | - to read any and all data related to a user (e.g. following/followed-by - lists, photos, etc.) (granted by default) - comments: to create or delete comments on a user’s behalf - relationships: to follow and unfollow users on a user’s behalf - likes: to like and unlike items on a user’s behalf - key: - type: apiKey - in: query - name: access_token -security: - - oauth: - - basic - - comments - - relationships - - likes - - key: [] - -################################################################################ -# Parameters # -################################################################################ -parameters: - user-id: - name: user-id - in: path - description: The user identifier number - type: number - required: true - tag-name: - name: tag-name - in: path - description: Tag name - type: string - required: true - -################################################################################ -# Paths # -################################################################################ -paths: - /users/{user-id}: - parameters: - - $ref: '#/parameters/user-id' - get: - security: - - key: [] - - oauth: - - basic - tags: - - Users - - JSONP - - Pagination - description: Get basic information about a user. - responses: - 200: - description: The user object - schema: - type: object - properties: - data: - $ref: '#/definitions/User' - - /users/self/feed: - get: - tags: - - Users - - JSONP - - Pagination - description: See the authenticated user's feed. - parameters: - - name: count - in: query - description: Count of media to return. - type: integer - - name: max_id - in: query - description: Return media earlier than this max_id.s - type: integer - - name: min_id - in: query - description: Return media later than this min_id. - - type: integer - responses: - 200: - description: OK - schema: - type: object - properties: - data: - type: array - items: - $ref: '#/definitions/Media' - - /users/{user-id}/media/recent: - parameters: - - $ref: '#/parameters/user-id' - get: - tags: - - Users - - JSONP - - Pagination - responses: - 200: - description: | - Get the most recent media published by a user. To get the most recent - media published by the owner of the access token, you can use `self` - instead of the `user-id`. - schema: - type: object - properties: - data: - type: array - items: - $ref: '#/definitions/Media' - parameters: - - name: count - in: query - description: Count of media to return. - type: integer - - name: max_timestamp - in: query - description: Return media before this UNIX timestamp. - type: integer - - name: min_timestamp - in: query - description: Return media after this UNIX timestamp. - type: integer - - name: min_id - in: query - description: Return media later than this min_id. - type: string - - name: max_id - in: query - description: Return media earlier than this max_id. - type: string - - /users/self/media/liked: - get: - tags: - - Users - - JSONP - - Pagination - description: | - See the list of media liked by the authenticated user. - Private media is returned as long as the authenticated user - has permissionto view that media. Liked media lists are only - available for the currently authenticated user. - responses: - 200: - description: OK - schema: - type: object - properties: - data: - type: array - items: - $ref: '#/definitions/Media' - parameters: - - name: count - in: query - description: Count of media to return. - type: integer - - name: max_like_id - in: query - description: Return media liked before this id. - type: integer - - /users/search: - get: - tags: - - Users - - JSONP - - Pagination - description: Search for a user by name. - parameters: - - name: q - in: query - description: A query string - type: string - required: true - - name: count - in: query - description: Number of users to return. - type: string - responses: - 200: - description: OK - schema: - type: object - properties: - data: - type: array - items: - $ref: '#/definitions/MiniProfile' - - /users/{user-id}/follows: - parameters: - - $ref: '#/parameters/user-id' - get: - tags: - - Relationships - - JSONP - - Pagination - description: Get the list of users this user follows. - responses: - 200: - description: OK - schema: - properties: - data: - type: array - items: - $ref: '#/definitions/MiniProfile' - - /users/{user-id}/followed-by: - parameters: - - $ref: '#/parameters/user-id' - get: - tags: - - Relationships - - JSONP - - Pagination - description: Get the list of users this user is followed by. - responses: - 200: - description: OK - schema: - properties: - data: - type: array - items: - $ref: '#/definitions/MiniProfile' - - /users/self/requested-by: - get: - tags: - - Relationships - - JSONP - - Pagination - description: | - List the users who have requested this user's permission to follow. - responses: - 200: - description: OK - schema: - properties: - meta: - properties: - code: - type: integer - data: - type: array - items: - $ref: '#/definitions/MiniProfile' - - /users/{user-id}/relationship: - parameters: - - $ref: '#/parameters/user-id' - post: - tags: - - Relationships - - JSONP - description: | - Modify the relationship between the current user and thetarget user. - security: - - oauth: - - relationships - parameters: - - name: action - in: body - description: One of follow/unfollow/block/unblock/approve/ignore. - schema: - type: string - enum: - - follow - - unfollow - - block - - unblock - - approve - - responses: - 200: - description: OK - schema: - properties: - data: - type: array - items: - $ref: '#/definitions/MiniProfile' - - /media/{media-id}: - parameters: - - name: media-id - in: path - description: The media ID - type: integer - required: true - get: - tags: - - Media - - JSONP - - Pagination - description: | - Get information about a media object. - The returned type key will allow you to differentiate between `image` - and `video` media. - - Note: if you authenticate with an OAuth Token, you will receive the - `user_has_liked` key which quickly tells you whether the current user - has liked this media item. - responses: - 200: - description: OK - schema: - $ref: '#/definitions/Media' - - /media1/{shortcode}: #FIXME: correct path is /media/{shortcode} - parameters: - - name: shortcode - in: path - description: The media shortcode - type: string - required: true - get: - tags: - - Media - - JSONP - - Pagination - description: | - This endpoint returns the same response as **GET** `/media/media-id`. - - A media object's shortcode can be found in its shortlink URL. - An example shortlink is `http://instagram.com/p/D/` - Its corresponding shortcode is D. - - responses: - 200: - description: OK - schema: - $ref: '#/definitions/Media' - - /media/search: - get: - tags: - - Media - - JSONP - - Pagination - description: | - Search for media in a given area. The default time span is set to 5 - days. The time span must not exceed 7 days. Defaults time stamps cover - the last 5 days. Can return mix of image and video types. - - parameters: - - name: LAT - description: | - Latitude of the center search coordinate. If used, lng is required. - type: number - in: query - - name: MIN_TIMESTAMP - description: | - A unix timestamp. All media returned will be taken later than - this timestamp. - type: integer - in: query - - name: LNG - description: | - Longitude of the center search coordinate. If used, lat is required. - type: number - in: query - - name: MAX_TIMESTAMP - description: | - A unix timestamp. All media returned will be taken earlier than this - timestamp. - type: integer - in: query - - name: DISTANCE - description: Default is 1km (distance=1000), max distance is 5km. - type: integer - maximum: 5000 - default: 1000 - in: query - responses: - 200: - description: OK - schema: - type: object - description: List of all media with added `distance` property - properties: - data: - type: array - items: - allOf: - - $ref: '#/definitions/Media' - - - properties: - distance: - type: number - - /media/popular: - get: - tags: - - Media - - JSONP - - Pagination - description: | - Get a list of what media is most popular at the moment. - Can return mix of image and video types. - responses: - 200: - description: OK - schema: - type: object - properties: - data: - type: array - items: - $ref: '#/definitions/Media' - - /media/{media-id}/comments: - parameters: - - name: media-id - in: path - description: Media ID - type: integer - required: true - get: - tags: - - Comments - - JSONP - - Pagination - description: | - Get a list of recent comments on a media object. - responses: - 200: - description: OK - schema: - properties: - meta: - properties: - code: - type: number - data: - type: array - items: - $ref: '#/definitions/Comment' - post: - tags: - - Comments - - Media - - JSONP - description: | - Create a comment on a media object with the following rules: - - * The total length of the comment cannot exceed 300 characters. - * The comment cannot contain more than 4 hashtags. - * The comment cannot contain more than 1 URL. - * The comment cannot consist of all capital letters. - security: - - oauth: - - comments - parameters: - - name: TEXT - description: | - Text to post as a comment on the media object as specified in - media-id. - in: body - schema: - type: number - responses: - 200: - description: OK - schema: - type: object - properties: - meta: - properties: - code: - type: number - data: - type: object - delete: - tags: - - Comments - - PUT & DELETE in old browsers - description: | - Remove a comment either on the authenticated user's media object or - authored by the authenticated user. - responses: - 200: - description: OK - schema: - type: object - properties: - meta: - properties: - code: - type: number - data: - type: object - - /media/{media-id}/likes: - parameters: - - name: media-id - in: path - description: Media ID - type: integer - required: true - get: - tags: - - Likes - - Media - - JSONP - - Pagination - description: | - Get a list of users who have liked this media. - responses: - 200: - description: OK - schema: - properties: - meta: - properties: - code: - type: number - data: - type: array - items: - $ref: '#/definitions/Like' - post: - tags: - - Likes - description: Set a like on this media by the currently authenticated user. - security: - - oauth: - - comments - responses: - 200: - description: OK - schema: - type: object - properties: - meta: - properties: - code: - type: number - data: - type: object - delete: - tags: - - Likes - - PUT & DELETE in old browsers - description: | - Remove a like on this media by the currently authenticated user. - responses: - 200: - description: OK - schema: - type: object - properties: - meta: - properties: - code: - type: number - data: - type: object - - /tags/{tag-name}: - parameters: - - $ref: '#/parameters/tag-name' - get: - tags: - - Tags - - JSONP - - Pagination - description: Get information about a tag object. - responses: - 200: - description: OK - schema: - $ref: '#/definitions/Tag' - - /tags/{tag-name}/media/recent: - parameters: - - $ref: '#/parameters/tag-name' - get: - tags: - - Tags - - JSONP - - Pagination - description: | - Get a list of recently tagged media. Use the `max_tag_id` and - `min_tag_id` parameters in the pagination response to paginate through - these objects. - responses: - 200: - description: OK - schema: - properties: - data: - type: array - items: - $ref: '#/definitions/Tag' - - /tags/search: - get: - tags: - - Tags - - JSONP - - Pagination - parameters: - - name: q - description: | - A valid tag name without a leading #. (eg. snowy, nofilter) - in: query - type: string - responses: - 200: - description: OK - schema: - type: object - properties: - meta: - properties: - code: - type: integer - data: - type: array - items: - $ref: '#/definitions/Tag' - - /locations/{location-id}: - parameters: - - name: location-id - description: Location ID - in: path - type: integer - required: true - get: - tags: - - Location - - JSONP - - Pagination - description: Get information about a location. - responses: - 200: - description: OK - schema: - type: object - properties: - data: - $ref: '#/definitions/Location' - - /locations/{location-id}/media/recent: - parameters: - - name: location-id - description: Location ID - in: path - type: integer - required: true - get: - tags: - - Location - - Media - - JSONP - - Pagination - description: Get a list of recent media objects from a given location. - parameters: - - name: max_timestamp - in: query - description: Return media before this UNIX timestamp. - type: integer - - name: min_timestamp - in: query - description: Return media after this UNIX timestamp. - type: integer - - name: min_id - in: query - description: Return media later than this min_id. - type: string - - name: max_id - in: query - description: Return media earlier than this max_id. - type: string - responses: - 200: - description: OK - schema: - type: object - properties: - data: - type: array - items: - $ref: '#/definitions/Media' - - /locations/search: - get: - tags: - - Location - - JSONP - - Pagination - description: Search for a location by geographic coordinate. - parameters: - - name: distance - in: query - description: Default is 1000m (distance=1000), max distance is 5000. - type: integer - - - name: facebook_places_id - in: query - description: | - Returns a location mapped off of a Facebook places id. If used, a - Foursquare id and lat, lng are not required. - type: integer - - - name: foursquare_id - in: query - description: | - returns a location mapped off of a foursquare v1 api location id. - If used, you are not required to use lat and lng. Note that this - method is deprecated; you should use the new foursquare IDs with V2 - of their API. - type: integer - - - name: lat - in: query - description: | - atitude of the center search coordinate. If used, lng is required. - type: number - - - name: lng - in: query - description: | - ongitude of the center search coordinate. If used, lat is required. - type: number - - - name: foursquare_v2_id - in: query - description: | - Returns a location mapped off of a foursquare v2 api location id. If - used, you are not required to use lat and lng. - type: integer - responses: - 200: - description: OK - schema: - type: object - properties: - data: - type: array - items: - $ref: '#/definitions/Location' - - /geographies/{geo-id}/media/recent: - parameters: - - name: geo-id - in: path - description: Geolocation ID - type: integer - required: true - get: - tags: - - Media - - JSONP - - Pagination - description: | - Get recent media from a geography subscription that you created. - **Note**: You can only access Geographies that were explicitly created - by your OAuth client. Check the Geography Subscriptions section of the - [real-time updates page](https://instagram.com/developer/realtime/). - When you create a subscription to some geography - that you define, you will be returned a unique geo-id that can be used - in this query. To backfill photos from the location covered by this - geography, use the [media search endpoint - ](https://instagram.com/developer/endpoints/media/). - parameters: - - name: count - in: query - description: Max number of media to return. - type: integer - - name: min_id - in: query - description: Return media before this `min_id`. - type: integer - responses: - 200: - description: OK - -################################################################################ -# Definitions # -################################################################################ -definitions: - User: - type: object - properties: - id: - type: integer - username: - type: string - full_name: - type: string - profile_picture: - type: string - bio: - type: string - website: - type: string - counts: - type: object - properties: - media: - type: integer - follows: - type: integer - follwed_by: - type: integer - Media: - type: object - properties: - created_time: - description: Epoc time (ms) - type: integer - type: - type: string - filter: - type: string - tags: - type: array - items: - $ref: '#/definitions/Tag' - id: - type: integer - user: - $ref: '#/definitions/MiniProfile' - users_in_photo: - type: array - items: - $ref: '#/definitions/MiniProfile' - location: - $ref: '#/definitions/Location' - comments:: - type: object - properties: - count: - type: integer - data: - type: array - items: - $ref: '#/definitions/Comment' - likes: - type: object - properties: - count: - type: integer - data: - type: array - items: - $ref: '#/definitions/MiniProfile' - images: - properties: - low_resolution: - $ref: '#/definitions/Image' - thumbnail: - $ref: '#/definitions/Image' - standard_resolution: - $ref: '#/definitions/Image' - videos: - properties: - low_resolution: - $ref: '#/definitions/Image' - standard_resolution: - $ref: '#/definitions/Image' - Location: - type: object - properties: - id: - type: string - name: - type: string - latitude: - type: number - longitude: - type: number - Comment: - type: object - properties: - id: - type: string - created_time: - type: string - text: - type: string - from: - $ref: '#/definitions/MiniProfile' - Like: - type: object - properties: - user_name: - type: string - first_name: - type: string - last_name: - type: string - type: - type: string - id: - type: string - Tag: - type: object - properties: - media_count: - type: integer - name: - type: string - Image: - type: object - properties: - width: - type: integer - height: - type: integer - url: - type: string - MiniProfile: - type: object - description: A shorter version of User for likes array - properties: - user_name: - type: string - full_name: - type: string - id: - type: integer - profile_picture: - type: string From a4bae203f741717e8ecc79cbcf8c8d9aab45badf Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 30 Oct 2015 11:48:36 +0200 Subject: [PATCH 84/97] Minor schema manager fix --- lib/utils/SchemaManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index e70109f6..1afce1c7 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -119,6 +119,7 @@ export default class SchemaManager { tag2MethodMapping.set(tag, tagDetails); } if (tagDetails['x-secondaryTag']) continue; + if (!tagDetails.methods) tagDetails.methods = []; tagDetails.methods.push({pointer: methodPointer, summary: methodSummary}); } } From 1aebffd06ae90b7b20128a6b0ea1033700110e24 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 30 Oct 2015 11:51:29 +0200 Subject: [PATCH 85/97] side menu minor fix --- lib/components/SideMenu/side-menu.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/components/SideMenu/side-menu.html b/lib/components/SideMenu/side-menu.html index ea64d88b..7fe42f3b 100644 --- a/lib/components/SideMenu/side-menu.html +++ b/lib/components/SideMenu/side-menu.html @@ -1,6 +1,6 @@

    Api reference

    - +
    From 0e2b8aa6f5034e16a4b7fd19159e52fbc5658aa7 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 30 Oct 2015 12:03:13 +0200 Subject: [PATCH 86/97] minor styling --- demo/main.css | 6 ++++++ lib/components/Method/method.css | 7 +++++++ lib/components/MethodsList/methods-list.css | 9 +++++++-- lib/components/ParamsList/params-list.css | 4 ++-- lib/components/ResponsesList/responses-list.css | 4 ++-- lib/components/SideMenuCat/side-menu-cat.css | 1 + 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/demo/main.css b/demo/main.css index 27d300b2..2d12215e 100644 --- a/demo/main.css +++ b/demo/main.css @@ -3,6 +3,7 @@ body { font-size: 14px; color: #333; margin: 0; + line-height: 1.5; } side-menu, redoc { @@ -33,4 +34,9 @@ pre { background-color: #f2f2f2; padding: 10px; overflow-x: auto; + line-height: normal; +} + +code { + background-color: #f2f2f2; } diff --git a/lib/components/Method/method.css b/lib/components/Method/method.css index 87016e93..4759e427 100644 --- a/lib/components/Method/method.css +++ b/lib/components/Method/method.css @@ -18,6 +18,11 @@ h3 > span { vertical-align: middle; } +span.path { + font-family: monospace; + font-weight: bold; +} + .method-tags { margin-top: 10px; color: #666; @@ -78,6 +83,8 @@ responses-samples { font-size: 13px; color: white; background-color: #1976D3; + border-radius: 0 10px 10px 0; + font-weight: bold; } .http-method.delete { diff --git a/lib/components/MethodsList/methods-list.css b/lib/components/MethodsList/methods-list.css index 7411eb65..12638f12 100644 --- a/lib/components/MethodsList/methods-list.css +++ b/lib/components/MethodsList/methods-list.css @@ -6,15 +6,20 @@ method { .tag-info { padding: 0 20px; - width: 60%; box-sizing: border-box; + background-color: white; +} + +.tag-info:after, .tag-info:before { + content: ""; + display: table; } .tag-info h1 { color: rgb(102, 102, 102); text-transform: capitalize; padding-left: 10px; - border-left: 5px solid green; + border-left: 5px solid darkgreen; } .methods { diff --git a/lib/components/ParamsList/params-list.css b/lib/components/ParamsList/params-list.css index d8ae1808..cf9b58c9 100644 --- a/lib/components/ParamsList/params-list.css +++ b/lib/components/ParamsList/params-list.css @@ -7,7 +7,7 @@ h4 { table { width: 100%; border-spacing: 0; - border: 2px solid #1976D3; + border: 2px solid #053361; } td.param-name { @@ -19,7 +19,7 @@ td.param-description { } thead tr:first-child { - background: #1976D3; + background: #053361; color: #fff; border: none; } diff --git a/lib/components/ResponsesList/responses-list.css b/lib/components/ResponsesList/responses-list.css index 74fc76a5..a300a156 100644 --- a/lib/components/ResponsesList/responses-list.css +++ b/lib/components/ResponsesList/responses-list.css @@ -5,7 +5,7 @@ small { table { width: 100%; border-spacing: 0; - border: 2px solid green; + border: 2px solid darkgreen; } th.response-code { @@ -17,7 +17,7 @@ th.response-description { } thead tr:first-child { - background: green; + background: darkgreen; color: #fff; border: none; } diff --git a/lib/components/SideMenuCat/side-menu-cat.css b/lib/components/SideMenuCat/side-menu-cat.css index 1a851b83..ce228ab1 100644 --- a/lib/components/SideMenuCat/side-menu-cat.css +++ b/lib/components/SideMenuCat/side-menu-cat.css @@ -3,6 +3,7 @@ label { font-size: 15px; cursor: pointer; color: #666; + text-transform: capitalize; } ul { From a64c34cfa73921a8e12034432b77f93abf91a2f9 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 30 Oct 2015 12:26:30 +0200 Subject: [PATCH 87/97] Extend petstore schema to demonstrate extraction global concerns --- demo/swagger.json | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/demo/swagger.json b/demo/swagger.json index 9324cca2..f01aa0de 100644 --- a/demo/swagger.json +++ b/demo/swagger.json @@ -16,6 +16,21 @@ "host": "petstore.swagger.io", "basePath": "/v2", "tags": [{ + "name": "Pagination", + "description": "Sometimes you just can't get enough. For this reason, we've provided a convenient way to access more data in any request for sequential data. Simply call the url in the next_url parameter and we'll respond with the next set of data.\n```json\n{\n ...\n \"pagination\": {\n \"next_url\": \"https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296\",\n \"next_max_id\": \"13872296\"\n }\n}\n```\n On views where pagination is present, we also support the `count` parameter. Simply set this to the number of items you'd like to receive. Note that the default values should be fine for most applications - but if you decide to increase this number there is a maximum value defined on each endpoint.", + "externalDocs": { + "description": "Find out more", + "url": "http://swagger.io" + } + },{ + "name": "JSONP", + "x-secondaryTag": true, + "description": "If you're writing an AJAX application, and you'd like to wrap our response with a callback, all you have to do is specify a callback parameter with any API call:\n```\n https://api.instagram.com/v1/tags/coffee/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&callback=callbackFunction\n```\nWould respond with:\n```js\ncallbackFunction({\n ...\n});\n```", + "externalDocs": { + "description": "Find out more", + "url": "http://swagger.io" + } + },{ "name": "pet", "description": "Everything about your Pets", "externalDocs": { @@ -95,7 +110,7 @@ }, "/pet/findByStatus": { "get": { - "tags": ["pet"], + "tags": ["pet", "Pagination", "JSONP"], "summary": "Finds Pets by status", "description": "Multiple status values can be provided with comma seperated strings", "operationId": "findPetsByStatus", @@ -134,7 +149,7 @@ }, "/pet/findByTags": { "get": { - "tags": ["pet"], + "tags": ["pet", "Pagination", "JSONP"], "summary": "Finds Pets by tags", "description": "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", "operationId": "findPetsByTags", @@ -171,7 +186,7 @@ }, "/pet/{petId}": { "get": { - "tags": ["pet"], + "tags": ["pet", "JSONP"], "summary": "Find pet by ID", "description": "Returns a single pet", "operationId": "getPetById", @@ -310,7 +325,7 @@ }, "/store/inventory": { "get": { - "tags": ["store"], + "tags": ["store", "JSONP"], "summary": "Returns pet inventories by status", "description": "Returns a map of status codes to quantities", "operationId": "getInventory", @@ -364,7 +379,7 @@ }, "/store/order/{orderId}": { "get": { - "tags": ["store"], + "tags": ["store", "JSONP"], "summary": "Find purchase order by ID", "description": "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", "operationId": "getOrderById", @@ -555,7 +570,7 @@ }, "/user/{username}": { "get": { - "tags": ["user"], + "tags": ["user", "JSONP"], "summary": "Get user by user name", "description": "", "operationId": "getUserByName", From 93c626b27fa3e1ba0f682475bfcfc2ea178b04d9 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Fri, 30 Oct 2015 12:33:57 +0200 Subject: [PATCH 88/97] Add missed x-secondaryTag --- demo/swagger.json | 1 + 1 file changed, 1 insertion(+) diff --git a/demo/swagger.json b/demo/swagger.json index f01aa0de..74a51584 100644 --- a/demo/swagger.json +++ b/demo/swagger.json @@ -17,6 +17,7 @@ "basePath": "/v2", "tags": [{ "name": "Pagination", + "x-secondaryTag": true, "description": "Sometimes you just can't get enough. For this reason, we've provided a convenient way to access more data in any request for sequential data. Simply call the url in the next_url parameter and we'll respond with the next set of data.\n```json\n{\n ...\n \"pagination\": {\n \"next_url\": \"https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296\",\n \"next_max_id\": \"13872296\"\n }\n}\n```\n On views where pagination is present, we also support the `count` parameter. Simply set this to the number of items you'd like to receive. Note that the default values should be fine for most applications - but if you decide to increase this number there is a maximum value defined on each endpoint.", "externalDocs": { "description": "Find out more", From 613243c41101e93f16f9ad2ebefa49fc0f971e05 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 1 Nov 2015 00:43:08 +0200 Subject: [PATCH 89/97] Update json-schema-instantiator (closes #1) --- package.json | 2 +- system.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7abf0d70..b466cea7 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "es6-shim": "github:es-shims/es6-shim@^0.33.6", "json-formatter-js": "npm:json-formatter-js@^0.2.0", "json-pointer": "npm:json-pointer@^0.3.0", - "json-schema-instantiator": "npm:json-schema-instantiator@^0.2.2", + "json-schema-instantiator": "npm:json-schema-instantiator@^0.3.0", "json-schema-view-js": "npm:json-schema-view-js@^0.2.0", "marked": "npm:marked@^0.3.5", "reflect-metadata": "npm:reflect-metadata@^0.1.2", diff --git a/system.config.js b/system.config.js index 23f8e509..5d1922ef 100644 --- a/system.config.js +++ b/system.config.js @@ -47,7 +47,7 @@ System.config({ "json": "github:systemjs/plugin-json@0.1.0", "json-formatter-js": "npm:json-formatter-js@0.2.0", "json-pointer": "npm:json-pointer@0.3.0", - "json-schema-instantiator": "npm:json-schema-instantiator@0.2.2", + "json-schema-instantiator": "npm:json-schema-instantiator@0.3.0", "json-schema-view-js": "npm:json-schema-view-js@0.2.0", "marked": "npm:marked@0.3.5", "reflect-metadata": "npm:reflect-metadata@0.1.2", From 7d9652c61fc7989261cc6cf0931033c4a9055a08 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Tue, 3 Nov 2015 01:11:30 +0200 Subject: [PATCH 90/97] Updated angular to the latest alpha --- package.json | 2 +- system.config.js | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index b466cea7..e4851b41 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "jspm": { "configFile": "system.config.js", "dependencies": { - "angular2": "npm:angular2@^2.0.0-alpha.44", + "angular2": "npm:angular2@^2.0.0-alpha.45", "es6-shim": "github:es-shims/es6-shim@^0.33.6", "json-formatter-js": "npm:json-formatter-js@^0.2.0", "json-pointer": "npm:json-pointer@^0.3.0", diff --git a/system.config.js b/system.config.js index 5d1922ef..dc332070 100644 --- a/system.config.js +++ b/system.config.js @@ -37,7 +37,7 @@ System.config({ }, map: { - "angular2": "npm:angular2@2.0.0-alpha.44", + "angular2": "npm:angular2@2.0.0-alpha.45", "babel": "npm:babel-core@5.8.25", "babel-runtime": "npm:babel-runtime@5.8.25", "clean-css": "npm:clean-css@3.4.6", @@ -140,14 +140,14 @@ System.config({ "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" }, - "npm:angular2@2.0.0-alpha.44": { + "npm:angular2@2.0.0-alpha.45": { "@reactivex/rxjs": "npm:@reactivex/rxjs@5.0.0-alpha.4", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", "fs": "github:jspm/nodelibs-fs@0.1.2", "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2", - "reflect-metadata": "npm:reflect-metadata@0.1.1", + "reflect-metadata": "npm:reflect-metadata@0.1.2", "zone.js": "npm:zone.js@0.5.8" }, "npm:argparse@1.0.2": { @@ -208,7 +208,7 @@ System.config({ "npm:browserify-aes@1.0.5": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "buffer-xor": "npm:buffer-xor@1.0.3", - "cipher-base": "npm:cipher-base@1.0.1", + "cipher-base": "npm:cipher-base@1.0.2", "create-hash": "npm:create-hash@1.1.2", "crypto": "github:jspm/nodelibs-crypto@0.1.0", "evp_bytestokey": "npm:evp_bytestokey@1.0.0", @@ -225,7 +225,7 @@ System.config({ }, "npm:browserify-des@1.0.0": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", - "cipher-base": "npm:cipher-base@1.0.1", + "cipher-base": "npm:cipher-base@1.0.2", "crypto": "github:jspm/nodelibs-crypto@0.1.0", "des.js": "npm:des.js@1.0.0", "inherits": "npm:inherits@2.0.1" @@ -277,7 +277,7 @@ System.config({ "strip-ansi": "npm:strip-ansi@3.0.0", "supports-color": "npm:supports-color@2.0.0" }, - "npm:cipher-base@1.0.1": { + "npm:cipher-base@1.0.2": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "inherits": "npm:inherits@2.0.1", "stream": "github:jspm/nodelibs-stream@0.1.0", @@ -329,7 +329,7 @@ System.config({ }, "npm:create-hash@1.1.2": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", - "cipher-base": "npm:cipher-base@1.0.1", + "cipher-base": "npm:cipher-base@1.0.2", "crypto": "github:jspm/nodelibs-crypto@0.1.0", "fs": "github:jspm/nodelibs-fs@0.1.2", "inherits": "npm:inherits@2.0.1", @@ -648,10 +648,6 @@ System.config({ "string_decoder": "npm:string_decoder@0.10.31", "util-deprecate": "npm:util-deprecate@1.0.1" }, - "npm:reflect-metadata@0.1.1": { - "assert": "github:jspm/nodelibs-assert@0.1.0", - "process": "github:jspm/nodelibs-process@0.1.2" - }, "npm:reflect-metadata@0.1.2": { "assert": "github:jspm/nodelibs-assert@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" From 20157a6743eaafe7cbbfc8e4e4e02f891691028b Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Tue, 3 Nov 2015 01:12:08 +0200 Subject: [PATCH 91/97] Add reflect-metadata as external dependency --- build/tasks/build.js | 3 ++- lib/index.js | 1 - package.json | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index 7c585bf4..cdd9d426 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -26,7 +26,8 @@ gulp.task('inlineTemplates', function() { }); var JS_DEV_DEPS = [ - 'node_modules/zone.js/dist/zone-microtask.js' + 'node_modules/zone.js/dist/zone-microtask.js', + 'node_modules/reflect-metadata/Reflect.js' ]; // concatenate angular2 deps diff --git a/lib/index.js b/lib/index.js index 7b517747..5b9b6222 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,5 @@ 'use strict'; -import 'reflect-metadata'; import {bootstrap} from 'angular2/angular2'; import {Redoc, SideMenu} from './components/index'; import SchemaManager from './utils/SchemaManager'; diff --git a/package.json b/package.json index e4851b41..ec5c6ddc 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "gulp-sourcemaps": "^1.6.0", "jshint-stylish": "^2.0.1", "jspm": "^0.16.11", + "reflect-metadata": "^0.1.2", "require-dir": "^0.3.0", "run-sequence": "^1.1.4", "systemjs-builder": "^0.14.7", From 9a036b40e6b0c9920706aab733bbe600dc7e67cf Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Wed, 4 Nov 2015 21:31:10 +0200 Subject: [PATCH 92/97] Add navbar --- demo/index.html | 6 ++++++ demo/main.css | 37 +++++++++++++++++++++++++++++++++++++ demo/main.js | 9 +++++++++ 3 files changed, 52 insertions(+) create mode 100644 demo/main.js diff --git a/demo/index.html b/demo/index.html index 28f0293c..0a703013 100644 --- a/demo/index.html +++ b/demo/index.html @@ -6,6 +6,11 @@ + + @@ -15,6 +20,7 @@ +