Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Multiple allowed in oneOf? #178

Open
jscheid opened this issue Feb 2, 2024 · 2 comments
Open

Multiple allowed in oneOf? #178

jscheid opened this issue Feb 2, 2024 · 2 comments
Assignees
Labels
awaiting_feedback Waiting for the reporter to respond question

Comments

@jscheid
Copy link

jscheid commented Feb 2, 2024

Kia Ora, I have a question: why does each member of the generated oneOf specify only what's required -- doesn't it mean that multiple members are allowed (one is required but multiple allowed) which runs counter to the semantics of oneof?

For example it's generating this:

"properties": {
    "event_a": {
        "$ref": "#/definitions/EventA",
    },
    "event_b": {
        "$ref": "#/definitions/EventB",
    }
},
"oneOf": [
    {
        "required": [
            "event_a"
        ]
    },
    {
        "required": [
            "event_b"
        ]
    }
],

... but I would have expected it to generate the following instead, so that only one of event_a or event_b can be present:

"oneOf": [
    {
        "properties": {
            "event_a": {
                "$ref": "#/definitions/EventA",
            },
        },
        "required": ["event_a"]
    },
    {
        "properties": {
            "event_b": {
                "$ref": "#/definitions/EventB",
            }
        },
        "required": ["event_b"]
    }
],
@chrusty
Copy link
Owner

chrusty commented Feb 12, 2024

Hi @jscheid, thanks for your question. I've just merged a PR which changes the behaviour of "oneOf". Would you be able to have a go with the laster master and let me know if it addresses your concerns?

@chrusty chrusty self-assigned this Feb 12, 2024
@chrusty chrusty added question awaiting_feedback Waiting for the reporter to respond labels Feb 12, 2024
@jscheid
Copy link
Author

jscheid commented Feb 13, 2024

Thanks, I'll take a look today or tomorrow!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting_feedback Waiting for the reporter to respond question
Projects
None yet
Development

No branches or pull requests

2 participants