`union` schema type in `experimental.config.utils.schema`
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 15
- Forks
- 49
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 3
Description
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/config/utils_schema/
PR: https://github.com/tarantool/tarantool/pull/12621
Issue: https://github.com/tarantool/tarantool/issues/12539
Summary
The configuration schema module now supports a new schema node type: union.
schema.union() allows describing values that may match one of several schema variants. It is now used instead of legacy mixed scalar types such as string, number and number, string (these types should be dropped from documentation).
Suggested API shape:
schema.union({
variants = {
<schema node>,
<schema node>,
...
},
discriminator = <function>, -- optional
<annotations>
})
Where:
- variants is a non-empty array of schema nodes.
- discriminator is an optional function that selects one of the variants for a given value.
- If no discriminator is specified, union works for scalar variants that can be selected by Lua value type.
- Other schema annotations can be used in the same way as for other schema node types.
Behavior
A value is valid if it matches one of the union variants.
The new type is integrated with:
- schema validation;
- get() / set();
- JSON schema generation;
- environment variable parsing.
Migration note
The legacy scalar schema types string, number and number, string were removed from experimental.config.utils.schema.
Use schema.union() instead.
Example:
schema.union({
variants = {
schema.scalar({type = 'string'}),
schema.scalar({type = 'number'}),
},
})
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked configuration schema documentation at reference/reference_lua/config/utils_schema/. Document the experimental.config.utils.schema union node, including variants, optional discriminator, validation behavior, and the migration example; remove references to the legacy string, number and number, string scalar types. Verify the updated page and links in the documentation build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100