From 815dbe0b5d70fe1a52c0290da33a3862a9af7acf Mon Sep 17 00:00:00 2001 From: kyle Date: Thu, 21 Jun 2018 23:01:18 -0700 Subject: [PATCH 1/3] housekeeping: remove extraneous `getbase` aliases (#4671) * remove extraneous Babel alias * remove extraneous Webpack alias --- .babelrc | 4 ---- make-webpack-config.js | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.babelrc b/.babelrc index 57276240..50f9abc8 100644 --- a/.babelrc +++ b/.babelrc @@ -41,10 +41,6 @@ { "expose": "less", "src": "src/less" - }, - { - "expose": "base", - "src": "npm:getbase/src/less/base" } ] ] diff --git a/make-webpack-config.js b/make-webpack-config.js index 74eae669..4408498d 100644 --- a/make-webpack-config.js +++ b/make-webpack-config.js @@ -141,9 +141,7 @@ module.exports = function(rules, options) { "node_modules" ], extensions: [".web.js", ".js", ".jsx", ".json", ".less"], - alias: { - base: "getbase/src/less/base", - } + alias: {} }, devtool: specialOptions.sourcemaps ? "nosource-source-map" : false, From a86fcf312a0d9b04d99982bf88a3d95884eddb9a Mon Sep 17 00:00:00 2001 From: kyle Date: Fri, 22 Jun 2018 21:28:19 -0700 Subject: [PATCH 2/3] improvement: re-enable and improve Models jump-to-path (#4674) --- src/core/components/models.jsx | 6 +++++- src/style/_models.scss | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/components/models.jsx b/src/core/components/models.jsx index 13469eec..86c82d7d 100644 --- a/src/core/components/models.jsx +++ b/src/core/components/models.jsx @@ -41,6 +41,7 @@ export default class Models extends Component { const ModelWrapper = getComponent("ModelWrapper") const Collapse = getComponent("Collapse") const ModelCollapse = getComponent("ModelCollapse") + const JumpToPath = getComponent("JumpToPath") return

layoutActions.show("models", !showModels)}> @@ -64,11 +65,13 @@ export default class Models extends Component { this.props.specActions.requestResolvedSubtree([...this.getSchemaBasePath(), name]) } + const specPath = Im.List([...specPathBase, name]) + const content = return
+ Date: Wed, 27 Jun 2018 19:40:00 -0700 Subject: [PATCH 3/3] fix(sample-gen): respect null values in examples (via #4679) * improvement: re-enable and improve Models jump-to-path * fix(sample-gen): respect null values in examples --- src/core/plugins/samples/fn.js | 1 + src/core/utils.js | 2 +- test/core/plugins/samples/fn.js | 40 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/core/plugins/samples/fn.js b/src/core/plugins/samples/fn.js index d7fa8cad..feabcec4 100644 --- a/src/core/plugins/samples/fn.js +++ b/src/core/plugins/samples/fn.js @@ -29,6 +29,7 @@ export const sampleFromSchema = (schema, config={}) => { let { type, example, properties, additionalProperties, items } = objectify(schema) let { includeReadOnly, includeWriteOnly } = config + if(example !== undefined) { return deeplyStripKey(example, "$$ref", (val) => { // do a couple of quick sanity tests to ensure the value diff --git a/src/core/utils.js b/src/core/utils.js index 3f77a1bf..793a29ec 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -742,7 +742,7 @@ export const getCommonExtensions = (defObj) => defObj.filter((v, k) => /^pattern // `predicate` can be used to discriminate the stripping further, // by preserving the key's place in the object based on its value. export function deeplyStripKey(input, keyToStrip, predicate = () => true) { - if(typeof input !== "object" || Array.isArray(input) || !keyToStrip) { + if(typeof input !== "object" || Array.isArray(input) || input === null || !keyToStrip) { return input } diff --git a/test/core/plugins/samples/fn.js b/test/core/plugins/samples/fn.js index a3266177..609ba24b 100644 --- a/test/core/plugins/samples/fn.js +++ b/test/core/plugins/samples/fn.js @@ -379,6 +379,46 @@ describe("sampleFromSchema", function() { expect(sampleFromSchema(definition)).toEqual(expected) }) + + it("returns null for a null example", function() { + var definition = { + "type": "object", + "properties": { + "foo": { + "type": "string", + "nullable": true, + "example": null + } + } + } + + var expected = { + foo: null + } + + expect(sampleFromSchema(definition)).toEqual(expected) + }) + + it("returns null for a null object-level example", function() { + var definition = { + "type": "object", + "properties": { + "foo": { + "type": "string", + "nullable": true + } + }, + "example": { + "foo": null + } + } + + var expected = { + foo: null + } + + expect(sampleFromSchema(definition)).toEqual(expected) + }) }) })