@dogsbay/format-openapi 0.2.0-beta.117 → 0.2.0-beta.118

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/core.d.ts ADDED
@@ -0,0 +1,66 @@
1
+ import type { ExportPage, Heading, NavItem, TreeNode } from "@dogsbay/types";
2
+ export { findSpec, specCandidates, type SpecLookup } from "./spec-path.js";
3
+ export interface ParseOpenApiOptions {
4
+ /** When the importer wants nav hrefs to start with this prefix. */
5
+ hrefPrefix?: string;
6
+ /** Sub-path within the namespace for emitted pages, e.g. "api". */
7
+ section?: string;
8
+ }
9
+ /**
10
+ * A dereferenced spec (`prepareSpec`) as a page per operation, a page per tag
11
+ * and an info page, with their nav: for a spec that IS the source.
12
+ */
13
+ export declare function specToPages(spec: any, options?: ParseOpenApiOptions): {
14
+ pages: ExportPage[];
15
+ nav: NavItem[];
16
+ };
17
+ /**
18
+ * Spec text → object. JSON is read natively; YAML needs a parser passed in
19
+ * (`yaml`'s `parse`, js-yaml's `load`), so a host that has one does not
20
+ * bundle a second.
21
+ */
22
+ export declare function parseSpecText(text: string, parseYaml?: (text: string) => unknown): unknown;
23
+ /**
24
+ * A parsed spec → the dereferenced OpenAPI 3 document every function here
25
+ * reads. Swagger 2.0 is upgraded to OpenAPI 3 first: everything below reads
26
+ * the 3.x shape (`requestBody`, response `content`, `servers`), so a 2.0
27
+ * spec parsed without the upgrade lost every body parameter and response
28
+ * schema while still producing plausible-looking pages. Canonical's Anbox
29
+ * Cloud API specs are 2.0.
30
+ */
31
+ export declare function prepareSpec(parsed: unknown, label?: string): Promise<any>;
32
+ /**
33
+ * Prepared specs by path, each parsed and dereferenced once however many
34
+ * pages embed it. `read` returns the file's text; failures are cached too,
35
+ * so a broken spec is reported per page without being parsed again.
36
+ */
37
+ export declare function createSpecCache(read: (path: string) => string | Promise<string>, parseYaml?: (text: string) => unknown): {
38
+ get(path: string): Promise<any>;
39
+ readonly size: number;
40
+ };
41
+ export interface OpenApiEmbedOptions {
42
+ level?: number;
43
+ /** Ids the page already uses: the embed's headings get others. */
44
+ usedIds?: Iterable<string>;
45
+ }
46
+ export interface OpenApiEmbed {
47
+ /** Version line, description, then one section per tag of endpoint nodes. */
48
+ tree: TreeNode[];
49
+ /** One entry per tag section, for the page's table of contents. */
50
+ headings: Heading[];
51
+ operations: number;
52
+ }
53
+ /**
54
+ * A whole spec as the BODY of one page: what Swagger UI or Redoc show when a
55
+ * page embeds them. The info version and description, then a section per tag
56
+ * (declared order, then first use; untagged operations last, under "Other"),
57
+ * each holding its operations as `endpoint` nodes in document order.
58
+ *
59
+ * `spec` is a dereferenced spec (`prepareSpec`), and is not modified: the
60
+ * nodes are copies, so one parsed spec serves every page that embeds it.
61
+ *
62
+ * `specToPages` is the other shape — a page per operation — for a spec
63
+ * that IS the source. This one is for a spec a prose page points at.
64
+ */
65
+ export declare function embedSpec(spec: any, options?: OpenApiEmbedOptions): OpenApiEmbed;
66
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK7E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAY3E,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,GAAG,EACT,OAAO,GAAE,mBAAwB,GAChC;IAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,GAAG,EAAE,OAAO,EAAE,CAAA;CAAE,CA4EzC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,C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