summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>2021-01-13 12:06:20 +0000
committerRishi Chail <rishi.chail@est.tech>2021-01-15 06:52:13 +0000
commit001e7738f4968ec390ea8af36de019aa87e3c2f2 (patch)
tree13347974f001bdf596dca49a0c64924aa70e1703
parentd45b2dc0ec3bb7d56ef1eee784a887459f609832 (diff)
Split OpenAPI yaml file
1. components like schema, parameters, responses, requestBodies all moved to components.yml (https://swagger.io/docs/specification/components/) 2. CpAdmin.yml includes the configuration details for cpsAdmin APIs 3. CpsData.yml includes the API configuration details for cpsData Issue-ID: CPS-155 Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca> Change-Id: I18fb9b8a2be85d180d4625657aca399dbf60b7bc
-rw-r--r--cps-rest/docs/api/swagger/components.yaml105
-rw-r--r--cps-rest/docs/api/swagger/cpsAdmin.yml165
-rw-r--r--cps-rest/docs/api/swagger/cpsData.yml65
-rwxr-xr-xcps-rest/docs/api/swagger/openapi.yml409
-rw-r--r--cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java4
-rw-r--r--cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java2
-rw-r--r--cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy2
7 files changed, 356 insertions, 396 deletions
diff --git a/cps-rest/docs/api/swagger/components.yaml b/cps-rest/docs/api/swagger/components.yaml
new file mode 100644
index 0000000000..ab964a93a0
--- /dev/null
+++ b/cps-rest/docs/api/swagger/components.yaml
@@ -0,0 +1,105 @@
+components:
+ schemas:
+ ErrorMessage:
+ type: object
+ title: Error
+ properties:
+ status:
+ type: string
+ message:
+ type: string
+ details:
+ type: string
+ MultipartFile:
+ required:
+ - file
+ properties:
+ multipartFile:
+ type: string
+ description: multipartFile
+ format: binary
+
+ parameters:
+ dataspaceNameInQuery:
+ name: dataspace-name
+ in: query
+ description: dataspace-name
+ required: true
+ schema:
+ type: string
+ dataspaceNameInPath:
+ name: dataspace-name
+ in: path
+ description: dataspace-name
+ required: true
+ schema:
+ type: string
+ anchorNameInPath:
+ name: anchor-name
+ in: path
+ description: anchor-name
+ required: true
+ schema:
+ type: string
+ schemaSetNameInQuery:
+ name: schema-set-name
+ in: query
+ description: schema-set-name
+ required: true
+ schema:
+ type: string
+ schemaSetNameInPath:
+ name: schema-set-name
+ in: path
+ description: schema-set-name
+ required: true
+ schema:
+ type: string
+ anchorNameInQuery:
+ name: anchor-name
+ in: query
+ description: anchor-name
+ required: true
+ schema:
+ type: string
+
+ responses:
+ NotFound:
+ description: The specified resource was not found
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ Unauthorized:
+ description: Unauthorized
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ Forbidden:
+ description: Forbidden
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ BadRequest:
+ description: Bad Request
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ Ok:
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: object
+ Created:
+ description: Created
+ content:
+ text/plain:
+ schema:
+ type: string
+ NoContent:
+ description: No Content
+ content: {}
diff --git a/cps-rest/docs/api/swagger/cpsAdmin.yml b/cps-rest/docs/api/swagger/cpsAdmin.yml
new file mode 100644
index 0000000000..948c43b763
--- /dev/null
+++ b/cps-rest/docs/api/swagger/cpsAdmin.yml
@@ -0,0 +1,165 @@
+dataspace:
+ post:
+ tags:
+ - cps-admin
+ summary: Create a new dataspace
+ operationId: createDataspace
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInQuery'
+ responses:
+ 201:
+ $ref: 'components.yaml#/components/responses/Created'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+
+dataspaceByDataspaceName:
+ delete:
+ tags:
+ - cps-admin
+ summary: Delete the given dataspace - DRAFT
+ operationId: deleteDataspace
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInPath'
+ responses:
+ 200:
+ $ref: 'components.yaml#/components/responses/Ok'
+ 204:
+ $ref: 'components.yaml#/components/responses/NoContent'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+
+
+schemaSet:
+ post:
+ tags:
+ - cps-admin
+ summary: Create a new schema set in the given dataspace
+ operationId: createSchemaSet
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInPath'
+ - $ref: 'components.yaml#/components/parameters/schemaSetNameInQuery'
+ requestBody:
+ required: true
+ content:
+ multipart/form-data:
+ schema:
+ $ref: 'components.yaml#/components/schemas/MultipartFile'
+
+ responses:
+ 201:
+ $ref: 'components.yaml#/components/responses/Created'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+
+schemaSetBySchemaSetName:
+ get:
+ tags:
+ - cps-admin
+ summary: Read a schema set given a schema set and a dataspace
+ operationId: getSchemaSet
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInPath'
+ - $ref: 'components.yaml#/components/parameters/schemaSetNameInPath'
+ responses:
+ 200:
+ $ref: 'components.yaml#/components/responses/Ok'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+ 404:
+ $ref: 'components.yaml#/components/responses/NotFound'
+
+anchorsByDataspace:
+ get:
+ tags:
+ - cps-admin
+ summary: Read all anchors, given a dataspace
+ operationId: getAnchors
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInPath'
+ responses:
+ 200:
+ $ref: 'components.yaml#/components/responses/Ok'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+ 404:
+ $ref: 'components.yaml#/components/responses/NotFound'
+
+ post:
+ tags:
+ - cps-admin
+ summary: Create a new anchor in the given dataspace
+ operationId: createAnchor
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInPath'
+ - $ref: 'components.yaml#/components/parameters/schemaSetNameInQuery'
+ - $ref: 'components.yaml#/components/parameters/anchorNameInQuery'
+ responses:
+ 201:
+ $ref: 'components.yaml#/components/responses/Created'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+
+anchorByDataspaceAndAnchorName:
+ get:
+ tags:
+ - cps-admin
+ summary: Read an anchor given a anchor and a dataspace - DRAFT
+ operationId: getAnchor
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInPath'
+ - $ref: 'components.yaml#/components/parameters/anchorNameInPath'
+ responses:
+ 200:
+ $ref: 'components.yaml#/components/responses/Ok'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+ 404:
+ $ref: 'components.yaml#/components/responses/NotFound'
+
+ delete:
+ tags:
+ - cps-admin
+ summary: Delete an anchor given a anchor and a dataspace - DRAFT
+ operationId: deleteAnchor
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInPath'
+ - $ref: 'components.yaml#/components/parameters/anchorNameInPath'
+ responses:
+ 200:
+ $ref: 'components.yaml#/components/responses/Ok'
+ 204:
+ $ref: 'components.yaml#/components/responses/NoContent'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden' \ No newline at end of file
diff --git a/cps-rest/docs/api/swagger/cpsData.yml b/cps-rest/docs/api/swagger/cpsData.yml
new file mode 100644
index 0000000000..c33cf168e2
--- /dev/null
+++ b/cps-rest/docs/api/swagger/cpsData.yml
@@ -0,0 +1,65 @@
+nodesByDataspaceAndAnchor:
+ get:
+ tags:
+ - cps-data
+ summary: Get a node given an anchor for the given dataspace - DRAFT
+ operationId: getNodeByDataspaceAndAnchor
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInPath'
+ - $ref: 'components.yaml#/components/parameters/anchorNameInPath'
+ responses:
+ 200:
+ $ref: 'components.yaml#/components/responses/Ok'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+ 404:
+ $ref: 'components.yaml#/components/responses/NotFound'
+ x-codegen-request-body-name: xpath
+
+nodesByDataspace:
+ get:
+ tags:
+ - cps-data
+ summary: Get all nodes for a given dataspace using an xpath or schema node identifier - DRAFT
+ operationId: getNode
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInPath'
+ responses:
+ 200:
+ $ref: 'components.yaml#/components/responses/Ok'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+ 404:
+ $ref: 'components.yaml#/components/responses/NotFound'
+ x-codegen-request-body-name: requestBody
+
+ post:
+ tags:
+ - cps-data
+ summary: Create a node for a given anchor for the given dataspace - DRAFT
+ operationId: createNode
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/dataspaceNameInPath'
+ requestBody:
+ content:
+ multipart/form-data:
+ schema:
+ $ref: 'components.yaml#/components/schemas/MultipartFile'
+ required: true
+ responses:
+ 201:
+ $ref: 'components.yaml#/components/responses/Created'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden' \ No newline at end of file
diff --git a/cps-rest/docs/api/swagger/openapi.yml b/cps-rest/docs/api/swagger/openapi.yml
index 2acd2b1641..44064e2175 100755
--- a/cps-rest/docs/api/swagger/openapi.yml
+++ b/cps-rest/docs/api/swagger/openapi.yml
@@ -10,400 +10,25 @@ tags:
description: cps Resource
paths:
/v1/dataspaces:
- post:
- tags:
- - cps-admin
- summary: Create a new dataspace
- operationId: createDataspace
- parameters:
- - name: dataspace-name
- in: query
- description: dataspace-name
- required: true
- schema:
- type: string
- responses:
- 201:
- description: Created
- content:
- application/json:
- schema:
- type: string
- 400:
- description: Bad Request
- content: { }
- 401:
- description: Unauthorized
- content: { }
- 403:
- description: Forbidden
- content: { }
+ $ref: 'cpsAdmin.yml#/dataspace'
+
/v1/dataspaces/{dataspace-name}/:
- delete:
- tags:
- - cps-admin
- summary: Delete the given dataspace
- operationId: deleteDataspace
- parameters:
- - name: dataspace-name
- in: path
- description: dataspace-name
- required: true
- schema:
- type: string
- responses:
- 200:
- description: OK
- content:
- application/json:
- schema:
- type: object
- 204:
- description: No Content
- content: {}
- 401:
- description: Unauthorized
- content: {}
- 403:
- description: Forbidden
- content: {}
- /v1/dataspaces/{dataspace-name}/schema-sets/{schema-set-name}:
- get:
- tags:
- - cps-admin
- summary: Read a schema set given a schema set and a dataspace
- operationId: getSchemaSet
- parameters:
- - name: dataspace-name
- in: path
- description: dataspace-name
- required: true
- schema:
- type: string
- - name: schema-set-name
- in: path
- description: schema-name
- required: true
- schema:
- type: string
- responses:
- 200:
- description: OK
- content:
- application/json:
- schema:
- type: object
- 401:
- description: Unauthorized
- content: {}
- 403:
- description: Forbidden
- content: {}
- 404:
- description: Not Found
- content: {}
- /v1/dataspaces/{dataspace-name}/schema-sets:
- post:
- tags:
- - cps-admin
- summary: Create a new schema set in the given dataspace
- operationId: createSchemaSet
- parameters:
- - name: dataspace-name
- in: path
- description: dataspace-name
- required: true
- schema:
- type: string
- requestBody:
- required: true
- content:
- multipart/form-data:
- schema:
- required:
- - schemaSetName
- - multipartFile
- properties:
- schemaSetName:
- type: string
- multipartFile:
- type: string
- description: multipartFile
- format: binary
- responses:
- 201:
- description: Created
- content:
- application/json:
- schema:
- type: string
- 401:
- description: Unauthorized
- content: { }
- 403:
- description: Forbidden
- content: { }
+ $ref: 'cpsAdmin.yml#/dataspaceByDataspaceName'
+
/v1/dataspaces/{dataspace-name}/anchors:
- get:
- tags:
- - cps-admin
- summary: Read all anchors, given a dataspace
- operationId: getAnchors
- parameters:
- - name: dataspace-name
- in: path
- description: dataspace-name
- required: true
- schema:
- type: string
- responses:
- 200:
- description: OK
- content:
- application/json:
- schema:
- type: object
- 401:
- description: Unauthorized
- content: {}
- 400:
- description: Bad Request
- content: {}
- 403:
- description: Forbidden
- 404:
- description: Not Found
- content: {}
- 204:
- description: No Content
- content: {}
- post:
- tags:
- - cps-admin
- summary: Create a new anchor in the given dataspace
- operationId: createAnchor
- parameters:
- - name: dataspace-name
- in: path
- description: dataspace-name
- required: true
- schema:
- type: string
- - name: schema-set-name
- in: query
- description: schema-set-name
- required: true
- schema:
- type: string
- - name: anchor-name
- in: query
- description: anchor-name
- required: true
- schema:
- type: string
- responses:
- 201:
- description: Created
- content:
- application/json:
- schema:
- type: string
- 401:
- description: Unauthorized
- content: {}
- 403:
- description: Forbidden
- content: {}
- 404:
- description: Not Found
- content: {}
+ $ref: 'cpsAdmin.yml#/anchorsByDataspace'
+
/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}:
- get:
- tags:
- - cps-admin
- summary: Read an anchor given a anchor and a dataspace
- operationId: getAnchor
- parameters:
- - name: dataspace-name
- in: path
- description: dataspace-name
- required: true
- schema:
- type: string
- - name: anchor-name
- in: path
- description: anchor-name
- required: true
- schema:
- type: string
- responses:
- 200:
- description: OK
- content:
- application/json:
- schema:
- type: object
- 401:
- description: Unauthorized
- content: {}
- 403:
- description: Forbidden
- content: {}
- 404:
- description: Not Found
- content: {}
- delete:
- tags:
- - cps-admin
- summary: Delete an anchor given a anchor and a dataspace
- operationId: deleteAnchor
- parameters:
- - name: dataspace-name
- in: path
- description: dataspace-name
- required: true
- schema:
- type: string
- - name: anchor-name
- in: path
- description: anchor-name
- required: true
- schema:
- type: string
- responses:
- 200:
- description: OK
- content:
- application/json:
- schema:
- type: object
- 204:
- description: No Content
- content: {}
- 401:
- description: Unauthorized
- content: {}
- 403:
- description: Forbidden
- content: {}
+ $ref: 'cpsAdmin.yml#/anchorByDataspaceAndAnchorName'
+
+ /v1/dataspaces/{dataspace-name}/schema-sets:
+ $ref: 'cpsAdmin.yml#/schemaSet'
+
+ /v1/dataspaces/{dataspace-name}/schema-sets/{schema-set-name}:
+ $ref: 'cpsAdmin.yml#/schemaSetBySchemaSetName'
+
/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes:
- get:
- tags:
- - cps-data
- summary: Get a node given an anchor for the given dataspace
- operationId: getNodeByDataspaceAndAnchor
- parameters:
- - name: dataspace-name
- in: path
- description: dataspace-name
- required: true
- schema:
- type: string
- - name: anchor-name
- in: path
- description: anchor-name
- required: true
- schema:
- type: string
- responses:
- 200:
- description: OK
- content:
- application/json:
- schema:
- type: object
- 401:
- description: Unauthorized
- content: {}
- 403:
- description: Forbidden
- content: {}
- 404:
- description: Not Found
- content: {}
- x-codegen-request-body-name: xpath
+ $ref: 'cpsData.yml#/nodesByDataspaceAndAnchor'
+
/v1/dataspaces/{dataspace-name}/nodes:
- get:
- tags:
- - cps-data
- summary: Get all nodes for a given dataspace using an xpath or schema node identifier
- operationId: getNode
- parameters:
- - name: dataspace-name
- in: path
- description: dataspace-name
- required: true
- schema:
- type: string
- responses:
- 200:
- description: OK
- content:
- application/json:
- schema:
- type: object
- 401:
- description: Unauthorized
- content: {}
- 403:
- description: Forbidden
- content: {}
- 404:
- description: Not Found
- content: {}
- x-codegen-request-body-name: requestBody
- post:
- tags:
- - cps-data
- summary: Create a node for a given anchor for the given dataspace
- operationId: createNode
- parameters:
- - name: dataspace-name
- in: path
- description: dataspace-name
- required: true
- schema:
- type: string
- requestBody:
- content:
- multipart/form-data:
- schema:
- required:
- - file
- properties:
- multipartFile:
- type: string
- description: multipartFile
- format: binary
- required: true
- responses:
- 200:
- description: OK
- content:
- application/json:
- schema:
- type: object
- 201:
- description: Created
- content: {}
- 401:
- description: Unauthorized
- content: {}
- 403:
- description: Forbidden
- content: {}
- 404:
- description: Not Found
- content: {}
-components:
- schemas:
- ErrorMessage:
- type: object
- title: Error
- properties:
- status:
- type: string
- message:
- type: string
- details:
- type: string
+ $ref: 'cpsData.yml#/nodesByDataspace'
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
index 407a767389..4237846ee7 100644
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
@@ -54,8 +54,8 @@ public class AdminRestController implements CpsAdminApi {
}
@Override
- public ResponseEntity<String> createSchemaSet(final String schemaSetName, final MultipartFile multipartFile,
- final String dataspaceName) {
+ public ResponseEntity<String> createSchemaSet(final MultipartFile multipartFile,
+ final String schemaSetName, final String dataspaceName) {
cpsModuleService.createSchemaSet(dataspaceName, schemaSetName, extractYangResourcesMap(multipartFile));
return new ResponseEntity<>(schemaSetName, HttpStatus.CREATED);
}
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
index c637cc6d86..fcb8ddc1c1 100644
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
@@ -38,7 +38,7 @@ public class DataRestController implements CpsDataApi {
private ModelMapper modelMapper;
@Override
- public ResponseEntity<Object> createNode(@Valid final MultipartFile multipartFile, final String dataspaceName) {
+ public ResponseEntity<String> createNode(@Valid final MultipartFile multipartFile, final String dataspaceName) {
return null;
}
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
index 078253a64e..0a61c7dd59 100644
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
@@ -122,7 +122,7 @@ class AdminRestControllerSpec extends Specification {
MockMvcRequestBuilders
.multipart(schemaSetsEndpoint)
.file(multipartFile)
- .param('schemaSetName', 'test-schema-set')
+ .param('schema-set-name', 'test-schema-set')
).andReturn().response
}