@voltro/plugin-openapi 0.70.0 → 0.71.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/CHANGELOG.md +1289 -111
- package/dist/index.d.ts +92 -0
- package/dist/index.js +298 -137
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,15 @@ import { ProcedureDescriptor } from '@voltro/protocol';
|
|
|
2
2
|
import { RestRouteDescriptor } from '@voltro/protocol/rest';
|
|
3
3
|
import { VoltroPlugin } from '@voltro/protocol';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A body derived from a wire JSON schema, deterministically — the same schema
|
|
7
|
+
* always derives the same body, so a generated collection's diff stays quiet.
|
|
8
|
+
* Not a substitute for an author's `publicApi.example`: it exists so an
|
|
9
|
+
* operation without one is not an empty body in Swagger UI and in every
|
|
10
|
+
* collection, and it is marked `x-voltro-example: derived` where it is used.
|
|
11
|
+
*/
|
|
12
|
+
export declare const deriveExample: (schema: JsonObject, defs: Record<string, unknown>, depth?: number) => unknown;
|
|
13
|
+
|
|
5
14
|
/**
|
|
6
15
|
* Build the full OpenAPI 3.1 document from a list of REST descriptors and,
|
|
7
16
|
* optionally, the rpc procedure descriptors.
|
|
@@ -13,6 +22,8 @@ export declare function generateOpenApiSpec(routes: ReadonlyArray<RestRouteDescr
|
|
|
13
22
|
|
|
14
23
|
export declare function generateOpenApiSpec(routes: ReadonlyArray<RestRouteDescriptor<any, any>>, info: OpenApiInfo, sources: OpenApiSources, options?: OpenApiGenerateOptions): OpenApiDocument;
|
|
15
24
|
|
|
25
|
+
declare type JsonObject = Record<string, unknown>;
|
|
26
|
+
|
|
16
27
|
/** Every version mounted, newest first (`v2` before `v1`). */
|
|
17
28
|
export declare const mountedVersions: (routes: ReadonlyArray<RestRouteDescriptor<any, any>>) => ReadonlyArray<string>;
|
|
18
29
|
|
|
@@ -27,12 +38,27 @@ export declare interface OpenApiDocument {
|
|
|
27
38
|
readonly title: string;
|
|
28
39
|
readonly version: string;
|
|
29
40
|
readonly description?: string;
|
|
41
|
+
readonly contact?: OpenApiInfo['contact'];
|
|
42
|
+
readonly license?: OpenApiInfo['license'];
|
|
43
|
+
readonly termsOfService?: string;
|
|
44
|
+
readonly 'x-logo'?: OpenApiInfo['logo'];
|
|
30
45
|
};
|
|
46
|
+
readonly servers?: ReadonlyArray<{
|
|
47
|
+
readonly url: string;
|
|
48
|
+
readonly description?: string;
|
|
49
|
+
readonly 'x-voltro-environment'?: string;
|
|
50
|
+
}>;
|
|
51
|
+
readonly externalDocs?: OpenApiExternalDocs;
|
|
52
|
+
readonly 'x-voltro-environment'?: string;
|
|
53
|
+
/** The digest of the projected surface — what a generated client was built
|
|
54
|
+
* from, and what `voltro check --public-api --against` compares. */
|
|
55
|
+
readonly 'x-voltro-surface-digest'?: string;
|
|
31
56
|
readonly paths: Record<string, Record<string, unknown>>;
|
|
32
57
|
/** Every tag group an operation uses, with its description when one was given. */
|
|
33
58
|
readonly tags?: ReadonlyArray<{
|
|
34
59
|
readonly name: string;
|
|
35
60
|
readonly description?: string;
|
|
61
|
+
readonly externalDocs?: OpenApiExternalDocs;
|
|
36
62
|
}>;
|
|
37
63
|
readonly components: {
|
|
38
64
|
readonly schemas: Record<string, unknown>;
|
|
@@ -40,16 +66,51 @@ export declare interface OpenApiDocument {
|
|
|
40
66
|
};
|
|
41
67
|
}
|
|
42
68
|
|
|
69
|
+
export declare interface OpenApiExternalDocs {
|
|
70
|
+
readonly url: string;
|
|
71
|
+
readonly description?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
43
74
|
/** What the generator knows beyond the routes: a description per tag group
|
|
44
75
|
* (`teams` → "Teams and membership"), for the document's `tags[]`. */
|
|
45
76
|
export declare interface OpenApiGenerateOptions {
|
|
46
77
|
readonly tagDescriptions?: Readonly<Record<string, string>>;
|
|
78
|
+
/** A link per tag group — the handbook page of a domain — for `tags[].externalDocs`. */
|
|
79
|
+
readonly tagExternalDocs?: Readonly<Record<string, OpenApiExternalDocs>>;
|
|
80
|
+
/** The document's `externalDocs`. */
|
|
81
|
+
readonly externalDocs?: OpenApiExternalDocs;
|
|
82
|
+
/** The document's `servers` — the first entry is what a generated client
|
|
83
|
+
* and a collection take as the default base URL. */
|
|
84
|
+
readonly servers?: ReadonlyArray<OpenApiServer>;
|
|
85
|
+
/** The environment THIS instance serves (`x-voltro-environment` on the
|
|
86
|
+
* document): `dev`, `staging`, `production`, … */
|
|
87
|
+
readonly environment?: string;
|
|
47
88
|
}
|
|
48
89
|
|
|
49
90
|
export declare interface OpenApiInfo {
|
|
50
91
|
readonly title?: string;
|
|
51
92
|
readonly version?: string;
|
|
52
93
|
readonly description?: string;
|
|
94
|
+
/** The API team a consumer writes to — `info.contact`. */
|
|
95
|
+
readonly contact?: {
|
|
96
|
+
readonly name?: string;
|
|
97
|
+
readonly url?: string;
|
|
98
|
+
readonly email?: string;
|
|
99
|
+
};
|
|
100
|
+
/** `info.license`. */
|
|
101
|
+
readonly license?: {
|
|
102
|
+
readonly name: string;
|
|
103
|
+
readonly url?: string;
|
|
104
|
+
readonly identifier?: string;
|
|
105
|
+
};
|
|
106
|
+
/** `info.termsOfService` — a URL. */
|
|
107
|
+
readonly termsOfService?: string;
|
|
108
|
+
/** `x-logo` — what ReDoc renders at the top of the page. */
|
|
109
|
+
readonly logo?: {
|
|
110
|
+
readonly url: string;
|
|
111
|
+
readonly altText?: string;
|
|
112
|
+
readonly backgroundColor?: string;
|
|
113
|
+
};
|
|
53
114
|
}
|
|
54
115
|
|
|
55
116
|
export declare const openapiPlugin: (options: OpenApiPluginOptions) => VoltroPlugin;
|
|
@@ -71,6 +132,27 @@ export declare interface OpenApiPluginOptions {
|
|
|
71
132
|
/** A description per tag group (`teams` → 'Teams and membership'), for the
|
|
72
133
|
* document's `tags[]`. A group with no entry is listed by name. */
|
|
73
134
|
readonly tagDescriptions?: Readonly<Record<string, string>>;
|
|
135
|
+
/** A link per tag group — the handbook page of a domain — for
|
|
136
|
+
* `tags[].externalDocs`. */
|
|
137
|
+
readonly tagExternalDocs?: Readonly<Record<string, OpenApiExternalDocs>>;
|
|
138
|
+
/** The document's `externalDocs`. */
|
|
139
|
+
readonly externalDocs?: OpenApiExternalDocs;
|
|
140
|
+
/**
|
|
141
|
+
* Where the API is reachable — the document's `servers`. The first entry is
|
|
142
|
+
* the default base URL of a generated client and of a collection, and every
|
|
143
|
+
* entry becomes one environment file there. Omitted: one entry from
|
|
144
|
+
* `VOLTRO_PUBLIC_API_ORIGIN` when that is set (the public origin of THIS
|
|
145
|
+
* api — `VOLTRO_API_ORIGIN` is the web app's server-side route to it, and
|
|
146
|
+
* `VOLTRO_PUBLIC_URL` the storage plugin's), tagged with `environment`.
|
|
147
|
+
*/
|
|
148
|
+
readonly servers?: ReadonlyArray<OpenApiServer>;
|
|
149
|
+
/**
|
|
150
|
+
* The environment this instance serves — `dev`, `staging`, `production` —
|
|
151
|
+
* written as `x-voltro-environment` on the document and on the default
|
|
152
|
+
* server entry. Default `VOLTRO_ENVIRONMENT`, else `production` under
|
|
153
|
+
* `NODE_ENV=production` and `dev` otherwise.
|
|
154
|
+
*/
|
|
155
|
+
readonly environment?: string;
|
|
74
156
|
/** Path to serve the JSON spec. Default `/openapi.json`. */
|
|
75
157
|
readonly specPath?: string;
|
|
76
158
|
/** Path to serve the Swagger-UI page. Default `/docs`. `false` disables it. */
|
|
@@ -105,6 +187,16 @@ export declare interface OpenApiPluginOptions {
|
|
|
105
187
|
readonly includeAppProcedures?: boolean;
|
|
106
188
|
}
|
|
107
189
|
|
|
190
|
+
/** One `servers[]` entry: where the API is reachable, and for which
|
|
191
|
+
* environment (`x-voltro-environment`), so a collection can write one
|
|
192
|
+
* environment file per entry. */
|
|
193
|
+
export declare interface OpenApiServer {
|
|
194
|
+
readonly url: string;
|
|
195
|
+
readonly description?: string;
|
|
196
|
+
/** `dev` | `staging` | `production` — free text; the entry's environment. */
|
|
197
|
+
readonly environment?: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
108
200
|
/** Extra sources to fold into the spec beyond the REST `routes`. Today: the
|
|
109
201
|
* rpc procedure descriptors (queries / mutations / actions / streams). */
|
|
110
202
|
export declare interface OpenApiSources {
|