cue icon indicating copy to clipboard operation
cue copied to clipboard

encoding/openapi: invalid value for "items" keyword

Open rogpeppe opened this issue 1 year ago • 0 comments

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

v0.10.0

Does this issue reproduce with the latest stable release?

Yes

What did you do?

exec cue def --out openapi file.cue
! stdout '"items": *\['
-- file.cue --
#a: x?: [1, 2]

What did you expect to see?

A passing test. The OpenAPI 3.0 spec says:

Value MUST be an object and not an array. Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.

The output should specify an object that covers the types of all items in the array.

What did you see instead?

> exec cue def --out openapi file.cue
[stdout]
{
    "openapi": "3.0.0",
    "info": {
        "title": "Generated by cue.",
        "version": "no version"
    },
    "paths": {},
    "components": {
        "schemas": {
            "a": {
                "type": "object",
                "properties": {
                    "x": {
                        "type": "array",
                        "items": [
                            {
                                "type": "integer",
                                "enum": [
                                    1
                                ]
                            },
                            {
                                "type": "integer",
                                "enum": [
                                    2
                                ]
                            }
                        ],
                        "enum": [
                            [
                                1,
                                2
                         ]
                        ],
                        "default": [
                            1,
                            2
                        ]
                    }
                }
            }
        }
    }
}
> ! stdout '"items": *\['
FAIL: /tmp/y.txtar:2: unexpected match for `"items": *\[` found in stdout: "items": [

rogpeppe avatar Oct 07 '24 09:10 rogpeppe