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 as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.37k stars 228 forks source link

Unable to parse results to html report #2555

Closed mitra0911 closed 7 months ago

mitra0911 commented 7 months ago
  1. Unable to parse results to html report. Steps I have followed
  2. Configure and Run const results = await spectral.run(myDocument);
  3. Pass results in formatOutput() const htmlResults = formatOutput(results, "html", spectral.ruleset)
  4. This is the package i'm using import outputFormatter from '@stoplight/spectral-cli/dist/services/output.js' const { formatOutput, writeOutput } = outputFormatter

Const results Output: [ { "code": "operation-tags", "message": "Operation must have non-empty \"tags\" array.", "path": [ "paths", "/health", "get", "tags" ], "severity": "warn", "range": { "start": { "line": 15, "character": 11 }, "end": { "line": 15, "character": 14 } } }, { "code": "operation-tags", "message": "Operation must have non-empty \"tags\" array.", "path": [ "paths", "/policies", "post" ], "severity": "warn", "range": { "start": { "line": 43, "character": 9 }, "end": { "line": 72, "character": 55 } } }, { "code": "operation-tags", "message": "Operation must have non-empty \"tags\" array.", "path": [ "paths", "/policies", "get" ], "severity": "warn", "range": { "start": { "line": 73, "character": 8 }, "end": { "line": 102, "character": 58 } } } ] Const htmlResults Output : <!DOCTYPE html>

Spectral Report

Spectral Report

- Generated on Mon Nov 27 2023 12:19:18 GMT+0530 (India Standard Time)
P0lip commented 7 months ago

Hey!

import outputFormatter from '@stoplight/spectral-cli/dist/services/output.js'

Consider using @stoplight/spectral-formatters instead. LMK if you had any issues using that