The main goal of the spike mentioned above is to find out a way to load and use JSON schema for response validation in API tests.
There are some changes were announced to the RMB module recently, and especially we are interested in this commit, which introduces two additional endpoints for use, they are:
Those endpoints allow user to retrieve whether JSON schema or RAML file for specified module.
To include this functionality into your module you have to modify ModuleDescriptior.json file by adding following code
- for JSON Schemas API
{ "id": "_jsonSchemas", "version": "1.0", "interfaceType" : "multiple", "handlers" : [ { "methods" : [ "GET" ], "pathPattern" : "/_/jsonSchemas" } ] }
- for RAMLs API
{ "id": "_ramls", "version": "1.0", "interfaceType" : "multiple", "handlers" : [ { "methods" : [ "GET" ], "pathPattern" : "/_/ramls" } ] }
Then, you may want to see those endpoints enabled for the module.
To check it, use following endpoints
<host>:<port>/_/proxy/tenants/<tenant>/interfaces - to see all interfaces <host>:<port>/_/proxy/tenants/<tenant>/interfaces/_jsonSchemas - find modules which provide this interface
Here is the sample response with the list of interfaces available to use
You should see similar response if you are specified interface
and finally you are able to retrieve JSON Schema for your needs (Do not forget to specify `X-Okapi-Module-Id` header)
<host>:<port>/_/jsonSchemas?path=<path_to_file> Example: http://localhost:9130/_/jsonSchemas?path=types/packages/packageCollection.json
You can find the sample response below:
The main goal of the spike mentioned above is to find out a way to load and use json schema for response validation in API tests.
There are some changes were announced to the RMB module recently, and especially we are interested in this commit, which introduces two additional endpoints for use, they are:
Those endpoints allow user to retrieve whether JSON schema or RAML file for specified module.
You are already familiar with Okapi endpoints, such are
JSON Schemas
To include this functionality into your module you have to modify ModuleDescriptior.json file by adding following code
- for JSON Schemas API
{ "id": "_jsonSchemas", "version": "1.0", "interfaceType" : "multiple", "handlers" : [ { "methods" : [ "GET" ], "pathPattern" : "/_/jsonSchemas" } ] }
- for RAMLs API
{ "id": "_ramls", "version": "1.0", "interfaceType" : "multiple", "handlers" : [ { "methods" : [ "GET" ], "pathPattern" : "/_/ramls" } ] }
Then, you may want to see those endpoints enabled for the module.
To check it, use following endpoints
<host>:<port>/_/proxy/tenants/<tenant>/interfaces - to see all interfaces <host>:<port>/_/proxy/tenants/<tenant>/interfaces/_jsonSchemas - find modules which provide this interface
Here is the sample response with the list of interfaces available to use
You should see similar response if you are specified interface
and finally you are able to retrieve JSON Schema for your needs (Do not forget to specify `X-Okapi-Module-Id` header)
<host>:<port>/_/jsonSchemas?path=<path_to_file> Example: http://localhost:9130/_/jsonSchemas?path=types/packages/packageCollection.json
You can find the sample response below: