Compare commits

...
7 changed files with 56 additions and 9 deletions
-4
View File
@@ -41,10 +41,6 @@
{
"expose": "less",
"src": "src/less"
},
{
"expose": "base",
"src": "npm:getbase/src/less/base"
}
]
]
+1 -3
View File
@@ -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,
+5 -1
View File
@@ -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 <section className={ showModels ? "models is-open" : "models"}>
<h4 onClick={() => 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 = <ModelWrapper name={ name }
expandDepth={ defaultModelsExpandDepth }
schema={ schema || Im.Map() }
displayName={displayName}
specPath={Im.List([...specPathBase, name])}
specPath={specPath}
getComponent={ getComponent }
specSelectors={ specSelectors }
getConfigs = {getConfigs}
@@ -82,6 +85,7 @@ export default class Models extends Component {
</span>
return <div id={ `model-${name}` } className="model-container" key={ `models-section-${name}` }>
<span className="models-jump-to-path"><JumpToPath specPath={specPath} /></span>
<ModelCollapse
classes="model-box"
collapsedContent={this.getCollapsedContent(name)}
+1
View File
@@ -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
+1 -1
View File
@@ -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
}
+8
View File
@@ -166,6 +166,7 @@ section.models
.model-container
{
margin: 0 20px 15px;
position: relative;
transition: all .5s;
@@ -186,6 +187,13 @@ section.models
{
margin: 0 20px;
}
.models-jump-to-path {
position: absolute;
top: 8px;
right: 5px;
opacity: 0.65;
}
}
.model-box
+40
View File
@@ -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)
})
})
})