italia/publiccode-parser-go

Output in a structured format in pcvalidator

Closed this issue · 5 comments

Supporting output in a structured format (JSON?) would allow us to return validation metadata (fe. the line and column number with the validation error) and that would be useful when integrating pcvalidator in automated environments and CI/CD.

Yep it could be extremely useful but we do have also the publiccode-validator which is an API layer for this parser itself, and it, of course, returns in both JSON and yaml format. wdyt?

@sebbalex Sorry, I should've explained better.

The use case and format I had in mind is something among the lines of:

# Validation success
$ pcvalidator --json publiccode.yml
[]
# Validation failure
$ pcvalidator --json publiccode.yml
[
    {"message": "Invalid UTF: the file is not UTF encoded", "line": null, "column": null, "other_useful_fields": ...},
    {"message": "invalid key foobarbaz", "line": 3, "column": 1, "other_useful_fields": ...},
]

For instance, a GitHub action can run it and know exactly where the error is and use this information to bot-review the PR at that line.

Umh, I like the approach, I did not consider the pointer that an excerpt like this could gives. 👍

Depends on #74 .

Fixed by #81