apiuikit 0.5.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -5
- package/dist/apiuikit.cjs.js +1 -1
- package/dist/apiuikit.css +1 -1
- package/dist/apiuikit.es.js +24 -17
- package/dist/c-Bz1-FJiA.js +277 -0
- package/dist/c-C_Sx7N-F.cjs +1 -0
- package/dist/clojure-DWYEZwCD.cjs +1 -0
- package/dist/clojure-aY2138WD.js +135 -0
- package/dist/components/Authorization.d.ts +28 -17
- package/dist/components/ChannelAddress.d.ts +8 -2
- package/dist/components/CodeBlock.d.ts +4 -1
- package/dist/components/CodeSamples.d.ts +12 -0
- package/dist/components/CollapsiblePanel.d.ts +24 -0
- package/dist/components/CopyMarkdownButton.d.ts +15 -0
- package/dist/components/Examples.d.ts +4 -2
- package/dist/components/InfoMetadata.d.ts +15 -2
- package/dist/components/Markdown.d.ts +2 -0
- package/dist/components/MarkdownExportMenu.d.ts +13 -0
- package/dist/components/MethodBadge.d.ts +14 -0
- package/dist/components/Navigation/AsyncAPINavigation.d.ts +28 -0
- package/dist/components/Navigation/Navigation.d.ts +58 -0
- package/dist/components/Navigation/OpenAPINavigation.d.ts +22 -0
- package/dist/components/Navigation/SpecNavigation.d.ts +25 -0
- package/dist/components/Navigation/index.d.ts +4 -0
- package/dist/components/Navigation/sharedSections.d.ts +10 -0
- package/dist/components/RenderExtensions.d.ts +14 -1
- package/dist/components/Section.d.ts +3 -1
- package/dist/components/ServerAddressBanner.d.ts +16 -0
- package/dist/components/SidePanel.d.ts +2 -0
- package/dist/components/Tabs.d.ts +3 -1
- package/dist/components/schema/SchemaTab.d.ts +19 -3
- package/dist/components/tests/Bindings.test.d.ts +1 -0
- package/dist/components/tests/CodeBlock.test.d.ts +1 -0
- package/dist/components/tests/CodeSamples.test.d.ts +1 -0
- package/dist/components/tests/CopyMarkdownButton.test.d.ts +1 -0
- package/dist/components/tests/MarkdownExportMenu.test.d.ts +1 -0
- package/dist/config/config.d.ts +8 -0
- package/dist/containers/AsyncAPI/AsyncAPI.d.ts +1 -1
- package/dist/containers/Information/InformationSection.d.ts +22 -0
- package/dist/containers/Information/OpenAPIInformation.d.ts +9 -0
- package/dist/containers/OpenAPI/Layout.d.ts +7 -0
- package/dist/containers/OpenAPI/OpenAPI.d.ts +18 -0
- package/dist/containers/OpenAPI/OpenAPIDocumentProvider.d.ts +13 -0
- package/dist/containers/OpenAPI/OpenAPIRenderer.d.ts +17 -0
- package/dist/containers/OpenAPI/tests/OpenAPI.test.d.ts +1 -0
- package/dist/containers/OpenAPI/tests/OpenAPIRenderer.test.d.ts +1 -0
- package/dist/containers/Operation/Operations.d.ts +2 -1
- package/dist/containers/Path/OperationCallbacks.d.ts +37 -0
- package/dist/containers/Path/PathOperation.d.ts +21 -0
- package/dist/containers/Path/Paths.d.ts +16 -0
- package/dist/containers/Path/ResponseLinks.d.ts +21 -0
- package/dist/containers/Path/tests/PathOperation.test.d.ts +1 -0
- package/dist/containers/Server/OpenAPIServer.d.ts +4 -0
- package/dist/containers/Server/OpenAPIServers.d.ts +13 -0
- package/dist/contants.d.ts +7 -0
- package/dist/contexts/useSpec.d.ts +28 -6
- package/dist/crystal-BcGgviMR.cjs +1 -0
- package/dist/crystal-BtD5fR4q.js +283 -0
- package/dist/csharp-AnFv7wyC.js +382 -0
- package/dist/csharp-yuAGIuP4.cjs +1 -0
- package/dist/go-BpetKc7b.cjs +1 -0
- package/dist/go-CkZ9_bn0.js +151 -0
- package/dist/helpers/codeSamples.d.ts +92 -0
- package/dist/helpers/exampleSchema.d.ts +19 -0
- package/dist/helpers/hljsLanguages.d.ts +6 -0
- package/dist/helpers/openapiParser.d.ts +10 -0
- package/dist/helpers/openapiSearchIndex.d.ts +3 -0
- package/dist/helpers/resolveDocument.d.ts +8 -0
- package/dist/helpers/runtimeExpression.d.ts +15 -0
- package/dist/helpers/schemaExample.d.ts +9 -0
- package/dist/helpers/searchIndex.d.ts +5 -2
- package/dist/helpers/tests/codeSamples.test.d.ts +1 -0
- package/dist/helpers/tests/exampleSchema.test.d.ts +1 -0
- package/dist/helpers/tests/openapiSearchIndex.test.d.ts +1 -0
- package/dist/helpers/tests/toMarkdown.test.d.ts +1 -0
- package/dist/helpers/toMarkdown.d.ts +20 -0
- package/dist/hooks/useDocumentProviderValue.d.ts +27 -0
- package/dist/hooks/useFuseSearch.d.ts +14 -0
- package/dist/hooks/useOpenAPISearch.d.ts +9 -0
- package/dist/hooks/useSearchResultFocus.d.ts +18 -0
- package/dist/hooks/useSpecLayoutController.d.ts +51 -0
- package/dist/hooks/useSpecSearch.d.ts +2 -6
- package/dist/http--XH4hLDt.cjs +1 -0
- package/dist/http-DKeNlJKS.js +85 -0
- package/dist/icons/Copy.d.ts +6 -0
- package/dist/icons/Info.d.ts +5 -0
- package/dist/{index-BcNlIoEF.cjs → index-ArzwV232.cjs} +6 -6
- package/dist/index-Bh4OKjMA.js +25412 -0
- package/dist/index-C278WDNb.cjs +139 -0
- package/dist/index-C4I0xC5G.js +17544 -0
- package/dist/index-DuW5iShy.cjs +177 -0
- package/dist/index-PtAFPDfk.js +18851 -0
- package/dist/index.d.ts +7 -0
- package/dist/java-BIk0G-rH.cjs +1 -0
- package/dist/java-BicX26Pg.js +240 -0
- package/dist/kotlin-BwB8b-YX.js +242 -0
- package/dist/kotlin-kGuORR5a.cjs +2 -0
- package/dist/objectivec-CnyrJ13Z.js +237 -0
- package/dist/objectivec-CoeV81Tz.cjs +1 -0
- package/dist/ocaml-0j7KDjso.cjs +1 -0
- package/dist/ocaml-T8IqWCjo.js +67 -0
- package/dist/php-BL35ZHWM.js +566 -0
- package/dist/php-DF4zG2hq.cjs +2 -0
- package/dist/powershell-CvydS3ek.cjs +1 -0
- package/dist/powershell-DuhUKWoO.js +236 -0
- package/dist/protoToJsonSchema-AciPTlBK.cjs +83 -0
- package/dist/protoToJsonSchema-D1lojrO3.js +6131 -0
- package/dist/{protobufSchemaParser-sEw46uRx.cjs → protobufSchemaParser-7SgmMhQd.cjs} +1 -1
- package/dist/{protobufSchemaParser-BQVXzHsQ.js → protobufSchemaParser-BohWo_pY.js} +2 -2
- package/dist/public/createSectionRoot.d.ts +30 -0
- package/dist/public/openapiSections.d.ts +26 -0
- package/dist/r-B8fCBydS.js +207 -0
- package/dist/r-CYaZnHkA.cjs +1 -0
- package/dist/ruby-CvOid-1s.js +388 -0
- package/dist/ruby-nPcbuC2a.cjs +1 -0
- package/dist/rust-BocnJ3Ns.js +305 -0
- package/dist/rust-DKnYCg2f.cjs +1 -0
- package/dist/swift-C35Eof-I.js +799 -0
- package/dist/swift-CAnH__EC.cjs +1 -0
- package/dist/types/openapi.d.ts +85 -0
- package/package.json +13 -2
- package/dist/components/Navigation.d.ts +0 -28
- package/dist/icons/SideBar.d.ts +0 -6
- package/dist/index-BG6colCU.js +0 -11473
- package/dist/index-Bmw7IyyF.cjs +0 -73
- package/dist/index-CEf0X0H_.js +0 -25414
- package/dist/protoToJsonSchema-BcqPKXqK.js +0 -6174
- package/dist/protoToJsonSchema-C43lKcgx.cjs +0 -83
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
function c(e) {
|
|
2
|
+
const n = {
|
|
3
|
+
keyword: [
|
|
4
|
+
"break",
|
|
5
|
+
"case",
|
|
6
|
+
"chan",
|
|
7
|
+
"const",
|
|
8
|
+
"continue",
|
|
9
|
+
"default",
|
|
10
|
+
"defer",
|
|
11
|
+
"else",
|
|
12
|
+
"fallthrough",
|
|
13
|
+
"for",
|
|
14
|
+
"func",
|
|
15
|
+
"go",
|
|
16
|
+
"goto",
|
|
17
|
+
"if",
|
|
18
|
+
"import",
|
|
19
|
+
"interface",
|
|
20
|
+
"map",
|
|
21
|
+
"package",
|
|
22
|
+
"range",
|
|
23
|
+
"return",
|
|
24
|
+
"select",
|
|
25
|
+
"struct",
|
|
26
|
+
"switch",
|
|
27
|
+
"type",
|
|
28
|
+
"var"
|
|
29
|
+
],
|
|
30
|
+
type: [
|
|
31
|
+
"bool",
|
|
32
|
+
"byte",
|
|
33
|
+
"complex64",
|
|
34
|
+
"complex128",
|
|
35
|
+
"error",
|
|
36
|
+
"float32",
|
|
37
|
+
"float64",
|
|
38
|
+
"int8",
|
|
39
|
+
"int16",
|
|
40
|
+
"int32",
|
|
41
|
+
"int64",
|
|
42
|
+
"string",
|
|
43
|
+
"uint8",
|
|
44
|
+
"uint16",
|
|
45
|
+
"uint32",
|
|
46
|
+
"uint64",
|
|
47
|
+
"int",
|
|
48
|
+
"uint",
|
|
49
|
+
"uintptr",
|
|
50
|
+
"rune"
|
|
51
|
+
],
|
|
52
|
+
literal: [
|
|
53
|
+
"true",
|
|
54
|
+
"false",
|
|
55
|
+
"iota",
|
|
56
|
+
"nil"
|
|
57
|
+
],
|
|
58
|
+
built_in: [
|
|
59
|
+
"append",
|
|
60
|
+
"cap",
|
|
61
|
+
"close",
|
|
62
|
+
"complex",
|
|
63
|
+
"copy",
|
|
64
|
+
"imag",
|
|
65
|
+
"len",
|
|
66
|
+
"make",
|
|
67
|
+
"new",
|
|
68
|
+
"panic",
|
|
69
|
+
"print",
|
|
70
|
+
"println",
|
|
71
|
+
"real",
|
|
72
|
+
"recover",
|
|
73
|
+
"delete"
|
|
74
|
+
]
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
name: "Go",
|
|
78
|
+
aliases: ["golang"],
|
|
79
|
+
keywords: n,
|
|
80
|
+
illegal: "</",
|
|
81
|
+
contains: [
|
|
82
|
+
e.C_LINE_COMMENT_MODE,
|
|
83
|
+
e.C_BLOCK_COMMENT_MODE,
|
|
84
|
+
{
|
|
85
|
+
className: "string",
|
|
86
|
+
variants: [
|
|
87
|
+
e.QUOTE_STRING_MODE,
|
|
88
|
+
e.APOS_STRING_MODE,
|
|
89
|
+
{
|
|
90
|
+
begin: "`",
|
|
91
|
+
end: "`"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
className: "number",
|
|
97
|
+
variants: [
|
|
98
|
+
{
|
|
99
|
+
match: /-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,
|
|
100
|
+
// hex without a present digit before . (making a digit afterwards required)
|
|
101
|
+
relevance: 0
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
match: /-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,
|
|
105
|
+
// hex with a present digit before . (making a digit afterwards optional)
|
|
106
|
+
relevance: 0
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
match: /-?\b0[oO](_?[0-7])*i?/,
|
|
110
|
+
// leading 0o octal
|
|
111
|
+
relevance: 0
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
match: /-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,
|
|
115
|
+
// decimal without a present digit before . (making a digit afterwards required)
|
|
116
|
+
relevance: 0
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
match: /-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,
|
|
120
|
+
// decimal with a present digit before . (making a digit afterwards optional)
|
|
121
|
+
relevance: 0
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
begin: /:=/
|
|
127
|
+
// relevance booster
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
className: "function",
|
|
131
|
+
beginKeywords: "func",
|
|
132
|
+
end: "\\s*(\\{|$)",
|
|
133
|
+
excludeEnd: !0,
|
|
134
|
+
contains: [
|
|
135
|
+
e.TITLE_MODE,
|
|
136
|
+
{
|
|
137
|
+
className: "params",
|
|
138
|
+
begin: /\(/,
|
|
139
|
+
end: /\)/,
|
|
140
|
+
endsParent: !0,
|
|
141
|
+
keywords: n,
|
|
142
|
+
illegal: /["']/
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export {
|
|
150
|
+
c as default
|
|
151
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { availableTargets } from '@readme/httpsnippet';
|
|
2
|
+
import { HttpMethod, OpenAPIParameterData, OpenAPIRequestBodyData, OpenAPISecuritySchemeData, OpenAPIServerData } from '../types/openapi';
|
|
3
|
+
export declare const DEFAULT_CODE_SAMPLE_TARGET = "shell";
|
|
4
|
+
export declare const DEFAULT_CODE_SAMPLE_CLIENT = "curl";
|
|
5
|
+
export type AvailableCodeSampleTarget = ReturnType<typeof availableTargets>[number];
|
|
6
|
+
/** Every target/client @readme/httpsnippet knows how to generate (curl,
|
|
7
|
+
* fetch, axios, Python requests, Go, Rust, ...), grouped by target — this is
|
|
8
|
+
* the data source for the language/library dropdown. Pure passthrough kept
|
|
9
|
+
* here so `@readme/httpsnippet` stays imported in one place. */
|
|
10
|
+
export declare function getAvailableCodeSampleTargets(): AvailableCodeSampleTarget[];
|
|
11
|
+
interface HarNameValue {
|
|
12
|
+
name: string;
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
/** Loosely-typed HAR request we build ourselves — @readme/httpsnippet's own
|
|
16
|
+
* `HarRequest` type (from @types/har-format) declares several fields as
|
|
17
|
+
* required that its `init()` step actually defaults for us at runtime
|
|
18
|
+
* (httpVersion, headers, cookies, queryString, postData.mimeType). We build
|
|
19
|
+
* only what we need and cast at the single call site in `generateSnippet`. */
|
|
20
|
+
export interface CodeSampleHarRequest {
|
|
21
|
+
method: string;
|
|
22
|
+
url: string;
|
|
23
|
+
httpVersion: string;
|
|
24
|
+
headers: HarNameValue[];
|
|
25
|
+
queryString: HarNameValue[];
|
|
26
|
+
cookies: HarNameValue[];
|
|
27
|
+
postData?: {
|
|
28
|
+
mimeType: string;
|
|
29
|
+
text: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
interface ResolvedAuthPlaceholder {
|
|
33
|
+
location: "header" | "query" | "cookie";
|
|
34
|
+
name: string;
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
interface ResolvedRequestBodyMedia {
|
|
38
|
+
contentType: string;
|
|
39
|
+
schema?: unknown;
|
|
40
|
+
authorExample?: unknown;
|
|
41
|
+
}
|
|
42
|
+
/** Substitutes each `{var}` in a server URL template with its declared
|
|
43
|
+
* default (or first enum value, or the literal token as a last resort).
|
|
44
|
+
* Falls back to a placeholder host when the operation has no server at all,
|
|
45
|
+
* since HTTPSnippet's clients require an absolute URL. */
|
|
46
|
+
export declare function resolveServerBaseUrl(servers?: OpenAPIServerData[]): string;
|
|
47
|
+
/** Precedence: `param.example` → first `param.examples[...].value` →
|
|
48
|
+
* `schema.example` → first `schema.enum` value → a literal `{name}` token as
|
|
49
|
+
* a last-resort placeholder, so an undocumented parameter still produces a
|
|
50
|
+
* valid, copyable (if not runnable as-is) sample. */
|
|
51
|
+
export declare function resolveParamExampleValue(param: OpenAPIParameterData): string;
|
|
52
|
+
/** Substitutes `{token}` path placeholders using the matching `in: "path"`
|
|
53
|
+
* parameter's example value. Falls back to the literal token when no
|
|
54
|
+
* matching parameter is supplied — this is what keeps the sample valid even
|
|
55
|
+
* for operations whose path parameter is only declared at the path-item
|
|
56
|
+
* level (not merged into `op.parameters` today). */
|
|
57
|
+
export declare function buildRequestUrl(baseUrl: string, path: string, parameters: OpenAPIParameterData[]): string;
|
|
58
|
+
/** Resolves the first `security`/`globalSecurity` OR-alternative against
|
|
59
|
+
* `components.securitySchemes` into placeholder auth values, routed by
|
|
60
|
+
* location (header/query/cookie) so the caller can feed them into the
|
|
61
|
+
* matching HAR array. First code in the library to actually resolve a
|
|
62
|
+
* security requirement against its scheme definition. */
|
|
63
|
+
export declare function resolveAuthPlaceholders(security: Array<Record<string, string[]>>, securitySchemes?: Record<string, OpenAPISecuritySchemeData>): ResolvedAuthPlaceholder[];
|
|
64
|
+
/** Picks the request body media type to sample: prefers `application/json`,
|
|
65
|
+
* else the first declared content type. Surfaces the author-supplied
|
|
66
|
+
* `example`/`examples` value (never read anywhere else in the codebase
|
|
67
|
+
* today) so the caller can prefer it over a schema-faker-generated one. */
|
|
68
|
+
export declare function pickRequestBodyMedia(requestBody?: OpenAPIRequestBodyData): ResolvedRequestBodyMedia | null;
|
|
69
|
+
interface BuildHarRequestInput {
|
|
70
|
+
method: HttpMethod;
|
|
71
|
+
path: string;
|
|
72
|
+
servers?: OpenAPIServerData[];
|
|
73
|
+
parameters: OpenAPIParameterData[];
|
|
74
|
+
security: Array<Record<string, string[]>>;
|
|
75
|
+
securitySchemes?: Record<string, OpenAPISecuritySchemeData>;
|
|
76
|
+
media: ResolvedRequestBodyMedia | null;
|
|
77
|
+
resolvedBodyValue: unknown;
|
|
78
|
+
}
|
|
79
|
+
/** Assembles a HAR request object from a resolved operation — the input to
|
|
80
|
+
* `generateSnippet`/`@readme/httpsnippet`. Query parameters are supplied only
|
|
81
|
+
* via the `queryString` array (not appended to `url`); HTTPSnippet's own
|
|
82
|
+
* `prepare()` step reconstructs and encodes the final URL from that array. */
|
|
83
|
+
export declare function buildHarRequest(input: BuildHarRequestInput): CodeSampleHarRequest;
|
|
84
|
+
/** Generates a single target/client code sample for a resolved HAR request
|
|
85
|
+
* via @readme/httpsnippet. Fails soft: an unsupported target/client pair or a
|
|
86
|
+
* malformed request resolves to an empty string rather than throwing, so one
|
|
87
|
+
* bad operation (or a stale dropdown selection) can't crash the panel.
|
|
88
|
+
* `target`/`client` come from `getAvailableCodeSampleTargets()`'s own keys, so
|
|
89
|
+
* they're always valid at the httpsnippet level — the cast below only works
|
|
90
|
+
* around TargetId/ClientId not being exported types we can name directly. */
|
|
91
|
+
export declare function generateSnippet(harRequest: CodeSampleHarRequest, target: string, client: string): string;
|
|
92
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type JsonSchema = Record<string, unknown>;
|
|
2
|
+
export declare function includesType(schema: JsonSchema, type: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Prepares a schema for json-schema-faker's `generate()` so the Example tab
|
|
5
|
+
* shows something plausible and consistent with the Schema tab:
|
|
6
|
+
*
|
|
7
|
+
* - Leftover `$ref` nodes (resolveDocument's cycle cut-points) are unrolled
|
|
8
|
+
* exactly one level via `deref`, so a recursive schema's example shows one
|
|
9
|
+
* real nested occurrence. The second occurrence of the same ref on a path
|
|
10
|
+
* is cut to `{ type: "null" }` when the target allows null, else `{}`.
|
|
11
|
+
* Without this, generate() would throw on the unresolvable pointer and the
|
|
12
|
+
* tab would silently render nothing.
|
|
13
|
+
* - `oneOf`/`anyOf` collapse to their first branch, matching the case
|
|
14
|
+
* SchemaTree shows by default, instead of letting generate() pick an
|
|
15
|
+
* unrelated-looking one.
|
|
16
|
+
* - Plain string fields get placeholder examples (and `*id` fields a uuid
|
|
17
|
+
* format) instead of random character noise.
|
|
18
|
+
*/
|
|
19
|
+
export declare function extendExampleSchema(schema: JsonSchema, deref?: (ref: string) => unknown, active?: Set<object>, refStack?: ReadonlySet<string>): JsonSchema;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function hljsLanguageForTarget(target: string): string;
|
|
2
|
+
export declare function isHljsLanguageReady(hljsName: string): boolean;
|
|
3
|
+
/** Registers a highlight.js grammar on first use. No-op if already
|
|
4
|
+
* registered, if it's "plaintext" (needs no registration), or if there's no
|
|
5
|
+
* loader for it (CodeBlock falls back to unhighlighted text in that case). */
|
|
6
|
+
export declare function ensureHljsLanguage(hljsName: string): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OpenAPIDocumentData } from '../types/openapi';
|
|
2
|
+
import { ConfigInterface } from '../config/config';
|
|
3
|
+
export declare function parseDocument(raw: string): Promise<{
|
|
4
|
+
diagnostics: unknown[];
|
|
5
|
+
document: OpenAPIDocumentData | null;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function parseAndRender(raw: string, config?: ConfigInterface): Promise<{
|
|
8
|
+
diagnostics: unknown[];
|
|
9
|
+
view: import("react").JSX.Element | null;
|
|
10
|
+
}>;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only scan for `$ref` nodes only (not cycles). Used to verify a
|
|
3
|
+
* caller's `kind="resolved"` promise: leftover refs mean their upstream
|
|
4
|
+
* resolution isn't doing what they think, while object cycles are a normal
|
|
5
|
+
* property of parser output and no broken promise. Terminates on cyclic
|
|
6
|
+
* input via the visited set.
|
|
7
|
+
*/
|
|
8
|
+
export declare const containsRefs: (value: unknown, visited?: Set<object>) => boolean;
|
|
1
9
|
export declare function resolveDocument<T>(doc: T): T;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI runtime expressions (`$response.body#/id`) appear in response
|
|
3
|
+
* `links` parameters and in `callbacks` URL keys. They're written with a `$`
|
|
4
|
+
* sigil and a JSON Pointer (`#/a/b`), which is precise but hard to read mid
|
|
5
|
+
* sentence, so both places show them as a plain dotted path instead.
|
|
6
|
+
*/
|
|
7
|
+
/** `$response.body#/data/id` reads as `response.body.data.id`. Non-expressions are left alone. */
|
|
8
|
+
export declare function readableExpression(value: unknown): string;
|
|
9
|
+
/**
|
|
10
|
+
* A callback's key is a URL template that embeds expressions in braces, and
|
|
11
|
+
* may wrap them in literal URL text: `{$request.body#/callbackUrl}` or
|
|
12
|
+
* `https://example.com/{$request.body#/id}/events`. Only the embedded
|
|
13
|
+
* expressions are rewritten; the braces stay, since they mark the placeholder.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readableCallbackUrl(url: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type JsonSchema = Record<string, unknown>;
|
|
2
|
+
export declare function extendExampleSchema(schema: JsonSchema, active?: Set<object>): JsonSchema;
|
|
3
|
+
/**
|
|
4
|
+
* Generates a synthetic example value from a JSON Schema via json-schema-faker.
|
|
5
|
+
* Fails soft: circular or otherwise ungenerable schemas resolve to `undefined`
|
|
6
|
+
* rather than throwing/rejecting, since callers render "no example" instead of
|
|
7
|
+
* crashing.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateSchemaExample(schema: JsonSchema): Promise<unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncAPIDocumentData } from '../types/schema';
|
|
2
|
-
export type SearchTab = "operations" | "messages" | "schemas" | "info" | "servers";
|
|
3
|
-
export type SearchType = "operation" | "message" | "schema" | "info" | "server";
|
|
2
|
+
export type SearchTab = "operations" | "messages" | "schemas" | "info" | "servers" | "endpoints" | "webhooks";
|
|
3
|
+
export type SearchType = "operation" | "message" | "schema" | "info" | "server" | "endpoint" | "webhook";
|
|
4
4
|
export interface SearchEntry {
|
|
5
5
|
id: string;
|
|
6
6
|
targetId: string;
|
|
@@ -15,4 +15,7 @@ export interface SearchEntry {
|
|
|
15
15
|
focusSection?: string;
|
|
16
16
|
schemaFocusTokens?: string[];
|
|
17
17
|
}
|
|
18
|
+
export declare const normalizeString: (value: unknown) => string;
|
|
19
|
+
/** Walks a single JSON Schema node into flat search entries — spec-agnostic (AsyncAPI and OpenAPI schemas share the same shape), reused by openapiSearchIndex.ts. */
|
|
20
|
+
export declare const addSchemaEntries: (entries: SearchEntry[], schema: unknown, schemaKey: string, schemaName: string) => void;
|
|
18
21
|
export declare function buildSearchIndex(asyncapi: AsyncAPIDocumentData): SearchEntry[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AsyncAPIDocumentData } from '../types/schema';
|
|
2
|
+
import { HttpMethod, OpenAPIDocumentData } from '../types/openapi';
|
|
3
|
+
type Deref = (ref: string) => unknown;
|
|
4
|
+
export declare function asyncApiToMarkdown(doc: AsyncAPIDocumentData, deref: Deref): string;
|
|
5
|
+
/** Builds a self-contained Markdown snippet for a single AsyncAPI operation:
|
|
6
|
+
* doc info + servers, followed by that one operation's section (see
|
|
7
|
+
* `operationSectionToMarkdown`). Used by the per-operation copy button, as
|
|
8
|
+
* opposed to `asyncApiToMarkdown`'s whole-document export. */
|
|
9
|
+
export declare function asyncApiOperationToMarkdown(doc: AsyncAPIDocumentData, key: string, deref: Deref): string;
|
|
10
|
+
export declare function openApiToMarkdown(doc: OpenAPIDocumentData, deref: Deref): string;
|
|
11
|
+
/**
|
|
12
|
+
* Builds a self-contained Markdown snippet for a single OpenAPI endpoint:
|
|
13
|
+
* doc info + servers (so the snippet stands alone without the rest of the
|
|
14
|
+
* document) followed by that one endpoint's fully-dereferenced parameters,
|
|
15
|
+
* request body, and responses. Used by the per-endpoint copy button in the
|
|
16
|
+
* Endpoints side panel (Paths.tsx), as opposed to `openApiToMarkdown`'s
|
|
17
|
+
* whole-document export.
|
|
18
|
+
*/
|
|
19
|
+
export declare function openApiEndpointToMarkdown(doc: OpenAPIDocumentData, method: HttpMethod, path: string, deref: Deref): string;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ConfigInterface } from '../config';
|
|
2
|
+
import { SpecType } from '../contexts';
|
|
3
|
+
/**
|
|
4
|
+
* Builds the shared DocumentContext value (deref resolver, portal/root refs,
|
|
5
|
+
* theme-derived settings) plus the CSS custom properties for the theme,
|
|
6
|
+
* used by both AsyncAPIDocumentProvider and OpenAPIDocumentProvider, which
|
|
7
|
+
* differ only in the spec type they declare and the portal element's
|
|
8
|
+
* className. Generic so the returned contextValue keeps the caller's literal
|
|
9
|
+
* `specType` and document type, and thus lands as the right member of the
|
|
10
|
+
* DocumentContextValue union.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useDocumentProviderValue<S extends SpecType, D extends object>(specType: S, document: D, config?: ConfigInterface): {
|
|
13
|
+
contextValue: {
|
|
14
|
+
specType: S;
|
|
15
|
+
document: D;
|
|
16
|
+
deref: (refPath: string) => unknown;
|
|
17
|
+
portalHost: HTMLDivElement | null;
|
|
18
|
+
rootElement: HTMLDivElement | null;
|
|
19
|
+
defaultSchemaExpanded: boolean;
|
|
20
|
+
depthColors: string[];
|
|
21
|
+
showExtensions: boolean;
|
|
22
|
+
showCodeSamples: boolean;
|
|
23
|
+
};
|
|
24
|
+
themeVars: Record<string, string>;
|
|
25
|
+
setPortalHost: import('react').Dispatch<import('react').SetStateAction<HTMLDivElement | null>>;
|
|
26
|
+
setRootElement: import('react').Dispatch<import('react').SetStateAction<HTMLDivElement | null>>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SearchEntry } from '../helpers/searchIndex';
|
|
2
|
+
export interface UseSpecSearchOptions {
|
|
3
|
+
threshold?: number;
|
|
4
|
+
limit?: number;
|
|
5
|
+
/** Delay before a query change triggers a search, in ms. Defaults to 150. */
|
|
6
|
+
debounceMs?: number;
|
|
7
|
+
}
|
|
8
|
+
/** Shared debounce + Fuse setup behind useSpecSearch (AsyncAPI) and useOpenAPISearch — only the index-builder differs between specs. */
|
|
9
|
+
export declare function useFuseSearch<T>(document: T, buildIndex: (document: T) => SearchEntry[], options?: UseSpecSearchOptions): {
|
|
10
|
+
query: string;
|
|
11
|
+
setQuery: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
12
|
+
results: SearchEntry[];
|
|
13
|
+
searchIndex: SearchEntry[];
|
|
14
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OpenAPIDocumentData } from '../types/openapi';
|
|
2
|
+
import { UseSpecSearchOptions } from './useFuseSearch';
|
|
3
|
+
/** Mirrors useSpecSearch (AsyncAPI), built on buildOpenAPISearchIndex instead. */
|
|
4
|
+
export declare function useOpenAPISearch(openapi: OpenAPIDocumentData, options?: UseSpecSearchOptions): {
|
|
5
|
+
query: string;
|
|
6
|
+
setQuery: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
7
|
+
results: import('../helpers/searchIndex').SearchEntry[];
|
|
8
|
+
searchIndex: import('../helpers/searchIndex').SearchEntry[];
|
|
9
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ActiveHighlight {
|
|
2
|
+
targetId: string;
|
|
3
|
+
query: string;
|
|
4
|
+
highlight: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Scrolls to and highlights a search result's target element once it exists
|
|
8
|
+
* in the DOM, retrying since the target may not be rendered yet (e.g. the tab
|
|
9
|
+
* holding it just changed). Shared behind both AsyncAPI/Layout.tsx and
|
|
10
|
+
* OpenAPI/Layout.tsx, which otherwise duplicated this effect verbatim.
|
|
11
|
+
*
|
|
12
|
+
* `deps` should list every piece of state that changes which DOM subtree is
|
|
13
|
+
* currently rendered (active tab, selected item keys, focus targets, ...) —
|
|
14
|
+
* anything that could change whether `activeHighlight.targetId` already
|
|
15
|
+
* exists in the DOM. Its length must stay constant across renders for a given
|
|
16
|
+
* call site, same as any other hook dependency list.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useSearchResultFocus(activeHighlight: ActiveHighlight | null, deps: readonly unknown[]): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ContentTabItem } from '../components/ContentTab';
|
|
2
|
+
import { SearchEntry } from '../helpers/searchIndex';
|
|
3
|
+
export interface SchemaFocusTarget {
|
|
4
|
+
tokens: string[];
|
|
5
|
+
id: string;
|
|
6
|
+
}
|
|
7
|
+
export interface LayoutSection<TabKey extends string> {
|
|
8
|
+
id: TabKey | "servers";
|
|
9
|
+
/** Config `show` flag for this section: a hidden section reads back a null selection. */
|
|
10
|
+
visible: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SpecLayoutControllerOptions<TabKey extends string> {
|
|
13
|
+
/** Content tabs currently visible (already filtered by config.show). */
|
|
14
|
+
tabs: ContentTabItem[];
|
|
15
|
+
/** Tab to fall back to when no tabs are visible or the stored tab gets hidden. */
|
|
16
|
+
defaultTab: TabKey;
|
|
17
|
+
isTabKey: (value: string) => value is TabKey;
|
|
18
|
+
/**
|
|
19
|
+
* Selectable sections in nav priority order: the tab keys, then "servers".
|
|
20
|
+
* Must keep a constant length across renders (it feeds a hook dependency list).
|
|
21
|
+
*/
|
|
22
|
+
sections: readonly LayoutSection<TabKey>[];
|
|
23
|
+
/** Current search input, used to tag highlights and clear them when it empties. */
|
|
24
|
+
searchQuery: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Owns the tab/selection/search-focus state machine shared by the AsyncAPI and
|
|
28
|
+
* OpenAPI layouts, which previously duplicated it verbatim. Each layout
|
|
29
|
+
* supplies only its tab definitions, section visibility, and content
|
|
30
|
+
* renderers; everything about "what is selected where, and what should scroll
|
|
31
|
+
* into view" lives here.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useSpecLayoutController<TabKey extends string>({ tabs, defaultTab, isTabKey, sections, searchQuery, }: SpecLayoutControllerOptions<TabKey>): {
|
|
34
|
+
effectiveTab: TabKey;
|
|
35
|
+
focusTab: (tab: TabKey) => void;
|
|
36
|
+
/** What the sidebar nav should show as active: the focused section, falling back to the content tab. */
|
|
37
|
+
navActiveSection: "servers" | TabKey;
|
|
38
|
+
/** Per-section selections, clamped to visible sections. */
|
|
39
|
+
selected: Record<"servers" | TabKey, string | null>;
|
|
40
|
+
setSelectedKey: (section: "servers" | TabKey, key: string | null) => void;
|
|
41
|
+
selectedNavItem: {
|
|
42
|
+
tab: "servers" | TabKey;
|
|
43
|
+
key: NonNullable<Record<"servers" | TabKey, string | null>["servers" | TabKey]>;
|
|
44
|
+
} | null;
|
|
45
|
+
handleSearchSelect: (entry: SearchEntry) => void;
|
|
46
|
+
handleNavItemSelect: (tab: TabKey, key: string) => void;
|
|
47
|
+
handleNavServerSelect: (key: string) => void;
|
|
48
|
+
handleContentTabChange: (id: string) => void;
|
|
49
|
+
focusSection: string | null;
|
|
50
|
+
schemaFocusTarget: SchemaFocusTarget | null;
|
|
51
|
+
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { AsyncAPIDocumentData } from '../types/schema';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
limit?: number;
|
|
5
|
-
/** Delay before a query change triggers a search, in ms. Defaults to 150. */
|
|
6
|
-
debounceMs?: number;
|
|
7
|
-
}
|
|
2
|
+
import { UseSpecSearchOptions } from './useFuseSearch';
|
|
3
|
+
export type { UseSpecSearchOptions };
|
|
8
4
|
export declare function useSpecSearch(asyncapi: AsyncAPIDocumentData, options?: UseSpecSearchOptions): {
|
|
9
5
|
query: string;
|
|
10
6
|
setQuery: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(n){const s=n.regex,e="HTTP/([32]|1\\.[01])",i=/[A-Za-z][A-Za-z0-9-]*/,t={className:"attribute",begin:s.concat("^",i,"(?=\\:\\s)"),starts:{contains:[{className:"punctuation",begin:/: /,relevance:0,starts:{end:"$",relevance:0}}]}},a=[t,{begin:"\\n\\n",starts:{subLanguage:[],endsWithParent:!0}}];return{name:"HTTP",aliases:["https"],illegal:/\S/,contains:[{begin:"^(?="+e+" \\d{3})",end:/$/,contains:[{className:"meta",begin:e},{className:"number",begin:"\\b\\d{3}\\b"}],starts:{end:/\b\B/,illegal:/\S/,contains:a}},{begin:"(?=^[A-Z]+ (.*?) "+e+"$)",end:/$/,contains:[{className:"string",begin:" ",end:" ",excludeBegin:!0,excludeEnd:!0},{className:"meta",begin:e},{className:"keyword",begin:"[A-Z]+"}],starts:{end:/\b\B/,illegal:/\S/,contains:a}},n.inherit(t,{relevance:0})]}}exports.default=c;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function c(n) {
|
|
2
|
+
const s = n.regex, e = "HTTP/([32]|1\\.[01])", i = /[A-Za-z][A-Za-z0-9-]*/, a = {
|
|
3
|
+
className: "attribute",
|
|
4
|
+
begin: s.concat("^", i, "(?=\\:\\s)"),
|
|
5
|
+
starts: { contains: [
|
|
6
|
+
{
|
|
7
|
+
className: "punctuation",
|
|
8
|
+
begin: /: /,
|
|
9
|
+
relevance: 0,
|
|
10
|
+
starts: {
|
|
11
|
+
end: "$",
|
|
12
|
+
relevance: 0
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
] }
|
|
16
|
+
}, t = [
|
|
17
|
+
a,
|
|
18
|
+
{
|
|
19
|
+
begin: "\\n\\n",
|
|
20
|
+
starts: {
|
|
21
|
+
subLanguage: [],
|
|
22
|
+
endsWithParent: !0
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
];
|
|
26
|
+
return {
|
|
27
|
+
name: "HTTP",
|
|
28
|
+
aliases: ["https"],
|
|
29
|
+
illegal: /\S/,
|
|
30
|
+
contains: [
|
|
31
|
+
// response
|
|
32
|
+
{
|
|
33
|
+
begin: "^(?=" + e + " \\d{3})",
|
|
34
|
+
end: /$/,
|
|
35
|
+
contains: [
|
|
36
|
+
{
|
|
37
|
+
className: "meta",
|
|
38
|
+
begin: e
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
className: "number",
|
|
42
|
+
begin: "\\b\\d{3}\\b"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
starts: {
|
|
46
|
+
end: /\b\B/,
|
|
47
|
+
illegal: /\S/,
|
|
48
|
+
contains: t
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
// request
|
|
52
|
+
{
|
|
53
|
+
begin: "(?=^[A-Z]+ (.*?) " + e + "$)",
|
|
54
|
+
end: /$/,
|
|
55
|
+
contains: [
|
|
56
|
+
{
|
|
57
|
+
className: "string",
|
|
58
|
+
begin: " ",
|
|
59
|
+
end: " ",
|
|
60
|
+
excludeBegin: !0,
|
|
61
|
+
excludeEnd: !0
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
className: "meta",
|
|
65
|
+
begin: e
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
className: "keyword",
|
|
69
|
+
begin: "[A-Z]+"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
starts: {
|
|
73
|
+
end: /\b\B/,
|
|
74
|
+
illegal: /\S/,
|
|
75
|
+
contains: t
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
// to allow headers to work even without a preamble
|
|
79
|
+
n.inherit(a, { relevance: 0 })
|
|
80
|
+
]
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
c as default
|
|
85
|
+
};
|