lutaml-jsonschema 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CLAUDE.md +55 -0
- data/lib/lutaml/jsonschema/cli.rb +4 -3
- data/lib/lutaml/jsonschema/schema.rb +3 -1
- data/lib/lutaml/jsonschema/version.rb +1 -1
- metadata +19 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f6542de697d4e9bb258f8b2291430b9cc8c2244ec3b46ac7e30e92b7192e5d19
|
|
4
|
+
data.tar.gz: bc5641c42ecc85dad8098eb35302ff26ff2912f9f1a207f70301a4960a2e3883
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc41187d4a77c7a6c1c613696f1687595968928478bc4e6ee0fdcdb0a1fcca21816655efc36ca2989ddd6ed72bae238bc5e16dc949a3237138e234050b038433
|
|
7
|
+
data.tar.gz: bea291d15415a80a8487c44143065aec658e3a00c6235703de99bba8907e43f1377e2f4bf23fd4acfffdef8abadc25eecf748884da6175a183c7191b2bfc704e
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
`lutaml-jsonschema` parses JSON Schema documents into lutaml-model objects and generates a single-file SPA documentation site from them. It has two halves that must stay in sync:
|
|
8
|
+
|
|
9
|
+
1. **Ruby gem** (`lib/lutaml/jsonschema/`) — the JSON Schema model and documentation generator.
|
|
10
|
+
2. **Vue 3 frontend** (`frontend/`) — the SPA itself. The built bundle (`frontend/dist/app.iife.js` + `style.css`) gets inlined into a standalone `index.html`.
|
|
11
|
+
|
|
12
|
+
## Commands
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
bundle exec rspec # full suite
|
|
16
|
+
bundle exec rspec spec/lutaml/cli_spec.rb # one file
|
|
17
|
+
bundle exec rspec spec/lutaml/cli_spec.rb:76 # one example
|
|
18
|
+
bundle exec rubocop # lint (-a to autofix; .rubocop_todo.yml holds baselined offenses)
|
|
19
|
+
bundle exec rake # spec + rubocop (what CI runs)
|
|
20
|
+
|
|
21
|
+
bundle exec rake frontend:build # npm install + vite build → frontend/dist
|
|
22
|
+
cd frontend && npm test # vitest (frontend unit tests)
|
|
23
|
+
|
|
24
|
+
bundle exec exe/lutaml-jsonschema spa|combine|validate SCHEMA_FILES...
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`frontend/dist/` and `Gemfile.lock` are gitignored. `frontend/dist/` must exist (run `rake frontend:build`) for the `spa` command and for packaging — the gemspec ships it via `Dir.glob("frontend/dist/*")`.
|
|
28
|
+
|
|
29
|
+
## Architecture
|
|
30
|
+
|
|
31
|
+
Data flow: schema files → `SchemaSet.load_from_files` → `Spa::SpaBuilder` → `Spa::SpaDocument` → `to_json` → `Spa::VueInlinedStrategy` (embeds `window.SCHEMA_DATA` + inlined JS/CSS into `index.html`).
|
|
32
|
+
|
|
33
|
+
- **`Base`** — everything inherits from `Lutaml::Model::Serializable`. `Base` also forward-declares `Schema` to break the circular `Schema ↔ PropertyEntry ↔ Link` references.
|
|
34
|
+
- **`Schema`** — the central model of a JSON Schema document. Every `$`-prefixed keyword is a `dollar_`-prefixed attribute (`$schema` → `dollar_schema`) via json mappings. `Schema.from_json` / `to_json` are lutaml-model serialization.
|
|
35
|
+
- **`SchemaSet`** — in-memory named collection of schemas plus `$ref` resolution (local `#/...` pointers and relative `./file.json` refs through `ReferenceResolver`) and validation.
|
|
36
|
+
- **`SchemaStore`** — `SchemaSet` subclass that adds on-disk persistence through **lutaml-store** (`PackageStore`, package shape from `LjrPackageDefinition`).
|
|
37
|
+
- **`Combiner`** — merges a `SchemaSet` into one document: hoists all definitions, adds a top-level `$ref` property per source schema, rewrites `#/definitions/` → `#/$defs/`.
|
|
38
|
+
- **`Spa::*`** — `SpaBuilder` flattens a `SchemaSet` into a `SpaDocument` (metadata, `SpaSchema` list, flat `search_index` for FlexSearch). `Spa::Generator` renders through an `OutputStrategy`; `VueInlinedStrategy` is the only implementation.
|
|
39
|
+
- **`Configuration`** — YAML config for the SPA (title, theme, appearance…), loaded by `Cli#spa -c`.
|
|
40
|
+
- **`Cli`** — Thor commands: `spa` (generate docs), `combine` (merge schemas), `validate` (parse + shallow structural checks).
|
|
41
|
+
|
|
42
|
+
## JSON engine: yeptris
|
|
43
|
+
|
|
44
|
+
Two distinct paths, both engine-backed:
|
|
45
|
+
|
|
46
|
+
- **Direct parsing** in this gem (`Cli#combine`, `Cli#validate`, `Schema.serialize_additional_properties`) uses `Yeptris::JSON.load` — strict RFC 8259, exact-`JSON.parse` semantics, raises `Yeptris::JSON::ParseError`. JSON **generation** stays on the stdlib `json` gem (`JSON.pretty_generate`); yeptris's JSON surface is load-only.
|
|
47
|
+
- **Model serialization** (`Schema.from_json`/`to_json`, `Configuration.from_yaml`, lutaml-store I/O) goes through lutaml-model, whose `AdapterResolver` auto-detects yeptris from the bundle and routes both `:json` and `:yaml` to its `YeptrisAdapter`. That adapter re-raises parse failures as `JSON::ParserError`, so error handling must cover **both** exception types — see the rescue in `Cli#validate`.
|
|
48
|
+
- Raw-parse speed depends on the resolved yeptris build shipping a **native materializer for the running Ruby version**; without one it falls back to a pure-Ruby tape engine that is several times slower than `JSON.parse` on large documents (yeptris-ruby#278). Check with `defined?(Yeptris::Native)` (0.6.28.x shipped only Ruby 3.3; 3.4-native starts at 0.6.29.1).
|
|
49
|
+
- The GC-pressure SIGSEGV in the native JSON materializer (yeptris-ruby#279) is fixed in the yeptris **0.6.34 line** (staged pairs made GC-visible); the gemspec floors at `~> 0.6.34`, excluding the crashy 0.6.29.x–0.6.33.x native builds. Env-gated canary: yeptris-ruby#280.
|
|
50
|
+
|
|
51
|
+
## Repo notes
|
|
52
|
+
|
|
53
|
+
- `README.md` is unreplaced gem-template boilerplate — don't treat it as documentation.
|
|
54
|
+
- `TODO.redoc/`, `TODO.refactor/`, `TODO.store/` are untracked, numbered working notes (known gaps and planned refactors), not code. `TODO.sota/` holds the SOTA program (purpose, per-area tasks with done-when criteria, and the goal prompt).
|
|
55
|
+
- CI is metanorma/ci's `generic-rake` workflow; releases run through `.github/workflows/release.yml`.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "thor"
|
|
4
4
|
require "json"
|
|
5
|
+
require "yeptris"
|
|
5
6
|
|
|
6
7
|
module Lutaml
|
|
7
8
|
module Jsonschema
|
|
@@ -44,7 +45,7 @@ module Lutaml
|
|
|
44
45
|
|
|
45
46
|
schema_set = SchemaSet.load_from_files(*schema_files)
|
|
46
47
|
combined = Combiner.new.combine(schema_set)
|
|
47
|
-
json = JSON.pretty_generate(JSON.
|
|
48
|
+
json = JSON.pretty_generate(Yeptris::JSON.load(combined.to_json))
|
|
48
49
|
|
|
49
50
|
if options[:output] == "-"
|
|
50
51
|
$stdout.write(json)
|
|
@@ -59,7 +60,7 @@ module Lutaml
|
|
|
59
60
|
desc "validate SCHEMA_FILE", "Validate a JSON Schema file"
|
|
60
61
|
def validate(schema_file)
|
|
61
62
|
data = File.read(schema_file)
|
|
62
|
-
json = JSON.
|
|
63
|
+
json = Yeptris::JSON.load(data)
|
|
63
64
|
Schema.from_json(data)
|
|
64
65
|
|
|
65
66
|
errors = validate_structure(json)
|
|
@@ -69,7 +70,7 @@ module Lutaml
|
|
|
69
70
|
errors.each { |e| warn " #{e}" }
|
|
70
71
|
abort "#{schema_file}: #{errors.length} validation error(s)"
|
|
71
72
|
end
|
|
72
|
-
rescue JSON::ParserError => e
|
|
73
|
+
rescue Yeptris::JSON::ParseError, JSON::ParserError => e
|
|
73
74
|
abort "Invalid JSON: #{e.message}"
|
|
74
75
|
rescue Errno::ENOENT => e
|
|
75
76
|
abort "Error: #{e.message}"
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "yeptris"
|
|
4
|
+
|
|
3
5
|
module Lutaml
|
|
4
6
|
module Jsonschema
|
|
5
7
|
class Schema < Base
|
|
@@ -158,7 +160,7 @@ module Lutaml
|
|
|
158
160
|
def serialize_additional_properties(instance, hash)
|
|
159
161
|
if instance.additional_properties_schema
|
|
160
162
|
hash["additionalProperties"] =
|
|
161
|
-
JSON.
|
|
163
|
+
Yeptris::JSON.load(instance.additional_properties_schema.to_json)
|
|
162
164
|
elsif !instance.additional_properties.nil?
|
|
163
165
|
hash["additionalProperties"] = instance.additional_properties
|
|
164
166
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lutaml-jsonschema
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.23
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.8.
|
|
33
|
+
version: 0.8.114
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.8.
|
|
40
|
+
version: 0.8.114
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: lutaml-store
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -66,6 +66,20 @@ dependencies:
|
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '1.3'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: yeptris
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.6.34
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.6.34
|
|
69
83
|
description: Parse JSON Schema files into LutaML model objects and generate SPA documentation
|
|
70
84
|
sites
|
|
71
85
|
email:
|
|
@@ -77,6 +91,7 @@ extra_rdoc_files: []
|
|
|
77
91
|
files:
|
|
78
92
|
- ".rubocop_todo.yml"
|
|
79
93
|
- CHANGELOG.md
|
|
94
|
+
- CLAUDE.md
|
|
80
95
|
- CODE_OF_CONDUCT.md
|
|
81
96
|
- README.md
|
|
82
97
|
- Rakefile
|