CPS-723: Add Examples in the NCMP openapi
[cps.git] / cps-ncmp-rest / docs / openapi / components.yaml
1 #  ============LICENSE_START=======================================================
2 #  Copyright (C) 2021 Nordix Foundation
3 #  Modifications Copyright (C) 2021 Pantheon.tech
4 #  ================================================================================
5 #  Licensed under the Apache License, Version 2.0 (the "License");
6 #  you may not use this file except in compliance with the License.
7 #  You may obtain a copy of the License at
8 #
9 #        http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #  Unless required by applicable law or agreed to in writing, software
12 #  distributed under the License is distributed on an "AS IS" BASIS,
13 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #  See the License for the specific language governing permissions and
15 #  limitations under the License.
16 #
17 #  SPDX-License-Identifier: Apache-2.0
18 #  ============LICENSE_END=========================================================
19
20 components:
21   schemas:
22     # Common Schemas
23     ErrorMessage:
24       type: object
25       title: Error
26       properties:
27         status:
28           type: string
29         message:
30           type: string
31         details:
32           type: string
33
34     # Request Schemas
35     RestDmiPluginRegistration:
36       type: object
37       properties:
38         dmiPlugin:
39           type: string
40           example: my-dmi-plugin
41         dmiDataPlugin:
42           type: string
43           example: my-dmi-data-plugin
44         dmiModelPlugin:
45           type: string
46           example: my-dmi-model-plugin
47         createdCmHandles:
48           type: array
49           items:
50             $ref: '#/components/schemas/RestCmHandle'
51           example: [my-cm-handle1, my-cm-handle2, my-cm-handle3]
52         updatedCmHandles:
53           type: array
54           items:
55             $ref: '#/components/schemas/RestCmHandle'
56         removedCmHandles:
57           type: array
58           items:
59             type: string
60             example: [my-cm-handle1, my-cm-handle2, my-cm-handle3]
61
62     RestCmHandle:
63       required:
64         - cmHandle
65       type: object
66       properties:
67         cmHandle:
68           type: string
69           example: my-cm-handle
70         cmHandleProperties:
71             $ref: '#/components/schemas/RestCmHandleAdditionalProperties'
72     RestCmHandleAdditionalProperties:
73         type: object
74         additionalProperties:
75             type: string
76             example: my-additional-property
77
78     Conditions:
79       type: object
80       properties:
81         conditions:
82           $ref: '#/components/schemas/ConditionsData'
83     ConditionsData:
84       type: array
85       items:
86         type: object
87         $ref: '#/components/schemas/ConditionProperties'
88     ConditionProperties:
89       properties:
90         name:
91           type: string
92           example: hasAllModules
93         conditionParameters:
94           $ref: '#/components/schemas/ModuleNamesAsJsonArray'
95     ModuleNamesAsJsonArray:
96       type: array
97       items:
98         type: object
99         $ref: '#/components/schemas/ModuleNameAsJsonObject'
100         example: [my-module-1, my-module-2, my-module-3]
101     ModuleNameAsJsonObject:
102         properties:
103           moduleName:
104             type: string
105             example: my-module
106
107     #Response Schemas
108     CmHandles:
109       type: object
110       properties:
111         cmHandles:
112           $ref: '#/components/schemas/CmHandleProperties'
113     CmHandleProperties:
114       type: array
115       items:
116         type: object
117         $ref: '#/components/schemas/CmHandleProperty'
118     CmHandleProperty:
119       properties:
120         cmHandleId:
121           type: string
122           example: my-cm-handle-id
123
124   examples:
125     dataSampleRequest:
126         summary: Sample request
127         description: Sample request body
128         value:
129           test:bookstore:
130             bookstore-name: Chapters
131             categories:
132               - code: '01'
133                 name: SciFi
134                 books:
135                 - authors:
136                     - Iain M. Banks
137                 - authors:
138                     - Ursula K. Le Guin
139               - code: '02'
140                 name: kids
141                 books:
142                 - authors:
143                     - Philip Pullman
144
145     dataSampleResponse:
146         summary: Sample response
147         description: Sample response for selecting 'sample 1'.
148         value:
149           bookstore:
150             categories:
151               - code: '01'
152                 books:
153                   - {}
154                   - {}
155                 name: SciFi
156               - code: '02'
157                 books:
158                   - {}
159                 name: kids
160             bookstore-name: Chapters
161
162   parameters:
163     cmHandleInPath:
164       name: cm-handle
165       in: path
166       description: The identifier for a network function, network element, subnetwork or any other cm object by managed Network CM Proxy
167       required: true
168       schema:
169         type: string
170         example: my-cm-handle
171     xpathInQuery:
172       name: xpath
173       in: query
174       description: xpath
175       required: false
176       schema:
177         type: string
178         default: /
179     requiredXpathInQuery:
180       name: xpath
181       in: query
182       description: xpath
183       required: true
184       schema:
185         type: string
186     includeDescendantsOptionInQuery:
187       name: include-descendants
188       in: query
189       description: include-descendants
190       required: false
191       schema:
192         type: boolean
193         default: false
194     cpsPathInQuery:
195       name: cps-path
196       in: query
197       description: cps-path
198       required: false
199       schema:
200         type: string
201         default: /
202     resourceIdentifierInQuery:
203       name: resourceIdentifier
204       in: query
205       description: The format of resource identifier depend on the associated DMI Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but it can really be anything.
206       required: true
207       allowReserved: true
208       schema:
209         type: string
210       examples:
211         sample 1:
212           value:
213             resourceIdentifier: \shops\bookstore
214         sample 2:
215           value:
216             resourceIdentifier: \shops\bookstore\categories[@code=1]
217         sample 3:
218           value:
219             resourceIdentifier: parent=shops,child=bookstore
220     acceptParamInHeader:
221       name: Accept
222       in: header
223       required: false
224       description: Accept parameter for response, if accept parameter is null, that means client can accept any format.
225       schema:
226         type: string
227         enum: [ application/json, application/yang-data+json ]
228     optionsParamInQuery:
229       name: options
230       in: query
231       description: options parameter in query, it is mandatory to wrap key(s)=value(s) in parenthesis'()'. The format of options parameter depend on the associated DMI Plugin implementation.
232       required: false
233       schema:
234         type: string
235       allowReserved: true
236       examples:
237         sample 1:
238           value:
239             options: (depth=3)
240         sample 2:
241           value:
242             options: (fields=book)
243         sample 3:
244           value:
245             options: (depth=2,fields=book/authors)
246     contentParamInHeader:
247       name: Content-Type
248       in: header
249       required: false
250       description: Content parameter for request, if content parameter is null, default value is application/json.
251       schema:
252         type: string
253         default: application/json
254         example: application/yang-data+json
255
256   responses:
257     NotFound:
258       description: The specified resource was not found
259       content:
260         application/json:
261           schema:
262             $ref: '#/components/schemas/ErrorMessage'
263           example:
264             status: 400
265             message: Not found error message
266             details: Not found error details
267     Unauthorized:
268       description: Unauthorized
269       content:
270         application/json:
271           schema:
272             $ref: '#/components/schemas/ErrorMessage'
273           example:
274             status: 401
275             message: Unauthorized error message
276             details: Unauthorized error details
277     Forbidden:
278       description: Forbidden
279       content:
280         application/json:
281           schema:
282             $ref: '#/components/schemas/ErrorMessage'
283           example:
284            status: 403
285            message: Forbidden error message
286            details: Forbidden error details
287     BadRequest:
288       description: Bad Request
289       content:
290         application/json:
291           schema:
292             $ref: '#/components/schemas/ErrorMessage'
293           example:
294            status: 400 BAD_REQUEST
295            message: Bad request error message
296            details: Bad request error details
297     Conflict:
298       description: Conflict
299       content:
300         application/json:
301           schema:
302             $ref: '#/components/schemas/ErrorMessage'
303           example:
304            status: 409 CONFLICT
305            message: Conflict error message
306            details: Conflict error details
307     NotImplemented:
308       description: The given path has not been implemented
309       content:
310         application/json:
311           schema:
312             $ref: '#/components/schemas/ErrorMessage'
313           example:
314            status: 501
315            message: Not implemented error message
316            details: Not implemented error details
317     Ok:
318       description: OK
319       content:
320         application/json:
321           schema:
322             type: object
323     Created:
324       description: Created
325       content: {}
326     NoContent:
327       description: No Content
328       content: {}