Skip to content

Commit

Permalink
add number modifier to default configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Pearson Radu <62548051+pearsonradu@users.noreply.github.com>
  • Loading branch information
pearsonradu committed Mar 25, 2024
1 parent 0eeb6ae commit 3fa2463
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 8 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Currently supported modifiers:
- `[string]` Indicates that the value of the parameter must be set to `""`.
- `[nullable]` Indicates that the parameter value can be set to `null`.
- `[default: DEFAULT_VALUE]` Sets the default value to `DEFAULT_VALUE`.
- `[number]` Indicates that the value of the parameter must be set to a number (ex. `0`).

The modifiers are also customizable via the [configuration file](#configuration-file).

Expand All @@ -141,8 +142,8 @@ Custom configuration snippet:
...
"modifiers": {
"array": "array",
"object": "object"
"string": "string"
"object": "object",
"string": "string",
"nullable": "nullable",
"number": "number"
},
Expand All @@ -169,9 +170,10 @@ The configuration file has the following structure:
},
"modifiers": {
"array": "array", <-- Modifier that indicates an array type
"object": "object" <-- Modifier that indicates an object type
"string": "string" <-- Modifier that indicates a string type
"nullable": "nullable" <-- Modifier that indicates a parameter that can be set to null
"object": "object", <-- Modifier that indicates an object type
"string": "string", <-- Modifier that indicates a string type
"nullable": "nullable", <-- Modifier that indicates a parameter that can be set to null
"number": "number" <-- Modifier that indicates a number type
},
"regexp": {
"paramsSectionTitle": "Parameters" <-- Title of the parameters section to replace in the README.md
Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"array": "array",
"object": "object",
"string": "string",
"number": "number",
"nullable": "nullable",
"default": "default"
},
Expand Down
3 changes: 3 additions & 0 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ function renderOpenAPISchema(schemaFilePath, parametersList, config) {
case `${config.modifiers.string}`:
p.type = 'string';
break;
case `${config.modifiers.number}`:
p.type = 'number';
break;
default:
break;
}
Expand Down
4 changes: 2 additions & 2 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": "@bitnami/readme-generator-for-helm",
"version": "2.6.1",
"version": "2.7.0",
"description": "Autogenerate READMEs tables and OpenAPI schemas for Helm Charts",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions tests/expected-readme.first-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ This description starts in a new line instead of the same line of description st
| `serviceAccount.name` | Name of the created ServiceAccount | `""` |
| `inventedArray` | Test parameter to check arrays | `["a","b"]` |
| `arrayModifier` | Test parameter for modifier array | `[]` |
| `numberModifier` | Test parameter for modifier number | `0` |
| `configuration` | haproxy configuration | `""` |
| `jobs[0].nameOverride` | String to partially override jobs.names.fullname | `""` |
| `jobs[0].fullnameOverride` | String to fully override jobs.names.fullname | `""` |
Expand All @@ -137,6 +138,7 @@ This description starts in a new line instead of the same line of description st
| `nullableNullStringWithValueChange` | Nullable null string. We apply string modifier that will change the type and value, but the schema will show `nullable: true`. | `""` |
| `nullableNullArray` | Nullable null array. We apply array modifier that will change the type in the schema plus `nullable: true`. | `nil` |
| `nullableNullString` | Nullable null string. We apply string modifier to avoid infering an object type. The null must be preverved as value. | `nil` |
| `nullableNullNumber` | Nullable null number. We apply number modifier to avoid infering an object type. The null must be preverved as value. | `nil` |
| `nullableNotNull` | Nullable parameter with a non null value | `somestring` |
| `nullableObject` | Nullable parameter with an object value | `{}` |
| `nullableArray` | Nullable parameter with an array value | `[]` |
Expand Down
2 changes: 2 additions & 0 deletions tests/expected-readme.last-section-text-below.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ This description starts in a new line instead of the same line of description st
| `serviceAccount.name` | Name of the created ServiceAccount | `""` |
| `inventedArray` | Test parameter to check arrays | `["a","b"]` |
| `arrayModifier` | Test parameter for modifier array | `[]` |
| `numberModifier` | Test parameter for modifier number | `0` |
| `configuration` | haproxy configuration | `""` |
| `jobs[0].nameOverride` | String to partially override jobs.names.fullname | `""` |
| `jobs[0].fullnameOverride` | String to fully override jobs.names.fullname | `""` |
Expand All @@ -175,6 +176,7 @@ This description starts in a new line instead of the same line of description st
| `nullableNullStringWithValueChange` | Nullable null string. We apply string modifier that will change the type and value, but the schema will show `nullable: true`. | `""` |
| `nullableNullArray` | Nullable null array. We apply array modifier that will change the type in the schema plus `nullable: true`. | `nil` |
| `nullableNullString` | Nullable null string. We apply string modifier to avoid infering an object type. The null must be preverved as value. | `nil` |
| `nullableNullNumber` | Nullable null number. We apply number modifier to avoid infering an object type. The null must be preverved as value. | `nil` |
| `nullableNotNull` | Nullable parameter with a non null value | `somestring` |
| `nullableObject` | Nullable parameter with an object value | `{}` |
| `nullableArray` | Nullable parameter with an array value | `[]` |
Expand Down
2 changes: 2 additions & 0 deletions tests/expected-readme.last-section.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ This description starts in a new line instead of the same line of description st
| `serviceAccount.name` | Name of the created ServiceAccount | `""` |
| `inventedArray` | Test parameter to check arrays | `["a","b"]` |
| `arrayModifier` | Test parameter for modifier array | `[]` |
| `numberModifier` | Test parameter for modifier number | `0` |
| `configuration` | haproxy configuration | `""` |
| `jobs[0].nameOverride` | String to partially override jobs.names.fullname | `""` |
| `jobs[0].fullnameOverride` | String to fully override jobs.names.fullname | `""` |
Expand All @@ -175,6 +176,7 @@ This description starts in a new line instead of the same line of description st
| `nullableNullStringWithValueChange` | Nullable null string. We apply string modifier that will change the type and value, but the schema will show `nullable: true`. | `""` |
| `nullableNullArray` | Nullable null array. We apply array modifier that will change the type in the schema plus `nullable: true`. | `nil` |
| `nullableNullString` | Nullable null string. We apply string modifier to avoid infering an object type. The null must be preverved as value. | `nil` |
| `nullableNullNumber` | Nullable null number. We apply number modifier to avoid infering an object type. The null must be preverved as value. | `nil` |
| `nullableNotNull` | Nullable parameter with a non null value | `somestring` |
| `nullableObject` | Nullable parameter with an object value | `{}` |
| `nullableArray` | Nullable parameter with an array value | `[]` |
Expand Down
2 changes: 2 additions & 0 deletions tests/expected-readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ This description starts in a new line instead of the same line of description st
| `serviceAccount.name` | Name of the created ServiceAccount | `""` |
| `inventedArray` | Test parameter to check arrays | `["a","b"]` |
| `arrayModifier` | Test parameter for modifier array | `[]` |
| `numberModifier` | Test parameter for modifier number | `0` |
| `configuration` | haproxy configuration | `""` |
| `jobs[0].nameOverride` | String to partially override jobs.names.fullname | `""` |
| `jobs[0].fullnameOverride` | String to fully override jobs.names.fullname | `""` |
Expand All @@ -175,6 +176,7 @@ This description starts in a new line instead of the same line of description st
| `nullableNullStringWithValueChange` | Nullable null string. We apply string modifier that will change the type and value, but the schema will show `nullable: true`. | `""` |
| `nullableNullArray` | Nullable null array. We apply array modifier that will change the type in the schema plus `nullable: true`. | `nil` |
| `nullableNullString` | Nullable null string. We apply string modifier to avoid infering an object type. The null must be preverved as value. | `nil` |
| `nullableNullNumber` | Nullable null number. We apply number modifier to avoid infering an object type. The null must be preverved as value. | `nil` |
| `nullableNotNull` | Nullable parameter with a non null value | `somestring` |
| `nullableObject` | Nullable parameter with an object value | `{}` |
| `nullableArray` | Nullable parameter with an array value | `[]` |
Expand Down
11 changes: 11 additions & 0 deletions tests/expected-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,11 @@
"type": "string"
}
},
"numberModifier": {
"type": "number",
"description": "Test parameter for modifier number",
"default": 0
},
"configuration": {
"type": "string",
"description": "haproxy configuration",
Expand Down Expand Up @@ -689,6 +694,12 @@
"default": null,
"nullable": true
},
"nullableNullNumber": {
"type": "number",
"description": "Nullable null number. We apply number modifier to avoid infering an object type. The null must be preverved as value.",
"default": null,
"nullable": true
},
"nullableNotNull": {
"type": "string",
"description": "Nullable parameter with a non null value",
Expand Down
2 changes: 2 additions & 0 deletions tests/test-readme.last-section-text-below.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ This description starts in a new line instead of the same line of description st
| `serviceAccount.name` | Name of the created ServiceAccount | `""` |
| `inventedArray` | Test parameter to check arrays | `["a","b"]` |
| `arrayModifier` | Test parameter for modifier array | `[]` |
| `numberModifier` | Test parameter for modifier number | `0` |
| `configuration` | haproxy configuration | `""` |
| `jobs[0].nameOverride` | String to partially override jobs.names.fullname | `""` |
| `jobs[0].fullnameOverride` | String to fully override jobs.names.fullname | `""` |
Expand All @@ -175,6 +176,7 @@ This description starts in a new line instead of the same line of description st
| `nullableNullStringWithValueChange` | Nullable null string. We apply string modifier that will change the type and value, but the schema will show `nullable: true`. | `""` |
| `nullableNullArray` | Nullable null array. We apply array modifier that will change the type in the schema plus `nullable: true`. | `nil` |
| `nullableNullString` | Nullable null string. We apply string modifier to avoid infering an object type. The null must be preverved as value. | `nil` |
| `nullableNullNumber` | Nullable null number. We apply number modifier to avoid infering an object type. The null must be preverved as value. | `nil` |
| `nullableNotNull` | Nullable parameter with a non null value | `somestring` |
| `nullableObject` | Nullable parameter with an object value | `{}` |
| `nullableArray` | Nullable parameter with an array value | `[]` |
Expand Down
Loading

0 comments on commit 3fa2463

Please sign in to comment.