Support JSON spec files alongside YAML#74
Merged
jorgenosberg merged 2 commits intomainfrom Mar 13, 2026
Merged
Conversation
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.
There was a problem hiding this comment.
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.jsonand treat.jsonas a candidate spec extension. - Replace
is_yaml()filtering withis_spec_file()and adjustis_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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #71
.jsonfiles (root-level quick check and deep traversal)is_yaml()→is_spec_file()to accept.jsonalongside.yaml/.ymlis_openapi_spec()to read only the first 512 bytes instead of fully parsing each file"openapi":(key + colon) for JSON to avoid false positives on string valuestests/discover.rs): root/nested/negative cases for JSON and YAML, including false-positive guard