cuelang / cue

CUE has moved to https://github.com/cue-lang/cue
https://cuelang.org
Apache License 2.0
3.09k stars 171 forks source link

[regression] cue def openapi fails to handle disjunctions #1058

Closed eadlam closed 3 years ago

eadlam commented 3 years ago

What version of CUE are you using (cue version)?

$ cue version
cue version v0.4.0 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

main.cue

#A: {}
#blocks: a: {a: #A}

#B: {}
#blocks: b: {b: #B}

#Block: or([for k, v in #blocks {v}])
$ cue def main.cue -o openapi:example.openapi.json

What did you expect to see?

Note: this works correctly in v0.4.0-rc.1 example.openapi.json

{
    "openapi": "3.0.0",
    "info": {
        "title": "Generated by cue.",
        "version": "no version"
    },
    "paths": {},
    "components": {
        "schemas": {
            "A": {
                "type": "object"
            },
            "B": {
                "type": "object"
            },
            "Block": {
                "type": "object",
                "oneOf": [
                    {
                        "required": [
                            "a"
                        ],
                        "properties": {
                            "a": {
                                "$ref": "#/components/schemas/A"
                            }
                        }
                    },
                    {
                        "required": [
                            "b"
                        ],
                        "properties": {
                            "b": {
                                "$ref": "#/components/schemas/B"
                            }
                        }
                    }
                ]
            },
            ...
        }
    }
}

What did you see instead?

example.openapi.json

{
    "openapi": "3.0.0",
    "info": {
        "title": "Generated by cue.",
        "version": "no version"
    },
    "paths": {},
    "components": {
        "schemas": {
            "A": {
                "type": "object"
            },
            "B": {
                "type": "object"
            },
            "Block": {
                "type": "object",
                "oneOf": [
                    {
                        "$ref": "#/components/schemas/_.v"
                    },
                    {
                        "$ref": "#/components/schemas/_.v"
                    }
                ]
            },
            ...
        }
    }
}
eadlam commented 3 years ago

This worked correctly on v0.4.0-rc.1 but fails on v0.4.0.

cueckoo commented 3 years ago

This issue has been migrated to https://github.com/cue-lang/cue/issues/1058.

For more details about CUE's migration to a new home, please see https://github.com/cue-lang/cue/issues/1078.