@adhd/apigen-plugin-jsonschema 0.1.0
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/README.md +17 -0
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/index.mjs +24 -0
- package/lib/plugin.d.ts +4 -0
- package/package.json +13 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @adhd/apigen-plugin-jsonschema
|
|
2
|
+
|
|
3
|
+
apigen target plugin (`--type jsonschema`) — emits the **JSON Schema** for each export's
|
|
4
|
+
input/output to disk. A **generate-only** plugin (no `run` mode); useful for validation,
|
|
5
|
+
docs, client generation, or as the IR other tools consume.
|
|
6
|
+
|
|
7
|
+
Part of [apigen](../../README.md). Driven via [`@adhd/apigen-cli`](../../cli).
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
alias apigen='npx tsx packages/apigen/cli/src/index.ts'
|
|
11
|
+
|
|
12
|
+
apigen generate --source ./api.ts --type jsonschema --out-dir ./out # → out/*.json
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The schemas are the same IR the other plugins consume (params object with the `data` wrapper,
|
|
16
|
+
`ctx` excluded, plus any middleware envelope fields) — so what you validate against is exactly
|
|
17
|
+
what the MCP/HTTP/CLI targets dispatch.
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o={id:"jsonschema",description:"Emit one JSON Schema file per function per package",optionsSchema:{type:"object",properties:{pretty:{type:"boolean",description:"Pretty-print JSON (default: true)"}}},generate(e){const s=e.options.pretty!==!1,t=[];for(const n of e.packages)for(const[r,i]of Object.entries(n.schemas))t.push({path:(void 0)(n.id,`${r}.json`),content:JSON.stringify(i,null,s?2:0)});return{files:t}}};exports.default=o;exports.jsonschemaPlugin=o;
|
package/index.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const c = {
|
|
2
|
+
id: "jsonschema",
|
|
3
|
+
description: "Emit one JSON Schema file per function per package",
|
|
4
|
+
optionsSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
pretty: { type: "boolean", description: "Pretty-print JSON (default: true)" }
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
generate(e) {
|
|
11
|
+
const o = e.options.pretty !== !1, t = [];
|
|
12
|
+
for (const n of e.packages)
|
|
13
|
+
for (const [s, r] of Object.entries(n.schemas))
|
|
14
|
+
t.push({
|
|
15
|
+
path: (void 0)(n.id, `${s}.json`),
|
|
16
|
+
content: JSON.stringify(r, null, o ? 2 : 0)
|
|
17
|
+
});
|
|
18
|
+
return { files: t };
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
c as default,
|
|
23
|
+
c as jsonschemaPlugin
|
|
24
|
+
};
|
package/lib/plugin.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adhd/apigen-plugin-jsonschema",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "./index.js",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@adhd/apigen-core": "^0.1.0"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"module": "./index.mjs",
|
|
12
|
+
"types": "./index.d.ts"
|
|
13
|
+
}
|