Page 1 of 1

Unexpected json schema errors

Posted: Mon Jan 25, 2021 9:21 pm
by davidmichaelkarr
Perhaps I'm just doing something invalid with json schema, but perhaps not. I have a StackOverflow question pending on this, if that's the issue.

I wanted to define an enum type in my schema, and also use that enum type in other types in the same schema. I noticed the following SO posting, which seemed to cover at least the definition part of this: https://stackoverflow.com/questions/377 ... son-schema .

So, I defined a schema, which this is an excerpt of:

Code: Select all

{
    "$schema": "https://json-schema.org/draft/2019-09/schema#",
    "type": "object",
    "properties": {
        "content": {"$ref": "#/definitions/content_type"}
    },
    "additionalProperties": false,
    "definitions": {
        "costCategory_type": {
            "type": "object",
            "enum": ["VH", "H", "M", "L"]  
        },
        "allowedDevices_type": {
            "type": "object",
            "properties": {
                "costCategory": {
                    "type": "costCategory_type"
                },
On the line near the bottom of this, where I reference "costCategory_type", Oxygen gives me a syntax error, saying
#/definitions/allowedDevices_type/properties/costCategory/type: unknown type: [costCategory_type]
What am I missing?

Re: Unexpected json schema errors

Posted: Tue Jan 26, 2021 12:20 am
by davidmichaelkarr
I got an answer on StackOverflow. I have to make them type "string" and use the "$ref" and "#/definitions/..." syntax.