Skip to content

fix: Extend spec loading#72

Merged
thced merged 5 commits into
masterfrom
fix/spec-loading
May 20, 2026
Merged

fix: Extend spec loading#72
thced merged 5 commits into
masterfrom
fix/spec-loading

Conversation

@thced

@thced thced commented May 20, 2026

Copy link
Copy Markdown
Contributor

No description provided.

thced added 3 commits May 20, 2026 10:06
Spec.fromPath required a filesystem Path, which is awkward for callers
loading the spec from the classpath via getResourceAsStream and outright
broken when the resource lives inside a JAR.

Add four new entry points:

- Spec.fromJson(InputStream)                       — Gson (reflective)
- Spec.fromJson(InputStream, Function<byte[],Map>) — BYO parser (Jackson, ...)
- Spec.fromYaml(InputStream)                       — SnakeYAML (reflective)
- Spec.fromYaml(InputStream, Function<byte[],Map>) — BYO parser

All four consume and close the stream, NPE on null args, and surface IO
failures as UncheckedIOException. fromPath now shares the same byte-based
internal parsers.

Also ignore .claude/worktrees/ so local agent worktrees don't pollute
git status.
README only covered Spec.fromPath; add a classpath example using
getResourceAsStream and document the BYO-parser overloads for callers
that don't want a Gson or SnakeYAML dependency.
Comment thread README.md
thced added 2 commits May 20, 2026 11:01
Surrounding text builds the server from spec, so it must be reachable
after the try block. Use an uninitialized declaration rather than
null-init — javac's definite-assignment analysis covers the only
non-throwing path.
SnakeYAML is the only YAML parser in common Java use, so the parser-
injecting variant carries API surface for no real callers. Users who
need a different YAML library can decode the stream themselves and
call Spec.from(Map).
@sonarqubecloud

Copy link
Copy Markdown

@thced thced merged commit 7d99cea into master May 20, 2026
5 checks passed
@thced thced deleted the fix/spec-loading branch May 20, 2026 09:14
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.

2 participants