From 4005d8f61b2568518906504b3b9efce65e2bf146 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 29 May 2016 20:26:20 +0300 Subject: [PATCH 1/3] Proper examples generation: fixes #43 --- lib/components/SchemaSample/schema-sample.js | 8 ++++++-- lib/components/SchemaSample/schema-sample.scss | 1 + package.json | 6 +++++- system.config.js | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js index 0c350ba1..034d8fa4 100644 --- a/lib/components/SchemaSample/schema-sample.js +++ b/lib/components/SchemaSample/schema-sample.js @@ -2,7 +2,7 @@ import { ElementRef } from '@angular/core'; -import SchemaSampler from 'json-schema-instantiator'; +import * as OpenAPISampler from 'openapi-sampler'; import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import { JsonFormatter } from '../../utils/JsonFormatterPipe'; @@ -36,7 +36,11 @@ export class SchemaSample extends BaseComponent { sample = base.examples['application/json']; } else { this.dereference(this.componentSchema); - sample = SchemaSampler.instantiate(this.componentSchema); + try { + sample = OpenAPISampler.sample(this.componentSchema); + } catch(e) { + console.error('@@@@@@@@@@@@@@@@@@@' + e); + } } this.data.sample = sample; diff --git a/lib/components/SchemaSample/schema-sample.scss b/lib/components/SchemaSample/schema-sample.scss index ef191331..0df65e80 100644 --- a/lib/components/SchemaSample/schema-sample.scss +++ b/lib/components/SchemaSample/schema-sample.scss @@ -65,6 +65,7 @@ pre { } .redoc-json { + overflow-x: auto; padding: 20px; border-radius: $border-radius*2; background-color: darken($black, 2%); diff --git a/package.json b/package.json index c40c1599..af90f6e8 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,9 @@ "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.3.0", "json-schema-ref-parser": "npm:json-schema-ref-parser@^3.1.2", "marked": "npm:marked@^0.3.5", + "openapi-sampler": "npm:openapi-sampler@^0.1.2", "prismjs": "npm:prismjs@^1.3.0", "rxjs": "npm:rxjs@5.0.0-beta.6", "scrollparent": "npm:scrollparent@^0.1.0", @@ -63,6 +63,10 @@ "overrides": { "github:Robdel12/DropKick@2.1.7": { "format": "global" + }, + "npm:openapi-sampler@0.1.2": { + "main": "src/openapi-sampler", + "format": "esm" } } }, diff --git a/system.config.js b/system.config.js index 2983ac4c..6ff4a4b0 100644 --- a/system.config.js +++ b/system.config.js @@ -53,9 +53,9 @@ System.config({ "json": "github:systemjs/plugin-json@0.1.2", "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.3.0", "json-schema-ref-parser": "npm:json-schema-ref-parser@3.1.2", "marked": "npm:marked@0.3.5", + "openapi-sampler": "npm:openapi-sampler@0.1.2", "prismjs": "npm:prismjs@1.3.0", "rxjs": "npm:rxjs@5.0.0-beta.6", "scrollparent": "npm:scrollparent@0.1.0", From 9df1c450e85d968fb74882b35326f97f9546b399 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 29 May 2016 20:31:39 +0300 Subject: [PATCH 2/3] v0.13.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index af90f6e8..21a60c91 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "redoc", "description": "Swagger-generated API Reference Documentation", - "version": "0.12.0", + "version": "0.13.0", "repository": { "type": "git", "url": "git://github.com/Rebilly/ReDoc" From 40b03e993c2f5fb9808eb89cb2f1a695d878173b Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 29 May 2016 20:47:38 +0300 Subject: [PATCH 3/3] Simplified deployment --- build/prepare_deploy.js | 20 ++++++-------------- build/tasks/copy-version.js | 10 ---------- package.json | 4 ++-- 3 files changed, 8 insertions(+), 26 deletions(-) delete mode 100644 build/tasks/copy-version.js diff --git a/build/prepare_deploy.js b/build/prepare_deploy.js index 74638103..31e7b3a8 100755 --- a/build/prepare_deploy.js +++ b/build/prepare_deploy.js @@ -5,28 +5,20 @@ require('shelljs/global'); var paths = require('./paths'); var path = require('path'); -// copy old releases -mkdir('-p', '.ghpages-tmp'); -cd('.ghpages-tmp'); - -// reset local changes before checkout -exec('git reset --hard'); -exec('git fetch origin gh-pages:gh-pages'); -exec('git checkout gh-pages'); -cp('-R', '../releases/*', '.'); -exec('git checkout @{-1}'); -cd('..'); +set('-e'); +set('-v'); // build exec('npm run build-dist'); cd('demo'); mkdir('-p', 'dist'); cp('-R', '../dist/*', './dist/'); -mkdir('-p', 'releases'); -cp('-R', '../.ghpages-tmp/*', './releases/'); cd('..'); + var version = 'v' + require(path.join(__dirname, '../package.json')).version + '/'; var versionDir = path.join(paths.releases, version); +var latestDir = path.join(paths.releases, 'latest/'); mkdir('-p', versionDir) +mkdir('-p', latestDir); cp(paths.redocBuilt + '.min.js', versionDir); -cp(paths.redocBuilt + '.min.js', path.join(paths.releases, 'latest/')); +cp(paths.redocBuilt + '.min.js', latestDir); diff --git a/build/tasks/copy-version.js b/build/tasks/copy-version.js deleted file mode 100644 index aaf93012..00000000 --- a/build/tasks/copy-version.js +++ /dev/null @@ -1,10 +0,0 @@ -var gulp = require('gulp'); -var path = require('path'); -var paths = require('../paths'); - -gulp.task('copy-version', function() { - var tag = 'v' + require(path.join(__dirname, '../../package.json')).version; - gulp.src(paths.redocBuilt + '.min.js') - .pipe(gulp.dest(path.join(paths.releases, tag))) - .pipe(gulp.dest(path.join(paths.releases, 'latest'))); -}); diff --git a/package.json b/package.json index 21a60c91..1f09a58a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "branch-release": "git reset --hard && branch-release", "unit": "gulp test", "e2e": "gulp e2e --prod", - "deploy": "node ./build/prepare_deploy.js && deploy-to-gh-pages demo" + "deploy": "node ./build/prepare_deploy.js && deploy-to-gh-pages --update demo" }, "keywords": [ "OpenAPI", @@ -76,7 +76,7 @@ "branch-release": "^0.3.2", "browser-sync": "^2.10.1", "del": "^2.2.0", - "deploy-to-gh-pages": "^1.0.0", + "deploy-to-gh-pages": "^1.1.2", "gulp": "^3.9.1", "gulp-concat": "^2.6.0", "gulp-eslint": "^1.1.1",