Skip to content

Support JSON spec files alongside YAML#74

Merged
jorgenosberg merged 2 commits intomainfrom
feature/json-spec-support
Mar 13, 2026
Merged

Support JSON spec files alongside YAML#74
jorgenosberg merged 2 commits intomainfrom
feature/json-spec-support

Conversation

@jorgenosberg
Copy link
Collaborator

@jorgenosberg jorgenosberg commented Mar 13, 2026

Closes #71

  • Extend spec discovery to include .json files (root-level quick check and deep traversal)
  • Rename is_yaml()is_spec_file() to accept .json alongside .yaml/.yml
  • Optimize is_openapi_spec() to read only the first 512 bytes instead of fully parsing each file
  • Match "openapi": (key + colon) for JSON to avoid false positives on string values
  • 9 new discovery tests (tests/discover.rs): root/nested/negative cases for JSON and YAML, including false-positive guard
  • 4 new Docker integration tests: valid/invalid JSON specs with both Spectral and Redocly

Extend spec discovery to include .json files in both root-level quick
check and deep walkdir traversal. Use serde_json for stricter content
inspection of JSON files while keeping serde_yaml for YAML. Optimize
is_openapi_spec to read only the first 512 bytes instead of parsing
the full file.

Add integration tests for JSON spec discovery and Docker-based linting
with both Spectral and Redocly.
Copilot AI review requested due to automatic review settings March 13, 2026 09:15
@jorgenosberg jorgenosberg self-assigned this Mar 13, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds OpenAPI spec discovery support for .json files (in addition to .yaml/.yml) and extends the test suite to cover JSON discovery/validation paths.

Changes:

  • Extend spec discovery to include openapi.json and treat .json as a candidate spec extension.
  • Replace is_yaml() filtering with is_spec_file() and adjust is_openapi_spec() to do a small “header scan”.
  • Add new unit/integration tests plus JSON fixtures for valid/invalid OpenAPI specs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/util.rs Adds .json to discovery and changes OpenAPI “is this a spec?” detection logic.
tests/discover.rs New tests for root + nested discovery, including JSON cases and negative cases.
tests/validate.rs Adds ignored Docker validation tests for JSON specs (Spectral/Redocly).
tests/fixtures/valid.json New valid OpenAPI JSON fixture.
tests/fixtures/invalid.json New invalid OpenAPI JSON fixture.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Check for "openapi": (with colon) instead of just "openapi" to avoid
false positives when the word appears as a JSON string value. Add a
test covering this case.
@jorgenosberg jorgenosberg merged commit 53c4e91 into main Mar 13, 2026
3 checks passed
@jorgenosberg jorgenosberg deleted the feature/json-spec-support branch March 13, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support JSON spec files alongside YAML

2 participants