Orange-OpenSource / hurl

Hurl, run and test HTTP requests with plain text.
https://hurl.dev
Apache License 2.0
13.11k stars 490 forks source link

Support --error-format=json #2499

Open hsanson opened 8 months ago

hsanson commented 8 months ago

Problem to solve

Current error formats short and long are too complex to parse. Would be nice to have the output formatted in JSON so is easier to parse.

Proposal

Output compatible with vim's quickfix list would be best:

[
  {  
    "filename": "/absolute/path/to/file.hurl", 
    "lnum": 20, 
    "end_lnum": 20,
    "col": 1,
    "end_col": 25,
    "text":  "Undefined Variable: you must set the variable post_id" ,
    "type": "E"
  }
]

Additional context and resources

Trying to improve the hurl.nvim plugin.

Tasks to complete

jcamiel commented 8 months ago

Hi @hsanson

Sorry for the delay!

Yes, it's make totally sens to add --error-format=json.

Just a small note, the JSON format will certainly be a little different from vim's. Partly because we already serialise error with --json but also because I think we'll add specific HTTP fields (like body response, headers etc...). Of course, we'll have every field necessary to display an error: filename, error start and end position, textual description so it should be easy to map to a vim's error JSON.

It's okay with you?

hsanson commented 8 months ago

As long as it is json format, I can parse, modify, and present it whichever way is best for my editor.