Describe the bug
When running spectral lint with --format json against a valid OpenAPI document that produces no findings, the output is []No results with a severity of 'warn' or higher found! instead of just []. The informational message is
appended directly to the JSON array, making the output invalid JSON and breaking any tooling that parses stdout.
To Reproduce
- Given this OpenAPI document
valid.yaml:
openapi: "3.0.3"
info:
title: Test
version: "1.0.0"
description: Test API
contact:
name: test
paths: {}
servers:
- url: https://example.com
-
Run:
spectral lint valid.yaml --format json --fail-severity warn
-
stdout is:
[]No results with a severity of 'warn' or higher found!
This is not valid JSON.
Expected behavior
When --format json is used, stdout should contain only valid JSON. The informational message No results with a severity of 'warn' or higher found! should either be suppressed, written to stderr, or not appended to the JSON
output. Expected stdout:
Environment:
- Library version: 6.15.0
- OS: Linux
Describe the bug
When running
spectral lint with --format jsonagainst a valid OpenAPI document that produces no findings, the output is[]No results with a severity of 'warn' or higher found!instead of just[]. The informational message isappended directly to the JSON array, making the output invalid JSON and breaking any tooling that parses
stdout.To Reproduce
valid.yaml:Run:
spectral lint valid.yaml --format json --fail-severity warnstdout is:
[]No results with a severity of 'warn' or higher found!This is not valid JSON.
Expected behavior
When
--format jsonis used,stdoutshould contain only valid JSON. The informational messageNo results with a severity of 'warn' or higher found!should either be suppressed, written tostderr, or not appended to the JSONoutput. Expected
stdout:Environment: