From f1e10dbf490de7d7144a50f14278a86243714848 Mon Sep 17 00:00:00 2001 From: Aleksandar Stojanov Date: Sun, 10 Dec 2023 15:09:37 +0100 Subject: [PATCH] add some docs --- README.md | 2 +- docs/README.md | 54 ++++++++++++++++++++++++++++++++++++--- testdata/full.schema.json | 5 ++++ testdata/full.yaml | 2 +- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4e54c95..a870f3c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![GitHub release (with filter)](https://img.shields.io/github/v/release/losisin/helm-values-schema-json)](https://github.com/losisin/helm-values-schema-json/releases) -Helm plugin for generating `values.schema.json` from single or multiple values files. Works only with Helm3 charts. +Helm plugin for generating `values.schema.json` from single or multiple values files. Schema can be enriched by reading annotations from comments. Works only with Helm3 charts. ## Installation diff --git a/docs/README.md b/docs/README.md index c0d27bd..07cae5b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,13 +1,61 @@ # Annotations from comments JSON schema is partially implemented in this tool. It uses line comments to add annotations for the schema because head comments are frequently used by humans and tools like helm-docs. The following annotations are supported: -* [Validation Keywords for Any Instance Type](#strings) + +* [Validation Keywords for Any Instance Type](#validation-keywords-for-any-instance-type) + * [Type](#type) + * [Enum](#enum) +* [Strings](#strings) + * [maxLength](#maxlength) + * [minLength](#minlength) + * [pattern](#pattern) * [Numbers](#numbers) + * [minimum](#minimum) + * [maximum](#maximum) + * [multipleOf](#multipleof) * [Booleans](#booleans) * [Arrays](#arrays) + * [minItems](#minitems) + * [maxItems](#maxitems) + * [uniqueItems](#uniqueitems) + * [Items](#items) * [Objects](#objects) + * [minProperties](#minproperties) + * [maxProperties](#maxproperties) + * [required](#required) * [Nulls](#nulls) -* [Required](#required) -* [Enum](#enum) ## Validation Keywords for Any Instance Type + +### Type + +The `type` keyword is used to restrict a value to a specific primitive type. There are several possible values for `type`: + +* `string` +* `number` +* `integer` +* `boolean` +* `object` +* `array` +* `null` + +Default behaviour returns always a string unless annotation is used. In that case, it returns array of strings. [section 6.1.1](https://json-schema.org/draft/2020-12/json-schema-validation#section-6.1.1) + +### Enum + +Always returns array of strings. Special case is `null` where instead of string, it is treated as valid inpput type. [section 6.1.2](https://json-schema.org/draft/2020-12/json-schema-validation#section-6.1.2) + +## Strings + +### maxLength + +NOn-negative integer. [section 6.3.1](https://json-schema.org/draft/2020-12/json-schema-validation#section-6.3.1) + +### minLength + +NOn-negative integer. [section 6.3.1](https://json-schema.org/draft/2020-12/json-schema-validation#section-6.3.2) + +### pattern + +String that is valid regular expression, according to the ECMA-262 regular expression dialect. [section 6.3.3](https://json-schema.org/draft/2020-12/json-schema-validation#section-6.3.3) + diff --git a/testdata/full.schema.json b/testdata/full.schema.json index 12cc891..281f256 100644 --- a/testdata/full.schema.json +++ b/testdata/full.schema.json @@ -121,6 +121,11 @@ "type": "integer" }, "service": { + "enum": [ + "ClusterIP", + "LoadBalancer", + null + ], "type": "string" }, "tolerations": { diff --git a/testdata/full.yaml b/testdata/full.yaml index ac3219a..2ee15b7 100644 --- a/testdata/full.yaml +++ b/testdata/full.yaml @@ -6,7 +6,7 @@ image: nameOverride: foo # @schema required: true # Enum -service: ClusterIP #schema enum: [ClusterIP, LoadBalancer] +service: ClusterIP # @schema enum: [ClusterIP, LoadBalancer, null] # NULL empty: # @schema type: [string, null]