Skip to content

Commit

Permalink
Use empty items when array types cannot be identified #51
Browse files Browse the repository at this point in the history
  • Loading branch information
fmulero authored Oct 11, 2022
2 parents 51701b9 + eb7e05d commit 498ea5d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 95 deletions.
4 changes: 1 addition & 3 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ function generateSchema(value, tree, properties, ignoreDefault = false) {
// The last element of the tree is an array. It is a plain or empty array since if not, the tree would have more elements
if (value.value == null || value.value.length === 0) {
// When it is an empty array
properties[tree[i]].items = {
type: "", //TODO: how do we know the type in empty arrays?
};
properties[tree[i]].items = {}; //TODO: how do we know the type in empty arrays?
} else {
properties[tree[i]].items = { type: (typeof value.value[0]) };
}
Expand Down
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "readme-generator-for-helm",
"version": "2.4.0",
"version": "2.4.1",
"description": "Autogenerate READMEs' tables for Bitnami Helm Charts",
"main": "index.js",
"scripts": {
Expand Down
48 changes: 12 additions & 36 deletions tests/expected-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"type": "array",
"description": "Global Docker registry secret names as an array",
"default": [],
"items": {
"type": ""
}
"items": {}
}
}
},
Expand Down Expand Up @@ -44,17 +42,13 @@
"type": "array",
"description": "Array of extra objects to deploy with the release",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"hostAliases": {
"type": "array",
"description": "Add deployment host aliases",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"image": {
"type": "object",
Expand Down Expand Up @@ -83,9 +77,7 @@
"type": "array",
"description": "Specify docker-registry secret names as an array",
"default": [],
"items": {
"type": ""
}
"items": {}
}
}
},
Expand Down Expand Up @@ -323,17 +315,13 @@
"type": "array",
"description": "Override default container command (useful when using custom images)",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"args": {
"type": "array",
"description": "Override default container args (useful when using custom images)",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"extraEnvVars": {
"type": "array",
Expand Down Expand Up @@ -524,9 +512,7 @@
"type": "array",
"description": "Node label values to match. Ignored if `affinity` is set",
"default": [],
"items": {
"type": ""
}
"items": {}
}
}
},
Expand All @@ -544,9 +530,7 @@
"type": "array",
"description": "Tolerations for pod assignment",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"podLabels": {
"type": "object",
Expand All @@ -562,17 +546,13 @@
"type": "array",
"description": "Optionally specify extra list of additional volumes for Kubewatch pods",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"extraVolumeMounts": {
"type": "array",
"description": "Optionally specify extra list of additional volumeMounts for Kubewatch container(s)",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"initContainers": {
"type": "object",
Expand Down Expand Up @@ -766,9 +746,7 @@
"description": "Nullable null array. We apply array modifier that will change the type in the schema plus `nullable: true`.",
"default": null,
"nullable": true,
"items": {
"type": ""
}
"items": {}
},
"nullableNullString": {
"type": "string",
Expand All @@ -793,9 +771,7 @@
"description": "Nullable parameter with an array value",
"default": [],
"nullable": true,
"items": {
"type": ""
}
"items": {}
},
"arrayEmptyModifier": {
"type": "array",
Expand Down
48 changes: 12 additions & 36 deletions tests/test-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"type": "array",
"description": "Global Docker registry secret names as an array",
"default": [],
"items": {
"type": ""
}
"items": {}
}
}
},
Expand Down Expand Up @@ -44,17 +42,13 @@
"type": "array",
"description": "Array of extra objects to deploy with the release",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"hostAliases": {
"type": "array",
"description": "Add deployment host aliases",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"image": {
"type": "object",
Expand Down Expand Up @@ -83,9 +77,7 @@
"type": "array",
"description": "Specify docker-registry secret names as an array",
"default": [],
"items": {
"type": ""
}
"items": {}
}
}
},
Expand Down Expand Up @@ -323,17 +315,13 @@
"type": "array",
"description": "Override default container command (useful when using custom images)",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"args": {
"type": "array",
"description": "Override default container args (useful when using custom images)",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"extraEnvVars": {
"type": "array",
Expand Down Expand Up @@ -524,9 +512,7 @@
"type": "array",
"description": "Node label values to match. Ignored if `affinity` is set",
"default": [],
"items": {
"type": ""
}
"items": {}
}
}
},
Expand All @@ -544,9 +530,7 @@
"type": "array",
"description": "Tolerations for pod assignment",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"podLabels": {
"type": "object",
Expand All @@ -562,17 +546,13 @@
"type": "array",
"description": "Optionally specify extra list of additional volumes for Kubewatch pods",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"extraVolumeMounts": {
"type": "array",
"description": "Optionally specify extra list of additional volumeMounts for Kubewatch container(s)",
"default": [],
"items": {
"type": ""
}
"items": {}
},
"initContainers": {
"type": "object",
Expand Down Expand Up @@ -766,9 +746,7 @@
"description": "Nullable null array. We apply array modifier that will change the type in the schema plus `nullable: true`.",
"default": null,
"nullable": true,
"items": {
"type": ""
}
"items": {}
},
"nullableNullString": {
"type": "string",
Expand All @@ -793,9 +771,7 @@
"description": "Nullable parameter with an array value",
"default": [],
"nullable": true,
"items": {
"type": ""
}
"items": {}
},
"arrayEmptyModifier": {
"type": "array",
Expand Down

0 comments on commit 498ea5d

Please sign in to comment.