I'm looking for a way to convert a schema defined inside a swagger to a JSON-Schema.
For example, in my swagger i have :
"definitions" : {
"response" : {
"properties" : {
"responseContent" : {
"$ref" : "#/definitions/objectResponse"
}
}
},
"objectResponse" : {
"description" : "response",
"properties" : {
"idResponse" : {
"type" : "string",
"description" : "Response",
"minLength" : 0,
"maxLength" : 255
}
}
}
}
I want :
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {},
"id": "http://example.com/example.json",
"properties": {
"responseContent": {
"id": "/properties/responseContent",
"properties": {
"idResponse": {
"id": "/properties/responseContent/properties/idResponse",
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
At the moment, i found a solution :
- generate a response based on the swagger (e.g. with apimatic.io)
- convert the response with jsonschema.net
But with this process, i lose restrictions, and i depend on external tools.
Thanks for your help.
PS : I'm kind of new to the API world, don't hesitate to explain deeply I'm curious
PIer