Skip to content
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

Generated example does not contain properties of type "oneOf" #42

Open
JSteunou opened this issue Aug 6, 2020 · 1 comment
Open

Generated example does not contain properties of type "oneOf" #42

JSteunou opened this issue Aug 6, 2020 · 1 comment

Comments

@JSteunou
Copy link

JSteunou commented Aug 6, 2020

I have a schema like this

{
    "type": "object",
    "properties": {
        "monitor": {
            "type": "object",
            "properties": {
                "status": {
                    "oneOf": [
                        {
                            "type": "string",
                            "enum": ["ok"]
                        },
                        {
                            "type": "string",
                            "enum": ["ko"]
                        }
                    ]
                }
            },
            "required": ["status"]
        }
    },
    "required": ["monitor"]
}

generated with the nice library https://github.com/sinclairzx81/typebox but the generated example looks like

{
  "monitor": {}
}

whereas the interactive schema shows monitor* -> status* -> oneOf -> etc

For bigger schema it can be a problem because user easily jump on the example as documentation, and missing attributes are just ignored, MIA...

@JSteunou
Copy link
Author

JSteunou commented Aug 6, 2020

For those stuck with the same problem, this simple example can be solved with schema redefine like this:

{
    "type": "object",
    "properties": {
        "monitor": {
            "type": "object",
            "properties": {"status": {"type": "string"}},
            "required": ["status"]
        }
    },
    "required": ["monitor"]
}

But I have complex cases with no alternative, so the issue is still on :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant