# @socialgouv/helm-schema

> [JSON Schema](https://json-schema.org) generator for your [HELM charts](https://helm.sh).

Latest version **1.2.4** (published 2023-11-11) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @socialgouv/helm-schema
pnpm add @socialgouv/helm-schema
yarn add @socialgouv/helm-schema
bun add @socialgouv/helm-schema
```

Provides the command `helm-schema`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.4 |
| Published | 2023-11-11 |
| First published | 2023-08-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16.17.0 |
| Dependencies | 2 |
| Unpacked size | 450 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | revolunet, socialgroovybot |

## Links

- npm: https://www.npmjs.com/package/@socialgouv/helm-schema
- npm.io page: https://npm.io/package/@socialgouv/helm-schema

## Dependencies (2)

- [yaml](https://npm.io/package/yaml.md) ^2.3.2
- [comment-parser](https://npm.io/package/comment-parser.md) ^1.4.0

## Recent versions

- 1.2.4 (latest) — 2023-11-11
- 1.2.3 — 2023-09-04
- 1.2.2 — 2023-08-30
- 1.2.1 — 2023-08-29
- 1.2.0 — 2023-08-29
- 1.1.1 — 2023-08-29
- 1.1.0 — 2023-08-29
- 1.0.6 — 2023-08-06
- 1.0.5 — 2023-08-04
- 1.0.4 — 2023-08-04
- 1.0.3 — 2023-08-04
- 1.0.2 — 2023-08-04
- 1.0.1 — 2023-08-04
- 1.0.0 — 2023-08-04

## README

# @socialgouv/helm-schema ![npm (scoped)](https://img.shields.io/npm/v/%40socialgouv/helm-schema)

[JSON Schema](https://json-schema.org) generator for your [HELM charts](https://helm.sh).

Demo : https://socialgouv.github.io/helm-schema

## Usage

Example `values.yaml`, following [JSDoc standards](https://devhints.io/jsdoc)

```yaml
# @param {object} smtp Your SMTP setup
smtp:
  # @param {string} host SMTP hostname
  host:
  # @param {number} [port] SMTP port
  port: 587

# Setup your securityContext to reduce security risks, see https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
# @param {https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.PodSecurityContext} [securityContext]
securityContext:
```

To generate a JSON schema from your `values.yaml` :

```sh
npx @socialgouv/helm-schema -f values.yaml
```

Or via TS :

```js
import { toJsonSchema } from "@socialgouv/helm-schema";

import yaml from "./values.yaml";

const schema = toJsonSchema(yaml);
```

You get such JSON schema in result :

```json
{
  "type": "object",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "required": ["smtp"],
  "properties": {
    "smtp": {
      "type": "object",
      "title": "Your SMTP setup",
      "required": ["host"],
      "properties": {
        "host": {
          "type": "string",
          "title": "SMTP hostname"
        },
        "port": {
          "type": "number",
          "title": "SMTP port",
          "default": "587"
        }
      }
    },
    "securityContext": {
      "$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.PodSecurityContext",
      "description": "Setup your securityContext to reduce security risks, see https://kubernetes.io/docs/tasks/configure-pod-container/security-context/"
    }
  }
}
```

This schema can then be used with your favorite editor for HELM values validation.

⚠️ Be sure to add an `$id` to the schema if its meant to be referenced from other schemas

## Dev

update snapshots : `yarn snapshots`

## Todo

- ~~multiline comments~~
- sections
- infer types from default values
- ~~handle arrays~~

---
_Source: https://npm.io/package/@socialgouv/helm-schema · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
