@webpieces/docs-site 0.4.933 → 0.4.935
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 +8 -2
- package/package.json +1 -1
- package/src/assets/SiteStyles.d.ts +1 -1
- package/src/assets/SiteStyles.js +2 -0
- package/src/assets/SiteStyles.js.map +1 -1
- package/src/render/OperationPageRenderer.d.ts +5 -0
- package/src/render/OperationPageRenderer.js +10 -2
- package/src/render/OperationPageRenderer.js.map +1 -1
- package/src/render/SiteRenderer.js +3 -0
- package/src/render/SiteRenderer.js.map +1 -1
- package/src/spec/ApiSpec.d.ts +36 -2
- package/src/spec/ApiSpec.js +24 -2
- package/src/spec/ApiSpec.js.map +1 -1
- package/src/spec/SpecReader.js +4 -3
- package/src/spec/SpecReader.js.map +1 -1
package/README.md
CHANGED
|
@@ -14,13 +14,19 @@ your project does not grow your dependency surface, and this package's own build
|
|
|
14
14
|
|
|
15
15
|
```
|
|
16
16
|
site/
|
|
17
|
-
index.html the overview: info.description, plus every tag and its operations
|
|
17
|
+
index.html the overview: info.title, info.summary under it, info.description, plus every tag and its operations
|
|
18
18
|
styles.css site.js one stylesheet, one script
|
|
19
19
|
prose/<kebab-title>/index.html one per page docs.manifest.json names, in ITS order
|
|
20
|
-
reference/<kebab-
|
|
20
|
+
reference/<kebab-operationId>/index.html
|
|
21
21
|
schemas/<kebab-name>/index.html one per named OBJECT dto
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
Each operation page is HEADED, and its sidebar link LABELLED, with the operation's `summary` — its short
|
|
25
|
+
human title (#1296) — and shows the `operationId` beside the method and path as the code identifier a
|
|
26
|
+
generated client names the method by. The page's URL is kebabed from the `operationId`, so rewording a
|
|
27
|
+
title never moves a bookmarked link. A document that states no `summary` falls back to the
|
|
28
|
+
`operationId`, then the path or event name.
|
|
29
|
+
|
|
24
30
|
One PRE-RENDERED file per URL. A deep link resolves without JavaScript, the folder works on any
|
|
25
31
|
static host (and under a path prefix, and over `file://`), and a JSDoc edit shows up as a diff on the
|
|
26
32
|
one page it affects. The client script does three things only: disclosure state, the language tabs,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/docs-site",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.935",
|
|
4
4
|
"description": "Render a static, three-pane API reference site from any OpenAPI 3.0-or-3.1 document plus a directory of markdown prose. Node builtins only. Ships the wp-docs-site bin.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
* one attribute on `<html>` and nothing else in the site knows about it.
|
|
10
10
|
*/
|
|
11
11
|
export declare class SiteStyles {
|
|
12
|
-
static readonly CSS = "\n:root {\n --bg: #ffffff;\n --bg-soft: #f6f7f9;\n --fg: #1d2129;\n --fg-soft: #5b6472;\n --line: #e2e5ea;\n --accent: #2f5cff;\n --code-bg: #f2f3f6;\n --badge-fg: #ffffff;\n}\n:root[data-theme='dark'] {\n --bg: #14171c;\n --bg-soft: #1b1f26;\n --fg: #e7eaf0;\n --fg-soft: #9aa4b2;\n --line: #2a2f38;\n --accent: #7f9bff;\n --code-bg: #10131a;\n --badge-fg: #14171c;\n}\n* { box-sizing: border-box; }\nbody {\n margin: 0;\n background: var(--bg);\n color: var(--fg);\n font: 15px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n}\na { color: var(--accent); text-decoration: none; }\na:hover { text-decoration: underline; }\ncode, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }\ncode { background: var(--code-bg); padding: 1px 4px; border-radius: 3px; }\npre { background: var(--code-bg); padding: 12px; border-radius: 6px; overflow-x: auto; }\npre code { background: none; padding: 0; }\ntable { border-collapse: collapse; width: 100%; margin: 12px 0; }\nth, td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }\nth { background: var(--bg-soft); }\nhr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }\nblockquote { margin: 12px 0; padding: 4px 14px; border-left: 3px solid var(--line); color: var(--fg-soft); }\n\n.site { display: grid; grid-template-columns: 260px minmax(0, 1fr) 360px; gap: 0; min-height: 100vh; }\n.pane-nav { border-right: 1px solid var(--line); padding: 20px 16px; background: var(--bg-soft); }\n.pane-body { padding: 28px 32px; min-width: 0; }\n.pane-cards { border-left: 1px solid var(--line); padding: 20px 16px; background: var(--bg-soft); }\n.pane-cards-inner { position: sticky; top: 20px; }\n\n.site-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; display: block; color: var(--fg); }\n.site-version { color: var(--fg-soft); font-size: 12px; margin-bottom: 16px; }\n.nav-group { margin-bottom: 10px; }\n.nav-group > summary { cursor: pointer; font-weight: 600; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-soft); }\n.nav-group ul { list-style: none; margin: 6px 0 0; padding: 0 0 0 4px; }\n.nav-group li { margin: 2px 0; }\n.nav-group a { display: flex; gap: 6px; align-items: center; padding: 3px 6px; border-radius: 4px; color: var(--fg); }\n.nav-group a.current { background: var(--accent); color: var(--badge-fg); }\n.nav-group a.current .badge { background: var(--badge-fg); color: var(--accent); }\n\n.badge { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 5px; border-radius: 3px; background: var(--accent); color: var(--badge-fg); }\n.op-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }\n.op-path { background: var(--code-bg); padding: 3px 8px; border-radius: 4px; }\n\n.card { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin-bottom: 16px; }\n.card-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-soft); }\n.card-body { padding: 12px; }\n.card-body pre { margin: 0; }\nbutton { font: inherit; font-size: 11px; cursor: pointer; background: none; border: 1px solid var(--line); border-radius: 4px; padding: 2px 8px; color: var(--fg-soft); }\nbutton:hover { color: var(--fg); }\n.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 12px 0; }\n.tab[aria-selected='true'] { border-color: var(--accent); color: var(--accent); }\n.sample[hidden] { display: none; }\n\n.field { border-top: 1px solid var(--line); padding: 10px 0; }\n.field-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }\n.field-name { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }\n.field-type { color: var(--fg-soft); font-size: 12px; }\n.field-required { color: #c0392b; font-size: 11px; font-weight: 700; letter-spacing: .04em; }\n.field-optional { color: var(--fg-soft); font-size: 11px; font-weight: 700; letter-spacing: .04em; }\n.headers { margin: 8px 0 12px; }\n.headers-head { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--fg-soft); text-transform: uppercase; }\n.field-doc { margin: 4px 0 0; color: var(--fg-soft); }\n.field-children { margin-left: 16px; border-left: 1px solid var(--line); padding-left: 12px; }\n.chips { margin-top: 6px; font-size: 12px; color: var(--fg-soft); }\n.chip { display: inline-block; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; margin: 2px 4px 2px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }\n.variant { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 12px 0; }\n.variant-head { font-weight: 600; }\ndetails.disclosure > summary { cursor: pointer; color: var(--fg-soft); font-size: 12px; }\n\n@media (max-width: 1100px) {\n .site { grid-template-columns: 1fr; }\n .pane-nav, .pane-cards { border: 0; }\n .pane-cards-inner { position: static; }\n}\n";
|
|
12
|
+
static readonly CSS = "\n:root {\n --bg: #ffffff;\n --bg-soft: #f6f7f9;\n --fg: #1d2129;\n --fg-soft: #5b6472;\n --line: #e2e5ea;\n --accent: #2f5cff;\n --code-bg: #f2f3f6;\n --badge-fg: #ffffff;\n}\n:root[data-theme='dark'] {\n --bg: #14171c;\n --bg-soft: #1b1f26;\n --fg: #e7eaf0;\n --fg-soft: #9aa4b2;\n --line: #2a2f38;\n --accent: #7f9bff;\n --code-bg: #10131a;\n --badge-fg: #14171c;\n}\n* { box-sizing: border-box; }\nbody {\n margin: 0;\n background: var(--bg);\n color: var(--fg);\n font: 15px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n}\na { color: var(--accent); text-decoration: none; }\na:hover { text-decoration: underline; }\ncode, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }\ncode { background: var(--code-bg); padding: 1px 4px; border-radius: 3px; }\npre { background: var(--code-bg); padding: 12px; border-radius: 6px; overflow-x: auto; }\npre code { background: none; padding: 0; }\ntable { border-collapse: collapse; width: 100%; margin: 12px 0; }\nth, td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }\nth { background: var(--bg-soft); }\nhr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }\nblockquote { margin: 12px 0; padding: 4px 14px; border-left: 3px solid var(--line); color: var(--fg-soft); }\n\n.site { display: grid; grid-template-columns: 260px minmax(0, 1fr) 360px; gap: 0; min-height: 100vh; }\n.pane-nav { border-right: 1px solid var(--line); padding: 20px 16px; background: var(--bg-soft); }\n.pane-body { padding: 28px 32px; min-width: 0; }\n.pane-cards { border-left: 1px solid var(--line); padding: 20px 16px; background: var(--bg-soft); }\n.pane-cards-inner { position: sticky; top: 20px; }\n\n.site-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; display: block; color: var(--fg); }\n.site-version { color: var(--fg-soft); font-size: 12px; margin-bottom: 16px; }\n.nav-group { margin-bottom: 10px; }\n.nav-group > summary { cursor: pointer; font-weight: 600; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-soft); }\n.nav-group ul { list-style: none; margin: 6px 0 0; padding: 0 0 0 4px; }\n.nav-group li { margin: 2px 0; }\n.nav-group a { display: flex; gap: 6px; align-items: center; padding: 3px 6px; border-radius: 4px; color: var(--fg); }\n.nav-group a.current { background: var(--accent); color: var(--badge-fg); }\n.nav-group a.current .badge { background: var(--badge-fg); color: var(--accent); }\n\n.badge { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 5px; border-radius: 3px; background: var(--accent); color: var(--badge-fg); }\n.op-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }\n.op-path { background: var(--code-bg); padding: 3px 8px; border-radius: 4px; }\n.op-id { color: var(--fg-soft); font-size: 12px; }\n.api-summary { font-size: 1.1em; color: var(--fg-soft); margin-top: -4px; }\n\n.card { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin-bottom: 16px; }\n.card-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-soft); }\n.card-body { padding: 12px; }\n.card-body pre { margin: 0; }\nbutton { font: inherit; font-size: 11px; cursor: pointer; background: none; border: 1px solid var(--line); border-radius: 4px; padding: 2px 8px; color: var(--fg-soft); }\nbutton:hover { color: var(--fg); }\n.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 12px 0; }\n.tab[aria-selected='true'] { border-color: var(--accent); color: var(--accent); }\n.sample[hidden] { display: none; }\n\n.field { border-top: 1px solid var(--line); padding: 10px 0; }\n.field-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }\n.field-name { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }\n.field-type { color: var(--fg-soft); font-size: 12px; }\n.field-required { color: #c0392b; font-size: 11px; font-weight: 700; letter-spacing: .04em; }\n.field-optional { color: var(--fg-soft); font-size: 11px; font-weight: 700; letter-spacing: .04em; }\n.headers { margin: 8px 0 12px; }\n.headers-head { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--fg-soft); text-transform: uppercase; }\n.field-doc { margin: 4px 0 0; color: var(--fg-soft); }\n.field-children { margin-left: 16px; border-left: 1px solid var(--line); padding-left: 12px; }\n.chips { margin-top: 6px; font-size: 12px; color: var(--fg-soft); }\n.chip { display: inline-block; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; margin: 2px 4px 2px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }\n.variant { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 12px 0; }\n.variant-head { font-weight: 600; }\ndetails.disclosure > summary { cursor: pointer; color: var(--fg-soft); font-size: 12px; }\n\n@media (max-width: 1100px) {\n .site { grid-template-columns: 1fr; }\n .pane-nav, .pane-cards { border: 0; }\n .pane-cards-inner { position: static; }\n}\n";
|
|
13
13
|
}
|
package/src/assets/SiteStyles.js
CHANGED
|
@@ -71,6 +71,8 @@ blockquote { margin: 12px 0; padding: 4px 14px; border-left: 3px solid var(--lin
|
|
|
71
71
|
.badge { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 5px; border-radius: 3px; background: var(--accent); color: var(--badge-fg); }
|
|
72
72
|
.op-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
|
|
73
73
|
.op-path { background: var(--code-bg); padding: 3px 8px; border-radius: 4px; }
|
|
74
|
+
.op-id { color: var(--fg-soft); font-size: 12px; }
|
|
75
|
+
.api-summary { font-size: 1.1em; color: var(--fg-soft); margin-top: -4px; }
|
|
74
76
|
|
|
75
77
|
.card { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin-bottom: 16px; }
|
|
76
78
|
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-soft); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SiteStyles.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/assets/SiteStyles.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,MAAa,UAAU;IACnB,MAAM,CAAU,GAAG,GAAG
|
|
1
|
+
{"version":3,"file":"SiteStyles.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/assets/SiteStyles.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,MAAa,UAAU;IACnB,MAAM,CAAU,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6FzB,CAAC;;AA9FF,gCA+FC","sourcesContent":["/**\n * The whole stylesheet, as one string written to `styles.css` beside the pages.\n *\n * It is hand-written rather than generated by a framework because #985 puts the framework, the\n * bundler and the markdown library out of scope: adding an API reference to an upstream project must\n * not grow that project's dependency surface, and this package's own build has to stay `tsc`.\n *\n * Colours are declared once as custom properties and redefined for dark mode, so a theme toggle is\n * one attribute on `<html>` and nothing else in the site knows about it.\n */\nexport class SiteStyles {\n static readonly CSS = `\n:root {\n --bg: #ffffff;\n --bg-soft: #f6f7f9;\n --fg: #1d2129;\n --fg-soft: #5b6472;\n --line: #e2e5ea;\n --accent: #2f5cff;\n --code-bg: #f2f3f6;\n --badge-fg: #ffffff;\n}\n:root[data-theme='dark'] {\n --bg: #14171c;\n --bg-soft: #1b1f26;\n --fg: #e7eaf0;\n --fg-soft: #9aa4b2;\n --line: #2a2f38;\n --accent: #7f9bff;\n --code-bg: #10131a;\n --badge-fg: #14171c;\n}\n* { box-sizing: border-box; }\nbody {\n margin: 0;\n background: var(--bg);\n color: var(--fg);\n font: 15px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n}\na { color: var(--accent); text-decoration: none; }\na:hover { text-decoration: underline; }\ncode, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }\ncode { background: var(--code-bg); padding: 1px 4px; border-radius: 3px; }\npre { background: var(--code-bg); padding: 12px; border-radius: 6px; overflow-x: auto; }\npre code { background: none; padding: 0; }\ntable { border-collapse: collapse; width: 100%; margin: 12px 0; }\nth, td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }\nth { background: var(--bg-soft); }\nhr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }\nblockquote { margin: 12px 0; padding: 4px 14px; border-left: 3px solid var(--line); color: var(--fg-soft); }\n\n.site { display: grid; grid-template-columns: 260px minmax(0, 1fr) 360px; gap: 0; min-height: 100vh; }\n.pane-nav { border-right: 1px solid var(--line); padding: 20px 16px; background: var(--bg-soft); }\n.pane-body { padding: 28px 32px; min-width: 0; }\n.pane-cards { border-left: 1px solid var(--line); padding: 20px 16px; background: var(--bg-soft); }\n.pane-cards-inner { position: sticky; top: 20px; }\n\n.site-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; display: block; color: var(--fg); }\n.site-version { color: var(--fg-soft); font-size: 12px; margin-bottom: 16px; }\n.nav-group { margin-bottom: 10px; }\n.nav-group > summary { cursor: pointer; font-weight: 600; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-soft); }\n.nav-group ul { list-style: none; margin: 6px 0 0; padding: 0 0 0 4px; }\n.nav-group li { margin: 2px 0; }\n.nav-group a { display: flex; gap: 6px; align-items: center; padding: 3px 6px; border-radius: 4px; color: var(--fg); }\n.nav-group a.current { background: var(--accent); color: var(--badge-fg); }\n.nav-group a.current .badge { background: var(--badge-fg); color: var(--accent); }\n\n.badge { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 5px; border-radius: 3px; background: var(--accent); color: var(--badge-fg); }\n.op-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }\n.op-path { background: var(--code-bg); padding: 3px 8px; border-radius: 4px; }\n.op-id { color: var(--fg-soft); font-size: 12px; }\n.api-summary { font-size: 1.1em; color: var(--fg-soft); margin-top: -4px; }\n\n.card { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin-bottom: 16px; }\n.card-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-soft); }\n.card-body { padding: 12px; }\n.card-body pre { margin: 0; }\nbutton { font: inherit; font-size: 11px; cursor: pointer; background: none; border: 1px solid var(--line); border-radius: 4px; padding: 2px 8px; color: var(--fg-soft); }\nbutton:hover { color: var(--fg); }\n.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 12px 0; }\n.tab[aria-selected='true'] { border-color: var(--accent); color: var(--accent); }\n.sample[hidden] { display: none; }\n\n.field { border-top: 1px solid var(--line); padding: 10px 0; }\n.field-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }\n.field-name { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }\n.field-type { color: var(--fg-soft); font-size: 12px; }\n.field-required { color: #c0392b; font-size: 11px; font-weight: 700; letter-spacing: .04em; }\n.field-optional { color: var(--fg-soft); font-size: 11px; font-weight: 700; letter-spacing: .04em; }\n.headers { margin: 8px 0 12px; }\n.headers-head { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--fg-soft); text-transform: uppercase; }\n.field-doc { margin: 4px 0 0; color: var(--fg-soft); }\n.field-children { margin-left: 16px; border-left: 1px solid var(--line); padding-left: 12px; }\n.chips { margin-top: 6px; font-size: 12px; color: var(--fg-soft); }\n.chip { display: inline-block; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; margin: 2px 4px 2px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }\n.variant { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 12px 0; }\n.variant-head { font-weight: 600; }\ndetails.disclosure > summary { cursor: pointer; color: var(--fg-soft); font-size: 12px; }\n\n@media (max-width: 1100px) {\n .site { grid-template-columns: 1fr; }\n .pane-nav, .pane-cards { border: 0; }\n .pane-cards-inner { position: static; }\n}\n`;\n}\n"]}
|
|
@@ -36,6 +36,11 @@ export declare class OperationPageRenderer {
|
|
|
36
36
|
constructor(spec: ApiSpec, fields: FieldTreeBuilder, trees: FieldTreeRenderer, markdown: Markdown, cards: CardRenderer, samples: CodeSampleBuilder, examples: ExampleBuilder, layout: Layout, urls: SiteUrls, headers: HeaderListRenderer);
|
|
37
37
|
page(operation: OperationInfo): SitePage;
|
|
38
38
|
private body;
|
|
39
|
+
/**
|
|
40
|
+
* The badge, the path (or event) and the `operationId`. The page HEADING is the operation's
|
|
41
|
+
* summary (#1296); the operationId stays visible here because it is what a generated client names
|
|
42
|
+
* the method, which is what a developer searches their code for.
|
|
43
|
+
*/
|
|
39
44
|
private head;
|
|
40
45
|
/** The request's `in: "header"` parameters, then its body — each only when there is one. */
|
|
41
46
|
private requestSection;
|
|
@@ -53,11 +53,19 @@ class OperationPageRenderer {
|
|
|
53
53
|
parts.push(this.responseSection(operation, prefix));
|
|
54
54
|
return parts.join('\n');
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The badge, the path (or event) and the `operationId`. The page HEADING is the operation's
|
|
58
|
+
* summary (#1296); the operationId stays visible here because it is what a generated client names
|
|
59
|
+
* the method, which is what a developer searches their code for.
|
|
60
|
+
*/
|
|
56
61
|
head(operation) {
|
|
62
|
+
const id = operation.operationId === ''
|
|
63
|
+
? ''
|
|
64
|
+
: `<code class="op-id" title="operationId">${this.html.escape(operation.operationId)}</code>`;
|
|
57
65
|
if (operation.isWebhook) {
|
|
58
|
-
return `<div class="op-head"><span class="badge">${exports.WEBHOOK_BADGE}</span><code class="op-path">${this.html.escape(operation.eventName)}</code
|
|
66
|
+
return `<div class="op-head"><span class="badge">${exports.WEBHOOK_BADGE}</span><code class="op-path">${this.html.escape(operation.eventName)}</code>${id}</div>`;
|
|
59
67
|
}
|
|
60
|
-
return `<div class="op-head"><span class="badge">${this.html.escape(operation.httpMethod)}</span><code class="op-path">${this.html.escape(operation.path)}</code
|
|
68
|
+
return `<div class="op-head"><span class="badge">${this.html.escape(operation.httpMethod)}</span><code class="op-path">${this.html.escape(operation.path)}</code>${id}</div>`;
|
|
61
69
|
}
|
|
62
70
|
/** The request's `in: "header"` parameters, then its body — each only when there is one. */
|
|
63
71
|
requestSection(operation, prefix) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationPageRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/render/OperationPageRenderer.ts"],"names":[],"mappings":";;;AAOA,iCAA8B;AAK9B,yCAAsC;AAEtC,yDAAyD;AAC5C,QAAA,aAAa,GAAG,SAAS,CAAC;AAEvC;;;;;;;;;GASG;AACH,MAAa,qBAAqB;IAIT;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAZJ,IAAI,GAAG,IAAI,WAAI,EAAE,CAAC;IAEnC,YACqB,IAAa,EACb,MAAwB,EACxB,KAAwB,EACxB,QAAkB,EAClB,KAAmB,EACnB,OAA0B,EAC1B,QAAwB,EACxB,MAAc,EACd,IAAc,EACd,OAA2B;QAT3B,SAAI,GAAJ,IAAI,CAAS;QACb,WAAM,GAAN,MAAM,CAAkB;QACxB,UAAK,GAAL,KAAK,CAAmB;QACxB,aAAQ,GAAR,QAAQ,CAAU;QAClB,UAAK,GAAL,KAAK,CAAc;QACnB,YAAO,GAAP,OAAO,CAAmB;QAC1B,aAAQ,GAAR,QAAQ,CAAgB;QACxB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAU;QACd,YAAO,GAAP,OAAO,CAAoB;IAC7C,CAAC;IAEJ,IAAI,CAAC,SAAwB;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACxC,OAAO,IAAI,mBAAQ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","sourcesContent":["import { ApiSpec, OperationInfo, ResponseInfo } from '../spec/ApiSpec';\nimport { CardRenderer } from './CardRenderer';\nimport { CodeSampleBuilder } from '../samples/CodeSamples';\nimport { ExampleBuilder } from '../spec/ExampleBuilder';\nimport { FieldTreeBuilder } from '../spec/FieldTree';\nimport { FieldTreeRenderer } from './FieldTreeRenderer';\nimport { HeaderListRenderer } from './HeaderListRenderer';\nimport { Html } from './Html';\nimport { JsonNode } from '../spec/JsonNode';\nimport { Layout } from './Layout';\nimport { Markdown } from '../markdown/Markdown';\nimport { SiteUrls } from './SiteUrls';\nimport { SitePage } from './SitePage';\n\n/** The badge a webhook carries everywhere it appears. */\nexport const WEBHOOK_BADGE = 'WEBHOOK';\n\n/**\n * One pre-rendered page per operation, at `reference/<kebab-operation>/index.html`.\n *\n * ## What a WEBHOOK page leaves out, and why\n *\n * No method, no path, no code samples. The url is the PARTNER's — they host the endpoint wherever\n * they choose — so a `POST https://api.example.com/...` sample on a webhook page invites them to\n * call something that does not exist. What it keeps is the payload, because the payload is the part\n * that IS ours, and the event name, because that is what they match on the wire.\n */\nexport class OperationPageRenderer {\n private readonly html = new Html();\n\n constructor(\n private readonly spec: ApiSpec,\n private readonly fields: FieldTreeBuilder,\n private readonly trees: FieldTreeRenderer,\n private readonly markdown: Markdown,\n private readonly cards: CardRenderer,\n private readonly samples: CodeSampleBuilder,\n private readonly examples: ExampleBuilder,\n private readonly layout: Layout,\n private readonly urls: SiteUrls,\n private readonly headers: HeaderListRenderer,\n ) {}\n\n page(operation: OperationInfo): SitePage {\n const url = this.urls.operation(operation);\n const prefix = this.urls.prefixFor(url);\n return new SitePage(\n url,\n operation.name,\n this.layout.render(\n url,\n operation.name,\n this.body(operation, prefix),\n this.cardColumn(operation),\n ),\n );\n }\n\n private body(operation: OperationInfo, prefix: string): string {\n const parts = [this.head(operation), `<h1>${this.html.escape(operation.name)}</h1>`];\n if (operation.description !== '') {\n parts.push(this.markdown.render(operation.description));\n }\n parts.push(this.requestSection(operation, prefix));\n parts.push(this.responseSection(operation, prefix));\n return parts.join('\\n');\n }\n\n private head(operation: OperationInfo): string {\n if (operation.isWebhook) {\n return `<div class=\"op-head\"><span class=\"badge\">${WEBHOOK_BADGE}</span><code class=\"op-path\">${this.html.escape(operation.eventName)}</code></div>`;\n }\n return `<div class=\"op-head\"><span class=\"badge\">${this.html.escape(operation.httpMethod)}</span><code class=\"op-path\">${this.html.escape(operation.path)}</code></div>`;\n }\n\n /** The request's `in: \"header\"` parameters, then its body — each only when there is one. */\n private requestSection(operation: OperationInfo, prefix: string): string {\n const parts: string[] = [];\n if (operation.requestHeaders.length > 0) {\n parts.push(`<h2>Request headers</h2>${this.headers.render(operation.requestHeaders)}`);\n }\n if (operation.requestSchema !== undefined) {\n parts.push(`<h2>Request body</h2>${this.tree(operation.requestSchema, prefix)}`);\n }\n return parts.join('');\n }\n\n private responseSection(operation: OperationInfo, prefix: string): string {\n if (operation.responses.length === 0) {\n return '';\n }\n const blocks = operation.responses\n .map((response: ResponseInfo): string => this.response(response, prefix))\n .join('');\n return `<h2>Responses</h2>${blocks}`;\n }\n\n private response(response: ResponseInfo, prefix: string): string {\n const summary = `${this.html.escape(response.status)} — ${this.html.escape(response.description)}`;\n const body =\n response.schema === undefined\n ? '<p class=\"field-doc\">No body.</p>'\n : this.tree(response.schema, prefix);\n // The headers ride the card beside the body (#1292) — the response a partner holds carries both.\n const headers = this.headers.render(response.headers);\n return `<details class=\"disclosure\" open><summary>${summary}</summary>${headers}${body}</details>`;\n }\n\n /** A `oneOf` renders as expanded variants; anything else renders as one flat field tree. */\n private tree(schema: JsonNode, prefix: string): string {\n const variants = this.fields.variantsOf(schema);\n if (variants.length > 0) {\n return this.trees.renderVariants(\n variants,\n this.fields.discriminatorPropertyOf(schema),\n prefix,\n );\n }\n return this.trees.render(this.fields.fieldsOf(schema), prefix);\n }\n\n private cardColumn(operation: OperationInfo): string {\n const payload = this.examples.render(this.examples.build(operation.requestSchema));\n if (operation.isWebhook) {\n return this.cards.example('EVENT PAYLOAD', payload);\n }\n return [\n this.cards.authorization(operation, this.spec.securitySchemes),\n this.cards.samples(this.samples.samplesFor(operation)),\n ].join('\\n');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"OperationPageRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/render/OperationPageRenderer.ts"],"names":[],"mappings":";;;AAOA,iCAA8B;AAK9B,yCAAsC;AAEtC,yDAAyD;AAC5C,QAAA,aAAa,GAAG,SAAS,CAAC;AAEvC;;;;;;;;;GASG;AACH,MAAa,qBAAqB;IAIT;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAZJ,IAAI,GAAG,IAAI,WAAI,EAAE,CAAC;IAEnC,YACqB,IAAa,EACb,MAAwB,EACxB,KAAwB,EACxB,QAAkB,EAClB,KAAmB,EACnB,OAA0B,EAC1B,QAAwB,EACxB,MAAc,EACd,IAAc,EACd,OAA2B;QAT3B,SAAI,GAAJ,IAAI,CAAS;QACb,WAAM,GAAN,MAAM,CAAkB;QACxB,UAAK,GAAL,KAAK,CAAmB;QACxB,aAAQ,GAAR,QAAQ,CAAU;QAClB,UAAK,GAAL,KAAK,CAAc;QACnB,YAAO,GAAP,OAAO,CAAmB;QAC1B,aAAQ,GAAR,QAAQ,CAAgB;QACxB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAU;QACd,YAAO,GAAP,OAAO,CAAoB;IAC7C,CAAC;IAEJ,IAAI,CAAC,SAAwB;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACxC,OAAO,IAAI,mBAAQ,CACf,GAAG,EACH,SAAS,CAAC,IAAI,EACd,IAAI,CAAC,MAAM,CAAC,MAAM,CACd,GAAG,EACH,SAAS,CAAC,IAAI,EACd,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C,UAAU,CAAC,SAAS,CAAC,CAAC;SACzD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;CACJ;AAjHD,sDAiHC","sourcesContent":["import { ApiSpec, OperationInfo, ResponseInfo } from '../spec/ApiSpec';\nimport { CardRenderer } from './CardRenderer';\nimport { CodeSampleBuilder } from '../samples/CodeSamples';\nimport { ExampleBuilder } from '../spec/ExampleBuilder';\nimport { FieldTreeBuilder } from '../spec/FieldTree';\nimport { FieldTreeRenderer } from './FieldTreeRenderer';\nimport { HeaderListRenderer } from './HeaderListRenderer';\nimport { Html } from './Html';\nimport { JsonNode } from '../spec/JsonNode';\nimport { Layout } from './Layout';\nimport { Markdown } from '../markdown/Markdown';\nimport { SiteUrls } from './SiteUrls';\nimport { SitePage } from './SitePage';\n\n/** The badge a webhook carries everywhere it appears. */\nexport const WEBHOOK_BADGE = 'WEBHOOK';\n\n/**\n * One pre-rendered page per operation, at `reference/<kebab-operation>/index.html`.\n *\n * ## What a WEBHOOK page leaves out, and why\n *\n * No method, no path, no code samples. The url is the PARTNER's — they host the endpoint wherever\n * they choose — so a `POST https://api.example.com/...` sample on a webhook page invites them to\n * call something that does not exist. What it keeps is the payload, because the payload is the part\n * that IS ours, and the event name, because that is what they match on the wire.\n */\nexport class OperationPageRenderer {\n private readonly html = new Html();\n\n constructor(\n private readonly spec: ApiSpec,\n private readonly fields: FieldTreeBuilder,\n private readonly trees: FieldTreeRenderer,\n private readonly markdown: Markdown,\n private readonly cards: CardRenderer,\n private readonly samples: CodeSampleBuilder,\n private readonly examples: ExampleBuilder,\n private readonly layout: Layout,\n private readonly urls: SiteUrls,\n private readonly headers: HeaderListRenderer,\n ) {}\n\n page(operation: OperationInfo): SitePage {\n const url = this.urls.operation(operation);\n const prefix = this.urls.prefixFor(url);\n return new SitePage(\n url,\n operation.name,\n this.layout.render(\n url,\n operation.name,\n this.body(operation, prefix),\n this.cardColumn(operation),\n ),\n );\n }\n\n private body(operation: OperationInfo, prefix: string): string {\n const parts = [this.head(operation), `<h1>${this.html.escape(operation.name)}</h1>`];\n if (operation.description !== '') {\n parts.push(this.markdown.render(operation.description));\n }\n parts.push(this.requestSection(operation, prefix));\n parts.push(this.responseSection(operation, prefix));\n return parts.join('\\n');\n }\n\n /**\n * The badge, the path (or event) and the `operationId`. The page HEADING is the operation's\n * summary (#1296); the operationId stays visible here because it is what a generated client names\n * the method, which is what a developer searches their code for.\n */\n private head(operation: OperationInfo): string {\n const id =\n operation.operationId === ''\n ? ''\n : `<code class=\"op-id\" title=\"operationId\">${this.html.escape(operation.operationId)}</code>`;\n if (operation.isWebhook) {\n return `<div class=\"op-head\"><span class=\"badge\">${WEBHOOK_BADGE}</span><code class=\"op-path\">${this.html.escape(operation.eventName)}</code>${id}</div>`;\n }\n return `<div class=\"op-head\"><span class=\"badge\">${this.html.escape(operation.httpMethod)}</span><code class=\"op-path\">${this.html.escape(operation.path)}</code>${id}</div>`;\n }\n\n /** The request's `in: \"header\"` parameters, then its body — each only when there is one. */\n private requestSection(operation: OperationInfo, prefix: string): string {\n const parts: string[] = [];\n if (operation.requestHeaders.length > 0) {\n parts.push(`<h2>Request headers</h2>${this.headers.render(operation.requestHeaders)}`);\n }\n if (operation.requestSchema !== undefined) {\n parts.push(`<h2>Request body</h2>${this.tree(operation.requestSchema, prefix)}`);\n }\n return parts.join('');\n }\n\n private responseSection(operation: OperationInfo, prefix: string): string {\n if (operation.responses.length === 0) {\n return '';\n }\n const blocks = operation.responses\n .map((response: ResponseInfo): string => this.response(response, prefix))\n .join('');\n return `<h2>Responses</h2>${blocks}`;\n }\n\n private response(response: ResponseInfo, prefix: string): string {\n const summary = `${this.html.escape(response.status)} — ${this.html.escape(response.description)}`;\n const body =\n response.schema === undefined\n ? '<p class=\"field-doc\">No body.</p>'\n : this.tree(response.schema, prefix);\n // The headers ride the card beside the body (#1292) — the response a partner holds carries both.\n const headers = this.headers.render(response.headers);\n return `<details class=\"disclosure\" open><summary>${summary}</summary>${headers}${body}</details>`;\n }\n\n /** A `oneOf` renders as expanded variants; anything else renders as one flat field tree. */\n private tree(schema: JsonNode, prefix: string): string {\n const variants = this.fields.variantsOf(schema);\n if (variants.length > 0) {\n return this.trees.renderVariants(\n variants,\n this.fields.discriminatorPropertyOf(schema),\n prefix,\n );\n }\n return this.trees.render(this.fields.fieldsOf(schema), prefix);\n }\n\n private cardColumn(operation: OperationInfo): string {\n const payload = this.examples.render(this.examples.build(operation.requestSchema));\n if (operation.isWebhook) {\n return this.cards.example('EVENT PAYLOAD', payload);\n }\n return [\n this.cards.authorization(operation, this.spec.securitySchemes),\n this.cards.samples(this.samples.samplesFor(operation)),\n ].join('\\n');\n }\n}\n"]}
|
|
@@ -71,6 +71,9 @@ class SiteRenderer {
|
|
|
71
71
|
}
|
|
72
72
|
overview(spec, layout) {
|
|
73
73
|
const parts = [`<h1>${this.html.escape(spec.title)}</h1>`];
|
|
74
|
+
if (spec.summary !== '') {
|
|
75
|
+
parts.push(`<p class="api-summary">${this.html.escape(spec.summary)}</p>`);
|
|
76
|
+
}
|
|
74
77
|
if (spec.description !== '') {
|
|
75
78
|
parts.push(this.markdown.render(spec.description));
|
|
76
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SiteRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/render/SiteRenderer.ts"],"names":[],"mappings":";;;AACA,iDAA8C;AAC9C,wDAA2D;AAC3D,2DAAwD;AACxD,iDAAqD;AACrD,2DAAwD;AACxD,iCAA8B;AAC9B,qCAAkC;AAClC,mDAAgD;AAChD,yCAAwC;AACxC,6DAA0D;AAC1D,mEAAgE;AAEhE,yCAA+D;AAC/D,mDAAgD;AAChD,qDAAkD;AAClD,qDAAkD;AAClD,yCAAsC;AAEtC,gDAAgD;AACnC,QAAA,cAAc,GAAG,UAAU,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,MAAa,YAAY;IACJ,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC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U,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChD,KAAK,CAAC,IAAI,CACN,QAAQ,CAAC,MAAM,GAAG,CAAC;YACf,CAAC,CAAC,KAAK,CAAC,cAAc,CAChB,QAAQ,EACR,MAAM,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,EAC3C,MAAM,CACT;YACH,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAC3D,CAAC;QACF,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,OAAO,IAAI,mBAAQ,CACf,GAAG,EACH,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,MAAM,CACT,GAAG,EACH,MAAM,CAAC,IAAI,EACX,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAChB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CACxC,CACJ,CAAC;IACN,CAAC;CACJ;AArID,oCAqIC","sourcesContent":["import { ApiSpec, NamedSchema, OperationInfo, ServerInfo, TagSection } from '../spec/ApiSpec';\nimport { CardRenderer } from './CardRenderer';\nimport { CodeSampleBuilder } from '../samples/CodeSamples';\nimport { ExampleBuilder } from '../spec/ExampleBuilder';\nimport { FieldTreeBuilder } from '../spec/FieldTree';\nimport { FieldTreeRenderer } from './FieldTreeRenderer';\nimport { Html } from './Html';\nimport { Layout } from './Layout';\nimport { Markdown } from '../markdown/Markdown';\nimport { NavBuilder } from './NavModel';\nimport { HeaderListRenderer } from './HeaderListRenderer';\nimport { OperationPageRenderer } from './OperationPageRenderer';\nimport { ProsePage } from '../manifest/DocsManifest';\nimport { RenderedSite, SiteAsset, SitePage } from './SitePage';\nimport { SchemaLens } from '../spec/SchemaLens';\nimport { SiteScript } from '../assets/SiteScript';\nimport { SiteStyles } from '../assets/SiteStyles';\nimport { SiteUrls } from './SiteUrls';\n\n/** The nav title of the generated home page. */\nexport const OVERVIEW_TITLE = 'Overview';\n\n/**\n * Turns one {@link ApiSpec} plus its prose into the complete list of files to write.\n *\n * Every URL is a FILE — `index.html`, `prose/<slug>/index.html`, `reference/<slug>/index.html`,\n * `schemas/<slug>/index.html` — so a deep link resolves without JS, the output is a folder any\n * static host serves, and a JSDoc edit is a diff on the one page it affects.\n *\n * ## One page per named object DTO\n *\n * Only OBJECTS get pages. A named enum or scalar alias renders inline at each use site with its\n * chips, because a page holding one line of values costs a reader the context they were reading.\n * An UNDEFINED `$ref` also stays inline — a link to a page the document never defined is a dead\n * link, which is strictly worse than the unresolved type name it replaced.\n */\nexport class SiteRenderer {\n private readonly markdown = new Markdown();\n private readonly cards = new CardRenderer();\n private readonly html = new Html();\n private readonly urls = new SiteUrls();\n\n /** @param spec the document. @param prose the manifest's pages, in the manifest's order. */\n render(spec: ApiSpec, prose: readonly ProsePage[], titleOverride: string): RenderedSite {\n const lens = new SchemaLens(spec);\n const fields = new FieldTreeBuilder(lens);\n const trees = new FieldTreeRenderer(this.markdown, this.urls);\n const examples = new ExampleBuilder(lens);\n const title = titleOverride === '' ? spec.title : titleOverride;\n const nav = new NavBuilder(this.urls).build(spec, prose, OVERVIEW_TITLE);\n const layout = new Layout(nav, this.urls, title, spec.version);\n const operations = new OperationPageRenderer(\n spec,\n fields,\n trees,\n this.markdown,\n this.cards,\n new CodeSampleBuilder(spec, examples),\n examples,\n layout,\n this.urls,\n new HeaderListRenderer(lens, this.markdown),\n );\n const pages: SitePage[] = [this.overview(spec, layout)];\n for (const page of prose) {\n pages.push(this.prosePage(page, layout));\n }\n for (const operation of spec.operations()) {\n pages.push(operations.page(operation));\n }\n for (const schema of spec.schemas) {\n if (schema.hasOwnPage) {\n pages.push(this.schemaPage(schema, fields, trees, examples, layout));\n }\n }\n return new RenderedSite(pages, this.assets());\n }\n\n /** The stylesheet and the script, written beside the pages. */\n assets(): readonly SiteAsset[] {\n return [\n new SiteAsset('styles.css', SiteStyles.CSS),\n new SiteAsset('site.js', SiteScript.JS),\n ];\n }\n\n private overview(spec: ApiSpec, layout: Layout): SitePage {\n const parts = [`<h1>${this.html.escape(spec.title)}</h1>`];\n if (spec.description !== '') {\n parts.push(this.markdown.render(spec.description));\n }\n parts.push(this.sectionIndex(spec));\n const url = this.urls.home();\n return new SitePage(\n url,\n OVERVIEW_TITLE,\n layout.render(url, OVERVIEW_TITLE, parts.join('\\n'), this.serversCard(spec)),\n );\n }\n\n private sectionIndex(spec: ApiSpec): string {\n return spec.sections\n .map((section: TagSection): string => {\n const items = section.operations\n .map(\n (operation: OperationInfo): string =>\n `<li>${this.html.link(this.urls.operation(operation), operation.name)}</li>`,\n )\n .join('');\n return `<h2>${this.html.escape(section.name)}</h2>${this.markdown.render(section.description)}<ul>${items}</ul>`;\n })\n .join('\\n');\n }\n\n private serversCard(spec: ApiSpec): string {\n if (spec.servers.length === 0) {\n return '';\n }\n const rows = spec.servers\n .map(\n (server: ServerInfo): string =>\n `<div class=\"field\"><div class=\"field-head\"><span class=\"field-name\">${this.html.escape(server.url)}</span></div><div class=\"field-doc\">${this.html.escape(server.description ?? '')}</div></div>`,\n )\n .join('');\n return this.cards.panel('SERVERS', rows);\n }\n\n private prosePage(page: ProsePage, layout: Layout): SitePage {\n const url = this.urls.prose(page);\n const body = `<h1>${this.html.escape(page.title)}</h1>${this.markdown.render(page.markdown)}`;\n return new SitePage(url, page.title, layout.render(url, page.title, body, ''));\n }\n\n private schemaPage(\n schema: NamedSchema,\n fields: FieldTreeBuilder,\n trees: FieldTreeRenderer,\n examples: ExampleBuilder,\n layout: Layout,\n ): SitePage {\n const url = this.urls.schema(schema);\n const prefix = this.urls.prefixFor(url);\n const parts = [`<h1>${this.html.escape(schema.name)}</h1>`];\n const description = schema.node.text('description');\n if (description !== undefined) {\n parts.push(this.markdown.render(description));\n }\n const variants = fields.variantsOf(schema.node);\n parts.push(\n variants.length > 0\n ? trees.renderVariants(\n variants,\n fields.discriminatorPropertyOf(schema.node),\n prefix,\n )\n : trees.render(fields.fieldsOf(schema.node), prefix),\n );\n const sample = examples.render(examples.build(schema.node));\n return new SitePage(\n url,\n schema.name,\n layout.render(\n url,\n schema.name,\n parts.join('\\n'),\n this.cards.example('EXAMPLE', sample),\n ),\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SiteRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/render/SiteRenderer.ts"],"names":[],"mappings":";;;AACA,iDAA8C;AAC9C,wDAA2D;AAC3D,2DAAwD;AACxD,iDAAqD;AACrD,2DAAwD;AACxD,iCAA8B;AAC9B,qCAAkC;AAClC,mDAAgD;AAChD,yCAAwC;AACxC,6DAA0D;AAC1D,mEAAgE;AAEhE,yCAA+D;AAC/D,mDAAgD;AAChD,qDAAkD;AAClD,qDAAkD;AAClD,yCAAsC;AAEtC,gDAAgD;AACnC,QAAA,cAAc,GAAG,UAAU,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,MAAa,YAAY;IACJ,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;IAC1B,KAAK,GAAG,IAAI,2BAAY,EAAE,CAAC;IAC3B,IAAI,GAAG,IAAI,WAAI,EAAE,CAAC;IAClB,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;IAEvC,4FAA4F;IAC5F,MAAM,CAAC,IAAa,EAAE,KAA2B,EAAE,aAAqB;QACpE,MAAM,IAAI,GAAG,IAAI,uBAAU,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,IAAI,4BAAgB,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,IAAI,qCAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,KAAK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AC,CAC3D,CAAC;QACF,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,OAAO,IAAI,mBAAQ,CACf,GAAG,EACH,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,MAAM,CACT,GAAG,EACH,MAAM,CAAC,IAAI,EACX,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAChB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CACxC,CACJ,CAAC;IACN,CAAC;CACJ;AAxID,oCAwIC","sourcesContent":["import { ApiSpec, NamedSchema, OperationInfo, ServerInfo, TagSection } from '../spec/ApiSpec';\nimport { CardRenderer } from './CardRenderer';\nimport { CodeSampleBuilder } from '../samples/CodeSamples';\nimport { ExampleBuilder } from '../spec/ExampleBuilder';\nimport { FieldTreeBuilder } from '../spec/FieldTree';\nimport { FieldTreeRenderer } from './FieldTreeRenderer';\nimport { Html } from './Html';\nimport { Layout } from './Layout';\nimport { Markdown } from '../markdown/Markdown';\nimport { NavBuilder } from './NavModel';\nimport { HeaderListRenderer } from './HeaderListRenderer';\nimport { OperationPageRenderer } from './OperationPageRenderer';\nimport { ProsePage } from '../manifest/DocsManifest';\nimport { RenderedSite, SiteAsset, SitePage } from './SitePage';\nimport { SchemaLens } from '../spec/SchemaLens';\nimport { SiteScript } from '../assets/SiteScript';\nimport { SiteStyles } from '../assets/SiteStyles';\nimport { SiteUrls } from './SiteUrls';\n\n/** The nav title of the generated home page. */\nexport const OVERVIEW_TITLE = 'Overview';\n\n/**\n * Turns one {@link ApiSpec} plus its prose into the complete list of files to write.\n *\n * Every URL is a FILE — `index.html`, `prose/<slug>/index.html`, `reference/<slug>/index.html`,\n * `schemas/<slug>/index.html` — so a deep link resolves without JS, the output is a folder any\n * static host serves, and a JSDoc edit is a diff on the one page it affects.\n *\n * ## One page per named object DTO\n *\n * Only OBJECTS get pages. A named enum or scalar alias renders inline at each use site with its\n * chips, because a page holding one line of values costs a reader the context they were reading.\n * An UNDEFINED `$ref` also stays inline — a link to a page the document never defined is a dead\n * link, which is strictly worse than the unresolved type name it replaced.\n */\nexport class SiteRenderer {\n private readonly markdown = new Markdown();\n private readonly cards = new CardRenderer();\n private readonly html = new Html();\n private readonly urls = new SiteUrls();\n\n /** @param spec the document. @param prose the manifest's pages, in the manifest's order. */\n render(spec: ApiSpec, prose: readonly ProsePage[], titleOverride: string): RenderedSite {\n const lens = new SchemaLens(spec);\n const fields = new FieldTreeBuilder(lens);\n const trees = new FieldTreeRenderer(this.markdown, this.urls);\n const examples = new ExampleBuilder(lens);\n const title = titleOverride === '' ? spec.title : titleOverride;\n const nav = new NavBuilder(this.urls).build(spec, prose, OVERVIEW_TITLE);\n const layout = new Layout(nav, this.urls, title, spec.version);\n const operations = new OperationPageRenderer(\n spec,\n fields,\n trees,\n this.markdown,\n this.cards,\n new CodeSampleBuilder(spec, examples),\n examples,\n layout,\n this.urls,\n new HeaderListRenderer(lens, this.markdown),\n );\n const pages: SitePage[] = [this.overview(spec, layout)];\n for (const page of prose) {\n pages.push(this.prosePage(page, layout));\n }\n for (const operation of spec.operations()) {\n pages.push(operations.page(operation));\n }\n for (const schema of spec.schemas) {\n if (schema.hasOwnPage) {\n pages.push(this.schemaPage(schema, fields, trees, examples, layout));\n }\n }\n return new RenderedSite(pages, this.assets());\n }\n\n /** The stylesheet and the script, written beside the pages. */\n assets(): readonly SiteAsset[] {\n return [\n new SiteAsset('styles.css', SiteStyles.CSS),\n new SiteAsset('site.js', SiteScript.JS),\n ];\n }\n\n private overview(spec: ApiSpec, layout: Layout): SitePage {\n const parts = [`<h1>${this.html.escape(spec.title)}</h1>`];\n if (spec.summary !== '') {\n parts.push(`<p class=\"api-summary\">${this.html.escape(spec.summary)}</p>`);\n }\n if (spec.description !== '') {\n parts.push(this.markdown.render(spec.description));\n }\n parts.push(this.sectionIndex(spec));\n const url = this.urls.home();\n return new SitePage(\n url,\n OVERVIEW_TITLE,\n layout.render(url, OVERVIEW_TITLE, parts.join('\\n'), this.serversCard(spec)),\n );\n }\n\n private sectionIndex(spec: ApiSpec): string {\n return spec.sections\n .map((section: TagSection): string => {\n const items = section.operations\n .map(\n (operation: OperationInfo): string =>\n `<li>${this.html.link(this.urls.operation(operation), operation.name)}</li>`,\n )\n .join('');\n return `<h2>${this.html.escape(section.name)}</h2>${this.markdown.render(section.description)}<ul>${items}</ul>`;\n })\n .join('\\n');\n }\n\n private serversCard(spec: ApiSpec): string {\n if (spec.servers.length === 0) {\n return '';\n }\n const rows = spec.servers\n .map(\n (server: ServerInfo): string =>\n `<div class=\"field\"><div class=\"field-head\"><span class=\"field-name\">${this.html.escape(server.url)}</span></div><div class=\"field-doc\">${this.html.escape(server.description ?? '')}</div></div>`,\n )\n .join('');\n return this.cards.panel('SERVERS', rows);\n }\n\n private prosePage(page: ProsePage, layout: Layout): SitePage {\n const url = this.urls.prose(page);\n const body = `<h1>${this.html.escape(page.title)}</h1>${this.markdown.render(page.markdown)}`;\n return new SitePage(url, page.title, layout.render(url, page.title, body, ''));\n }\n\n private schemaPage(\n schema: NamedSchema,\n fields: FieldTreeBuilder,\n trees: FieldTreeRenderer,\n examples: ExampleBuilder,\n layout: Layout,\n ): SitePage {\n const url = this.urls.schema(schema);\n const prefix = this.urls.prefixFor(url);\n const parts = [`<h1>${this.html.escape(schema.name)}</h1>`];\n const description = schema.node.text('description');\n if (description !== undefined) {\n parts.push(this.markdown.render(description));\n }\n const variants = fields.variantsOf(schema.node);\n parts.push(\n variants.length > 0\n ? trees.renderVariants(\n variants,\n fields.discriminatorPropertyOf(schema.node),\n prefix,\n )\n : trees.render(fields.fieldsOf(schema.node), prefix),\n );\n const sample = examples.render(examples.build(schema.node));\n return new SitePage(\n url,\n schema.name,\n layout.render(\n url,\n schema.name,\n parts.join('\\n'),\n this.cards.example('EXAMPLE', sample),\n ),\n );\n }\n}\n"]}
|
package/src/spec/ApiSpec.d.ts
CHANGED
|
@@ -64,7 +64,21 @@ export declare class ResponseInfo {
|
|
|
64
64
|
* exist — see `responsibilities.md`.
|
|
65
65
|
*/
|
|
66
66
|
export declare class OperationInfo {
|
|
67
|
+
/**
|
|
68
|
+
* The operation's short TITLE — its `summary`, which is the page heading and the sidebar label
|
|
69
|
+
* (#1296). A document that states none falls back to the `operationId`, then the path or event.
|
|
70
|
+
*/
|
|
67
71
|
readonly name: string;
|
|
72
|
+
/**
|
|
73
|
+
* The `operationId` — the CODE identifier a generated client names the method by — shown on the
|
|
74
|
+
* page beside the method and path. Empty when the document states none.
|
|
75
|
+
*/
|
|
76
|
+
readonly operationId: string;
|
|
77
|
+
/**
|
|
78
|
+
* The page's URL segment. Kebabed from the `operationId` when there is one, because a title
|
|
79
|
+
* is prose an author rewords and a bookmarked URL should not move when they do; otherwise from
|
|
80
|
+
* the title.
|
|
81
|
+
*/
|
|
68
82
|
readonly slug: string;
|
|
69
83
|
readonly httpMethod: string;
|
|
70
84
|
readonly path: string;
|
|
@@ -86,7 +100,23 @@ export declare class OperationInfo {
|
|
|
86
100
|
* `order.state-changed` is what the partner matches on the wire.
|
|
87
101
|
*/
|
|
88
102
|
readonly eventName: string;
|
|
89
|
-
constructor(
|
|
103
|
+
constructor(
|
|
104
|
+
/**
|
|
105
|
+
* The operation's short TITLE — its `summary`, which is the page heading and the sidebar label
|
|
106
|
+
* (#1296). A document that states none falls back to the `operationId`, then the path or event.
|
|
107
|
+
*/
|
|
108
|
+
name: string,
|
|
109
|
+
/**
|
|
110
|
+
* The `operationId` — the CODE identifier a generated client names the method by — shown on the
|
|
111
|
+
* page beside the method and path. Empty when the document states none.
|
|
112
|
+
*/
|
|
113
|
+
operationId: string,
|
|
114
|
+
/**
|
|
115
|
+
* The page's URL segment. Kebabed from the `operationId` when there is one, because a title
|
|
116
|
+
* is prose an author rewords and a bookmarked URL should not move when they do; otherwise from
|
|
117
|
+
* the title.
|
|
118
|
+
*/
|
|
119
|
+
slug: string, httpMethod: string, path: string, description: string, tag: string, requestSchema: JsonNode | undefined,
|
|
90
120
|
/**
|
|
91
121
|
* Every `in: "header"` parameter, the path item's and the operation's (#1292). A credential
|
|
92
122
|
* header from a security scheme is not here: the authorization card documents those.
|
|
@@ -128,6 +158,8 @@ export declare class NamedSchema {
|
|
|
128
158
|
/** The whole document, read once. */
|
|
129
159
|
export declare class ApiSpec {
|
|
130
160
|
readonly title: string;
|
|
161
|
+
/** `info.summary` (OpenAPI 3.1) — the one-line pitch shown under the title. Empty when absent. */
|
|
162
|
+
readonly summary: string;
|
|
131
163
|
readonly version: string;
|
|
132
164
|
readonly description: string;
|
|
133
165
|
readonly servers: readonly ServerInfo[];
|
|
@@ -135,7 +167,9 @@ export declare class ApiSpec {
|
|
|
135
167
|
readonly securitySchemes: readonly SecuritySchemeInfo[];
|
|
136
168
|
readonly schemas: readonly NamedSchema[];
|
|
137
169
|
readonly documentSecurityKeys: readonly string[];
|
|
138
|
-
constructor(title: string,
|
|
170
|
+
constructor(title: string,
|
|
171
|
+
/** `info.summary` (OpenAPI 3.1) — the one-line pitch shown under the title. Empty when absent. */
|
|
172
|
+
summary: string, version: string, description: string, servers: readonly ServerInfo[], sections: readonly TagSection[], securitySchemes: readonly SecuritySchemeInfo[], schemas: readonly NamedSchema[], documentSecurityKeys: readonly string[]);
|
|
139
173
|
/** The named schema `name` refers to, or `undefined` when the document does not define it. */
|
|
140
174
|
schemaNamed(name: string): NamedSchema | undefined;
|
|
141
175
|
/** Every operation, across every section, in published order. */
|
package/src/spec/ApiSpec.js
CHANGED
|
@@ -88,6 +88,7 @@ exports.ResponseInfo = ResponseInfo;
|
|
|
88
88
|
*/
|
|
89
89
|
class OperationInfo {
|
|
90
90
|
name;
|
|
91
|
+
operationId;
|
|
91
92
|
slug;
|
|
92
93
|
httpMethod;
|
|
93
94
|
path;
|
|
@@ -99,7 +100,23 @@ class OperationInfo {
|
|
|
99
100
|
isWebhook;
|
|
100
101
|
securityKeys;
|
|
101
102
|
eventName;
|
|
102
|
-
constructor(
|
|
103
|
+
constructor(
|
|
104
|
+
/**
|
|
105
|
+
* The operation's short TITLE — its `summary`, which is the page heading and the sidebar label
|
|
106
|
+
* (#1296). A document that states none falls back to the `operationId`, then the path or event.
|
|
107
|
+
*/
|
|
108
|
+
name,
|
|
109
|
+
/**
|
|
110
|
+
* The `operationId` — the CODE identifier a generated client names the method by — shown on the
|
|
111
|
+
* page beside the method and path. Empty when the document states none.
|
|
112
|
+
*/
|
|
113
|
+
operationId,
|
|
114
|
+
/**
|
|
115
|
+
* The page's URL segment. Kebabed from the `operationId` when there is one, because a title
|
|
116
|
+
* is prose an author rewords and a bookmarked URL should not move when they do; otherwise from
|
|
117
|
+
* the title.
|
|
118
|
+
*/
|
|
119
|
+
slug, httpMethod, path, description, tag, requestSchema,
|
|
103
120
|
/**
|
|
104
121
|
* Every `in: "header"` parameter, the path item's and the operation's (#1292). A credential
|
|
105
122
|
* header from a security scheme is not here: the authorization card documents those.
|
|
@@ -113,6 +130,7 @@ class OperationInfo {
|
|
|
113
130
|
*/
|
|
114
131
|
eventName) {
|
|
115
132
|
this.name = name;
|
|
133
|
+
this.operationId = operationId;
|
|
116
134
|
this.slug = slug;
|
|
117
135
|
this.httpMethod = httpMethod;
|
|
118
136
|
this.path = path;
|
|
@@ -166,6 +184,7 @@ exports.NamedSchema = NamedSchema;
|
|
|
166
184
|
/** The whole document, read once. */
|
|
167
185
|
class ApiSpec {
|
|
168
186
|
title;
|
|
187
|
+
summary;
|
|
169
188
|
version;
|
|
170
189
|
description;
|
|
171
190
|
servers;
|
|
@@ -173,8 +192,11 @@ class ApiSpec {
|
|
|
173
192
|
securitySchemes;
|
|
174
193
|
schemas;
|
|
175
194
|
documentSecurityKeys;
|
|
176
|
-
constructor(title,
|
|
195
|
+
constructor(title,
|
|
196
|
+
/** `info.summary` (OpenAPI 3.1) — the one-line pitch shown under the title. Empty when absent. */
|
|
197
|
+
summary, version, description, servers, sections, securitySchemes, schemas, documentSecurityKeys) {
|
|
177
198
|
this.title = title;
|
|
199
|
+
this.summary = summary;
|
|
178
200
|
this.version = version;
|
|
179
201
|
this.description = description;
|
|
180
202
|
this.servers = servers;
|
package/src/spec/ApiSpec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiSpec.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/spec/ApiSpec.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AAEH,4FAA4F;AAC5F,MAAa,UAAU;IAEN;IACA;IAFb,YACa,GAAW,EACX,WAA+B;QAD/B,QAAG,GAAH,GAAG,CAAQ;QACX,gBAAW,GAAX,WAAW,CAAoB;IACzC,CAAC;CACP;AALD,gCAKC;AAED;;;;GAIG;AACH,MAAa,kBAAkB;IAEd;IACA;IACA;IACA;IACA;IALb,YACa,GAAW,EACX,IAAY,EACZ,MAAc,EACd,UAAkB,EAClB,WAA+B;QAJ/B,QAAG,GAAH,GAAG,CAAQ;QACX,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAQ;QAClB,gBAAW,GAAX,WAAW,CAAoB;IACzC,CAAC;CACP;AARD,gDAQC;AAED;;;;;;;;GAQG;AACH,MAAa,UAAU;IAEN;IACA;IACA;IAEA;IALb,YACa,IAAY,EACZ,QAAiB,EACjB,WAAmB;IAC5B,oFAAoF;IAC3E,MAAgB;QAJhB,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAS;QACjB,gBAAW,GAAX,WAAW,CAAQ;QAEnB,WAAM,GAAN,MAAM,CAAU;IAC1B,CAAC;CACP;AARD,gCAQC;AAED,qCAAqC;AACrC,MAAa,YAAY;IAER;IACA;IACA;IAEA;IALb,YACa,MAAc,EACd,WAAmB,EACnB,MAA4B;IACrC,uFAAuF;IAC9E,OAA8B;QAJ9B,WAAM,GAAN,MAAM,CAAQ;QACd,gBAAW,GAAX,WAAW,CAAQ;QACnB,WAAM,GAAN,MAAM,CAAsB;QAE5B,YAAO,GAAP,OAAO,CAAuB;IACxC,CAAC;CACP;AARD,oCAQC;AAED;;;;;;GAMG;AACH,MAAa,aAAa;
|
|
1
|
+
{"version":3,"file":"ApiSpec.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/spec/ApiSpec.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AAEH,4FAA4F;AAC5F,MAAa,UAAU;IAEN;IACA;IAFb,YACa,GAAW,EACX,WAA+B;QAD/B,QAAG,GAAH,GAAG,CAAQ;QACX,gBAAW,GAAX,WAAW,CAAoB;IACzC,CAAC;CACP;AALD,gCAKC;AAED;;;;GAIG;AACH,MAAa,kBAAkB;IAEd;IACA;IACA;IACA;IACA;IALb,YACa,GAAW,EACX,IAAY,EACZ,MAAc,EACd,UAAkB,EAClB,WAA+B;QAJ/B,QAAG,GAAH,GAAG,CAAQ;QACX,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAQ;QAClB,gBAAW,GAAX,WAAW,CAAoB;IACzC,CAAC;CACP;AARD,gDAQC;AAED;;;;;;;;GAQG;AACH,MAAa,UAAU;IAEN;IACA;IACA;IAEA;IALb,YACa,IAAY,EACZ,QAAiB,EACjB,WAAmB;IAC5B,oFAAoF;IAC3E,MAAgB;QAJhB,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAS;QACjB,gBAAW,GAAX,WAAW,CAAQ;QAEnB,WAAM,GAAN,MAAM,CAAU;IAC1B,CAAC;CACP;AARD,gCAQC;AAED,qCAAqC;AACrC,MAAa,YAAY;IAER;IACA;IACA;IAEA;IALb,YACa,MAAc,EACd,WAAmB,EACnB,MAA4B;IACrC,uFAAuF;IAC9E,OAA8B;QAJ9B,WAAM,GAAN,MAAM,CAAQ;QACd,gBAAW,GAAX,WAAW,CAAQ;QACnB,WAAM,G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CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAU;QACd,eAAU,GAAV,UAAU,CAAS;IAC7B,CAAC;CACP;AAPD,kCAOC;AAED,qCAAqC;AACrC,MAAa,OAAO;IAEH;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAVb,YACa,KAAa;IACtB,kGAAkG;IACzF,OAAe,EACf,OAAe,EACf,WAAmB,EACnB,OAA8B,EAC9B,QAA+B,EAC/B,eAA8C,EAC9C,OAA+B,EAC/B,oBAAuC;QATvC,UAAK,GAAL,KAAK,CAAQ;QAEb,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAuB;QAC9B,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,oBAAe,GAAf,eAAe,CAA+B;QAC9C,YAAO,GAAP,OAAO,CAAwB;QAC/B,yBAAoB,GAApB,oBAAoB,CAAmB;IACjD,CAAC;IAEJ,8FAA8F;IAC9F,WAAW,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAmB,EAAW,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACrF,CAAC;IAED,iEAAiE;IACjE,UAAU;QACN,MAAM,GAAG,GAAoB,EAAE,CAAC;QAChC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,GAAG,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AA3BD,0BA2BC","sourcesContent":["import { JsonNode } from './JsonNode';\n\n/**\n * The model this package renders. It is read from a document STRUCTURALLY (see {@link JsonNode}), so\n * it is deliberately NOT `@webpieces/openapi-generator`'s document classes even though it looks like\n * them: a compile-time dependency on the generator would make \"generated by us\" a precondition for\n * \"renderable by us\", and #985 is explicit that any conforming 3.0 or 3.1 document renders here.\n *\n * Everything below is data, so everything below is a class (`CLAUDE.md` §1).\n */\n\n/** One entry of the document's `servers[]`. The first one is what the code samples call. */\nexport class ServerInfo {\n constructor(\n readonly url: string,\n readonly description: string | undefined,\n ) {}\n}\n\n/**\n * One published security scheme. Only the fields a partner has to ACT on are carried: what to send\n * and where. `headerName` is empty for a scheme that is not sent in a header, and the code samples\n * then omit it rather than inventing a header name the server never reads.\n */\nexport class SecuritySchemeInfo {\n constructor(\n readonly key: string,\n readonly kind: string,\n readonly sentIn: string,\n readonly headerName: string,\n readonly description: string | undefined,\n ) {}\n}\n\n/**\n * One HTTP header a page documents: a response's `headers` entry, or a request parameter declared\n * `in: \"header\"` (#1292). A `$ref` — into `components.headers` or `components.parameters` — is resolved\n * when the document is read, so a renderer never follows a pointer.\n *\n * `schema` is kept as the node rather than a label, because the type label is the same\n * `SchemaLens` reading every body field gets — a header typed by a named schema reads exactly like a\n * field typed by one.\n */\nexport class HeaderInfo {\n constructor(\n readonly name: string,\n readonly required: boolean,\n readonly description: string,\n /** The header's `schema`; a node over `undefined` when the document states none. */\n readonly schema: JsonNode,\n ) {}\n}\n\n/** One response of one operation. */\nexport class ResponseInfo {\n constructor(\n readonly status: string,\n readonly description: string,\n readonly schema: JsonNode | undefined,\n /** Its `headers`, in document order — rendered on the card beside the body (#1292). */\n readonly headers: readonly HeaderInfo[],\n ) {}\n}\n\n/**\n * One rendered page's worth of operation.\n *\n * A WEBHOOK carries `isWebhook`, and with it no method, no path and no code samples. The url belongs\n * to the PARTNER, so a curl of ours against one would invite them to call something that does not\n * exist — see `responsibilities.md`.\n */\nexport class OperationInfo {\n constructor(\n /**\n * The operation's short TITLE — its `summary`, which is the page heading and the sidebar label\n * (#1296). A document that states none falls back to the `operationId`, then the path or event.\n */\n readonly name: string,\n /**\n * The `operationId` — the CODE identifier a generated client names the method by — shown on the\n * page beside the method and path. Empty when the document states none.\n */\n readonly operationId: string,\n /**\n * The page's URL segment. Kebabed from the `operationId` when there is one, because a title\n * is prose an author rewords and a bookmarked URL should not move when they do; otherwise from\n * the title.\n */\n readonly slug: string,\n readonly httpMethod: string,\n readonly path: string,\n readonly description: string,\n readonly tag: string,\n readonly requestSchema: JsonNode | undefined,\n /**\n * Every `in: \"header\"` parameter, the path item's and the operation's (#1292). A credential\n * header from a security scheme is not here: the authorization card documents those.\n */\n readonly requestHeaders: readonly HeaderInfo[],\n readonly responses: readonly ResponseInfo[],\n readonly isWebhook: boolean,\n readonly securityKeys: readonly string[],\n /**\n * The event NAME a webhook is keyed by in the document's `webhooks:` block, and the empty\n * string for an ordinary operation. It is carried separately from `name` because the two\n * are different published facts — `orderStateChanged` is what we call the method,\n * `order.state-changed` is what the partner matches on the wire.\n */\n readonly eventName: string,\n ) {}\n}\n\n/**\n * One nav section: an OpenAPI tag and the operations under it, webhooks appended after the\n * operations that share the tag. EVERY tag gets one — a tag missing from the sidebar is an operation\n * a partner cannot find, which reads exactly like an operation that does not exist.\n */\nexport class TagSection {\n constructor(\n readonly name: string,\n readonly description: string,\n readonly operations: readonly OperationInfo[],\n ) {}\n}\n\n/**\n * One named schema from `components.schemas`.\n *\n * `hasOwnPage` is true for an OBJECT only. A named enum or scalar alias stays inline at every use\n * site, because a page carrying one line of chips is a click that costs the reader the context they\n * were reading in.\n */\nexport class NamedSchema {\n constructor(\n readonly name: string,\n readonly slug: string,\n readonly node: JsonNode,\n readonly hasOwnPage: boolean,\n ) {}\n}\n\n/** The whole document, read once. */\nexport class ApiSpec {\n constructor(\n readonly title: string,\n /** `info.summary` (OpenAPI 3.1) — the one-line pitch shown under the title. Empty when absent. */\n readonly summary: string,\n readonly version: string,\n readonly description: string,\n readonly servers: readonly ServerInfo[],\n readonly sections: readonly TagSection[],\n readonly securitySchemes: readonly SecuritySchemeInfo[],\n readonly schemas: readonly NamedSchema[],\n readonly documentSecurityKeys: readonly string[],\n ) {}\n\n /** The named schema `name` refers to, or `undefined` when the document does not define it. */\n schemaNamed(name: string): NamedSchema | undefined {\n return this.schemas.find((schema: NamedSchema): boolean => schema.name === name);\n }\n\n /** Every operation, across every section, in published order. */\n operations(): readonly OperationInfo[] {\n const all: OperationInfo[] = [];\n for (const section of this.sections) {\n all.push(...section.operations);\n }\n return all;\n }\n}\n"]}
|
package/src/spec/SpecReader.js
CHANGED
|
@@ -39,7 +39,7 @@ class SpecReader {
|
|
|
39
39
|
read(root) {
|
|
40
40
|
const schemas = this.readSchemas(root);
|
|
41
41
|
const sections = this.readSections(root);
|
|
42
|
-
return new ApiSpec_1.ApiSpec(root.at('info').text('title') ?? 'API reference', root.at('info').text('version') ?? '', root.at('info').text('description') ?? '', this.readServers(root), sections, this.readSecuritySchemes(root), schemas, this.securityKeysIn(root));
|
|
42
|
+
return new ApiSpec_1.ApiSpec(root.at('info').text('title') ?? 'API reference', root.at('info').text('summary') ?? '', root.at('info').text('version') ?? '', root.at('info').text('description') ?? '', this.readServers(root), sections, this.readSecuritySchemes(root), schemas, this.securityKeysIn(root));
|
|
43
43
|
}
|
|
44
44
|
readServers(root) {
|
|
45
45
|
return root
|
|
@@ -122,8 +122,9 @@ class SpecReader {
|
|
|
122
122
|
return found;
|
|
123
123
|
}
|
|
124
124
|
readOperation(root, node, slugs, httpMethod, pathOrEvent, isWebhook, pathItem) {
|
|
125
|
-
const
|
|
126
|
-
|
|
125
|
+
const operationId = node.text('operationId');
|
|
126
|
+
const name = node.text('summary') ?? operationId ?? pathOrEvent;
|
|
127
|
+
return new ApiSpec_1.OperationInfo(name, operationId ?? '', slugs.unique(operationId ?? name), httpMethod, isWebhook ? '' : pathOrEvent, node.text('description') ?? '', this.tagOf(node), this.requestSchemaOf(node), this.requestHeadersOf(root, pathItem, node), this.responsesOf(root, node), isWebhook, isWebhook ? [] : this.operationSecurityKeys(root, node), isWebhook ? pathOrEvent : '');
|
|
127
128
|
}
|
|
128
129
|
tagOf(node) {
|
|
129
130
|
for (const tag of node.list('tags')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpecReader.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/spec/SpecReader.ts"],"names":[],"mappings":";;;AAAA,uCASmB;AAEnB,+CAA4C;AAC5C,iCAA8B;AAE9B,MAAM,YAAY,GAAsB;IACpC,KAAK;IACL,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACT,MAAM;IACN,OAAO;IACP,OAAO;CACV,CAAC;AAEF,kGAAkG;AACrF,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,UAAU;IACF,KAAK,GAAG,IAAI,yBAAW,EAAE,CAAC;IAE3C,IAAI,CAAC,IAAc;QACf,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,IAAI,iBAAO,CACd,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,eAAe,EAChD,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EACrC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,EACzC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EACtB,QAAQ,EACR,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAC9B,OAAO,EACP,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAC5B,CAAC;IACN,CAAC;IAEO,WAAW,CAAC,IAAc;QAC9B,OAAO,IAAI;aACN,IAAI,CAAC,SAAS,CAAC;aACf,GAAG,CACA,CAAC,KAAe,EAAc,EAAE,CAC5B,IAAI,oBAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,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IAAI,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAEO,cAAc,CAAC,MAAgB;QACnC,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAChD,KAAK,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC;gBACnC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;oBACtB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA3SD,gCA2SC","sourcesContent":["import {\n ApiSpec,\n HeaderInfo,\n NamedSchema,\n OperationInfo,\n ResponseInfo,\n SecuritySchemeInfo,\n ServerInfo,\n TagSection,\n} from './ApiSpec';\nimport { JsonEntry, JsonNode } from './JsonNode';\nimport { SchemaShape } from './SchemaShape';\nimport { Slug } from './Slug';\n\nconst HTTP_METHODS: readonly string[] = [\n 'get',\n 'put',\n 'post',\n 'delete',\n 'options',\n 'head',\n 'patch',\n 'trace',\n];\n\n/** The section untagged operations land in, so an operation is never unreachable from the nav. */\nexport const UNTAGGED_SECTION = 'Operations';\n\n/**\n * Reads one OpenAPI 3.0-or-3.1 document into an {@link ApiSpec}.\n *\n * ## Nothing here is SORTED\n *\n * Both orders in the finished site are published decisions somebody made, so neither is re-derived:\n * the reference order is the document's own `tags[]`, and the prose order is `docs.manifest.json`.\n * Alphabetising either is not a cleanup — it reorders partner-facing navigation.\n *\n * A tag that appears on an operation without being declared in `tags[]` still gets its own section,\n * appended in first-seen order. A tag missing from the sidebar is an operation a partner cannot\n * find, which reads exactly like an operation that does not exist.\n *\n * ## Webhooks\n *\n * A top-level `webhooks:` entry files into the SAME section as the operations sharing its tag, and\n * is APPENDED after them, because the events are what happens as a result of the calls above.\n */\nexport class SpecReader {\n private readonly shape = new SchemaShape();\n\n read(root: JsonNode): ApiSpec {\n const schemas = this.readSchemas(root);\n const sections = this.readSections(root);\n return new ApiSpec(\n root.at('info').text('title') ?? 'API reference',\n root.at('info').text('version') ?? '',\n root.at('info').text('description') ?? '',\n this.readServers(root),\n sections,\n this.readSecuritySchemes(root),\n schemas,\n this.securityKeysIn(root),\n );\n }\n\n private readServers(root: JsonNode): readonly ServerInfo[] {\n return root\n .list('servers')\n .map(\n (entry: JsonNode): ServerInfo =>\n new ServerInfo(entry.text('url') ?? '', entry.text('description')),\n );\n }\n\n private readSecuritySchemes(root: JsonNode): readonly SecuritySchemeInfo[] {\n const declared = root.at('components').at('securitySchemes');\n return declared\n .entries()\n .map(\n (entry: JsonEntry): SecuritySchemeInfo =>\n new SecuritySchemeInfo(\n entry.key,\n entry.value.text('type') ?? '',\n entry.value.text('in') ?? '',\n entry.value.text('name') ?? '',\n entry.value.text('description'),\n ),\n );\n }\n\n private readSchemas(root: JsonNode): readonly NamedSchema[] {\n const slugs = new Slug();\n return root\n .at('components')\n .at('schemas')\n .entries()\n .map(\n (entry: JsonEntry): NamedSchema =>\n new NamedSchema(\n entry.key,\n slugs.unique(entry.key),\n entry.value,\n this.shape.hasOwnPage(entry.value),\n ),\n );\n }\n\n private readSections(root: JsonNode): readonly TagSection[] {\n const slugs = new Slug();\n const operations = this.readOperations(root, slugs);\n const webhooks = this.readWebhooks(root, slugs);\n const order = this.sectionOrder(root, operations, webhooks);\n const sections: TagSection[] = [];\n for (const tag of order) {\n const inTag = operations.filter((one: OperationInfo): boolean => one.tag === tag);\n const eventsInTag = webhooks.filter((one: OperationInfo): boolean => one.tag === tag);\n sections.push(\n new TagSection(tag, this.tagDescription(root, tag), [...inTag, ...eventsInTag]),\n );\n }\n return sections;\n }\n\n /** `tags[]` first, in its published order, then any tag only an operation mentions. */\n private sectionOrder(\n root: JsonNode,\n operations: readonly OperationInfo[],\n webhooks: readonly OperationInfo[],\n ): readonly string[] {\n const order: string[] = [];\n for (const declared of root.list('tags')) {\n const name = declared.text('name');\n if (name !== undefined && !order.includes(name)) {\n order.push(name);\n }\n }\n for (const one of [...operations, ...webhooks]) {\n if (!order.includes(one.tag)) {\n order.push(one.tag);\n }\n }\n return order.filter((tag: string): boolean =>\n [...operations, ...webhooks].some((one: OperationInfo): boolean => one.tag === tag),\n );\n }\n\n private tagDescription(root: JsonNode, tag: string): string {\n for (const declared of root.list('tags')) {\n if (declared.text('name') === tag) {\n return declared.text('description') ?? '';\n }\n }\n return '';\n }\n\n private readOperations(root: JsonNode, slugs: Slug): readonly OperationInfo[] {\n const found: OperationInfo[] = [];\n for (const pathEntry of root.at('paths').entries()) {\n for (const methodEntry of pathEntry.value.entries()) {\n if (!HTTP_METHODS.includes(methodEntry.key)) {\n continue;\n }\n found.push(\n this.readOperation(\n root,\n methodEntry.value,\n slugs,\n methodEntry.key.toUpperCase(),\n pathEntry.key,\n false,\n pathEntry.value,\n ),\n );\n }\n }\n return found;\n }\n\n private readWebhooks(root: JsonNode, slugs: Slug): readonly OperationInfo[] {\n const found: OperationInfo[] = [];\n for (const eventEntry of root.at('webhooks').entries()) {\n for (const methodEntry of eventEntry.value.entries()) {\n if (!HTTP_METHODS.includes(methodEntry.key)) {\n continue;\n }\n found.push(\n this.readOperation(\n root,\n methodEntry.value,\n slugs,\n '',\n eventEntry.key,\n true,\n eventEntry.value,\n ),\n );\n }\n }\n return found;\n }\n\n private readOperation(\n root: JsonNode,\n node: JsonNode,\n slugs: Slug,\n httpMethod: string,\n pathOrEvent: string,\n isWebhook: boolean,\n pathItem: JsonNode,\n ): OperationInfo {\n const name = node.text('summary') ?? node.text('operationId') ?? pathOrEvent;\n return new OperationInfo(\n name,\n slugs.unique(name),\n httpMethod,\n isWebhook ? '' : pathOrEvent,\n node.text('description') ?? '',\n this.tagOf(node),\n this.requestSchemaOf(node),\n this.requestHeadersOf(root, pathItem, node),\n this.responsesOf(root, node),\n isWebhook,\n isWebhook ? [] : this.operationSecurityKeys(root, node),\n isWebhook ? pathOrEvent : '',\n );\n }\n\n private tagOf(node: JsonNode): string {\n for (const tag of node.list('tags')) {\n const name = tag.asText();\n if (name !== undefined) {\n return name;\n }\n }\n return UNTAGGED_SECTION;\n }\n\n private requestSchemaOf(node: JsonNode): JsonNode | undefined {\n const schema = node.at('requestBody').at('content').at('application/json').at('schema');\n return schema.isObject() ? schema : undefined;\n }\n\n private responsesOf(root: JsonNode, node: JsonNode): readonly ResponseInfo[] {\n return node\n .at('responses')\n .entries()\n .map((entry: JsonEntry): ResponseInfo => {\n const response = this.dereference(root, entry.value);\n const schema = response.at('content').at('application/json').at('schema');\n return new ResponseInfo(\n entry.key,\n response.text('description') ?? '',\n schema.isObject() ? schema : undefined,\n this.responseHeadersOf(root, response),\n );\n });\n }\n\n /** A response's `headers` map, each entry resolved through a `$ref` into `components.headers`. */\n private responseHeadersOf(root: JsonNode, response: JsonNode): readonly HeaderInfo[] {\n return response\n .at('headers')\n .entries()\n .map((entry: JsonEntry): HeaderInfo => {\n const header = this.dereference(root, entry.value);\n return new HeaderInfo(\n entry.key,\n header.flag('required') === true,\n header.text('description') ?? '',\n header.at('schema'),\n );\n });\n }\n\n /**\n * Every `in: \"header\"` parameter: the PATH ITEM's first, then the operation's — an operation\n * parameter of the same name overrides the path item's, which is OpenAPI's own rule.\n */\n private requestHeadersOf(\n root: JsonNode,\n pathItem: JsonNode,\n node: JsonNode,\n ): readonly HeaderInfo[] {\n const byName = new Map<string, HeaderInfo>();\n for (const holder of [pathItem, node]) {\n for (const listed of holder.list('parameters')) {\n const parameter = this.dereference(root, listed);\n const name = parameter.text('name');\n if (parameter.text('in') !== 'header' || name === undefined) {\n continue;\n }\n byName.set(\n name.toLowerCase(),\n new HeaderInfo(\n name,\n parameter.flag('required') === true,\n parameter.text('description') ?? '',\n parameter.at('schema'),\n ),\n );\n }\n }\n return Array.from(byName.values());\n }\n\n /**\n * The object a LOCAL `$ref` (`#/components/headers/x-request-id`) points at, or the node itself\n * when it is no reference. A dangling or foreign reference also reads as the node itself, so the\n * header still renders under its own name rather than vanishing — the same total-reading choice\n * `JsonNode` makes everywhere.\n */\n private dereference(root: JsonNode, node: JsonNode): JsonNode {\n const pointer = node.text('$ref');\n if (pointer === undefined || !pointer.startsWith('#/')) {\n return node;\n }\n let current = root;\n for (const step of pointer.slice(2).split('/')) {\n current = current.at(step.replace(/~1/g, '/').replace(/~0/g, '~'));\n }\n return current.isObject() ? current : node;\n }\n\n /**\n * The credentials this operation needs: its own `security` when it states one, the document's\n * otherwise. An operation stating `security: []` needs none, and that empty array is the\n * OpenAPI spelling of \"no credential\" rather than of \"inherit\" — so it must not fall back.\n */\n private operationSecurityKeys(root: JsonNode, node: JsonNode): readonly string[] {\n if (Array.isArray(node.at('security').raw)) {\n return this.securityKeysIn(node);\n }\n return this.securityKeysIn(root);\n }\n\n private securityKeysIn(holder: JsonNode): readonly string[] {\n const keys: string[] = [];\n for (const requirement of holder.list('security')) {\n for (const key of requirement.keys()) {\n if (!keys.includes(key)) {\n keys.push(key);\n }\n }\n }\n return keys;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SpecReader.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/spec/SpecReader.ts"],"names":[],"mappings":";;;AAAA,uCASmB;AAEnB,+CAA4C;AAC5C,iCAA8B;AAE9B,MAAM,YAAY,GAAsB;IACpC,KAAK;IACL,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACT,MAAM;IACN,OAAO;IACP,OAAO;CACV,CAAC;AAEF,kGAAkG;AACrF,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,UAAU;IACF,KAAK,GAAG,IAAI,yBAAW,EAAE,CAAC;IAE3C,IAAI,CAAC,IAAc;QACf,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACv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CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA9SD,gCA8SC","sourcesContent":["import {\n ApiSpec,\n HeaderInfo,\n NamedSchema,\n OperationInfo,\n ResponseInfo,\n SecuritySchemeInfo,\n ServerInfo,\n TagSection,\n} from './ApiSpec';\nimport { JsonEntry, JsonNode } from './JsonNode';\nimport { SchemaShape } from './SchemaShape';\nimport { Slug } from './Slug';\n\nconst HTTP_METHODS: readonly string[] = [\n 'get',\n 'put',\n 'post',\n 'delete',\n 'options',\n 'head',\n 'patch',\n 'trace',\n];\n\n/** The section untagged operations land in, so an operation is never unreachable from the nav. */\nexport const UNTAGGED_SECTION = 'Operations';\n\n/**\n * Reads one OpenAPI 3.0-or-3.1 document into an {@link ApiSpec}.\n *\n * ## Nothing here is SORTED\n *\n * Both orders in the finished site are published decisions somebody made, so neither is re-derived:\n * the reference order is the document's own `tags[]`, and the prose order is `docs.manifest.json`.\n * Alphabetising either is not a cleanup — it reorders partner-facing navigation.\n *\n * A tag that appears on an operation without being declared in `tags[]` still gets its own section,\n * appended in first-seen order. A tag missing from the sidebar is an operation a partner cannot\n * find, which reads exactly like an operation that does not exist.\n *\n * ## Webhooks\n *\n * A top-level `webhooks:` entry files into the SAME section as the operations sharing its tag, and\n * is APPENDED after them, because the events are what happens as a result of the calls above.\n */\nexport class SpecReader {\n private readonly shape = new SchemaShape();\n\n read(root: JsonNode): ApiSpec {\n const schemas = this.readSchemas(root);\n const sections = this.readSections(root);\n return new ApiSpec(\n root.at('info').text('title') ?? 'API reference',\n root.at('info').text('summary') ?? '',\n root.at('info').text('version') ?? '',\n root.at('info').text('description') ?? '',\n this.readServers(root),\n sections,\n this.readSecuritySchemes(root),\n schemas,\n this.securityKeysIn(root),\n );\n }\n\n private readServers(root: JsonNode): readonly ServerInfo[] {\n return root\n .list('servers')\n .map(\n (entry: JsonNode): ServerInfo =>\n new ServerInfo(entry.text('url') ?? '', entry.text('description')),\n );\n }\n\n private readSecuritySchemes(root: JsonNode): readonly SecuritySchemeInfo[] {\n const declared = root.at('components').at('securitySchemes');\n return declared\n .entries()\n .map(\n (entry: JsonEntry): SecuritySchemeInfo =>\n new SecuritySchemeInfo(\n entry.key,\n entry.value.text('type') ?? '',\n entry.value.text('in') ?? '',\n entry.value.text('name') ?? '',\n entry.value.text('description'),\n ),\n );\n }\n\n private readSchemas(root: JsonNode): readonly NamedSchema[] {\n const slugs = new Slug();\n return root\n .at('components')\n .at('schemas')\n .entries()\n .map(\n (entry: JsonEntry): NamedSchema =>\n new NamedSchema(\n entry.key,\n slugs.unique(entry.key),\n entry.value,\n this.shape.hasOwnPage(entry.value),\n ),\n );\n }\n\n private readSections(root: JsonNode): readonly TagSection[] {\n const slugs = new Slug();\n const operations = this.readOperations(root, slugs);\n const webhooks = this.readWebhooks(root, slugs);\n const order = this.sectionOrder(root, operations, webhooks);\n const sections: TagSection[] = [];\n for (const tag of order) {\n const inTag = operations.filter((one: OperationInfo): boolean => one.tag === tag);\n const eventsInTag = webhooks.filter((one: OperationInfo): boolean => one.tag === tag);\n sections.push(\n new TagSection(tag, this.tagDescription(root, tag), [...inTag, ...eventsInTag]),\n );\n }\n return sections;\n }\n\n /** `tags[]` first, in its published order, then any tag only an operation mentions. */\n private sectionOrder(\n root: JsonNode,\n operations: readonly OperationInfo[],\n webhooks: readonly OperationInfo[],\n ): readonly string[] {\n const order: string[] = [];\n for (const declared of root.list('tags')) {\n const name = declared.text('name');\n if (name !== undefined && !order.includes(name)) {\n order.push(name);\n }\n }\n for (const one of [...operations, ...webhooks]) {\n if (!order.includes(one.tag)) {\n order.push(one.tag);\n }\n }\n return order.filter((tag: string): boolean =>\n [...operations, ...webhooks].some((one: OperationInfo): boolean => one.tag === tag),\n );\n }\n\n private tagDescription(root: JsonNode, tag: string): string {\n for (const declared of root.list('tags')) {\n if (declared.text('name') === tag) {\n return declared.text('description') ?? '';\n }\n }\n return '';\n }\n\n private readOperations(root: JsonNode, slugs: Slug): readonly OperationInfo[] {\n const found: OperationInfo[] = [];\n for (const pathEntry of root.at('paths').entries()) {\n for (const methodEntry of pathEntry.value.entries()) {\n if (!HTTP_METHODS.includes(methodEntry.key)) {\n continue;\n }\n found.push(\n this.readOperation(\n root,\n methodEntry.value,\n slugs,\n methodEntry.key.toUpperCase(),\n pathEntry.key,\n false,\n pathEntry.value,\n ),\n );\n }\n }\n return found;\n }\n\n private readWebhooks(root: JsonNode, slugs: Slug): readonly OperationInfo[] {\n const found: OperationInfo[] = [];\n for (const eventEntry of root.at('webhooks').entries()) {\n for (const methodEntry of eventEntry.value.entries()) {\n if (!HTTP_METHODS.includes(methodEntry.key)) {\n continue;\n }\n found.push(\n this.readOperation(\n root,\n methodEntry.value,\n slugs,\n '',\n eventEntry.key,\n true,\n eventEntry.value,\n ),\n );\n }\n }\n return found;\n }\n\n private readOperation(\n root: JsonNode,\n node: JsonNode,\n slugs: Slug,\n httpMethod: string,\n pathOrEvent: string,\n isWebhook: boolean,\n pathItem: JsonNode,\n ): OperationInfo {\n const operationId = node.text('operationId');\n const name = node.text('summary') ?? operationId ?? pathOrEvent;\n return new OperationInfo(\n name,\n operationId ?? '',\n slugs.unique(operationId ?? name),\n httpMethod,\n isWebhook ? '' : pathOrEvent,\n node.text('description') ?? '',\n this.tagOf(node),\n this.requestSchemaOf(node),\n this.requestHeadersOf(root, pathItem, node),\n this.responsesOf(root, node),\n isWebhook,\n isWebhook ? [] : this.operationSecurityKeys(root, node),\n isWebhook ? pathOrEvent : '',\n );\n }\n\n private tagOf(node: JsonNode): string {\n for (const tag of node.list('tags')) {\n const name = tag.asText();\n if (name !== undefined) {\n return name;\n }\n }\n return UNTAGGED_SECTION;\n }\n\n private requestSchemaOf(node: JsonNode): JsonNode | undefined {\n const schema = node.at('requestBody').at('content').at('application/json').at('schema');\n return schema.isObject() ? schema : undefined;\n }\n\n private responsesOf(root: JsonNode, node: JsonNode): readonly ResponseInfo[] {\n return node\n .at('responses')\n .entries()\n .map((entry: JsonEntry): ResponseInfo => {\n const response = this.dereference(root, entry.value);\n const schema = response.at('content').at('application/json').at('schema');\n return new ResponseInfo(\n entry.key,\n response.text('description') ?? '',\n schema.isObject() ? schema : undefined,\n this.responseHeadersOf(root, response),\n );\n });\n }\n\n /** A response's `headers` map, each entry resolved through a `$ref` into `components.headers`. */\n private responseHeadersOf(root: JsonNode, response: JsonNode): readonly HeaderInfo[] {\n return response\n .at('headers')\n .entries()\n .map((entry: JsonEntry): HeaderInfo => {\n const header = this.dereference(root, entry.value);\n return new HeaderInfo(\n entry.key,\n header.flag('required') === true,\n header.text('description') ?? '',\n header.at('schema'),\n );\n });\n }\n\n /**\n * Every `in: \"header\"` parameter: the PATH ITEM's first, then the operation's — an operation\n * parameter of the same name overrides the path item's, which is OpenAPI's own rule.\n */\n private requestHeadersOf(\n root: JsonNode,\n pathItem: JsonNode,\n node: JsonNode,\n ): readonly HeaderInfo[] {\n const byName = new Map<string, HeaderInfo>();\n for (const holder of [pathItem, node]) {\n for (const listed of holder.list('parameters')) {\n const parameter = this.dereference(root, listed);\n const name = parameter.text('name');\n if (parameter.text('in') !== 'header' || name === undefined) {\n continue;\n }\n byName.set(\n name.toLowerCase(),\n new HeaderInfo(\n name,\n parameter.flag('required') === true,\n parameter.text('description') ?? '',\n parameter.at('schema'),\n ),\n );\n }\n }\n return Array.from(byName.values());\n }\n\n /**\n * The object a LOCAL `$ref` (`#/components/headers/x-request-id`) points at, or the node itself\n * when it is no reference. A dangling or foreign reference also reads as the node itself, so the\n * header still renders under its own name rather than vanishing — the same total-reading choice\n * `JsonNode` makes everywhere.\n */\n private dereference(root: JsonNode, node: JsonNode): JsonNode {\n const pointer = node.text('$ref');\n if (pointer === undefined || !pointer.startsWith('#/')) {\n return node;\n }\n let current = root;\n for (const step of pointer.slice(2).split('/')) {\n current = current.at(step.replace(/~1/g, '/').replace(/~0/g, '~'));\n }\n return current.isObject() ? current : node;\n }\n\n /**\n * The credentials this operation needs: its own `security` when it states one, the document's\n * otherwise. An operation stating `security: []` needs none, and that empty array is the\n * OpenAPI spelling of \"no credential\" rather than of \"inherit\" — so it must not fall back.\n */\n private operationSecurityKeys(root: JsonNode, node: JsonNode): readonly string[] {\n if (Array.isArray(node.at('security').raw)) {\n return this.securityKeysIn(node);\n }\n return this.securityKeysIn(root);\n }\n\n private securityKeysIn(holder: JsonNode): readonly string[] {\n const keys: string[] = [];\n for (const requirement of holder.list('security')) {\n for (const key of requirement.keys()) {\n if (!keys.includes(key)) {\n keys.push(key);\n }\n }\n }\n return keys;\n }\n}\n"]}
|