cuelang.org/go@v0.13.0/encoding/openapi/testdata/script/basics.txtar (about) 1 -- type.yaml -- 2 openapi: 3.0.0 3 info: 4 title: Users schema 5 version: v1beta1 6 contact: 7 name: The CUE Authors 8 url: https://cuelang.org 9 10 components: 11 schemas: 12 User: 13 description: "A User uses something." 14 type: object 15 properties: 16 id: 17 type: integer 18 name: 19 type: string 20 address: 21 $ref: "#/components/schemas/PhoneNumber" 22 PhoneNumber: 23 description: "The number to dial." 24 type: string 25 26 -- out.cue -- 27 // Users schema 28 package foo 29 30 info: { 31 title: *"Users schema" | string 32 version: *"v1beta1" | string 33 contact: { 34 name: "The CUE Authors" 35 url: "https://cuelang.org" 36 } 37 } 38 // The number to dial. 39 #PhoneNumber: string 40 41 // A User uses something. 42 #User: { 43 id?: int 44 name?: string 45 address?: #PhoneNumber 46 ... 47 } 48 -- out/TestGenerateOpenAPI/out.json -- 49 { 50 "openapi": "3.0.0", 51 "info": { 52 "title": "Users schema", 53 "version": "v1beta1", 54 "contact": { 55 "name": "The CUE Authors", 56 "url": "https://cuelang.org" 57 } 58 }, 59 "paths": {}, 60 "components": { 61 "schemas": { 62 "PhoneNumber": { 63 "description": "The number to dial.", 64 "type": "string" 65 }, 66 "User": { 67 "description": "A User uses something.", 68 "type": "object", 69 "properties": { 70 "id": { 71 "type": "integer" 72 }, 73 "name": { 74 "type": "string" 75 }, 76 "address": { 77 "$ref": "#/components/schemas/PhoneNumber" 78 } 79 } 80 } 81 } 82 } 83 }