From fdb485fa911d354f860fe69aed44b7900708f604 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sat, 9 Apr 2016 02:53:41 +0300 Subject: [PATCH 1/7] Add missing script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f76e15a8..785f0d2a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "branch-release": "git reset --hard && branch-release", "unit": "gulp test", "e2e": "gulp e2e", - "deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo" + "deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo", + "github-release": "gulp github-release" }, "keywords": [ "OpenAPI", From fc86c93d878e5440db2de6e7757badd3e4cf6f27 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 13 Apr 2016 14:21:56 +0300 Subject: [PATCH 2/7] Fix discriminator end-less recursion --- lib/components/JsonSchema/json-schema.html | 2 +- lib/components/JsonSchema/json-schema.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index d1377c59..cab1de2c 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -47,7 +47,7 @@
- +
diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 4434b935..552264e3 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -11,7 +11,7 @@ import JsonPointer from '../../utils/JsonPointer'; templateUrl: './lib/components/JsonSchema/json-schema.html', styleUrls: ['./lib/components/JsonSchema/json-schema.css'], directives: [JsonSchema, Tabs, Tab], - inputs: ['isArray', 'final', 'nestOdd'] + inputs: ['isArray', 'final', 'nestOdd', 'childFor'] }) @Reflect.metadata('parameters', [[SchemaManager], [ElementRef]]) export default class JsonSchema extends BaseComponent { @@ -74,6 +74,10 @@ export default class JsonSchema extends BaseComponent { let propertySchema = schema.properties[prop]; let propPointer = JsonPointer.join(schema._pointer || this.pointer, ['properties', prop]); propertySchema = JsonSchema.injectPropertyData(propertySchema, prop, propPointer); + // stop endless discriminator recursion + if (propertySchema._pointer === this.childFor) { + propertySchema._pointer = null; + } propertySchema.required = !!requiredMap[prop]; propertySchema.isDiscriminator = (schema.discriminator === prop); if (propertySchema.isDiscriminator) discriminatorFieldIdx = idx; From b097f1fdfaf81382120fce053e0e64a22b563e2f Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 13 Apr 2016 14:22:32 +0300 Subject: [PATCH 3/7] Don't show enum info for discriminator field --- lib/components/JsonSchema/json-schema.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 552264e3..ea93461a 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -80,7 +80,10 @@ export default class JsonSchema extends BaseComponent { } propertySchema.required = !!requiredMap[prop]; propertySchema.isDiscriminator = (schema.discriminator === prop); - if (propertySchema.isDiscriminator) discriminatorFieldIdx = idx; + if (propertySchema.isDiscriminator) { + discriminatorFieldIdx = idx; + propertySchema.enum = null; + } return propertySchema; }); // Move discriminator field to the end of properties list From 7562bc41f06daf50b1ac6e785bfbf7293287a243 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 13 Apr 2016 14:23:58 +0300 Subject: [PATCH 4/7] Nested schema ui minor fix --- lib/components/JsonSchema/json-schema.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/components/JsonSchema/json-schema.scss b/lib/components/JsonSchema/json-schema.scss index e32c0628..6970bd44 100644 --- a/lib/components/JsonSchema/json-schema.scss +++ b/lib/components/JsonSchema/json-schema.scss @@ -61,6 +61,12 @@ json-schema[nesteven="true"] { > .params-wrap > .param:first-of-type > .param-name:before, > .params-wrap > .param:last-of-type > .param-name:after { border-color: $side-menu-active-bg-color; } + + > .params-wrap > .param:last-of-type, > .params-wrap > .param.last { + > .param-name:after { + border-color: $side-menu-active-bg-color; + } + } } .param.complex > .param-info { From 6d2a49fb13d96bd64054e8af9ba9979bb2a828d8 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 13 Apr 2016 14:26:59 +0300 Subject: [PATCH 5/7] Minor font-weight fix --- lib/components/JsonSchema/json-schema.html | 2 +- lib/components/JsonSchema/json-schema.scss | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index cab1de2c..d61431ff 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -28,7 +28,7 @@
- This field value determines the exact schema: + This field value determines the exact schema:
  • {{derived.name}}
  • diff --git a/lib/components/JsonSchema/json-schema.scss b/lib/components/JsonSchema/json-schema.scss index 6970bd44..2c2a1b90 100644 --- a/lib/components/JsonSchema/json-schema.scss +++ b/lib/components/JsonSchema/json-schema.scss @@ -134,6 +134,11 @@ json-schema[nesteven="true"] { .discriminator-info { font-weight: $regular; margin-bottom: 10px; + + > span { + font-size: 0.9em; + font-weight: $light; + } } .discriminator-wrap > td { From 823c0e60c52093f1ba8969bbe1a7dab3005af12c Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 13 Apr 2016 15:46:41 +0300 Subject: [PATCH 6/7] Hanlde empty discriminator --- lib/components/JsonSchema/json-schema.html | 6 +++--- lib/components/JsonSchema/json-schema.js | 4 +++- lib/components/JsonSchema/json-schema.scss | 2 +- lib/utils/SchemaManager.js | 6 +++++- tests/unit/SchemaManager.spec.js | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index d61431ff..e764f016 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -11,7 +11,7 @@ - + diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index ea93461a..05e964af 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -27,6 +27,8 @@ export default class JsonSchema extends BaseComponent { subSchema.active = false; }); subClass.active = true; + this.derivedEmtpy = false; + if (subClass.empty) this.derivedEmtpy = true; } unwrapArray(schema) { @@ -54,13 +56,13 @@ export default class JsonSchema extends BaseComponent { runInjectors(schema, schema, schema._pointer || this.pointer); schema.derived = schema.derived || []; - if (schema.derived.length) schema.derived[0].active = true; if (!schema.isTrivial) { this.prepareObjectPropertiesData(schema); } this.schema = schema; + if (schema.derived.length) this.selectDerived(schema.derived[0]); } prepareObjectPropertiesData(schema) { diff --git a/lib/components/JsonSchema/json-schema.scss b/lib/components/JsonSchema/json-schema.scss index 2c2a1b90..a24d883f 100644 --- a/lib/components/JsonSchema/json-schema.scss +++ b/lib/components/JsonSchema/json-schema.scss @@ -141,7 +141,7 @@ json-schema[nesteven="true"] { } } -.discriminator-wrap > td { +.discriminator-wrap:not(.empty) > td { //border-left: $line-border; padding: 0; position: relative; diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index b3f9dca4..3ba6f650 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -179,7 +179,11 @@ export default class SchemaManager { }); if (idx < 0) continue; - res.push({name: defName, $ref: `#/definitions/${defName}`}); + let empty = false; + if (subTypes.length === 1) { + empty = true; + } + res.push({name: defName, $ref: `#/definitions/${defName}`, empty}); } return res; } diff --git a/tests/unit/SchemaManager.spec.js b/tests/unit/SchemaManager.spec.js index 1ec4ec87..e436093d 100644 --- a/tests/unit/SchemaManager.spec.js +++ b/tests/unit/SchemaManager.spec.js @@ -238,7 +238,7 @@ describe('Utils', () => { let deriveDefs = schemaMgr.findDerivedDefinitions('#/definitions/Pet'); deriveDefs.should.be.instanceof(Array); deriveDefs.should.not.be.empty(); - deriveDefs.should.be.deepEqual([{name: 'Cat', $ref: '#/definitions/Cat'}, {name: 'Dog', $ref: '#/definitions/Dog'}]); + deriveDefs.should.be.deepEqual([{name: 'Cat', empty: false, $ref: '#/definitions/Cat'}, {name: 'Dog', empty: false, $ref: '#/definitions/Dog'}]); }); it('should return emtpy array for definitions that dont have discriminator', () => { From d6a994c54eccb6ea3c5a19b747e3d18afd0a653d Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 13 Apr 2016 15:47:04 +0300 Subject: [PATCH 7/7] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 785f0d2a..38e974ba 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "redoc", "description": "Swagger-generated API Reference Documentation", - "version": "0.7.11", + "version": "0.7.12", "repository": { "type": "git", "url": "git://github.com/Rebilly/ReDoc"
    - +