Skip to content

fix(utils): keep a property named $ref in makeLocalDefs - #67

Merged
BatLeDev merged 1 commit into
mainfrom
fix-local-defs-ref-property
Nov 9, 2026
Merged

BatLeDev merged 1 commit into
mainfrom
fix-local-defs-ref-property

Conversation

@BatLeDev

@BatLeDev BatLeDev commented Nov 9, 2026

Copy link
Copy Markdown
Member

makeLocalDefs treated every $ref key as a reference, including a property named $ref (the Reference Object of the OpenAPI 3.1 meta-schema), and crashed with value.startsWith is not a function. A JSON Schema $ref keyword is always a string, so non-string values are now walked as ordinary schema fragments.

Why: lib-types-builder >= 1.11 crashes on openapi-viewer's OpenAPI 3.1 schema because of this, which keeps openapi-viewer pinned at 1.10.1.

Heads-up: schemas that built before only had string $ref values, so their output is unchanged.

makeLocalDefs treated every "$ref" key as a reference, including a property named "$ref"
(the Reference Object of the OpenAPI 3.1 meta-schema), and crashed on value.startsWith.
A JSON Schema $ref keyword is always a string, so non-string values are now walked as
ordinary schema fragments. Schemas that built before only had string $ref values, so
their output does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BatLeDev
BatLeDev merged commit 91addfb into main Nov 9, 2026
1 check passed
@BatLeDev
BatLeDev deleted the fix-local-defs-ref-property branch November 9, 2026 09:57
BatLeDev added a commit to data-fair/openapi-viewer that referenced this pull request Nov 9, 2026
lib-utils 1.14.2 keeps a property named $ref in makeLocalDefs (data-fair/lib#67), so
lib-types-builder no longer crashes on the OpenAPI 3.1 meta-schema: ^1.14.6 with
lib-utils ^1.14.2 instead of the exact 1.10.1 pin. build-types and check-types pass with
the published versions.
BatLeDev added a commit to data-fair/openapi-viewer that referenced this pull request Nov 9, 2026
* docs(readme): homogeneous header and sponsors, link to datafair.cloud

Same header and sponsors block as the other data-fair services; Dawizz is no
longer listed as a sponsor.

* chore(deps): dependency refresh

- @data-fair/lib-express 2 and lib-node 3: the breaking change is the pino logger,
  which this service does not use (only session, errorHandler, site and SPA middlewares)
- @data-fair/lib-types-builder stays pinned at 1.10.1: later versions crash on the OpenAPI 3.1
  meta-schema (makeLocalDefs reads its $ref property as a reference)
- @data-fair/frame 0.19, @apidevtools/json-schema-ref-parser 16
- js-yaml 5: no default export any more, imported as a namespace
- lockfile refresh (minor and patch updates, npm audit fix: no high vulnerability left)
- dev environment tooling for the next commit: @data-fair/lib-dev, nodemon, dotenv
- engines.node >=24.22.1, like .nvmrc and the Docker image

* feat(api): add a /api/ping health route

Used as the readiness URL of the api pane in the dev environment, and usable as a
container healthcheck. The service has no dependency to check, so it answers ok.

* chore(dev): move the dev environment to @data-fair/lib-dev

- dev/dev.json: ports in .env (no more hard-coded 5600 / 8081 / 3000, nor the HMR port 7200
  shared with metrics), readiness URLs (api /api/ping, ui), dev page URL
- .zellij.kdl: panes run their command directly (no nvm/npm wrappers), status pane with
  df-status --start-deps, api with nodemon after df-dev wait-deps, vite under df-mem-cap
- api/nodemon.json replaces node --watch
- docker-compose: canonical nginx 1.29.4, simple-directory (healthcheck, shared dev secrets)
  and mongo 8.0.17 (healthcheck, 0.25 GB cache) blocks; no fake "dev" profile
- dev nginx template with the shared head instead of a full nginx.conf
- api config files in .mjs; the development one reads .env, the example docs URL follows
  the dev env's host and port; the unused test config and its branch in config.ts are removed
- vite: ports from .env with strictPort, no server block for vite preview
- scripts: dev-zellij through df-dev, stop-dev-deps on every profile, dev-* scripts removed
- playwright reads .env for its baseURL; the /dev page links follow the page's origin (and the
  recursive example link had a typo)
- .gitignore on the shared template (.env, dev/logs, agent working files)
- CONTRIBUTING: install with npx --no df-dev setup, standalone vs integrated mode

Moving from mongo 4.2 to 8 needs the dev volume reset (docker compose down -v).

* chore: align tooling with the other data-fair services

- CI reads the node version from .nvmrc instead of any 24.x
- CI no longer prints the logs of a "data-fair" compose service that does not exist here
  (the quality job never starts the compose)
- playwright: trace and screenshot kept on failure, 30 s test timeout; the html reporter
  stays locally, the snapshot review reads it
- vite: typed router declarations in dts/typed-router.d.ts like the other UIs

* chore(ui): no dependency discovery in the vite dev server

A dependency discovered while browsing reloaded the page (three times on a first visit),
which breaks cold e2e runs. Only the commonjs dependencies are pre-bundled now: vjsf's,
debug, prismjs and its components, statuses. Validated on an empty ui/node_modules/.vite:
the e2e suite passes and vite logs no reload.

* fix(ui): bash and yaml highlighting in the dev server

vite-plugin-node-polyfills prepends its globals shim to every pre-bundled dependency without a
trailing semicolon. prism-bash.min.js and prism-yaml.min.js start with an IIFE, which then
became an argument of the process polyfill call, so these languages never registered in dev
("Prism component for language bash was not found"). The production build was not affected.

The plugin was added for json-schema-ref-parser, whose version 16 only needs the Buffer
global (process is guarded, path is no longer imported): the plugin is replaced by the
buffer package assigned to globalThis.Buffer next to the dereference call. This also drops
the node-stdlib-browser / crypto-browserify / elliptic chain from the UI dependencies.

* fix(ui): null in a parameter enum crashed the operation form

data-fair documents its collapse and sampling parameters with enum: [null, ...]. vjsf
renders that enum as a select whose null item crashes (Cannot read properties of null
(reading 'header')), and every re-render of the form then fails. null means "no value",
which an empty optional field already expresses: it is removed from the field schema
(and from items.enum), without mutating the documentation.

* perf(ui): lighter code highlighting of large responses

Measured on a 1000 lines /lines response (307 kB of JSON, 1.4 MB of highlighted HTML): Prism
64 ms, DOMPurify 378 ms, DOM insertion 536 ms; about 4 s for 5000 lines.

- Prism output is inserted as is: Prism escapes the code it highlights, so sanitizing it
  again was pure cost
- past 100 kB the code is shown as plain text, without the DOM of every token
- an unknown language shows the code as text instead of inserting it as HTML (a "<div>" in a
  response body disappeared)
- the copy button shows whenever there is code, not only when highlighting produced a tag
- v-safe-html no longer sanitizes and rewrites the element on every update of its parent
  when its value did not change

* chore(deps): unpin @data-fair/lib-types-builder

lib-utils 1.14.2 keeps a property named $ref in makeLocalDefs (data-fair/lib#67), so
lib-types-builder no longer crashes on the OpenAPI 3.1 meta-schema: ^1.14.6 with
lib-utils ^1.14.2 instead of the exact 1.10.1 pin. build-types and check-types pass with
the published versions.
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.

1 participant