Skip to content

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

Open
@TarantoolBot

Description

@TarantoolBot

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.3reference[location] Tarantool manual, Reference part

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions