fix: Extend spec loading#72
Merged
Merged
Conversation
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.
sasjo
approved these changes
May 20, 2026
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).
|
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.



No description provided.