lutaml-openapi 0.1.3 → 0.1.4
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 +40 -0
- data/README.md +39 -5
- data/lib/lutaml/openapi/version.rb +1 -1
- data/script/axe_audit +14 -7
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a13447333197bc73f7ab9e0763de44bd60b43afdb8b7412a9d8b5be785714b1
|
|
4
|
+
data.tar.gz: cac05b7b1faaa9125cd2c4c940d399ff731facccca9d5b6bc68aa227b931cb50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 252cff177542a2521cfff3449cde4751940736b882974471a64013d1ef95861e1ed52a8d0d9794a378eebef801769b84a7a53a78bf4802831c91b7ed377d254a
|
|
7
|
+
data.tar.gz: f9dc0913ced60ac6e68e116dea1edd357e1aa9e40b201ea6f22f09e3017f2110b03b67c5c992c3180341d045ee2ccc9e59c3e37d5fd023510014a09f2ec4be89
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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-openapi` parses OpenAPI 3.0/3.1 documents into lutaml-model objects and generates a single-file SPA documentation site from them. It is the model layer for model-based OpenAPI standards (metanorma-ogc#153); `metanorma-plugin-openapi` renders these models into Metanorma documents.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
bundle exec rspec # full suite (corpus golden included)
|
|
13
|
+
bundle exec rspec spec/openapi_spec.rb # one file
|
|
14
|
+
bundle exec rubocop # lint (-a to autofix; .rubocop_todo.yml holds baselined offenses)
|
|
15
|
+
bundle exec rake # spec + rubocop + frontend:audit (axe; needs Chrome, skips cleanly without)
|
|
16
|
+
|
|
17
|
+
cd frontend && npm test # vitest (frontend i18n suite)
|
|
18
|
+
cd frontend && npm run build # vite build → frontend/dist
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`frontend/dist/` and `Gemfile.lock` are gitignored. `frontend/dist/` must exist for the SPA generator; the rake gate audits the generated site when Chrome is present. The rake CI does NOT build the frontend — a green CI says nothing about the SPA; run `npm ci && npm run build` locally to verify frontend changes.
|
|
22
|
+
|
|
23
|
+
## Architecture
|
|
24
|
+
|
|
25
|
+
- **`Lutaml::Openapi.parse`** stores the document **verbatim** — every parsed section is kept exactly as the source carried it (3.0 dialects included), so both wire serializations (`to_json`, `to_hash`) round-trip losslessly with no emit-time transform. `source_dialect` tracks the frontend used.
|
|
26
|
+
- **`Document#schemas`** is the typed view: it materializes `Lutaml::Jsonschema::Schema` models, applying `Oas30.normalize` per schema for 3.0 sources (nullable → null-union, exclusive bounds folded). That view is the only place the 3.0 frontend runs.
|
|
27
|
+
- **`Oas30`** normalizes 3.0 schema nodes into the 3.1 shape as a pure hash walk. There is no denormalization — do not add emit-time transforms; losslessness is structural.
|
|
28
|
+
- Unmapped root keys (vendor `x-*`, stray sections like `definitions`) ride the `extensions` catch-all and re-emit verbatim.
|
|
29
|
+
- **`CorpusAudit`** (lib/lutaml/openapi/corpus_audit.rb) asserts the wire round trip for every fixture in `spec/fixtures/` — 19 OGC API OAS documents. New fixtures are picked up automatically; validate Gemfile changes with a local `bundle lock` before shipping.
|
|
30
|
+
- **`Spa`** inlines `frontend/dist` with `window.OPENAPI_DATA` into a standalone `index.html`; dist enters the gem only at release time (the release train builds it).
|
|
31
|
+
|
|
32
|
+
## CI/release
|
|
33
|
+
|
|
34
|
+
- `.github/workflows/rake.yml` builds the frontend (`after-setup-ruby`) so green lanes validate the SPA.
|
|
35
|
+
- `release.yml` is self-contained (RubyGems Trusted Publishing is registered against THIS repo's workflow): dispatch with `next_version=patch|minor|major|x.y.z`. It bumps the version, builds the dist, publishes, and tags.
|
|
36
|
+
|
|
37
|
+
## Frontend
|
|
38
|
+
|
|
39
|
+
- All UI strings flow through the typed catalog `frontend/src/i18n/messages.ts` (`en` + `ar`); a missing key in a locale is a type error. The header locale switch mirrors `lang`/`dir` onto `<html>` (RTL without a second stylesheet); `?locale=ar` boots into a locale.
|
|
40
|
+
- Layout uses CSS logical properties; the axe audit gates both the LTR and Arabic RTL renders.
|
data/README.md
CHANGED
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
# Lutaml::Openapi
|
|
2
2
|
|
|
3
|
-
OpenAPI 3.0/3.1 as a lossless lutaml-model
|
|
4
|
-
|
|
5
|
-
metanorma
|
|
3
|
+
OpenAPI 3.0/3.1 as a lossless [lutaml-model](https://github.com/lutaml/lutaml-model)
|
|
4
|
+
object graph — the model layer for model-based OpenAPI standards
|
|
5
|
+
(metanorma-ogc#153).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```ruby
|
|
8
|
+
require "lutaml/openapi"
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
doc = Lutaml::Openapi.parse(File.read("ogcapi-features-1.yaml"))
|
|
11
|
+
doc.openapi # => "3.1.0"
|
|
12
|
+
doc.source_dialect # => "3.1" (or "3.0" for normalized-on-read sources)
|
|
13
|
+
doc.info["title"] # => "OGC API - Features - Part 1: Core"
|
|
14
|
+
doc.paths # => { "/collections" => { "get" => { ... } } }
|
|
15
|
+
doc.to_json # lossless re-serialization
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Losslessness
|
|
19
|
+
|
|
20
|
+
The document is stored **verbatim**: every parsed section is kept exactly as
|
|
21
|
+
the source carried it, unmodeled keywords (vendor `x-*`, stray root sections)
|
|
22
|
+
re-emit on serialization via `map_unmapped`, and the wire round trip
|
|
23
|
+
(`parse → to_json`) is asserted losslessly for the **full 19-document OGC API
|
|
24
|
+
corpus** vendored in `spec/fixtures` — 3.0 and 3.1 dialects, YAML and JSON.
|
|
25
|
+
3.0 documents need no denormalization pass; see the architecture notes in
|
|
26
|
+
[CLAUDE.md](CLAUDE.md).
|
|
27
|
+
|
|
28
|
+
## Typed schema view
|
|
29
|
+
|
|
30
|
+
`Document#schemas` materializes `components.schemas` as
|
|
31
|
+
`Lutaml::Jsonschema::Schema` objects — 3.0 dialect semantics normalize into
|
|
32
|
+
the 3.1 shape here (`nullable: true` becomes the null-member type union,
|
|
33
|
+
`exclusiveMinimum: true` folds into the bound). This is the view
|
|
34
|
+
[metanorma-plugin-openapi](https://github.com/metanorma/metanorma-plugin-openapi)
|
|
35
|
+
renders from.
|
|
36
|
+
|
|
37
|
+
## SPA
|
|
38
|
+
|
|
39
|
+
`Lutaml::Openapi::Spa.generate(doc)` builds a standalone single-file
|
|
40
|
+
documentation site (Vue bundle + document data inlined). The frontend ships
|
|
41
|
+
an en+ar locale switch with RTL layout and passes an axe AA audit in CI.
|
|
42
|
+
|
|
43
|
+
See [PLAN.md](PLAN.md) for the program plan.
|
data/script/axe_audit
CHANGED
|
@@ -67,15 +67,22 @@ dir = Dir.mktmpdir("axe-audit")
|
|
|
67
67
|
document = Lutaml::Openapi.parse(File.read(DOCUMENT))
|
|
68
68
|
File.write(File.join(dir, "index.html"), Lutaml::Openapi::Spa.generate(document))
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
# an empty document must boot and stay accessible too: a JS crash on
|
|
71
|
+
# missing sections would otherwise ship and only surface in production
|
|
72
|
+
empty = Lutaml::Openapi.parse("{}")
|
|
73
|
+
File.write(File.join(dir, "empty.html"), Lutaml::Openapi::Spa.generate(empty))
|
|
74
|
+
|
|
71
75
|
File.write(File.join(dir, "audit.html"),
|
|
72
|
-
File.read(
|
|
76
|
+
File.read(File.join(dir, "index.html")).sub("</body>", "#{INJECT}\n</body>"))
|
|
77
|
+
File.write(File.join(dir, "audit-empty.html"),
|
|
78
|
+
File.read(File.join(dir, "empty.html")).sub("</body>", "#{INJECT}\n</body>"))
|
|
73
79
|
|
|
74
|
-
# both locales
|
|
75
|
-
#
|
|
80
|
+
# gate matrix: both locales on the real document (the mirrored layout
|
|
81
|
+
# must stay accessible), plus the empty document in the default locale
|
|
76
82
|
VARIANTS = [
|
|
77
|
-
{ label: "en", query: "" },
|
|
78
|
-
{ label: "ar (rtl)", query: "?locale=ar" },
|
|
83
|
+
{ label: "en", page: "audit.html", query: "" },
|
|
84
|
+
{ label: "ar (rtl)", page: "audit.html", query: "?locale=ar" },
|
|
85
|
+
{ label: "empty doc", page: "audit-empty.html", query: "" },
|
|
79
86
|
].freeze
|
|
80
87
|
|
|
81
88
|
failed = false
|
|
@@ -83,7 +90,7 @@ failed = false
|
|
|
83
90
|
VARIANTS.each do |variant|
|
|
84
91
|
dom, err, status = Open3.capture3(
|
|
85
92
|
chrome, "--headless=new", "--disable-gpu", "--virtual-time-budget=20000",
|
|
86
|
-
"--dump-dom", "file://#{File.join(dir,
|
|
93
|
+
"--dump-dom", "file://#{File.join(dir, variant[:page])}#{variant[:query]}"
|
|
87
94
|
)
|
|
88
95
|
abort "axe audit: Chrome failed: #{err[0, 400]}" unless status.success?
|
|
89
96
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lutaml-openapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
@@ -44,14 +44,14 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.8.
|
|
47
|
+
version: 0.8.156
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.8.
|
|
54
|
+
version: 0.8.156
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: yeptris
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -76,6 +76,7 @@ extra_rdoc_files: []
|
|
|
76
76
|
files:
|
|
77
77
|
- ".rubocop_todo.yml"
|
|
78
78
|
- CHANGELOG.md
|
|
79
|
+
- CLAUDE.md
|
|
79
80
|
- CODE_OF_CONDUCT.md
|
|
80
81
|
- LICENSE.md
|
|
81
82
|
- PLAN.md
|