Skip to content

how to force a field to be a specific type? #82

Closed
@benny-medflyt

Description

@benny-medflyt

I am trying to do something like:

/**
* How to force a Widget to be encoded as number?
*
* @type number
*/
export interface Widget {}

export interface House {
    name: string;

    mainWidget: Widget;
    otherWidgets: Widget[];
}

So that the mainWidget field is encoded as a regular "number", and also otherWidgets will be an array of numbers.

In other words I would like to get the following schema:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "properties": {
        "name": {
            "type": "string"
        },
        "mainWidget": {
            "type": "number"
        },
        "otherWidgets": {
            "items": {
                "type": "number"
            },
            "type": "array"
        }
    },
    "required": [
        "name",
        "mainWidget",
        "otherWidgets"
    ],
    "type": "object"
}

thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions