Skip to content

[Feature Request] Add support to JSON Schema "default" keyword #396

@caio-porto

Description

@caio-porto

It would be great if we could generate a JSON Schema with Default fields based on the struct initial value.

For instance:

C++ Struct

struct Foo {
    bool value1 = false;
    double value2 = 1.0;
}

JSON Schema

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$ref": "#/definitions/foo",
    "definitions": {
        "Foo": {
            "type": "object",
            "properties": {
                "value1": {
                    "type": "boolean",
                    "default": false
                },
                "value2": {
                    "type": "number",
                    "default": 1.0
                }
            },
            "required": [
                "value1",
                "value2"
            ]
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions