Skip to content

experimental.config.utils.schema: JSON schema for schema object. #4658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
TarantoolBot opened this issue Nov 26, 2024 · 0 comments
Open

experimental.config.utils.schema: JSON schema for schema object. #4658

TarantoolBot opened this issue Nov 26, 2024 · 0 comments
Labels
3.3 reference [location] Tarantool manual, Reference part

Comments

@TarantoolBot
Copy link
Collaborator

TarantoolBot commented Nov 26, 2024

Dev. issue: tarantool/tarantool#10636

Product: Tarantool
Since: 3.3.0
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/config/utils_schema/
SME: @ mandesero

Details

Connected with #4659, #4660

Brief API description
The schema object has the new method:

  • Generate JSON schema as lua table
<schema object>:jsonschema() -> lua table

Detailed API description
Example:
You can obtain the JSON schema representation of a ,
encode it using json.encode(), and integrate it with tools like
VSCode or similar.

local json = require('json')
local schema = require('experimental.config.utils.schema')

local my_schema = schema.new('my_schema', schema.record({
    name = schema.scalar({
        type = 'string'
    }),
    list = schema.array({
        items = schema.scalar({
            type = 'string'
        })
    }),
}))

local json_schema = json.encode(my_schema:jsonschema())
...

Requested by @mandesero in tarantool/tarantool@ea5d3cd.

@p7nov p7nov self-assigned this Dec 3, 2024
@p7nov p7nov added 3.3 reference [location] Tarantool manual, Reference part labels Dec 3, 2024
@p7nov p7nov removed their assignment Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.3 reference [location] Tarantool manual, Reference part
Projects
None yet
Development

No branches or pull requests

2 participants