Closed xp-vit closed 5 years ago
@xp-vit Thanks for creating the issue. There is already some validation for Swagger files, but it is not complete. Can you post the spec file for testing purposes?
I changed a datatype to an incorrect "objekt" instead of "object" which the Swagger online editor flags as invalid, but the plugin currently does not.
@keilw Thanks for the feedback.
Validation has not been worked on recently. Now that the Open API support is mostly done, proper validation could be next in the priority list.
I found that specifying a JSON schema (openapi-3.0
or swagger-2.0
) warns about a lot of the errors that the Swagger Editor detects. Maybe this plugin can enable that by default.
https://www.jetbrains.com/help/idea/json.html#ws_json_using_schemas
I also would like some additional validation. In particular, validating that the $ref references are pointing to valid files. Eg.
/root/inputs:
$ref: './paths/roots/inputs.yaml'
If there is no such inputs.yaml file, the plugin should detect it and give a warning
I found that specifying a JSON schema (openapi-3.0 or swagger-2.0) warns about a lot of the errors that the Swagger Editor detects. Maybe this plugin can enable that by default. https://www.jetbrains.com/help/idea/json.html#ws_json_using_schemas
I have been planning to take a look at this! This would likely be a big help with keeping spec files valid.
In particular, validating that the $ref references are pointing to valid files.
Agree, created an issue #226
in #227, I was looking for libraries that could be integrated. In doing so I came across these linters. Most of them aren't Java, and those that are implement their own parser as well, so I'm not sure how embeddable these could be. But, all of them might offer hints about how to do validation logic beyond using the json schema.
Thanks for the list @cognifloyd I will start with a JSON Schema validation as a "low hanging fruit", and iterate on top of that.
A Swagger/OpenAPI specification file is currently validated with a JSON Schema. On top of that, we validate that references point to existing objects.
I will close this issue; validation issues should be handled by individual issues from now on.
When I paste the content of my swagger file to http://editor.swagger.io/ it reports a lot of errors(bad indentation, semantic errors, schema errors), while plugin itself doesn't report anything.
This is the request to add the ability to provide the same level of validation in the plugin. To achieve this we can go following ways: