IBM / openapi-validator

Configurable and extensible validator/linter for OpenAPI documents
Apache License 2.0
507 stars 91 forks source link

[feature request] new output format for Code Climate #512

Open Blaimi opened 2 years ago

Blaimi commented 2 years ago

For the integration of the validation results in other software, it would be nice to have the possibility to get the output as json as specified by Code Climate. Especially the integration in gitlab-ci requires this format.

https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#data-types

dpopp07 commented 2 years ago

@Blaimi Are you using the validator as a Node module within JavaScript code or as a CLI tool?

Blaimi commented 2 years ago

I want to use it in a gitlab-pipeline [1]. gitlab requires the code climate output format for integration in code quality reports [2].

[1] https://gitlab.com/biletado/apidocs/-/blob/0dfa977c8cc38282dada77f50c8db151f5e6926d/.gitlab-ci.yml#L6 [2] https://docs.gitlab.com/ee/ci/testing/code_quality.html#implementing-a-custom-tool

dpopp07 commented 2 years ago

I see. So it's not sufficient just to have JSON output, you need an entirely new output structure?

padamstx commented 1 year ago

@Blaimi in our official 1.0.0 release of the validator, we have defined a json schema that describes the JSON output produced by the validator. Perhaps a way to solve this would be to use a tool such as jq to post-process the validator's JSON output to produce the correct format needed by Code Climate.

Blaimi commented 1 year ago

Yes, I considered jq for a few moments, but when I remember correct, the structures are too different for an easy and maintainable solution. It's probably easier to write a small node tool or wrapper in a oop language which transforms the output.

Would you accept a PR on this topic with an implementation? e.g. with outputFormat: codeclimate/--codeclimate?