Jira | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Table of Contents |
---|
Issues and Decisions
# | Issue | Solution | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
1 | API Generation method in DMI-Plugin | See
| |||||||||
2 | Backward compatibility move from <String> to <object> REST Interfaces for json objects | Need to verify backward compatibility for client URLs | These changes will introduce no changes at the client side. All users can continue to use the API as as they are using currently. This could be verified by executing the CSIT test of cps and dmi-plugin. Test by aditya puthuparambil |
What Is OpenAPI?
OpenAPI Specification (formerly Swagger Specification) is an API description format for REST APIs. An OpenAPI file allows you to describe your entire API, including:
...
You can add examples to parameters, properties and objects to make OpenAPI specification of your web service clearer. Examples can be read by tools and libraries that process your API in some way. To specify an example, you use the example
or examples
keys.
Request and Response Body Examples
Here is an example in a request body:
requestBody:
required: true
content:
application/json:
schema:
type: string
examples:
dataSample:
value:
test:bookstore:
bookstore-name: Chapters
categories:
- code: 01
name: SciFi
- code: 02
name: kids
All request and response body examples in CPS will be added at the object level.
Parameter Examples
Here is an example of a parameter value:
dataspaceNameInPath:
name: dataspace-name
in: path
description: dataspace-name
required: true
schema:
type: string
example: DataspaceName1Request Example:
Reusing Examples:
You can define common examples in the components/examples
section of your specification and then re-use them in various parameter descriptions, request and response body descriptions, objects and properties:
Sample example defined in components.yaml
components:
examplesrequestBody:
required: true
content:
application/jsondataSample:
schemavalue:
typetest:bookstore: string
examples:
bookstoreData:bookstore-name: Chapters
valuecategories:
- testcode:bookstore 01:
bookstore-name: ChaptersSciFi
- code: categories:02
name: kids
- code: 01
summary: A sample data
Sample response using examples defined in components:
responses:
'200':
description: OK
namecontent:
SciFi
application/json:
schema:
- code: 02
type: object
example:
name: kids $ref: 'components.yml#/components/examples/dataSample'
Sample request using examples defined in components:
requestBody:
required: true
content:
application/json:
schema:
type: string
examples:
objectExample dataSample:
$ref: 'components.yml#/components/examples/testBookStoreDatadataSample'
examples
Examples for composite components:
DataAccessRequest:
type: object
properties:
testBookStoreDataoperation:
value type: string
test:bookstore:
enum: [ read, create, update, delete ]
example: create
dataType:
bookstore-nametype: Chaptersstring
example: dataTypeValue
categoriesdata:
type: string
- codeexample: 01data
cmHandleProperties:
$ref: '#/components/schemas/cmHandleProperties'
cmHandleProperties:
nametype: SciFi
object
additionalProperties:
type: string
example:
- prop1: value
prop2: value
Schema Type for Request and Response
At present most of the requests are defined as schema type String for Request body json. These could be updated to object type. This will introduce below changes:
S. No | Summary | Current code | Expected code |
---|---|---|---|
1 | Changing the schema type in openapi. | content: |
...
| content: |
...
application/json: |
...
type: object | |||
2 | Changes in Controller Changing the datatype to Object | public ResponseEntity<String> createNode | public ResponseEntity<String> createNode |
Converting jsonData to String while passing the data to service layer | cpsDataService.saveData(dataspaceName, anchorName, jsonData, | cpsDataService.saveData(dataspaceName, anchorName, jsonData.toString(), |
Note: These changes will introduce no changes at the client side. All users can continue to use the API as as they are using currently. This could be verified by executing the CSIT test of cps and dmi-plugin.