Jira Legacy | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Issue:
Currently CPS core API's are not consistent. for example few of the POST operations return "plain/text" but few of the APIs does not return any response. So to make those APIs consistent, we need to change response of existing APIs. To make APIs backward compatible, we need to apply API versioning so that previous APIs still return "plain/text". newer versions of POST APIs will not return any response body. below is details of changes which will be required to support API versioning. create dataspace API explained below for reference
...
create dataspace v1 | create dataspace v2 | |
---|---|---|
URI | POST: http://localhost:8883/cps/api/v1/dataspaces?dataspace-name=testDataspace | POST: http://localhost:8883/cps/api/v2/dataspaces?dataspace-name=testDataspace |
Response | HTTP Code : 201 content-type: plain/text response body : testDataspace | HTTP Code : 201 response body : NO CONTENT |
Note : all
- Once we migrate to v2, other existing APIs will be supported in
...
- v1 and v2 without any impact.
- New endpoints will be supported under v2 only
Code changes to support v2 :
S.No | changes |
---|---|
1. | change cps-rest/docs/openapi.yaml file /v1{apiVersion}/dataspaces: /v2/dataspaces: Note : Since same URL support more then one actions (CRUD) and we need to change any one of the action, we need to create two different URL in yml file. if all the CRUD operations to be supported in v2, we can make changes in yml file as below : /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/node: |
2. | create cpsAdminV2.yml file and add POST APIs(as below) which need to be changed for v2 . dataspaces: changes in cpsAdmin.yml for deprecated version(s): /{version}/dataspaces: changes in cpsAdmin.yml for APIs to be supported in all the versions as it is: delete: |
3. | add CreateV2 in componentscomponentsV2.yml as file and add below lines: CreatedV2: changes in components.yml to add apiVersion path parameter parameters: |
4. | autogenerated code in CpsAdminApi.java @RequestMapping(value = "/v2/dataspaces", existing APIs will also change in CpsAdminApi. now all API method will have a path parameter argument as below : ResponseEntity<Void> deleteDataspace(@Parameter(in = ParameterIn.PATH, description = "apiVersion", required=true, schema=@Schema(allowableValues={ "v1", "v2" } |
5. | Implement autogenerated method "createDataspaceV2" in AdminRestController.java @Override |
Note : once we migrate to v2, other existing APIs will be supported in v1 and v2 without any impact. Open Issues :