Short version: I want to validate a JSON model to see if it is a valid swagger model.
For example, I have:
{
"swagger" : "2.0",
"info" : {
"version" : "0.0.1",
"title" : "API"
},
"basePath" : "/api",
"paths" : {
"/{myVar}" : {
"get" : {
"summary" : "Summary",
"parameters" : [],
"responses" : {
"200" : {
"description" : "OK"
}
}
}
}
}
}
If I use the online editor (editor.swagger.io), I have the following error:
Semantic error at paths./{myVar} Declared path parameter "myVar" needs to be defined as a path parameter at either the path or operation level
I would like to retrieve the same error in my java code.
I tried the following:
- validating the json against the swagger schema (http://swagger.io/v2/schema.json)
- parsing the json with SwaggerParser.readWithInfo then calling getMessages (= empty list)
Any idea if it is feasible with the current java librairies?