Matteo Scandolo | 431781c | 2017-09-06 15:33:07 -0700 | [diff] [blame] | 1 | swagger: "2.0" |
| 2 | info: |
| 3 | title: "XOS REST APIs" |
| 4 | description: "XOS - REST API Docs" |
| 5 | version: "1.0.0" |
| 6 | contact: |
| 7 | email: "cord-dev@opencord.org" |
| 8 | |
| 9 | {#tags:#} |
| 10 | {#{%- for object in proto.messages %}#} |
| 11 | {#- name: "{{ xproto_unquote(xproto_first_non_empty([object.options.app_label, object.options.name])) }}"#} |
| 12 | {# description: "{{ xproto_unquote(xproto_first_non_empty([object.options.app_label, object.options.name])) }} Models"#} |
| 13 | {# externalDocs:#} |
| 14 | {# description: "Find out more"#} |
| 15 | {# url: "https://guide.opencord.org/xos/core_models.html"#} |
| 16 | {#{% endfor %}#} |
| 17 | |
| 18 | paths: |
| 19 | {%- for object in proto.messages %} |
| 20 | /xosapi/v1/{{ xproto_unquote(xproto_first_non_empty([object.options.name, object.options.app_label, options.name, context.app_label])) }}/{{ xproto_pluralize(object) | lower }}/: |
| 21 | get: |
| 22 | tags: |
| 23 | - "{{ xproto_unquote(xproto_first_non_empty([object.options.app_label, object.options.name])) }}" |
| 24 | summary: "List {{xproto_pluralize(object)}}" |
| 25 | responses: |
| 26 | 200: |
| 27 | description: OK |
| 28 | 401: |
| 29 | description: "Unauthorized" |
| 30 | 403: |
| 31 | description: "Forbidden" |
| 32 | 500: |
| 33 | description: "Internal Server Error" |
| 34 | post: |
| 35 | tags: |
| 36 | - "{{ xproto_unquote(xproto_first_non_empty([object.options.app_label, object.options.name])) }}" |
| 37 | summary: "Create {{object.name}}" |
| 38 | parameters: |
| 39 | - in: "body" |
| 40 | name: "body" |
| 41 | description: "{{object.name}} model properties" |
| 42 | required: true |
| 43 | schema: |
| 44 | $ref: "#/definitions/{{object.name}}" |
| 45 | responses: |
| 46 | 200: |
| 47 | description: OK |
| 48 | 401: |
| 49 | description: "Unauthorized" |
| 50 | 403: |
| 51 | description: "Forbidden" |
| 52 | 500: |
| 53 | description: "Internal Server Error" |
| 54 | /xosapi/v1/{{ xproto_unquote(xproto_first_non_empty([object.options.name, object.options.app_label, options.name, context.app_label])) }}/{{ xproto_pluralize(object) | lower }}/{id}: |
| 55 | get: |
| 56 | tags: |
| 57 | - "{{ xproto_unquote(xproto_first_non_empty([object.options.app_label, object.options.name])) }}" |
| 58 | summary: "Get {{object.name}}" |
| 59 | parameters: |
| 60 | - in: "path" |
| 61 | name: "id" |
| 62 | description: "ID of {{ object.name }} to return" |
| 63 | required: true |
| 64 | type: "integer" |
| 65 | format: "int64" |
| 66 | responses: |
| 67 | 200: |
| 68 | description: OK |
| 69 | 401: |
| 70 | description: "Unauthorized" |
| 71 | 403: |
| 72 | description: "Forbidden" |
| 73 | 500: |
| 74 | description: "Internal Server Error" |
| 75 | put: |
| 76 | tags: |
| 77 | - "{{ xproto_unquote(xproto_first_non_empty([object.options.app_label, object.options.name])) }}" |
| 78 | summary: "Get {{object.name}}" |
| 79 | parameters: |
| 80 | - in: "path" |
| 81 | name: "id" |
| 82 | description: "ID of {{ object.name }} to return" |
| 83 | required: true |
| 84 | type: "integer" |
| 85 | format: "int64" |
| 86 | responses: |
| 87 | 200: |
| 88 | description: OK |
| 89 | 401: |
| 90 | description: "Unauthorized" |
| 91 | 403: |
| 92 | description: "Forbidden" |
| 93 | 500: |
| 94 | description: "Internal Server Error" |
| 95 | delete: |
| 96 | tags: |
| 97 | - "{{ xproto_unquote(xproto_first_non_empty([object.options.app_label, object.options.name])) }}" |
| 98 | summary: "Delete {{object.name}}" |
| 99 | parameters: |
| 100 | - in: "path" |
| 101 | name: "id" |
| 102 | description: "ID of {{ object.name }} to return" |
| 103 | required: true |
| 104 | type: "integer" |
| 105 | format: "int64" |
| 106 | responses: |
| 107 | 200: |
| 108 | description: OK |
| 109 | 401: |
| 110 | description: "Unauthorized" |
| 111 | 403: |
| 112 | description: "Forbidden" |
| 113 | 500: |
| 114 | description: "Internal Server Error" |
| 115 | {% endfor %} |
| 116 | |
| 117 | definitions: |
| 118 | {%- for object in proto.messages %} |
| 119 | {{ object.name }}: |
| 120 | type: "object" |
| 121 | properties: |
| 122 | {%- for f in object.fields %} |
| 123 | {{ f.name }}: |
| 124 | type: {{ xproto_type_to_swagger_type(f) }} |
| 125 | {%- if xproto_field_to_swagger_enum(f) %} |
| 126 | enum: |
| 127 | {%- for e in xproto_field_to_swagger_enum(f) %} |
| 128 | - {{ e }} |
| 129 | {%- endfor %} |
| 130 | {%- endif %} |
| 131 | {%- if f.options.help_text %} |
| 132 | description: "{{ xproto_unquote(f.options.help_text) }}" |
| 133 | {% endif %} |
| 134 | {%- endfor %} |
| 135 | {% endfor %} |