exec cue def test.cue test.json -o openapi:- -e '{#Output: #Test}'

cmp stdout stdout.golden

-- test.cue --
#Int: int
#Test: test: #Int

-- test.json --
{ }

-- stdout.golden --
{
    "openapi": "3.0.0",
    "info": {
        "title": "Generated by cue.",
        "version": "no version"
    },
    "paths": {},
    "components": {
        "schemas": {
            "Int": {
                "type": "integer"
            },
            "Output": {
                "$ref": "#/components/schemas/Test"
            },
            "Test": {
                "type": "object",
                "required": [
                    "test"
                ],
                "properties": {
                    "test": {
                        "$ref": "#/components/schemas/Int"
                    }
                }
            }
        }
    }
}