feat(validate): accept file and http(s) URLs as input - #102
Merged
Conversation
Read the validate input through @speclynx/apidom-reference's readFile so a local path, a file:// URL, or an http(s):// URL are all accepted, replacing the file-only fs.readFileSync. Resolvers are passed explicitly (FileResolver with an open allow-list + HTTPResolverAxios) rather than inherited from the mutable global options, keeping the CLI's file access and network egress policy legible. The input is canonicalized to a URI before use: http(s) URLs pass through, file: URLs are round-tripped through fileURLToPath so every legal form normalizes alike, and bare paths become absolute file:// URLs. This matters because the URI also serves as the apidom-ls baseURI, where a raw Windows path or a relative path would otherwise misresolve. Add tests for file:// (JSON, YAML, single-slash), relative-path resolution, http fetch, query-string language detection, and a 404 error path, and run the test job on a Windows matrix leg to cover platform path handling.
There was a problem hiding this comment.
Pull request overview
Extends speclynx validate to accept local paths, file URLs, and HTTP(S) URLs.
Changes:
- Canonicalizes input URIs and reads them through explicit ApiDOM resolvers.
- Adds URI and HTTP validation tests across Linux and Windows.
- Updates CLI help and documentation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/commands/validate/action.ts |
Adds URI normalization and resolver-based input loading. |
src/commands/validate/index.ts |
Renames the input argument to <uri>. |
test/commands/validate/index.ts |
Tests file and HTTP URL inputs. |
README.md |
Documents URL validation support. |
.github/workflows/build.yml |
Runs tests on Ubuntu and Windows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use a /.*/ allow-list instead of the '*' glob so the file resolver accepts leading-dot basenames (.openapi.yaml). picomatch does not match a leading dot without dot:true, so '*' regressed valid local paths that the previous fs.readFileSync accepted.
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 20, 2026
# [1.3.0](v1.2.0...v1.3.0) (2026-07-20) ### Features * **validate:** accept file and http(s) URLs as input ([#102](#102)) ([36fb6d0](36fb6d0))
|
🎉 This PR is included in version 1.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
frantuma
added a commit
that referenced
this pull request
Jul 20, 2026
Address review of the rebased branch (char0n, Copilot): - Fix the overwrite guard, broken by the rebase onto the URL-input work (#102). It referenced an undefined `resolvedPath` (build failure) and, once named, compared a filesystem path against a file:// URI so it never matched. Now compares path-to-path via fileURLToPath(fileURI), and skips http(s) inputs where there is no local file to clobber. - Remove duplicate `fs` import in the validate test left by the rebase (was a duplicate-identifier build error). - Simplify color handling: instead of threading a `color` flag through FormatterContext/stylish/severityToString, strip ANSI at the single file write site. Formatters are oblivious to their destination again; stylish.ts and types.ts revert to their pre-refactor form. tsc, eslint, and the validate suite (incl. the overwrite and no-ANSI file tests) pass.
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.
Summary
speclynx validatenow accepts any URI as its input argument — a local file path (as before), afile://URL, or anhttp(s)://URL — instead of only a local filesystem path.Input is read through
@speclynx/apidom-reference'sreadFile, which dispatches to file and HTTP resolver plugins, replacing the file-onlyfs.readFileSync. The resolvers are passed explicitly (FileResolverwith an open allow-list +HTTPResolverAxioswith the network egress policy spelled out) rather than inherited from apidom-reference's mutable globaloptionssingleton, so the CLI's file access and network behavior are legible and reviewable in our source.URI canonicalization
The input is normalized to a canonical URI before use:
http(s)://URLs pass through untouched.file:URLs are round-tripped throughfileURLToPath→pathToFileURL, so every legal form (file:/x,file:///x,file://localhost/x) normalizes to the samefile:///x.This canonicalization is not for
readFile(it sanitizes its own argument) but because the same URI serves as thebaseURIapidom-ls uses verbatim to resolve relative external$refs — where a raw Windows path throwsERR_INVALID_URLand a relative path would resolve against the filesystem root instead of the document. Onlyhttp/https/fileare treated as schemes, so a relative filename containing a colon (draft:v1.json) is still read as a path.Tests
New
input URIstest block covering:file://URL to JSON and YAML documentsfile:URL normalizationhttpfetch via an ephemeral loopback serverContent-Type)The
testCI job now runs on anubuntu-latest+windows-latestmatrix, giving real coverage for the Windows path →file://URL branch that can't be exercised on Linux.Docs
README updated:
<file>→<uri>argument, a URL example, and the reference-validation description clarified to note it checks local (#/...) refs (external refs are not validated in apidom-ls's default mode).Test plan
npm run lint,npm run typescript:check-typescleannpm test— 75 passingfile://(single/triple-slash), andhttpURL inputs, plus the colon-in-filename and 404 cases