Compare commits
4
Commits
editor-1791
...
bug/4578
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08b2048917 | ||
|
|
889f4d1262 | ||
|
|
a86fcf312a | ||
|
|
815dbe0b5d |
@@ -41,10 +41,6 @@
|
|||||||
{
|
{
|
||||||
"expose": "less",
|
"expose": "less",
|
||||||
"src": "src/less"
|
"src": "src/less"
|
||||||
},
|
|
||||||
{
|
|
||||||
"expose": "base",
|
|
||||||
"src": "npm:getbase/src/less/base"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -141,9 +141,7 @@ module.exports = function(rules, options) {
|
|||||||
"node_modules"
|
"node_modules"
|
||||||
],
|
],
|
||||||
extensions: [".web.js", ".js", ".jsx", ".json", ".less"],
|
extensions: [".web.js", ".js", ".jsx", ".json", ".less"],
|
||||||
alias: {
|
alias: {}
|
||||||
base: "getbase/src/less/base",
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
devtool: specialOptions.sourcemaps ? "nosource-source-map" : false,
|
devtool: specialOptions.sourcemaps ? "nosource-source-map" : false,
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export const sampleFromSchema = (schema, config={}) => {
|
|||||||
let { type, example, properties, additionalProperties, items } = objectify(schema)
|
let { type, example, properties, additionalProperties, items } = objectify(schema)
|
||||||
let { includeReadOnly, includeWriteOnly } = config
|
let { includeReadOnly, includeWriteOnly } = config
|
||||||
|
|
||||||
|
|
||||||
if(example !== undefined) {
|
if(example !== undefined) {
|
||||||
return deeplyStripKey(example, "$$ref", (val) => {
|
return deeplyStripKey(example, "$$ref", (val) => {
|
||||||
// do a couple of quick sanity tests to ensure the value
|
// do a couple of quick sanity tests to ensure the value
|
||||||
|
|||||||
+1
-1
@@ -742,7 +742,7 @@ export const getCommonExtensions = (defObj) => defObj.filter((v, k) => /^pattern
|
|||||||
// `predicate` can be used to discriminate the stripping further,
|
// `predicate` can be used to discriminate the stripping further,
|
||||||
// by preserving the key's place in the object based on its value.
|
// by preserving the key's place in the object based on its value.
|
||||||
export function deeplyStripKey(input, keyToStrip, predicate = () => true) {
|
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
|
return input
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -379,6 +379,46 @@ describe("sampleFromSchema", function() {
|
|||||||
|
|
||||||
expect(sampleFromSchema(definition)).toEqual(expected)
|
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)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user