I was provided with some JSON files created by the REST API with a lot of properties.
I created a Swagger 2.0 definition for this API and must provide it with the appropriate schema for the response.
The main problem: this JSON file has many properties. This will take a lot of time, and I would make many mistakes if I wrote the diagram manually. And this is not the only API I need to describe.
I know that there are some tools for converting JSON to JSON schemes, but if Im not mistaken, Swagger has only $ refs to define other objects, so there is only one level, while Ive tools find that they produce only structured tree schemes. My question is: is there any tool to convert JSON (or JSON schemas) to compatible with Swagger 2.0?
Note. I work in YAML, but I would not be a problem, right?
For example, what I need:
List of Movements: type: "array" items: $ref: "#/definitions/Movement" Movement: properties: dateKey: type: "string" movement: $ref: "#/definitions/Stock" additionalProperties: false Stock: properties: stkUnitQty: type: "string" stkDateTime: type: "string" stkUnitType: type: "string" stkOpKey: type: "string" additionalProperties: false
For my JSON document:
[ { "dateKey": "20161110", "stkLvls": [ { "stkOpKey": "0", "stkUnitType": "U", "stkDateTime": "20161110T235010.240+0100", "stkUnitQty": 30 } ] }, { "dateKey": "20161111", "stkLvls": [ { "stkOpKey": "0", "stkUnitType": "U", "stkDateTime": "20161111T231245.087+0100", "stkUnitQty": 21 } ] } ]
But what http://jsonschema.net/#/ gives me:
--- "$schema": http://json-schema.org/draft-04/schema
I am new to this, but curiously, feel free to explain deeply.
Thank you in advance for your help!