github.com/jbking/gohan@v0.0.0-20151217002006-b41ccf1c2a96/tools/template/doc.tmpl (about) 1 # for schema in schemas: 2 3 {{ schema.title }} 4 ============================ 5 6 Description: {{ schema.description }} 7 8 Properties 9 ------------ 10 11 .. csv-table:: Properties 12 :header: "Key", "Title", "Description", "Type", "Default", "Format", "Permission" 13 14 15 # set jsonschema = schema.schema 16 # for key in jsonschema.propertiesOrder: 17 # set property = jsonschema.properties[key] 18 "{{ key }}", "{{ property.title }}", "{{property.description}}", "{{ property.type }}", "{{ property.default }}", "{{ property.format }}", "{{ property.permission | join(', ') }}" 19 # endfor 20 {##} 21 {##} 22 23 24 Note: it is mandatory property if there is no default value specified. 25 id is an exception. if id property is null, gohan server will put uuid. 26 27 28 API Endpoint 29 30 List API 31 ----------- 32 33 GET {{schema.prefix}}/{{schema.plural}} 34 35 Sample Output 36 37 .. code-block:: javascript 38 39 { 40 "{{schema.plural}}": [ 41 { 42 # set jsonschema = schema.schema 43 # for key in jsonschema.propertiesOrder: 44 # set property = jsonschema.properties[key] 45 "{{ key }}": xxx{% if not loop.last %},{%endif%} 46 # endfor 47 } 48 ] 49 } 50 {##} 51 {##} 52 53 54 POST API 55 ----------- 56 57 POST {{schema.prefix}}/{{schema.plural}} 58 59 GET {{schema.prefix}}/{{schema.plural}} 60 61 Sample Request 62 63 .. code-block:: javascript 64 65 { 66 # set jsonschema = schema.schema 67 # for key in jsonschema.propertiesOrder: 68 # set property = jsonschema.properties[key] 69 # if "create" in property.permission: 70 "{{ key }}": xxx{% if not loop.last %},{%endif%} 71 # endif 72 # endfor 73 } 74 {##} 75 {##} 76 77 Sample Response 78 79 .. code-block:: javascript 80 81 { 82 "{{schema.id}}": { 83 # set jsonschema = schema.schema 84 # for key in jsonschema.propertiesOrder: 85 # set property = jsonschema.properties[key] 86 "{{ key }}": xxx{% if not loop.last %},{%endif%} 87 # endfor 88 } 89 } 90 {##} 91 {##} 92 93 94 SHOW API 95 ----------- 96 97 GET {{schema.prefix}}/{{schema.id}}/{id} 98 99 Sample Response 100 101 .. code-block:: javascript 102 103 { 104 "{{schema.id}}": { 105 # set jsonschema = schema.schema 106 # for key in jsonschema.propertiesOrder: 107 # set property = jsonschema.properties[key] 108 "{{ key }}": xxx{% if not loop.last %},{%endif%} 109 # endfor 110 } 111 } 112 {##} 113 {##} 114 115 116 Update API 117 ------------ 118 119 PUT {{schema.prefix}}/{{schema.id}}/{id} 120 121 Sample Request 122 123 .. code-block:: javascript 124 125 { 126 # set jsonschema = schema.schema 127 # for key in jsonschema.propertiesOrder: 128 # set property = jsonschema.properties[key] 129 # if "update" in property.permission: 130 "{{ key }}": xxx{% if not loop.last %},{%endif%} 131 # endif 132 # endfor 133 } 134 {##} 135 {##} 136 137 Sample Response 138 139 .. code-block:: javascript 140 141 { 142 "{{schema.id}}": { 143 # set jsonschema = schema.schema 144 # for key in jsonschema.propertiesOrder: 145 # set property = jsonschema.properties[key] 146 "{{ key }}": xxx{% if not loop.last %},{%endif%} 147 # endfor 148 } 149 } 150 {##} 151 {##} 152 153 DELETE API 154 ------------ 155 156 DELETE {{schema.prefix}}/{{schema.id}}/{id} 157 158 # endfor 159 160 161 162 163