This is a proposal how to improve documentation examples. As a newbie with Robot and JSON schema validation, I was struggling a bit with the JSON schema validation with RESTinstance. I had difficulties to understand that some of the JSON schema keywords are in the Robot command and some in the schema itself. This is in the documentation, but as a newcomer I tend to read and implement first based on examples.
The second thing I am not sure if I have understood correctly is the use case for the schema building in the background by the RESTinstance. I would assume that the use case is an existing REST API server that does not have Robot tests? In this case it is possible to build tests and construct the JSON schema in the background without doing any changes to the server. It is possible to run run tests without validation since the existing functionality is recorded. Eventually there is a well defined JSON schema made by RESTinstance that allows validating the response from the server when refactoring and new features are done. But for a new implementation, there is anyways a need to build the API validation with schema validation in order to be able to develop the server. So in the later case the background schema is a bit redundant?
Feel free to modify the example anyhow you please. It is made mainly to illustrate the problem I had.
So far the library seems good. Thank you.
Example: Schema validation for JSON array
Validating JSON list against JSON schema with the RESTinstance can be done with JSON Schema validation keywords for array like items and contains. The list validation is useful for arrays of arbitrary length arrays where each item matches the same schema [1]. The JSON schema definition below, can be constructed to a Robot keyword like in the example below.
Description
This is a proposal how to improve documentation examples. As a newbie with Robot and JSON schema validation, I was struggling a bit with the JSON schema validation with RESTinstance. I had difficulties to understand that some of the JSON schema keywords are in the Robot command and some in the schema itself. This is in the documentation, but as a newcomer I tend to read and implement first based on examples.
The second thing I am not sure if I have understood correctly is the use case for the schema building in the background by the RESTinstance. I would assume that the use case is an existing REST API server that does not have Robot tests? In this case it is possible to build tests and construct the JSON schema in the background without doing any changes to the server. It is possible to run run tests without validation since the existing functionality is recorded. Eventually there is a well defined JSON schema made by RESTinstance that allows validating the response from the server when refactoring and new features are done. But for a new implementation, there is anyways a need to build the API validation with schema validation in order to be able to develop the server. So in the later case the background schema is a bit redundant?
Feel free to modify the example anyhow you please. It is made mainly to illustrate the problem I had.
So far the library seems good. Thank you.
Example: Schema validation for JSON array
Validating JSON list against JSON schema with the RESTinstance can be done with JSON Schema validation keywords for array like
items
andcontains
. The list validation is useful for arrays of arbitrary length arrays where each item matches the same schema [1]. The JSONschema
definition below, can be constructed to a Robot keyword like in the example below.[1] https://json-schema.org/understanding-json-schema/reference/array.html