Skip to content

Commit 6d28037

Browse files
authored
fix(wrangler): emit markdownDescription in config schema (#13735)
1 parent 83a1c7e commit 6d28037

3 files changed

Lines changed: 41 additions & 7 deletions

File tree

.changeset/fuzzy-zoos-hear.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Improve `config-schema.json` hover text in more editors
6+
7+
Wrangler now emits `markdownDescription` in `config-schema.json` alongside the existing `description` field. Editors that support rich JSON Schema hovers can use that markdown directly instead of rendering escaped links and formatting.

packages/wrangler/scripts/generate-json-schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const config: Config = {
88
tsconfig: join(__dirname, "../../workers-utils/tsconfig.json"),
99
type: "RawConfig",
1010
skipTypeCheck: true,
11+
markdownDescription: true,
1112
};
1213

1314
const applyFormattingRules = (schema: Schema) => {

packages/wrangler/src/__tests__/containers/schema.test.ts

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,46 @@ import fs from "node:fs";
22
import path from "node:path";
33
import { describe, it } from "vitest";
44

5-
describe("containers config schema", () => {
6-
it("documents ssh without exposing wrangler_ssh", ({ expect }) => {
7-
const schemaFile = path.join(__dirname, "../../../config-schema.json");
8-
const schema = JSON.parse(fs.readFileSync(schemaFile, "utf-8")) as {
9-
definitions: {
10-
ContainerApp: {
11-
properties: Record<string, unknown>;
5+
type WranglerSchema = {
6+
definitions: {
7+
ContainerApp: {
8+
properties: Record<string, unknown>;
9+
};
10+
RawConfig: {
11+
properties: {
12+
build: {
13+
description: string;
14+
markdownDescription?: string;
1215
};
1316
};
1417
};
18+
};
19+
};
20+
21+
function readSchema(): WranglerSchema {
22+
const schemaFile = path.join(__dirname, "../../../config-schema.json");
23+
return JSON.parse(fs.readFileSync(schemaFile, "utf-8")) as WranglerSchema;
24+
}
25+
26+
describe("config schema", () => {
27+
it("documents ssh without exposing wrangler_ssh", ({ expect }) => {
28+
const schema = readSchema();
1529

1630
expect(schema.definitions.ContainerApp.properties).toHaveProperty("ssh");
1731
expect(schema.definitions.ContainerApp.properties).not.toHaveProperty(
1832
"wrangler_ssh"
1933
);
2034
});
35+
36+
it("emits markdownDescription for rich editor hovers", ({ expect }) => {
37+
const schema = readSchema();
38+
const build = schema.definitions.RawConfig.properties.build;
39+
40+
expect(build.description).toContain(
41+
"[custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)"
42+
);
43+
expect(build.markdownDescription).toContain(
44+
"[custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)"
45+
);
46+
});
2147
});

0 commit comments

Comments
 (0)