Skip to content

Commit

Permalink
add some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
losisin committed Dec 10, 2023
1 parent e1b464b commit f1e10db
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
54 changes: 51 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -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)

5 changes: 5 additions & 0 deletions testdata/full.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@
"type": "integer"
},
"service": {
"enum": [
"ClusterIP",
"LoadBalancer",
null
],
"type": "string"
},
"tolerations": {
Expand Down
2 changes: 1 addition & 1 deletion testdata/full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit f1e10db

Please sign in to comment.