@sdk-it/spec 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/find-polymorphic-varients.test.js +1 -1
- package/dist/lib/find-polymorphic-varients.test.js.map +1 -1
- package/dist/lib/{operation.d.ts → ir.d.ts} +1 -1
- package/dist/lib/ir.d.ts.map +1 -0
- package/dist/lib/{operation.js → ir.js} +1 -1
- package/dist/lib/{operation.js.map → ir.js.map} +1 -1
- package/dist/lib/ir.test.d.ts +2 -0
- package/dist/lib/ir.test.d.ts.map +1 -0
- package/dist/lib/{operation.test.js → ir.test.js} +1 -1
- package/dist/lib/{operation.test.js.map → ir.test.js.map} +1 -1
- package/dist/lib/options.d.ts +1 -1
- package/dist/lib/options.d.ts.map +1 -1
- package/dist/lib/options.js +2 -1
- package/dist/lib/options.js.map +2 -2
- package/dist/lib/overview-docs/doc-templates.d.ts +51 -0
- package/dist/lib/overview-docs/doc-templates.d.ts.map +1 -0
- package/dist/lib/overview-docs/doc-templates.js +123 -0
- package/dist/lib/overview-docs/doc-templates.js.map +7 -0
- package/dist/lib/overview-docs/doc-text-utils.d.ts +86 -0
- package/dist/lib/overview-docs/doc-text-utils.d.ts.map +1 -0
- package/dist/lib/overview-docs/doc-text-utils.js +108 -0
- package/dist/lib/overview-docs/doc-text-utils.js.map +7 -0
- package/dist/lib/overview-docs/overview-auth.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-auth.js +34 -52
- package/dist/lib/overview-docs/overview-auth.js.map +2 -2
- package/dist/lib/overview-docs/overview-errors.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-errors.js +11 -28
- package/dist/lib/overview-docs/overview-errors.js.map +2 -2
- package/dist/lib/overview-docs/overview-intro.d.ts +1 -1
- package/dist/lib/overview-docs/overview-intro.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-intro.js +41 -36
- package/dist/lib/overview-docs/overview-intro.js.map +2 -2
- package/dist/lib/tune.test.js +1 -1
- package/dist/lib/tune.test.js.map +1 -1
- package/dist/lib/types.d.ts +2 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/lib/operation.d.ts.map +0 -1
- package/dist/lib/operation.test.d.ts +0 -2
- package/dist/lib/operation.test.d.ts.map +0 -1
- package/dist/lib/overview-docs/overview-quick-reference.d.ts +0 -4
- package/dist/lib/overview-docs/overview-quick-reference.d.ts.map +0 -1
- package/dist/lib/overview-docs/overview-sdk-examples.d.ts +0 -4
- package/dist/lib/overview-docs/overview-sdk-examples.d.ts.map +0 -1
- package/dist/lib/overview-docs/overview-usage.d.ts +0 -4
- package/dist/lib/overview-docs/overview-usage.d.ts.map +0 -1
- package/dist/lib/overview-docs.d.ts +0 -4
- package/dist/lib/overview-docs.d.ts.map +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preset documentation text templates for consistent singular/plural handling
|
|
3
|
+
*/
|
|
4
|
+
export declare const presetDocs: {
|
|
5
|
+
readonly auth: {
|
|
6
|
+
readonly section: {
|
|
7
|
+
readonly singular: "Available Authentication Method";
|
|
8
|
+
readonly plural: "Available Authentication Methods";
|
|
9
|
+
};
|
|
10
|
+
readonly description: {
|
|
11
|
+
readonly singular: "an authentication method";
|
|
12
|
+
readonly plural: "various authentication methods";
|
|
13
|
+
};
|
|
14
|
+
readonly scheme: {
|
|
15
|
+
readonly singular: "the available authentication scheme";
|
|
16
|
+
readonly plural: "each available authentication scheme";
|
|
17
|
+
};
|
|
18
|
+
readonly intro: {
|
|
19
|
+
readonly template: (count: number, methods: string, schemes: string, pronoun: string) => string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
readonly server: {
|
|
23
|
+
readonly section: {
|
|
24
|
+
readonly singular: "API Server";
|
|
25
|
+
readonly plural: "API Servers";
|
|
26
|
+
};
|
|
27
|
+
readonly description: {
|
|
28
|
+
readonly singular: "The following server is available for this API:";
|
|
29
|
+
readonly plural: "The following servers are available for this API:";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly client: {
|
|
33
|
+
readonly section: {
|
|
34
|
+
readonly singular: "Official API Client";
|
|
35
|
+
readonly plural: "Official API Clients";
|
|
36
|
+
};
|
|
37
|
+
readonly sdk: {
|
|
38
|
+
readonly singular: "SDK";
|
|
39
|
+
readonly plural: "SDKs";
|
|
40
|
+
};
|
|
41
|
+
readonly language: {
|
|
42
|
+
readonly singular: "a programming language";
|
|
43
|
+
readonly plural: "multiple programming languages";
|
|
44
|
+
};
|
|
45
|
+
readonly recommendation: {
|
|
46
|
+
readonly singular: "this client";
|
|
47
|
+
readonly plural: "these clients";
|
|
48
|
+
};
|
|
49
|
+
readonly location: {
|
|
50
|
+
readonly singular: "it";
|
|
51
|
+
readonly plural: "them";
|
|
52
|
+
};
|
|
53
|
+
readonly intro: {
|
|
54
|
+
readonly template: (apiTitle: string, count: number, sdks: string, languages: string, recommendation: string, location: string) => string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Common pronouns and determiners based on count
|
|
60
|
+
*/
|
|
61
|
+
export declare const pronouns: {
|
|
62
|
+
readonly pronoun: (count: number) => "it" | "them";
|
|
63
|
+
readonly determiner: (count: number) => "this" | "these";
|
|
64
|
+
readonly article: (count: number) => "" | "a";
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Get the appropriate text based on count (singular/plural)
|
|
68
|
+
*/
|
|
69
|
+
export declare function getTextByCount<T extends Record<'singular' | 'plural', string>>(count: number, textOptions: T): string;
|
|
70
|
+
/**
|
|
71
|
+
* Automatically pluralize a word based on count using the pluralize library
|
|
72
|
+
*/
|
|
73
|
+
export declare function pluralizeWord(word: string, count: number): string;
|
|
74
|
+
/**
|
|
75
|
+
* Helper function to get common text variations based on count
|
|
76
|
+
*/
|
|
77
|
+
export declare function getCommonText(count: number): {
|
|
78
|
+
pronoun: string;
|
|
79
|
+
determiner: string;
|
|
80
|
+
article: string;
|
|
81
|
+
isAre: string;
|
|
82
|
+
hasHave: string;
|
|
83
|
+
};
|
|
84
|
+
export declare function getAuthIntroText(count: number): string;
|
|
85
|
+
export declare function getClientIntroText(apiTitle: string, count: number): string;
|
|
86
|
+
//# sourceMappingURL=doc-text-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-text-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/doc-text-utils.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;uCAgBR,MAAM,WACJ,MAAM,WACN,MAAM,WACN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0CAsCL,MAAM,SACT,MAAM,QACP,MAAM,aACD,MAAM,kBACD,MAAM,YACZ,MAAM;;;CAKd,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,QAAQ;8BACF,MAAM;iCACH,MAAM;8BACT,MAAM;CACf,CAAC;AAEX;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,UAAU,GAAG,QAAQ,EAAE,MAAM,CAAC,EAC5E,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,CAAC,GACb,MAAM,CAER;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM;;;;;;EAQ1C;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAiB1E"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import pluralize from "pluralize";
|
|
2
|
+
const presetDocs = {
|
|
3
|
+
auth: {
|
|
4
|
+
section: {
|
|
5
|
+
singular: "Available Authentication Method",
|
|
6
|
+
plural: "Available Authentication Methods"
|
|
7
|
+
},
|
|
8
|
+
description: {
|
|
9
|
+
singular: "an authentication method",
|
|
10
|
+
plural: "various authentication methods"
|
|
11
|
+
},
|
|
12
|
+
scheme: {
|
|
13
|
+
singular: "the available authentication scheme",
|
|
14
|
+
plural: "each available authentication scheme"
|
|
15
|
+
},
|
|
16
|
+
intro: {
|
|
17
|
+
template: (count, methods, schemes, pronoun) => `This API provides secure access through ${methods}. Below you'll find details about ${schemes} and how to use ${pronoun}.`
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
server: {
|
|
21
|
+
section: {
|
|
22
|
+
singular: "API Server",
|
|
23
|
+
plural: "API Servers"
|
|
24
|
+
},
|
|
25
|
+
description: {
|
|
26
|
+
singular: "The following server is available for this API:",
|
|
27
|
+
plural: "The following servers are available for this API:"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
client: {
|
|
31
|
+
section: {
|
|
32
|
+
singular: "Official API Client",
|
|
33
|
+
plural: "Official API Clients"
|
|
34
|
+
},
|
|
35
|
+
sdk: {
|
|
36
|
+
singular: "SDK",
|
|
37
|
+
plural: "SDKs"
|
|
38
|
+
},
|
|
39
|
+
language: {
|
|
40
|
+
singular: "a programming language",
|
|
41
|
+
plural: "multiple programming languages"
|
|
42
|
+
},
|
|
43
|
+
recommendation: {
|
|
44
|
+
singular: "this client",
|
|
45
|
+
plural: "these clients"
|
|
46
|
+
},
|
|
47
|
+
location: {
|
|
48
|
+
singular: "it",
|
|
49
|
+
plural: "them"
|
|
50
|
+
},
|
|
51
|
+
intro: {
|
|
52
|
+
template: (apiTitle, count, sdks, languages, recommendation, location) => `${apiTitle} provides official client ${sdks} for ${languages}. We recommend using ${recommendation} to interact with all stable endpoints. You can find ${location} here:`
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const pronouns = {
|
|
57
|
+
pronoun: (count) => count === 1 ? "it" : "them",
|
|
58
|
+
determiner: (count) => count === 1 ? "this" : "these",
|
|
59
|
+
article: (count) => count === 1 ? "a" : ""
|
|
60
|
+
};
|
|
61
|
+
function getTextByCount(count, textOptions) {
|
|
62
|
+
return count === 1 ? textOptions.singular : textOptions.plural;
|
|
63
|
+
}
|
|
64
|
+
function pluralizeWord(word, count) {
|
|
65
|
+
return pluralize(word, count);
|
|
66
|
+
}
|
|
67
|
+
function getCommonText(count) {
|
|
68
|
+
return {
|
|
69
|
+
pronoun: pronouns.pronoun(count),
|
|
70
|
+
determiner: pronouns.determiner(count),
|
|
71
|
+
article: pronouns.article(count),
|
|
72
|
+
isAre: count === 1 ? "is" : "are",
|
|
73
|
+
hasHave: count === 1 ? "has" : "have"
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function getAuthIntroText(count) {
|
|
77
|
+
const methods = getTextByCount(count, presetDocs.auth.description);
|
|
78
|
+
const schemes = getTextByCount(count, presetDocs.auth.scheme);
|
|
79
|
+
const pronoun = pronouns.pronoun(count);
|
|
80
|
+
return presetDocs.auth.intro.template(count, methods, schemes, pronoun);
|
|
81
|
+
}
|
|
82
|
+
function getClientIntroText(apiTitle, count) {
|
|
83
|
+
const sdks = getTextByCount(count, presetDocs.client.sdk);
|
|
84
|
+
const languages = getTextByCount(count, presetDocs.client.language);
|
|
85
|
+
const recommendation = getTextByCount(
|
|
86
|
+
count,
|
|
87
|
+
presetDocs.client.recommendation
|
|
88
|
+
);
|
|
89
|
+
const location = getTextByCount(count, presetDocs.client.location);
|
|
90
|
+
return presetDocs.client.intro.template(
|
|
91
|
+
apiTitle,
|
|
92
|
+
count,
|
|
93
|
+
sdks,
|
|
94
|
+
languages,
|
|
95
|
+
recommendation,
|
|
96
|
+
location
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
getAuthIntroText,
|
|
101
|
+
getClientIntroText,
|
|
102
|
+
getCommonText,
|
|
103
|
+
getTextByCount,
|
|
104
|
+
pluralizeWord,
|
|
105
|
+
presetDocs,
|
|
106
|
+
pronouns
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=doc-text-utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/overview-docs/doc-text-utils.ts"],
|
|
4
|
+
"sourcesContent": ["import pluralize from 'pluralize';\n\n/**\n * Preset documentation text templates for consistent singular/plural handling\n */\nexport const presetDocs = {\n auth: {\n section: {\n singular: 'Available Authentication Method',\n plural: 'Available Authentication Methods',\n },\n description: {\n singular: 'an authentication method',\n plural: 'various authentication methods',\n },\n scheme: {\n singular: 'the available authentication scheme',\n plural: 'each available authentication scheme',\n },\n intro: {\n template: (\n count: number,\n methods: string,\n schemes: string,\n pronoun: string,\n ) =>\n `This API provides secure access through ${methods}. Below you'll find details about ${schemes} and how to use ${pronoun}.`,\n },\n },\n server: {\n section: {\n singular: 'API Server',\n plural: 'API Servers',\n },\n description: {\n singular: 'The following server is available for this API:',\n plural: 'The following servers are available for this API:',\n },\n },\n client: {\n section: {\n singular: 'Official API Client',\n plural: 'Official API Clients',\n },\n sdk: {\n singular: 'SDK',\n plural: 'SDKs',\n },\n language: {\n singular: 'a programming language',\n plural: 'multiple programming languages',\n },\n recommendation: {\n singular: 'this client',\n plural: 'these clients',\n },\n location: {\n singular: 'it',\n plural: 'them',\n },\n intro: {\n template: (\n apiTitle: string,\n count: number,\n sdks: string,\n languages: string,\n recommendation: string,\n location: string,\n ) =>\n `${apiTitle} provides official client ${sdks} for ${languages}. We recommend using ${recommendation} to interact with all stable endpoints. You can find ${location} here:`,\n },\n },\n} as const;\n\n/**\n * Common pronouns and determiners based on count\n */\nexport const pronouns = {\n pronoun: (count: number) => (count === 1 ? 'it' : 'them'),\n determiner: (count: number) => (count === 1 ? 'this' : 'these'),\n article: (count: number) => (count === 1 ? 'a' : ''),\n} as const;\n\n/**\n * Get the appropriate text based on count (singular/plural)\n */\nexport function getTextByCount<T extends Record<'singular' | 'plural', string>>(\n count: number,\n textOptions: T,\n): string {\n return count === 1 ? textOptions.singular : textOptions.plural;\n}\n\n/**\n * Automatically pluralize a word based on count using the pluralize library\n */\nexport function pluralizeWord(word: string, count: number): string {\n return pluralize(word, count);\n}\n\n/**\n * Helper function to get common text variations based on count\n */\nexport function getCommonText(count: number) {\n return {\n pronoun: pronouns.pronoun(count),\n determiner: pronouns.determiner(count),\n article: pronouns.article(count),\n isAre: count === 1 ? 'is' : 'are',\n hasHave: count === 1 ? 'has' : 'have',\n };\n}\n\nexport function getAuthIntroText(count: number): string {\n const methods = getTextByCount(count, presetDocs.auth.description);\n const schemes = getTextByCount(count, presetDocs.auth.scheme);\n const pronoun = pronouns.pronoun(count);\n\n return presetDocs.auth.intro.template(count, methods, schemes, pronoun);\n}\n\nexport function getClientIntroText(apiTitle: string, count: number): string {\n const sdks = getTextByCount(count, presetDocs.client.sdk);\n const languages = getTextByCount(count, presetDocs.client.language);\n const recommendation = getTextByCount(\n count,\n presetDocs.client.recommendation,\n );\n const location = getTextByCount(count, presetDocs.client.location);\n\n return presetDocs.client.intro.template(\n apiTitle,\n count,\n sdks,\n languages,\n recommendation,\n location,\n );\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,eAAe;AAKf,MAAM,aAAa;AAAA,EACxB,MAAM;AAAA,IACJ,SAAS;AAAA,MACP,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,aAAa;AAAA,MACX,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,QAAQ;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,OAAO;AAAA,MACL,UAAU,CACR,OACA,SACA,SACA,YAEA,2CAA2C,OAAO,qCAAqC,OAAO,mBAAmB,OAAO;AAAA,IAC5H;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AS,iBAAiB,OAAuB;AACtD,QAAM,UAAU,eAAe,OAAO,WAAW,KAAK,WAAW;AACjE,QAAM,UAAU,eAAe,OAAO,WAAW,KAAK,MAAM;AAC5D,QAAM,UAAU,SAAS,QAAQ,KAAK;AAEtC,SAAO,WAAW,KAAK,MAAM,SAAS,OAAO,SAAS,SAAS,OAAO;AACxE;AAEO,SAAS,mBAAmB,UAAkB,OAAuB;AAC1E,QAAM,OAAO,eAAe,OAAO,WAAW,OAAO,GAAG;AACxD,QAAM,YAAY,eAAe,OAAO,WAAW,OAAO,QAAQ;AAClE,QAAM,iBAAiB;AAAA,IACrB;AAAA,IACA,WAAW,OAAO;AAAA,EACpB;AACA,QAAM,WAAW,eAAe,OAAO,WAAW,OAAO,QAAQ;AAEjE,SAAO,WAAW,OAAO,MAAM;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview-auth.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-auth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"overview-auth.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-auth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA2FpD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAmDpE"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { resolveRef } from "@sdk-it/core";
|
|
2
|
+
import {
|
|
3
|
+
getAuthIntroText,
|
|
4
|
+
getTextByCount,
|
|
5
|
+
presetDocs
|
|
6
|
+
} from "./doc-text-utils.js";
|
|
2
7
|
function getSecuritySchemeDescription(scheme) {
|
|
3
8
|
switch (scheme.type) {
|
|
4
9
|
case "apiKey": {
|
|
@@ -77,85 +82,62 @@ function getFlowDisplayName(flowType) {
|
|
|
77
82
|
};
|
|
78
83
|
return flowNames[flowType] || flowType;
|
|
79
84
|
}
|
|
80
|
-
function formatSecurityRequirements(requirements) {
|
|
81
|
-
if (!requirements || requirements.length === 0) return "";
|
|
82
|
-
let result = "";
|
|
83
|
-
requirements.forEach((req, index) => {
|
|
84
|
-
const schemes = Object.entries(req);
|
|
85
|
-
if (schemes.length === 0) {
|
|
86
|
-
result += `${index + 1}. No authentication required
|
|
87
|
-
`;
|
|
88
|
-
} else {
|
|
89
|
-
result += `${index + 1}. Requires: `;
|
|
90
|
-
const schemeDescriptions = schemes.map(([scheme, scopes]) => {
|
|
91
|
-
const scopeArray = scopes;
|
|
92
|
-
if (scopeArray && scopeArray.length > 0) {
|
|
93
|
-
return `\`${scheme}\` with scopes: ${scopeArray.map((s) => `\`${s}\``).join(", ")}`;
|
|
94
|
-
}
|
|
95
|
-
return `\`${scheme}\``;
|
|
96
|
-
});
|
|
97
|
-
result += schemeDescriptions.join(" AND ") + "\n";
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
return result;
|
|
101
|
-
}
|
|
102
85
|
function generateAuthOverview(spec) {
|
|
103
|
-
let markdown = `#
|
|
86
|
+
let markdown = `# Authentication
|
|
104
87
|
|
|
105
88
|
`;
|
|
106
|
-
const securitySchemes = spec.components
|
|
89
|
+
const securitySchemes = spec.components.securitySchemes;
|
|
107
90
|
const globalSecurity = spec.security || [];
|
|
108
|
-
|
|
91
|
+
const authMethodCount = Object.keys(securitySchemes).length;
|
|
92
|
+
if (!authMethodCount && !globalSecurity.length) {
|
|
109
93
|
markdown += `This API does not require authentication.
|
|
110
94
|
|
|
111
95
|
`;
|
|
112
96
|
} else {
|
|
113
|
-
|
|
97
|
+
if (authMethodCount > 1) {
|
|
98
|
+
markdown += `${getAuthIntroText(authMethodCount)}
|
|
114
99
|
|
|
115
100
|
`;
|
|
116
|
-
|
|
117
|
-
markdown += `## Available Authentication Methods
|
|
101
|
+
markdown += `## ${getTextByCount(authMethodCount, presetDocs.auth.section)}
|
|
118
102
|
|
|
119
103
|
`;
|
|
120
|
-
|
|
121
|
-
|
|
104
|
+
}
|
|
105
|
+
for (const [name, scheme] of Object.entries(securitySchemes)) {
|
|
106
|
+
const schemeObj = resolveRef(spec, scheme);
|
|
107
|
+
if (authMethodCount > 1) {
|
|
122
108
|
markdown += `### ${name}
|
|
123
109
|
|
|
124
110
|
`;
|
|
125
|
-
|
|
126
|
-
|
|
111
|
+
}
|
|
112
|
+
const description = schemeObj.description || getSecuritySchemeDescription(schemeObj);
|
|
113
|
+
markdown += `${description}
|
|
127
114
|
|
|
128
115
|
`;
|
|
129
|
-
|
|
130
|
-
|
|
116
|
+
if (schemeObj.type === "apiKey") {
|
|
117
|
+
markdown += `**Details:**
|
|
131
118
|
`;
|
|
132
|
-
|
|
119
|
+
markdown += `- Parameter Name: \`${schemeObj.name}\`
|
|
133
120
|
`;
|
|
134
|
-
|
|
121
|
+
markdown += `- Location: ${schemeObj.in === "header" ? "HTTP Header" : schemeObj.in === "query" ? "Query Parameter" : "Cookie"}
|
|
135
122
|
|
|
136
123
|
`;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
markdown += `- Scheme: \`${schemeObj.scheme}\`
|
|
124
|
+
} else if (schemeObj.type === "http") {
|
|
125
|
+
if (schemeObj.bearerFormat) {
|
|
126
|
+
markdown += `- Token Format: \`${schemeObj.bearerFormat}\`
|
|
141
127
|
`;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
markdown += "\n";
|
|
147
|
-
} else if (schemeObj.type === "oauth2" && schemeObj.flows) {
|
|
148
|
-
markdown += `**OAuth 2.0 Flows:**
|
|
128
|
+
}
|
|
129
|
+
markdown += "\n";
|
|
130
|
+
} else if (schemeObj.type === "oauth2" && schemeObj.flows) {
|
|
131
|
+
markdown += `**OAuth 2.0 Flows:**
|
|
149
132
|
|
|
150
133
|
`;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
134
|
+
markdown += formatOAuth2Flows(schemeObj.flows);
|
|
135
|
+
} else if (schemeObj.type === "openIdConnect") {
|
|
136
|
+
markdown += `**Details:**
|
|
154
137
|
`;
|
|
155
|
-
|
|
138
|
+
markdown += `- Discovery URL: \`${schemeObj.openIdConnectUrl}\`
|
|
156
139
|
|
|
157
140
|
`;
|
|
158
|
-
}
|
|
159
141
|
}
|
|
160
142
|
}
|
|
161
143
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/overview-docs/overview-auth.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OAuthFlowsObject, SecuritySchemeObject } from 'openapi3-ts/oas31';\n\nimport { resolveRef } from '@sdk-it/core';\n\nimport type { NavItem } from '../sidebar.js';\nimport type { OurOpenAPIObject } from '../types.js';\n\nfunction getSecuritySchemeDescription(scheme: SecuritySchemeObject): string {\n switch (scheme.type) {\n case 'apiKey': {\n const location =\n scheme.in === 'header'\n ? 'HTTP header'\n : scheme.in === 'query'\n ? 'query parameter'\n : 'cookie';\n return `API Key authentication requires you to provide an API key in the ${location} named \\`${scheme.name}\\`.`;\n }\n case 'http':\n if (scheme.scheme === 'bearer') {\n const format = scheme.bearerFormat\n ? ` The expected token format is \\`${scheme.bearerFormat}\\`.`\n : '';\n return `Bearer token authentication requires you to include a bearer token in the \\`Authorization\\` header of your requests.${format}`;\n }\n if (scheme.scheme === 'basic') {\n return `Basic authentication requires you to provide a username and password, encoded in base64 format in the \\`Authorization\\` header.`;\n }\n return `HTTP ${scheme.scheme} authentication is required for accessing this API.`;\n case 'oauth2': {\n const flows = Object.keys(scheme.flows || {});\n const flowDescriptions = flows.map((flow) => {\n switch (flow) {\n case 'authorizationCode':\n return 'Authorization Code (for server-side applications)';\n case 'implicit':\n return 'Implicit (for browser-based applications)';\n case 'password':\n return 'Resource Owner Password Credentials';\n case 'clientCredentials':\n return 'Client Credentials (for machine-to-machine authentication)';\n default:\n return flow;\n }\n });\n return `OAuth 2.0 authentication is supported with the following grant type(s): ${flowDescriptions.join(', ')}.`;\n }\n case 'openIdConnect':\n return `OpenID Connect authentication is used for this API. You will need to authenticate through the OpenID provider to obtain access tokens.`;\n default:\n return 'This API uses a custom authentication scheme. Please refer to the API documentation for specific details.';\n }\n}\n\nfunction formatOAuth2Flows(flows: OAuthFlowsObject): string {\n let result = '';\n\n for (const [flowType, flow] of Object.entries(flows || {})) {\n result += `#### ${getFlowDisplayName(flowType)}\\n\\n`;\n\n if (flow.authorizationUrl) {\n result += `- **Authorization URL:** \\`${flow.authorizationUrl}\\`\\n`;\n }\n if (flow.tokenUrl) {\n result += `- **Token URL:** \\`${flow.tokenUrl}\\`\\n`;\n }\n if (flow.refreshUrl) {\n result += `- **Refresh URL:** \\`${flow.refreshUrl}\\`\\n`;\n }\n if (flow.scopes && Object.keys(flow.scopes).length > 0) {\n result += `- **Available Scopes:**\\n`;\n for (const [scope, description] of Object.entries(flow.scopes)) {\n result += ` - \\`${scope}\\`: ${description}\\n`;\n }\n }\n result += '\\n';\n }\n\n return result;\n}\n\nfunction getFlowDisplayName(flowType: string): string {\n const flowNames: Record<string, string> = {\n authorizationCode: 'Authorization Code Flow',\n implicit: 'Implicit Flow',\n password: 'Resource Owner Password Flow',\n clientCredentials: 'Client Credentials Flow',\n };\n return flowNames[flowType] || flowType;\n}\n\
|
|
5
|
-
"mappings": "AAEA,SAAS,kBAAkB;
|
|
4
|
+
"sourcesContent": ["import type { OAuthFlowsObject, SecuritySchemeObject } from 'openapi3-ts/oas31';\n\nimport { resolveRef } from '@sdk-it/core';\n\nimport type { NavItem } from '../sidebar.js';\nimport type { OurOpenAPIObject } from '../types.js';\nimport {\n getAuthIntroText,\n getTextByCount,\n presetDocs,\n} from './doc-text-utils.js';\n\nfunction getSecuritySchemeDescription(scheme: SecuritySchemeObject): string {\n switch (scheme.type) {\n case 'apiKey': {\n const location =\n scheme.in === 'header'\n ? 'HTTP header'\n : scheme.in === 'query'\n ? 'query parameter'\n : 'cookie';\n return `API Key authentication requires you to provide an API key in the ${location} named \\`${scheme.name}\\`.`;\n }\n case 'http':\n if (scheme.scheme === 'bearer') {\n const format = scheme.bearerFormat\n ? ` The expected token format is \\`${scheme.bearerFormat}\\`.`\n : '';\n return `Bearer token authentication requires you to include a bearer token in the \\`Authorization\\` header of your requests.${format}`;\n }\n if (scheme.scheme === 'basic') {\n return `Basic authentication requires you to provide a username and password, encoded in base64 format in the \\`Authorization\\` header.`;\n }\n return `HTTP ${scheme.scheme} authentication is required for accessing this API.`;\n case 'oauth2': {\n const flows = Object.keys(scheme.flows || {});\n const flowDescriptions = flows.map((flow) => {\n switch (flow) {\n case 'authorizationCode':\n return 'Authorization Code (for server-side applications)';\n case 'implicit':\n return 'Implicit (for browser-based applications)';\n case 'password':\n return 'Resource Owner Password Credentials';\n case 'clientCredentials':\n return 'Client Credentials (for machine-to-machine authentication)';\n default:\n return flow;\n }\n });\n return `OAuth 2.0 authentication is supported with the following grant type(s): ${flowDescriptions.join(', ')}.`;\n }\n case 'openIdConnect':\n return `OpenID Connect authentication is used for this API. You will need to authenticate through the OpenID provider to obtain access tokens.`;\n default:\n return 'This API uses a custom authentication scheme. Please refer to the API documentation for specific details.';\n }\n}\n\nfunction formatOAuth2Flows(flows: OAuthFlowsObject): string {\n let result = '';\n\n for (const [flowType, flow] of Object.entries(flows || {})) {\n result += `#### ${getFlowDisplayName(flowType)}\\n\\n`;\n\n if (flow.authorizationUrl) {\n result += `- **Authorization URL:** \\`${flow.authorizationUrl}\\`\\n`;\n }\n if (flow.tokenUrl) {\n result += `- **Token URL:** \\`${flow.tokenUrl}\\`\\n`;\n }\n if (flow.refreshUrl) {\n result += `- **Refresh URL:** \\`${flow.refreshUrl}\\`\\n`;\n }\n if (flow.scopes && Object.keys(flow.scopes).length > 0) {\n result += `- **Available Scopes:**\\n`;\n for (const [scope, description] of Object.entries(flow.scopes)) {\n result += ` - \\`${scope}\\`: ${description}\\n`;\n }\n }\n result += '\\n';\n }\n\n return result;\n}\n\nfunction getFlowDisplayName(flowType: string): string {\n const flowNames: Record<string, string> = {\n authorizationCode: 'Authorization Code Flow',\n implicit: 'Implicit Flow',\n password: 'Resource Owner Password Flow',\n clientCredentials: 'Client Credentials Flow',\n };\n return flowNames[flowType] || flowType;\n}\n\nexport function generateAuthOverview(spec: OurOpenAPIObject): NavItem {\n let markdown = `# Authentication\\n\\n`;\n\n const securitySchemes = spec.components.securitySchemes;\n const globalSecurity = spec.security || [];\n\n const authMethodCount = Object.keys(securitySchemes).length;\n if (!authMethodCount && !globalSecurity.length) {\n markdown += `This API does not require authentication.\\n\\n`;\n } else {\n if (authMethodCount > 1) {\n markdown += `${getAuthIntroText(authMethodCount)}\\n\\n`;\n markdown += `## ${getTextByCount(authMethodCount, presetDocs.auth.section)}\\n\\n`;\n }\n\n for (const [name, scheme] of Object.entries(securitySchemes)) {\n const schemeObj = resolveRef<SecuritySchemeObject>(spec, scheme);\n if (authMethodCount > 1) {\n markdown += `### ${name}\\n\\n`;\n }\n\n const description =\n schemeObj.description || getSecuritySchemeDescription(schemeObj);\n markdown += `${description}\\n\\n`;\n\n if (schemeObj.type === 'apiKey') {\n markdown += `**Details:**\\n`;\n markdown += `- Parameter Name: \\`${schemeObj.name}\\`\\n`;\n markdown += `- Location: ${schemeObj.in === 'header' ? 'HTTP Header' : schemeObj.in === 'query' ? 'Query Parameter' : 'Cookie'}\\n\\n`;\n } else if (schemeObj.type === 'http') {\n if (schemeObj.bearerFormat) {\n markdown += `- Token Format: \\`${schemeObj.bearerFormat}\\`\\n`;\n }\n markdown += '\\n';\n } else if (schemeObj.type === 'oauth2' && schemeObj.flows) {\n markdown += `**OAuth 2.0 Flows:**\\n\\n`;\n markdown += formatOAuth2Flows(schemeObj.flows);\n } else if (schemeObj.type === 'openIdConnect') {\n markdown += `**Details:**\\n`;\n markdown += `- Discovery URL: \\`${schemeObj.openIdConnectUrl}\\`\\n\\n`;\n }\n }\n }\n\n return {\n id: 'authorization',\n url: '/authorization',\n title: 'Authorization',\n description: 'Authentication methods and security schemes',\n content: markdown,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,kBAAkB;AAI3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,6BAA6B,QAAsC;AAC1E,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,UAAU;AACb,YAAM,WACJ,OAAO,OAAO,WACV,gBACA,OAAO,OAAO,UACZ,oBACA;AACR,aAAO,oEAAoE,QAAQ,YAAY,OAAO,IAAI;AAAA,IAC5G;AAAA,IACA,KAAK;AACH,UAAI,OAAO,WAAW,UAAU;AAC9B,cAAM,SAAS,OAAO,eAClB,mCAAmC,OAAO,YAAY,QACtD;AACJ,eAAO,uHAAuH,MAAM;AAAA,MACtI;AACA,UAAI,OAAO,WAAW,SAAS;AAC7B,eAAO;AAAA,MACT;AACA,aAAO,QAAQ,OAAO,MAAM;AAAA,IAC9B,KAAK,UAAU;AACb,YAAM,QAAQ,OAAO,KAAK,OAAO,SAAS,CAAC,CAAC;AAC5C,YAAM,mBAAmB,MAAM,IAAI,CAAC,SAAS;AAC3C,gBAAQ,MAAM;AAAA,UACZ,KAAK;AACH,mBAAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT;AACE,mBAAO;AAAA,QACX;AAAA,MACF,CAAC;AACD,aAAO,2EAA2E,iBAAiB,KAAK,IAAI,CAAC;AAAA,IAC/G;AAAA,IACA,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EAC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|
|
1
|
+
{"version":3,"file":"overview-errors.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-errors.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAsGpD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAwEtE"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { distillRef } from "@sdk-it/core";
|
|
2
2
|
import { forEachOperation } from "../for-each-operation.js";
|
|
3
3
|
import { isErrorStatusCode } from "../is.js";
|
|
4
|
-
function resolveSchema(spec, schema) {
|
|
5
|
-
return resolveRef(spec, schema);
|
|
6
|
-
}
|
|
7
4
|
function formatSchemaForDisplay(spec, schema) {
|
|
8
|
-
const resolvedSchema =
|
|
5
|
+
const resolvedSchema = distillRef(spec, schema);
|
|
9
6
|
return `\`\`\`json
|
|
10
7
|
${JSON.stringify(resolvedSchema, null, 2)}
|
|
11
8
|
\`\`\``;
|
|
@@ -62,10 +59,6 @@ function generateErrorsOverview(spec) {
|
|
|
62
59
|
markdown.push(
|
|
63
60
|
`This API uses conventional HTTP response codes to indicate the success or failure of an API request.`
|
|
64
61
|
);
|
|
65
|
-
markdown.push(`## Official API Clients`);
|
|
66
|
-
markdown.push(
|
|
67
|
-
`Vellum maintains official API clients for Python, Node/Typescript, and Go. We recommend using these clients to interact with all stable endpoints. You can find them here:`
|
|
68
|
-
);
|
|
69
62
|
markdown.push(`## HTTP Status Codes`);
|
|
70
63
|
forEachOperation(spec, (entry, operation) => {
|
|
71
64
|
if (operation.responses) {
|
|
@@ -76,20 +69,19 @@ function generateErrorsOverview(spec) {
|
|
|
76
69
|
const content = response.content;
|
|
77
70
|
if (content?.["application/json"]?.schema) {
|
|
78
71
|
const key = `${statusCode}`;
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
if (errorSchemas.has(key)) {
|
|
73
|
+
const existing = errorSchemas.get(key);
|
|
74
|
+
if (existing && !existing.operations.includes(operation.operationId)) {
|
|
75
|
+
existing.operations.push(operation.operationId);
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
81
78
|
errorSchemas.set(key, {
|
|
82
79
|
statusCode,
|
|
83
80
|
title: response.description || `${statusCode} Error`,
|
|
84
81
|
description: response.description,
|
|
85
82
|
schema: content["application/json"].schema,
|
|
86
|
-
operations: [operationId]
|
|
83
|
+
operations: [operation.operationId]
|
|
87
84
|
});
|
|
88
|
-
} else {
|
|
89
|
-
const existing = errorSchemas.get(key);
|
|
90
|
-
if (existing && !existing.operations.includes(operationId)) {
|
|
91
|
-
existing.operations.push(operationId);
|
|
92
|
-
}
|
|
93
85
|
}
|
|
94
86
|
}
|
|
95
87
|
}
|
|
@@ -106,17 +98,8 @@ function generateErrorsOverview(spec) {
|
|
|
106
98
|
} else {
|
|
107
99
|
for (const error of errors) {
|
|
108
100
|
markdown.push(`### ${error.statusCode} - ${error.title}`);
|
|
109
|
-
const description = error.description || getStatusDescription(error.statusCode);
|
|
110
|
-
|
|
111
|
-
markdown.push(description);
|
|
112
|
-
}
|
|
113
|
-
if (error.operations.length > 0) {
|
|
114
|
-
const operationsList = [`**Used by operations:**`];
|
|
115
|
-
for (const operation of error.operations) {
|
|
116
|
-
operationsList.push(`- \`${operation}\``);
|
|
117
|
-
}
|
|
118
|
-
markdown.push(operationsList.join("\n"));
|
|
119
|
-
}
|
|
101
|
+
const description = error.description || getStatusDescription(error.statusCode) || "";
|
|
102
|
+
markdown.push(description);
|
|
120
103
|
if (error.schema) {
|
|
121
104
|
markdown.push(`**Response Schema:**`);
|
|
122
105
|
markdown.push(formatSchemaForDisplay(spec, error.schema));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/overview-docs/overview-errors.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport {
|
|
5
|
-
"mappings": "AAEA,SAAS,kBAAkB;AAE3B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAYlC,SAAS,
|
|
4
|
+
"sourcesContent": ["import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport { distillRef } from '@sdk-it/core';\n\nimport { forEachOperation } from '../for-each-operation.js';\nimport { isErrorStatusCode } from '../is.js';\nimport type { NavItem } from '../sidebar.js';\nimport type { OurOpenAPIObject } from '../types.js';\n\ninterface ErrorSchema {\n statusCode: string;\n title: string;\n description?: string;\n schema: SchemaObject | ReferenceObject;\n operations: string[]; // Track which operations use this error\n}\n\nfunction formatSchemaForDisplay(\n spec: OurOpenAPIObject,\n schema: SchemaObject | ReferenceObject,\n): string {\n const resolvedSchema = distillRef(spec, schema);\n\n return `\\`\\`\\`json\n${JSON.stringify(resolvedSchema, null, 2)}\n\\`\\`\\``;\n}\n\nfunction getStatusDescription(statusCode: string): string {\n const descriptions: Record<string, string> = {\n '400': 'Bad Request - The request was invalid or cannot be served.',\n '401':\n 'Unauthorized - Authentication is required and has failed or has not been provided.',\n '402': 'Payment Required - Payment is required to access this resource.',\n '403':\n 'Forbidden - The request was valid, but the server is refusing action.',\n '404': 'Not Found - The requested resource could not be found.',\n '405':\n 'Method Not Allowed - The request method is not supported for this resource.',\n '406':\n 'Not Acceptable - The requested resource cannot generate content acceptable to the client.',\n '407':\n 'Proxy Authentication Required - Authentication with the proxy is required.',\n '408': 'Request Timeout - The server timed out waiting for the request.',\n '409': 'Conflict - The request could not be completed due to a conflict.',\n '410': 'Gone - The requested resource is no longer available.',\n '411':\n 'Length Required - The request did not specify the length of its content.',\n '412':\n 'Precondition Failed - The server does not meet one of the preconditions.',\n '413':\n 'Payload Too Large - The request is larger than the server is willing to process.',\n '414':\n 'URI Too Long - The URI provided was too long for the server to process.',\n '415':\n 'Unsupported Media Type - The request entity has a media type which the server does not support.',\n '416':\n 'Range Not Satisfiable - The client has asked for a portion of the file that the server cannot supply.',\n '417':\n 'Expectation Failed - The server cannot meet the requirements of the Expect request-header field.',\n '418':\n \"I'm a teapot - The server refuses the attempt to brew coffee with a teapot.\",\n '421':\n 'Misdirected Request - The request was directed at a server that is not able to produce a response.',\n '422':\n 'Unprocessable Entity - The request was well-formed but contains semantic errors.',\n '423': 'Locked - The resource that is being accessed is locked.',\n '424':\n 'Failed Dependency - The request failed due to failure of a previous request.',\n '425':\n 'Too Early - The server is unwilling to risk processing a request that might be replayed.',\n '426':\n 'Upgrade Required - The client should switch to a different protocol.',\n '428':\n 'Precondition Required - The origin server requires the request to be conditional.',\n '429':\n 'Too Many Requests - The user has sent too many requests in a given amount of time.',\n '431':\n 'Request Header Fields Too Large - The server is unwilling to process the request because header fields are too large.',\n '451':\n 'Unavailable For Legal Reasons - The server is denying access to the resource for legal reasons.',\n '500':\n 'Internal Server Error - The server encountered an unexpected condition.',\n '501':\n 'Not Implemented - The server does not support the functionality required to fulfill the request.',\n '502':\n 'Bad Gateway - The server received an invalid response from the upstream server.',\n '503': 'Service Unavailable - The server is currently unavailable.',\n '504':\n 'Gateway Timeout - The server did not receive a timely response from the upstream server.',\n '505':\n 'HTTP Version Not Supported - The server does not support the HTTP protocol version used in the request.',\n '506':\n 'Variant Also Negotiates - The server has an internal configuration error.',\n '507':\n 'Insufficient Storage - The server is unable to store the representation needed to complete the request.',\n '508':\n 'Loop Detected - The server detected an infinite loop while processing the request.',\n '510':\n 'Not Extended - Further extensions to the request are required for the server to fulfill it.',\n '511':\n 'Network Authentication Required - The client needs to authenticate to gain network access.',\n };\n return (\n descriptions[statusCode] ||\n 'An error occurred while processing the request.'\n );\n}\n\nexport function generateErrorsOverview(spec: OurOpenAPIObject): NavItem {\n const errorSchemas: Map<string, ErrorSchema> = new Map();\n const markdown: string[] = [];\n markdown.push(`# Error Handling`);\n markdown.push(\n `This API uses conventional HTTP response codes to indicate the success or failure of an API request.`,\n );\n\n markdown.push(`## HTTP Status Codes`);\n\n // First, collect all error schemas from operations\n forEachOperation(spec, (entry, operation) => {\n if (operation.responses) {\n for (const [statusCode, response] of Object.entries(\n operation.responses,\n )) {\n if (isErrorStatusCode(statusCode)) {\n const content = response.content;\n if (content?.['application/json']?.schema) {\n const key = `${statusCode}`;\n if (errorSchemas.has(key)) {\n const existing = errorSchemas.get(key);\n if (\n existing &&\n !existing.operations.includes(operation.operationId)\n ) {\n existing.operations.push(operation.operationId);\n }\n } else {\n errorSchemas.set(key, {\n statusCode,\n title: response.description || `${statusCode} Error`,\n description: response.description,\n schema: content['application/json'].schema,\n operations: [operation.operationId],\n });\n }\n }\n }\n }\n }\n });\n\n const errors = Array.from(errorSchemas.values()).sort(\n (a, b) => parseInt(a.statusCode) - parseInt(b.statusCode),\n );\n\n if (errors.length === 0) {\n markdown.push(\n `No error responses are documented in this API specification.`,\n );\n } else {\n for (const error of errors) {\n markdown.push(`### ${error.statusCode} - ${error.title}`);\n const description =\n error.description || getStatusDescription(error.statusCode) || '';\n markdown.push(description);\n\n if (error.schema) {\n markdown.push(`**Response Schema:**`);\n markdown.push(formatSchemaForDisplay(spec, error.schema));\n }\n }\n }\n\n return {\n id: 'errors',\n title: 'Errors',\n url: '/errors',\n description: 'Error handling and HTTP status codes',\n content: markdown.join('\\n\\n'),\n };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,kBAAkB;AAE3B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAYlC,SAAS,uBACP,MACA,QACQ;AACR,QAAM,iBAAiB,WAAW,MAAM,MAAM;AAE9C,SAAO;AAAA,EACP,KAAK,UAAU,gBAAgB,MAAM,CAAC,CAAC;AAAA;AAEzC;AAEA,SAAS,qBAAqB,YAA4B;AACxD,QAAM,eAAuC;AAAA,IAC3C,OAAO;AAAA,IACP,OACE;AAAA,IACF,OAAO;AAAA,IACP,OACE;AAAA,IACF,OAAO;AAAA,IACP,OACE;AAAA,IACF,OACE;AAAA,IACF,OACE;A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pB;AAAA,gBACA,OAAO,SAAS,eAAe,GAAG,UAAU;AAAA,gBAC5C,aAAa,SAAS;AAAA,gBACtB,QAAQ,QAAQ,kBAAkB,EAAE;AAAA,gBACpC,YAAY,CAAC,UAAU,WAAW;AAAA,cACpC,CAAC;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,SAAS,MAAM,KAAK,aAAa,OAAO,CAAC,EAAE;AAAA,IAC/C,CAAC,GAAG,MAAM,SAAS,EAAE,UAAU,IAAI,SAAS,EAAE,UAAU;AAAA,EAC1D;AAEA,MAAI,OAAO,WAAW,GAAG;AACvB,aAAS;AAAA,MACP;AAAA,IACF;AAAA,EACF,OAAO;AACL,eAAW,SAAS,QAAQ;AAC1B,eAAS,KAAK,OAAO,MAAM,UAAU,MAAM,MAAM,KAAK,EAAE;AACxD,YAAM,cACJ,MAAM,eAAe,qBAAqB,MAAM,UAAU,KAAK;AACjE,eAAS,KAAK,WAAW;AAEzB,UAAI,MAAM,QAAQ;AAChB,iBAAS,KAAK,sBAAsB;AACpC,iBAAS,KAAK,uBAAuB,MAAM,MAAM,MAAM,CAAC;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,KAAK;AAAA,IACL,aAAa;AAAA,IACb,SAAS,SAAS,KAAK,MAAM;AAAA,EAC/B;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { NavItem } from '../sidebar.js';
|
|
2
2
|
import type { OurOpenAPIObject } from '../types.js';
|
|
3
|
-
export declare function generateIntroOverview(spec: OurOpenAPIObject, availablesdks
|
|
3
|
+
export declare function generateIntroOverview(spec: OurOpenAPIObject, availablesdks: string[]): NavItem;
|
|
4
4
|
//# sourceMappingURL=overview-intro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview-intro.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-intro.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"overview-intro.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-intro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAOpD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,gBAAgB,EACtB,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CA2FT"}
|