cuelang.org/go@v0.13.0/encoding/openapi/testdata/builtins.txtar (about) 1 -- in.cue -- 2 import ( 3 "time" 4 "list" 5 ) 6 7 let _time = time 8 9 #MyStruct: { 10 timestamp1?: time.Time 11 timestamp2?: time.Time() 12 timestamp3?: time.Format(time.RFC3339Nano) 13 timestamp4?: _time.Time 14 date1?: time.Format(time.RFC3339Date) 15 date2?: _time.Format(time.RFC3339Date) 16 17 // This is not an OpenAPI type and has no format. In this case 18 // we map to a type so that it can be documented properly (without 19 // repeating it). 20 timeout?: time.Duration 21 22 contains: list.Contains("foo") // not supported, but should be recognized as list 23 } 24 25 -- out/TestGenerateOpenAPI/out.json -- 26 { 27 "openapi": "3.0.0", 28 "info": { 29 "title": "Generated by cue.", 30 "version": "no version" 31 }, 32 "paths": {}, 33 "components": { 34 "schemas": { 35 "Duration": { 36 "type": "string" 37 }, 38 "MyStruct": { 39 "type": "object", 40 "required": [ 41 "contains" 42 ], 43 "properties": { 44 "timestamp1": { 45 "type": "string", 46 "format": "date-time" 47 }, 48 "timestamp2": { 49 "type": "string", 50 "format": "date-time" 51 }, 52 "timestamp3": { 53 "type": "string", 54 "format": "date-time" 55 }, 56 "timestamp4": { 57 "type": "string", 58 "format": "date-time" 59 }, 60 "date1": { 61 "type": "string", 62 "format": "date" 63 }, 64 "date2": { 65 "type": "string", 66 "format": "date" 67 }, 68 "timeout": { 69 "$ref": "#/components/schemas/Duration" 70 }, 71 "contains": { 72 "type": "array" 73 } 74 } 75 } 76 } 77 } 78 }