argsbarg 7.0.2 → 7.0.3

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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.0.3] - 2026-08-13
11
+
12
+ ### Fixed
13
+
14
+ - **Partial config validation** — skip attaching empty `definitions` / `$defs` companion schemas (fixes `Duplicate schema URI "https://github.com/cfworker"` when schemagen emits `"definitions": {}`).
15
+
10
16
  ## [7.0.2] - 2026-08-13
11
17
 
12
18
 
@@ -947,7 +953,8 @@ const cli = { ... } satisfies CliProgram; // or : CliProgram
947
953
  - Migrate schemas: rename every `children` property to **`commands`**; move positional definitions to **`CliPositional`** objects on `positionals` and strip `positional` / `argMin` / `argMax` from flag definitions under `options` (flags only carry `name`, `description`, `kind`, and optional `shortName`).
948
954
  - Imports: use `CliPositional` where needed; replace `CliOptionDef` with `CliOption` or `CliPositional` as appropriate.
949
955
 
950
- [Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v7.0.2...HEAD
956
+ [Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v7.0.3...HEAD
957
+ [7.0.3]: https://github.com/bdombro/bun-argsbarg/releases/tag/v7.0.3
951
958
  [7.0.2]: https://github.com/bdombro/bun-argsbarg/releases/tag/v7.0.2
952
959
  [7.0.1]: https://github.com/bdombro/bun-argsbarg/releases/tag/v7.0.1
953
960
  [7.0.0]: https://github.com/bdombro/bun-argsbarg/releases/tag/v7.0.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argsbarg",
3
- "version": "7.0.2",
3
+ "version": "7.0.3",
4
4
  "main": "./src/index.ts",
5
5
  "module": "./src/index.ts",
6
6
  "dependencies": {
@@ -3,7 +3,12 @@ Tests for config/validate module behavior.
3
3
  */
4
4
 
5
5
  import { describe, expect, test } from "bun:test";
6
- import { parseConfigSetValue, resolveSchemaDraft, validateConfigDocument } from "./validate.ts";
6
+ import {
7
+ parseConfigSetValue,
8
+ resolveSchemaDraft,
9
+ validateConfigDocument,
10
+ validateConfigDocumentPartial,
11
+ } from "./validate.ts";
7
12
 
8
13
  const rootSchema = {
9
14
  type: "object",
@@ -121,6 +126,21 @@ describe("config/validate", () => {
121
126
  expect(validateConfigDocument({}, schema).valid).toBe(false);
122
127
  });
123
128
 
129
+ test("validateConfigDocumentPartial accepts schemagen root with empty definitions", () => {
130
+ const schema = {
131
+ $schema: "http://json-schema.org/draft-07/schema#",
132
+ type: "object",
133
+ additionalProperties: false,
134
+ required: ["email"],
135
+ properties: {
136
+ email: { type: "string" },
137
+ services: { type: "array", items: { type: "string" } },
138
+ },
139
+ definitions: {},
140
+ };
141
+ expect(validateConfigDocumentPartial({ email: "a@example.com", services: ["a"] }, schema).valid).toBe(true);
142
+ });
143
+
124
144
  test("validates draft 2020-12 $defs refs", () => {
125
145
  const schema = {
126
146
  $schema: "https://json-schema.org/draft/2020-12/schema",
@@ -129,10 +129,20 @@ function attachRootCompanionSchemas(validator: Validator, root: JsonSchema, acti
129
129
  return;
130
130
  }
131
131
  const companion: Schema = {};
132
- if (typeof root.definitions === "object" && root.definitions !== null && !Array.isArray(root.definitions)) {
132
+ if (
133
+ typeof root.definitions === "object" &&
134
+ root.definitions !== null &&
135
+ !Array.isArray(root.definitions) &&
136
+ Object.keys(root.definitions).length > 0
137
+ ) {
133
138
  companion.definitions = root.definitions;
134
139
  }
135
- if (typeof root.$defs === "object" && root.$defs !== null && !Array.isArray(root.$defs)) {
140
+ if (
141
+ typeof root.$defs === "object" &&
142
+ root.$defs !== null &&
143
+ !Array.isArray(root.$defs) &&
144
+ Object.keys(root.$defs).length > 0
145
+ ) {
136
146
  companion.$defs = root.$defs;
137
147
  }
138
148
  if (Object.keys(companion).length > 0) {