@orpc/openapi 2.0.0-beta.49 → 2.0.0-beta.50
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/adapters/aws-lambda/index.d.ts +3 -15
- package/dist/adapters/aws-lambda/index.js +1 -1
- package/dist/adapters/aws-lambda/openapi-handler.d.ts +8 -9
- package/dist/adapters/aws-lambda/openapi-handler.js +19 -17
- package/dist/adapters/fastify/index.d.ts +2 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/fastify/openapi-handler.d.ts +8 -9
- package/dist/adapters/fastify/openapi-handler.js +16 -14
- package/dist/adapters/fetch/index.d.ts +3 -2
- package/dist/adapters/fetch/index.js +2 -2
- package/dist/adapters/fetch/openapi-handler.d.ts +8 -9
- package/dist/adapters/fetch/openapi-handler.js +16 -14
- package/dist/adapters/fetch/openapi-link.d.ts +9 -10
- package/dist/adapters/fetch/openapi-link.js +21 -19
- package/dist/adapters/node/index.d.ts +2 -1
- package/dist/adapters/node/index.js +1 -1
- package/dist/adapters/node/openapi-handler.d.ts +8 -9
- package/dist/adapters/node/openapi-handler.js +16 -14
- package/dist/adapters/standard/index.d.ts +4 -3
- package/dist/adapters/standard/index.js +3 -3
- package/dist/adapters/standard/openapi-handler-codec.d.ts +56 -57
- package/dist/adapters/standard/openapi-handler-codec.js +143 -205
- package/dist/adapters/standard/openapi-link-codec.d.ts +55 -59
- package/dist/adapters/standard/openapi-link-codec.js +262 -377
- package/dist/adapters/standard/openapi-matcher.d.ts +26 -26
- package/dist/adapters/standard/openapi-matcher.js +78 -108
- package/dist/adapters/standard/utils.js +28 -44
- package/dist/bracket-notation.d.ts +22 -22
- package/dist/bracket-notation.js +123 -173
- package/dist/client-factory.d.ts +12 -12
- package/dist/client-factory.js +13 -11
- package/dist/constants.d.ts +1 -4
- package/dist/constants.js +5 -4
- package/dist/extensions/route.d.ts +36 -36
- package/dist/extensions/route.js +7 -6
- package/dist/helpers/form-data.d.ts +1 -1
- package/dist/helpers/form-data.js +74 -86
- package/dist/helpers/index.d.ts +2 -1
- package/dist/helpers/index.js +1 -1
- package/dist/index.d.ts +15 -13
- package/dist/index.js +11 -11
- package/dist/meta.d.ts +298 -298
- package/dist/meta.js +54 -72
- package/dist/openapi-generator-components.d.ts +2 -31
- package/dist/openapi-generator-components.js +200 -248
- package/dist/openapi-generator-operation.d.ts +12 -33
- package/dist/openapi-generator-operation.js +369 -437
- package/dist/openapi-generator.d.ts +75 -80
- package/dist/openapi-generator.js +114 -142
- package/dist/openapi-json-serializer.d.ts +65 -65
- package/dist/openapi-json-serializer.js +218 -257
- package/dist/openapi-serializer.d.ts +31 -32
- package/dist/openapi-serializer.js +68 -92
- package/dist/plugins/index.d.ts +2 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/openapi-reference.d.ts +99 -102
- package/dist/plugins/openapi-reference.js +109 -132
- package/dist/router-utils.d.ts +7 -10
- package/dist/router-utils.js +30 -34
- package/dist/types.d.ts +8 -12
- package/dist/utils.d.ts +5 -10
- package/dist/utils.js +39 -42
- package/package.json +12 -12
- package/dist/adapters/standard/utils.d.ts +0 -4
- package/dist/types.js +0 -1
package/dist/meta.js
CHANGED
|
@@ -1,84 +1,66 @@
|
|
|
1
|
-
import { mergeHttpPath } from
|
|
1
|
+
import { mergeHttpPath } from "@orpc/shared";
|
|
2
|
+
// src/meta.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const prefix = existing?.prefix && incoming.prefix
|
|
41
|
-
? mergeHttpPath(existing.prefix, incoming.prefix)
|
|
42
|
-
: 'prefix' in incoming
|
|
43
|
-
? incoming.prefix
|
|
44
|
-
: existing?.prefix;
|
|
45
|
-
// TODO: throw if incoming.path missing dynamic from existing.path
|
|
46
|
-
const merged = {
|
|
47
|
-
...existing,
|
|
48
|
-
...incoming,
|
|
49
|
-
tags,
|
|
50
|
-
queryStyles,
|
|
51
|
-
paramsStyles,
|
|
52
|
-
spec,
|
|
53
|
-
prefix,
|
|
54
|
-
};
|
|
55
|
-
return {
|
|
56
|
-
...meta,
|
|
57
|
-
'~openapi': merged,
|
|
58
|
-
};
|
|
59
|
-
},
|
|
4
|
+
* Creates OpenAPI meta plugins that control how a procedure is exposed over HTTP,
|
|
5
|
+
* such as its method, path, prefix, and OpenAPI operation spec.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link https://orpc.dev/docs/openapi/routing | OpenAPI Routing}
|
|
8
|
+
* @see {@link https://orpc.dev/docs/openapi/specification | OpenAPI Specification}
|
|
9
|
+
*/
|
|
10
|
+
const openapi = (incoming) => ({
|
|
11
|
+
name: "~openapi",
|
|
12
|
+
init(meta) {
|
|
13
|
+
const existing = meta["~openapi"];
|
|
14
|
+
const tags = existing?.tags && incoming.tags ? [...existing.tags, ...incoming.tags] : "tags" in incoming ? incoming.tags : existing?.tags;
|
|
15
|
+
const queryStyles = existing?.queryStyles && incoming.queryStyles ? {
|
|
16
|
+
...existing.queryStyles,
|
|
17
|
+
...incoming.queryStyles
|
|
18
|
+
} : "queryStyles" in incoming ? incoming.queryStyles : existing?.queryStyles;
|
|
19
|
+
const paramsStyles = existing?.paramsStyles && incoming.paramsStyles ? {
|
|
20
|
+
...existing.paramsStyles,
|
|
21
|
+
...incoming.paramsStyles
|
|
22
|
+
} : "paramsStyles" in incoming ? incoming.paramsStyles : existing?.paramsStyles;
|
|
23
|
+
const existingSpec = existing?.spec;
|
|
24
|
+
const incomingSpec = incoming.spec;
|
|
25
|
+
const spec = typeof existingSpec === "function" && typeof incomingSpec === "function" ? (current) => incomingSpec(existingSpec(current)) : typeof existingSpec === "function" && typeof incomingSpec === "object" ? existingSpec(incomingSpec) : typeof existingSpec === "object" && typeof incomingSpec === "function" ? incomingSpec(existingSpec) : "spec" in incoming ? incomingSpec : existingSpec;
|
|
26
|
+
const prefix = existing?.prefix && incoming.prefix ? mergeHttpPath(existing.prefix, incoming.prefix) : "prefix" in incoming ? incoming.prefix : existing?.prefix;
|
|
27
|
+
const merged = {
|
|
28
|
+
...existing,
|
|
29
|
+
...incoming,
|
|
30
|
+
tags,
|
|
31
|
+
queryStyles,
|
|
32
|
+
paramsStyles,
|
|
33
|
+
spec,
|
|
34
|
+
prefix
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
...meta,
|
|
38
|
+
"~openapi": merged
|
|
39
|
+
};
|
|
40
|
+
}
|
|
60
41
|
});
|
|
61
42
|
openapi.method = (method) => ({
|
|
62
|
-
|
|
63
|
-
|
|
43
|
+
...openapi({ method }),
|
|
44
|
+
name: "~openapi/method"
|
|
64
45
|
});
|
|
65
46
|
openapi.path = (path) => ({
|
|
66
|
-
|
|
67
|
-
|
|
47
|
+
...openapi({ path }),
|
|
48
|
+
name: "~openapi/path"
|
|
68
49
|
});
|
|
69
50
|
openapi.spec = (spec) => ({
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
...openapi({ spec }),
|
|
52
|
+
name: "~openapi/spec"
|
|
72
53
|
});
|
|
73
54
|
openapi.prefix = (prefix) => ({
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
...openapi({ prefix }),
|
|
56
|
+
name: "~openapi/prefix"
|
|
76
57
|
});
|
|
77
58
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
59
|
+
* Retrieves the OpenAPI metadata attached to a procedure or router, or `undefined` if not set.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link https://orpc.dev/docs/rpc/handler#enabling-the-get-method | RPC Handler - Enabling the GET Method}
|
|
62
|
+
*/
|
|
63
|
+
function getOpenAPIMeta(procedureOrLazy) {
|
|
64
|
+
return procedureOrLazy["~orpc"].meta["~openapi"];
|
|
84
65
|
}
|
|
66
|
+
export { getOpenAPIMeta, openapi };
|
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
/**
|
|
4
|
-
* Collects reusable schemas into `doc.components.schemas`.
|
|
5
|
-
*
|
|
6
|
-
* Equivalent schemas (including recursive ones) reuse a single component, and different
|
|
7
|
-
* schemas competing for the same name get direction-suffixed or numbered postfixes.
|
|
8
|
-
*/
|
|
9
|
-
export declare class OpenAPIComponentRegistry {
|
|
10
|
-
private readonly doc;
|
|
11
|
-
private readonly componentName;
|
|
12
|
-
/**
|
|
13
|
-
* The unsanitized name each minted component was requested under, so distinct names
|
|
14
|
-
* that sanitize to the same key (`User Profile`, `User_Profile`) are never merged.
|
|
15
|
-
* Components the registry did not mint are reusable only when the requested name needs
|
|
16
|
-
* no sanitizing, which keeps `base.components` family reuse (`Planet`, `Planet2`) intact.
|
|
17
|
-
*/
|
|
18
|
-
private readonly componentSources;
|
|
19
|
-
constructor(doc: OpenAPIV3_2.OpenAPIObject, componentName: ((defName: string, defSchema: JsonSchema) => string) | undefined);
|
|
20
|
-
/**
|
|
21
|
-
* Registers `schema` as a component under `preferredName` (or an equivalent/postfixed name)
|
|
22
|
-
* and returns a `$ref` to it.
|
|
23
|
-
*/
|
|
24
|
-
register(preferredName: string, schema: Exclude<JsonSchema, boolean>): JsonSchema;
|
|
25
|
-
/**
|
|
26
|
-
* Moves a schema's root-level `$defs` into `doc.components.schemas` and rewrites
|
|
27
|
-
* its refs accordingly.
|
|
28
|
-
*/
|
|
29
|
-
hoistDefs(schema: JsonSchema, direction?: JsonSchemaConverterDirection): JsonSchema;
|
|
30
|
-
toOpenAPISchema(schema: JsonSchema, direction?: JsonSchemaConverterDirection): OpenAPIV3_2.SchemaObject;
|
|
31
|
-
}
|
|
1
|
+
import "./types.js";
|
|
2
|
+
import "@orpc/json-schema";
|