Skip to content

Conversation

abfeb8
Copy link

@abfeb8 abfeb8 commented Jul 29, 2025

Fixes #2835.

This PR adds a new feature to display JSON paths in HTML result generated by Spectral.
It introduces a new CLI option --html-include-json-path that, when enabled, shows the JSON path for each reported issue in the HTML output, making it easier to locate and fix issues in large documents.

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

Screenshots

  • HTML format result with --html-include-json-path true
image
  • HTML format result without flag
image

Changes

  • Added --html-include-json-path CLI option (default: false)
  • Created HtmlFormatterOptions type to support HTML-specific formatter options
  • Modified HTML formatter to include JSON paths when requested
  • Updated HTML templates to add a column for JSON path display

Additional context

This enhancement improves the HTML report's usefulness by providing clear location information for each validation error through JSON paths. When diagnosing issues in complex API definitions, knowing the exact JSON path makes troubleshooting significantly faster.

The implementation uses the existing printPath utility from @stoplight/spectral-runtime to format paths in dot notation style. The JSON path is only included when specifically requested via the CLI option, maintaining backward compatibility with existing usage.

@abfeb8 abfeb8 requested a review from a team as a code owner July 29, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Include JsonPath in HTML Format
1 participant