stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI (v3.1, v3.0, and v2.0), Arazzo v1.0, as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.48k stars 233 forks source link

PowerShell: Multiple Formater / Output does not work #2553

Open LasneF opened 10 months ago

LasneF commented 10 months ago

Describe the bug the feature leveraging multiple formater / output is broken

To Reproduce

returns Invalid values: Argument: format, Given: "junit html", Choices: "json", "stylish", "junit", "html", "text", "teamcity", "pretty", "github-actions", "sarif

notice i provided a coma , but the is mentionning a space

return Multiple outputs have to be provided when more than a single format is specified

looks several -f is correctly interpreting as multiple formater , but not multiple output

Returns The number of outputs must match the number of formats

at the end i do not have found the right combination that make the multiple output working (target junit, html and stdout)

Expected behavior command line working like this

i can provide either -f junit,html or -f junit -f html , and same for output

documentation for the stdout output documentation with a basic sample with for instance stdout + a formater *

notice as well that in the simple case spectral lint openapi.yaml -r .spectral.yaml -f junit -o a.junit -q true

leveraging -q true or false as no impact , wheras i would expect it has (my target beeing output on stdout + html file)

Environment spectral --version : 6.11.0

kiranpatel11 commented 10 months ago

+1

Invalid values:
  Argument: format, Given: "json,junit", Choices: "json", "stylish", "junit", "html", "text", "teamcity", "pretty", "github-actions", "sarif"
mnaumanali94 commented 9 months ago

The documentation is incorrect. The command needs to be -f json -f text. We'll use this issue to update the docs.

quadrrem commented 8 months ago

Ran in the same issue. And also the documentation for multiple outputs (in combination with multiple formats) seems hard to understand

-o, --output                   where to output results, can be a single file name, multiple "output.<format>" or missing to print to stdout

For the part of "multiple "output."" it was not clear to me that this was referring to the output parameter itself and not the value that is passed with the parameter. Maybe an example in the documentation could help clear things up.

@LasneF a working command for your usecase would be

spectral lint openapi.yaml -r .spectral.yaml  -f junit -f html -o.junit a.xml -o.html a.html
LasneF commented 8 months ago

@P0lip are you sure it is only documentation ; the command line you provides does not work on my side

image

using spectral v6.11.0 running on windows

P0lip commented 8 months ago

@LasneF Could you try changing the shell to a Unix one like bash or zsh and see if it works? It might be possibly related to PowerShell - I don't know how it behaves there. There's a chance it gets parsed differently. I tried running a very similar command to yours and it completed just fine, but that's on Unix shell.

image
LasneF commented 8 months ago

@P0lip testing on Linux looks working , so this is a powershell topic , to me it deserve the bug to be re open , or to create a dedicated one on windows , as it is still a widely used platform

P0lip commented 8 months ago

@LasneF I'll follow up with that next week. I agree it's something we should at the very least document and offer a workaround.