-- in.cue --
#One:{
	field1: #Id,
	if true { #Two}
}
#Two: { field2: string }
#Id: 1 | 2

-- out/TestGenerateOpenAPI/out.json --
{
   "openapi": "3.0.0",
   "info": {
      "title": "Generated by cue.",
      "version": "no version"
   },
   "paths": {},
   "components": {
      "schemas": {
         "Id": {
            "type": "integer",
            "enum": [
               1,
               2
            ]
         },
         "One": {
            "type": "object",
            "required": [
               "field1",
               "field2"
            ],
            "properties": {
               "field1": {
                  "$ref": "#/components/schemas/Id"
               },
               "field2": {
                  "type": "string"
               }
            }
         },
         "Two": {
            "type": "object",
            "required": [
               "field2"
            ],
            "properties": {
               "field2": {
                  "type": "string"
               }
            }
         }
      }
   }
}
