InseeFrLab / InseeFrLab/onyxia

FR: Derive default arrays from a schema tuple validation

Open
#970 7 comments 1 reaction 0 assignees View on GitHub
low priority
Dominant language
TypeScript
Stars
872
Forks
109
Avg merge
6d 3h
Merged PRs (30d)
1

Description

It would be useful to automatically infer a default value for `array`s when using a JSON schema **tuple validation**
(cf [json-schema reference](https://json-schema.org/understanding-json-schema/reference/array#tupleValidation)).

Ideally an `array`'s `prefixItems` should behave similarly to an `object`'s `properties`:
its default value should be the array whose elements are the default values derived from each specified `prefixItems`.

For example, the following `schema.json`:

```json
{
"title": "extraEnvVars",
"type": "array",
"prefixItems": [
{
"type": "object",
"properties": {
"name": {
"const": "USER_EMAIL"
},
"value": {
"type": "string",
"default": "",
"x-onyxia": {
"overwriteDefaultWith": "{{git.email}}"
}
}
}
},
{
"type": "object",
"properties": {
"name": {
"const": "USER_PASSWORD"
},
"value": {
"type": "string",
"default": "",
"x-onyxia": {
"overwriteDefaultWith": "{{service.oneTimePassword}}"
}
}
}
}
]
}
```

should be inferred the following default value (even if unspecified)

```yaml
extraEnvVars:
- name: USER_EMAIL
value: "Templated from git.email"
- name: USER_PASSWORD
value: "Templated from service.oneTimePassword"
```

In particular, and as illustrated in the example, this new feature would allow templated default values in `array`s.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.