diff --git a/tools/docs/schema.ts b/tools/docs/schema.ts index 293e713af91ba0..3cafa6d9c30368 100644 --- a/tools/docs/schema.ts +++ b/tools/docs/schema.ts @@ -21,8 +21,20 @@ options.sort((a, b) => { }); const properties = schema.properties as Record; +type JsonSchemaBasicType = + | 'string' + | 'number' + | 'integer' + | 'boolean' + | 'object' + | 'array' + | 'null'; +type JsonSchemaType = JsonSchemaBasicType | JsonSchemaBasicType[]; + function createSingleConfig(option: RenovateOptions): Record { - const temp: Record & Partial = {}; + const temp: Record & { + type?: JsonSchemaType; + } & Omit, 'type'> = {}; if (option.description) { temp.description = option.description; } @@ -67,7 +79,13 @@ function createSingleConfig(option: RenovateOptions): Record { ) { temp.additionalProperties = option.additionalProperties; } - if (temp.type === 'object' && !option.freeChoice) { + if (option.default === null) { + temp.type = [option.type, 'null']; + } + if ( + (temp.type === 'object' || temp.type?.includes('object')) && + !option.freeChoice + ) { temp.$ref = '#'; } return temp;