@tsed/schema 8.3.5 → 8.3.6
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/.barrelsby.json +1 -1
- package/lib/browser/schema.umd.min.js +1 -1
- package/lib/browser/schema.umd.min.js.map +1 -1
- package/lib/esm/components/open-spec/pathsMapper.js +1 -0
- package/lib/esm/components/open-spec/pathsMapper.js.map +1 -1
- package/lib/esm/decorators/operations/operation.js +5 -1
- package/lib/esm/decorators/operations/operation.js.map +1 -1
- package/lib/esm/domain/JsonOperation.js +19 -7
- package/lib/esm/domain/JsonOperation.js.map +1 -1
- package/lib/esm/domain/__fixtures__/inspectOperationsPaths.js +7 -0
- package/lib/esm/domain/__fixtures__/inspectOperationsPaths.js.map +1 -0
- package/lib/types/domain/JsonOperation.d.ts +6 -4
- package/lib/types/domain/__fixtures__/inspectOperationsPaths.d.ts +5 -0
- package/package.json +10 -10
- package/src/components/open-spec/pathsMapper.ts +1 -0
- package/src/decorators/operations/operation.ts +8 -1
- package/src/decorators/operations/publish.spec.ts +2 -1
- package/src/decorators/operations/route.spec.ts +10 -9
- package/src/decorators/operations/subscribe.spec.ts +2 -1
- package/src/domain/JsonMethodStore.spec.ts +7 -9
- package/src/domain/JsonOperation.ts +23 -11
- package/src/domain/JsonOperationRoute.spec.ts +11 -16
- package/src/domain/__fixtures__/inspectOperationsPaths.ts +8 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathsMapper.js","sourceRoot":"","sources":["../../../../src/components/open-spec/pathsMapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,mCAAmC,CAAC;AAIjE,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,+CAA+C,CAAC;AACnG,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAC,kBAAkB,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AAED,wBAAwB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC"}
|
|
@@ -9,7 +9,9 @@ class OperationDecoratorContext extends DecoratorContext {
|
|
|
9
9
|
beforeInit() {
|
|
10
10
|
const path = this.get("path");
|
|
11
11
|
const method = OperationVerbs[this.get("method")] || OperationVerbs.CUSTOM;
|
|
12
|
-
|
|
12
|
+
if (path) {
|
|
13
|
+
this.operationPath = this.entity.operation.addOperationPath(method, path);
|
|
14
|
+
}
|
|
13
15
|
}
|
|
14
16
|
onMapKey(key, value) {
|
|
15
17
|
switch (key) {
|
|
@@ -18,9 +20,11 @@ class OperationDecoratorContext extends DecoratorContext {
|
|
|
18
20
|
this.entity.operation.operationId(value);
|
|
19
21
|
return;
|
|
20
22
|
case "summary":
|
|
23
|
+
this.operationPath?.summary(value);
|
|
21
24
|
this.entity.operation.summary(value);
|
|
22
25
|
return;
|
|
23
26
|
case "description":
|
|
27
|
+
this.operationPath?.description(value);
|
|
24
28
|
this.entity.operation.description(value);
|
|
25
29
|
return;
|
|
26
30
|
case "use":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/decorators/operations/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/decorators/operations/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAC;AAGlE,OAAO,EAAC,mBAAmB,EAAC,MAAM,oCAAoC,CAAC;AAiDvE,MAAM,yBAA0B,SAAQ,gBAAwC;IAAhF;;QACW,YAAO,GAAa,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EA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AAK,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;CACF;AAwBD,MAAM,UAAU,SAAS,CAAC,GAAG,IAAW;IACtC,MAAM,YAAY,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAI,yBAAyB,CAAC,YAAY,CAAC,CAAC;IAE5D,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -2,6 +2,21 @@ import { deepMerge, uniq, uniqBy } from "@tsed/core";
|
|
|
2
2
|
import { isRedirectionStatus, isSuccessStatus } from "../utils/isSuccessStatus.js";
|
|
3
3
|
import { JsonMap } from "./JsonMap.js";
|
|
4
4
|
import { JsonResponse } from "./JsonResponse.js";
|
|
5
|
+
export class JsonMethodPath extends JsonMap {
|
|
6
|
+
constructor(method, path) {
|
|
7
|
+
super();
|
|
8
|
+
this.method = method;
|
|
9
|
+
this.path = path;
|
|
10
|
+
}
|
|
11
|
+
summary(summary) {
|
|
12
|
+
super.set("summary", summary);
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
description(description) {
|
|
16
|
+
super.set("description", description);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
5
20
|
export class JsonOperation extends JsonMap {
|
|
6
21
|
#status;
|
|
7
22
|
#redirection;
|
|
@@ -134,13 +149,10 @@ export class JsonOperation extends JsonMap {
|
|
|
134
149
|
const produces = uniq([].concat(this.get("produces"), produce)).filter(Boolean);
|
|
135
150
|
this.set("produces", produces);
|
|
136
151
|
}
|
|
137
|
-
addOperationPath(method, path
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
path
|
|
142
|
-
});
|
|
143
|
-
return this;
|
|
152
|
+
addOperationPath(method, path) {
|
|
153
|
+
const operationPath = new JsonMethodPath(method, path);
|
|
154
|
+
this.operationPaths.set(String(method) + String(path), operationPath);
|
|
155
|
+
return operationPath;
|
|
144
156
|
}
|
|
145
157
|
getAllowedOperationPath(allowedVerbs) {
|
|
146
158
|
if (!allowedVerbs) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonOperation.js","sourceRoot":"","sources":["../../../src/domain/JsonOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AAInD,OAAO,EAAC,mBAAmB,EAAE,eAAe,EAAC,MAAM,6BAA6B,CAAC;AACjF,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"JsonOperation.js","sourceRoot":"","sources":["../../../src/domain/JsonOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AAInD,OAAO,EAAC,mBAAmB,EAAE,eAAe,EAAC,MAAM,6BAA6B,CAAC;AACjF,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG/C,MAAM,OAAO,cAAe,SAAQ,OAAY;IAC9C,YACS,MAAc,EACd,IAAqB;QAE5B,KAAK,EAAE,CAAC;QAHD,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAiB;IAG9B,CAAC;IAED,OAAO,CAAC,OAAe;QACrB,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,WAAmB;QAC7B,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAEtC,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAOD,MAAM,OAAO,aAAc,SAAQ,OAA6B;IAK9D,OAAO,CAAS;IAChB,YAAY,CAAkB;I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../src/domain/__fixtures__/inspectOperationsPaths.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CAAC,QAAyB;IAC9D,OAAO,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,EAAE,EAAE,CAAC,CAAC;QACpE,MAAM;QACN,IAAI;KACL,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -4,10 +4,12 @@ import { JsonMap } from "./JsonMap.js";
|
|
|
4
4
|
import { JsonParameter } from "./JsonParameter.js";
|
|
5
5
|
import { JsonResponse } from "./JsonResponse.js";
|
|
6
6
|
import { JsonSchema } from "./JsonSchema.js";
|
|
7
|
-
export
|
|
8
|
-
path: string | RegExp;
|
|
7
|
+
export declare class JsonMethodPath extends JsonMap<any> {
|
|
9
8
|
method: string;
|
|
10
|
-
|
|
9
|
+
path: string | RegExp;
|
|
10
|
+
constructor(method: string, path: string | RegExp);
|
|
11
|
+
summary(summary: string): this;
|
|
12
|
+
description(description: string): this;
|
|
11
13
|
}
|
|
12
14
|
export interface JsonOperationOptions extends OS3Operation<JsonSchema, JsonParameter, JsonMap<JsonResponse>> {
|
|
13
15
|
consumes: string[];
|
|
@@ -46,6 +48,6 @@ export declare class JsonOperation extends JsonMap<JsonOperationOptions> {
|
|
|
46
48
|
consumes(consumes: string[]): this;
|
|
47
49
|
produces(produces: string[]): this;
|
|
48
50
|
addProduce(produce: string): void;
|
|
49
|
-
addOperationPath(method: string, path: string | RegExp
|
|
51
|
+
addOperationPath(method: string, path: string | RegExp): JsonMethodPath;
|
|
50
52
|
getAllowedOperationPath(allowedVerbs?: string[]): JsonMethodPath[];
|
|
51
53
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/schema",
|
|
3
3
|
"description": "JsonSchema module for Ts.ED Framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.3.
|
|
5
|
+
"version": "8.3.6",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"tsed"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@tsed/openspec": "8.3.
|
|
40
|
+
"@tsed/openspec": "8.3.6",
|
|
41
41
|
"change-case": "^5.4.4",
|
|
42
42
|
"json-schema": "0.4.0",
|
|
43
43
|
"picomatch": "2.3.1",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@apidevtools/swagger-parser": "10.1.0",
|
|
49
|
-
"@tsed/barrels": "8.3.
|
|
50
|
-
"@tsed/core": "8.3.
|
|
51
|
-
"@tsed/hooks": "8.3.
|
|
52
|
-
"@tsed/openspec": "8.3.
|
|
53
|
-
"@tsed/typescript": "8.3.
|
|
49
|
+
"@tsed/barrels": "8.3.6",
|
|
50
|
+
"@tsed/core": "8.3.6",
|
|
51
|
+
"@tsed/hooks": "8.3.6",
|
|
52
|
+
"@tsed/openspec": "8.3.6",
|
|
53
|
+
"@tsed/typescript": "8.3.6",
|
|
54
54
|
"@types/fs-extra": "11.0.4",
|
|
55
55
|
"@types/json-schema": "7.0.15",
|
|
56
56
|
"@types/picomatch": "3.0.1",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"webpack": "^5.75.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@tsed/core": "8.3.
|
|
67
|
-
"@tsed/hooks": "8.3.
|
|
68
|
-
"@tsed/openspec": "8.3.
|
|
66
|
+
"@tsed/core": "8.3.6",
|
|
67
|
+
"@tsed/hooks": "8.3.6",
|
|
68
|
+
"@tsed/openspec": "8.3.6"
|
|
69
69
|
},
|
|
70
70
|
"peerDependenciesMeta": {
|
|
71
71
|
"@tsed/core": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {OperationVerbs} from "../../constants/OperationVerbs.js";
|
|
2
2
|
import {DecoratorContext} from "../../domain/DecoratorContext.js";
|
|
3
3
|
import {JsonMethodStore} from "../../domain/JsonMethodStore.js";
|
|
4
|
+
import {JsonMethodPath, type JsonOperation} from "../../domain/JsonOperation.js";
|
|
4
5
|
import {mapOperationOptions} from "../../utils/mapOperationOptions.js";
|
|
5
6
|
|
|
6
7
|
export interface RouteChainedDecorators {
|
|
@@ -53,12 +54,15 @@ export interface RouteChainedDecorators {
|
|
|
53
54
|
class OperationDecoratorContext extends DecoratorContext<RouteChainedDecorators> {
|
|
54
55
|
readonly methods: string[] = ["name", "description", "summary", "method", "id", "use", "useAfter", "useBefore"];
|
|
55
56
|
protected declare entity: JsonMethodStore;
|
|
57
|
+
protected operationPath: JsonMethodPath;
|
|
56
58
|
|
|
57
59
|
protected beforeInit() {
|
|
58
60
|
const path: string = this.get("path");
|
|
59
61
|
const method: string = OperationVerbs[this.get("method") as OperationVerbs] || OperationVerbs.CUSTOM;
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
if (path) {
|
|
64
|
+
this.operationPath = this.entity.operation.addOperationPath(method, path);
|
|
65
|
+
}
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
protected onMapKey(key: string, value: any) {
|
|
@@ -68,10 +72,13 @@ class OperationDecoratorContext extends DecoratorContext<RouteChainedDecorators>
|
|
|
68
72
|
this.entity.operation.operationId(value);
|
|
69
73
|
return;
|
|
70
74
|
case "summary":
|
|
75
|
+
this.operationPath?.summary(value);
|
|
71
76
|
this.entity.operation.summary(value);
|
|
72
77
|
return;
|
|
73
78
|
case "description":
|
|
79
|
+
this.operationPath?.description(value);
|
|
74
80
|
this.entity.operation.description(value);
|
|
81
|
+
|
|
75
82
|
return;
|
|
76
83
|
case "use":
|
|
77
84
|
this.entity.use(value);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../../index.js";
|
|
2
2
|
|
|
3
3
|
import {OperationVerbs} from "../../constants/OperationVerbs.js";
|
|
4
|
+
import {inspectOperationsPaths} from "../../domain/__fixtures__/inspectOperationsPaths.js";
|
|
4
5
|
import {JsonEntityStore} from "../../domain/JsonEntityStore.js";
|
|
5
6
|
import {Publish} from "./publish.js";
|
|
6
7
|
|
|
@@ -15,7 +16,7 @@ describe("Publish", () => {
|
|
|
15
16
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
16
17
|
|
|
17
18
|
// THEN
|
|
18
|
-
expect(
|
|
19
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
19
20
|
{
|
|
20
21
|
method: OperationVerbs.PUBLISH,
|
|
21
22
|
path: "event"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {inspectOperationsPaths} from "../../domain/__fixtures__/inspectOperationsPaths.js";
|
|
1
2
|
import {JsonEntityStore, OperationVerbs} from "../../index.js";
|
|
2
3
|
import {All, Delete, Get, Head, Options, Patch, Post, Put} from "./route.js";
|
|
3
4
|
|
|
@@ -13,7 +14,7 @@ describe("Route decorators", () => {
|
|
|
13
14
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
14
15
|
|
|
15
16
|
// THEN
|
|
16
|
-
expect(
|
|
17
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
17
18
|
{
|
|
18
19
|
method: OperationVerbs.ALL,
|
|
19
20
|
path: "/"
|
|
@@ -34,7 +35,7 @@ describe("Route decorators", () => {
|
|
|
34
35
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
35
36
|
|
|
36
37
|
// THEN
|
|
37
|
-
expect(
|
|
38
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
38
39
|
{
|
|
39
40
|
method: OperationVerbs.GET,
|
|
40
41
|
path: "/"
|
|
@@ -54,7 +55,7 @@ describe("Route decorators", () => {
|
|
|
54
55
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
55
56
|
|
|
56
57
|
// THEN
|
|
57
|
-
expect(
|
|
58
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
58
59
|
{
|
|
59
60
|
method: OperationVerbs.GET,
|
|
60
61
|
path: "/"
|
|
@@ -91,7 +92,7 @@ describe("Route decorators", () => {
|
|
|
91
92
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
92
93
|
|
|
93
94
|
// THEN
|
|
94
|
-
expect(
|
|
95
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
95
96
|
{
|
|
96
97
|
method: OperationVerbs.POST,
|
|
97
98
|
path: "/"
|
|
@@ -112,7 +113,7 @@ describe("Route decorators", () => {
|
|
|
112
113
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
113
114
|
|
|
114
115
|
// THEN
|
|
115
|
-
expect(
|
|
116
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
116
117
|
{
|
|
117
118
|
method: OperationVerbs.PUT,
|
|
118
119
|
path: "/"
|
|
@@ -136,7 +137,7 @@ describe("Route decorators", () => {
|
|
|
136
137
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
137
138
|
|
|
138
139
|
// THEN
|
|
139
|
-
expect(
|
|
140
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
140
141
|
{
|
|
141
142
|
method: OperationVerbs.DELETE,
|
|
142
143
|
path: "/"
|
|
@@ -157,7 +158,7 @@ describe("Route decorators", () => {
|
|
|
157
158
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
158
159
|
|
|
159
160
|
// THEN
|
|
160
|
-
expect(
|
|
161
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
161
162
|
{
|
|
162
163
|
method: OperationVerbs.HEAD,
|
|
163
164
|
path: "/"
|
|
@@ -178,7 +179,7 @@ describe("Route decorators", () => {
|
|
|
178
179
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
179
180
|
|
|
180
181
|
// THEN
|
|
181
|
-
expect(
|
|
182
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
182
183
|
{
|
|
183
184
|
method: OperationVerbs.PATCH,
|
|
184
185
|
path: "/"
|
|
@@ -199,7 +200,7 @@ describe("Route decorators", () => {
|
|
|
199
200
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
200
201
|
|
|
201
202
|
// THEN
|
|
202
|
-
expect(
|
|
203
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
203
204
|
{
|
|
204
205
|
method: OperationVerbs.OPTIONS,
|
|
205
206
|
path: "/"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../../index.js";
|
|
2
2
|
|
|
3
3
|
import {OperationVerbs} from "../../constants/OperationVerbs.js";
|
|
4
|
+
import {inspectOperationsPaths} from "../../domain/__fixtures__/inspectOperationsPaths.js";
|
|
4
5
|
import {JsonEntityStore} from "../../domain/JsonEntityStore.js";
|
|
5
6
|
import {Publish} from "./publish.js";
|
|
6
7
|
import {Subscribe} from "./subscribe.js";
|
|
@@ -17,7 +18,7 @@ describe("Subscribe", () => {
|
|
|
17
18
|
const endpoint = JsonEntityStore.fromMethod(Test, "test");
|
|
18
19
|
|
|
19
20
|
// THEN
|
|
20
|
-
expect(
|
|
21
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
21
22
|
{
|
|
22
23
|
method: OperationVerbs.SUBSCRIBE,
|
|
23
24
|
path: "event"
|
|
@@ -7,6 +7,7 @@ import {Property} from "../decorators/common/property.js";
|
|
|
7
7
|
import {In} from "../decorators/operations/in.js";
|
|
8
8
|
import {Returns} from "../decorators/operations/returns.js";
|
|
9
9
|
import {Get} from "../decorators/operations/route.js";
|
|
10
|
+
import {inspectOperationsPaths} from "./__fixtures__/inspectOperationsPaths.js";
|
|
10
11
|
import {JsonEntityStore} from "./JsonEntityStore.js";
|
|
11
12
|
import {EndpointMetadata, JsonMethodStore} from "./JsonMethodStore.js";
|
|
12
13
|
import {JsonOperation} from "./JsonOperation.js";
|
|
@@ -124,7 +125,7 @@ describe("JsonMethodStore", () => {
|
|
|
124
125
|
// THEN
|
|
125
126
|
expect(endpoint.middlewares).toHaveLength(1);
|
|
126
127
|
|
|
127
|
-
expect(
|
|
128
|
+
expect(inspectOperationsPaths(endpoint)).toEqual([
|
|
128
129
|
{
|
|
129
130
|
method: OperationVerbs.GET,
|
|
130
131
|
path: "/"
|
|
@@ -263,14 +264,11 @@ describe("JsonMethodStore", () => {
|
|
|
263
264
|
expect(storeMethod?.parameters.length).toEqual(1);
|
|
264
265
|
expect(storeMethod?.params.length).toEqual(1);
|
|
265
266
|
|
|
266
|
-
expect(
|
|
267
|
-
|
|
268
|
-
"GET
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
path: "/"
|
|
272
|
-
}
|
|
273
|
-
]
|
|
267
|
+
expect(inspectOperationsPaths(storeMethod as JsonMethodStore)).toEqual([
|
|
268
|
+
{
|
|
269
|
+
method: "GET",
|
|
270
|
+
path: "/"
|
|
271
|
+
}
|
|
274
272
|
]);
|
|
275
273
|
expect(storeMethod?.getResponseOptions(200)).toEqual({
|
|
276
274
|
groups: undefined,
|
|
@@ -8,11 +8,25 @@ import {JsonParameter} from "./JsonParameter.js";
|
|
|
8
8
|
import {JsonResponse} from "./JsonResponse.js";
|
|
9
9
|
import {JsonSchema} from "./JsonSchema.js";
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export class JsonMethodPath extends JsonMap<any> {
|
|
12
|
+
constructor(
|
|
13
|
+
public method: string,
|
|
14
|
+
public path: string | RegExp
|
|
15
|
+
) {
|
|
16
|
+
super();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
summary(summary: string): this {
|
|
20
|
+
super.set("summary", summary);
|
|
21
|
+
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
14
24
|
|
|
15
|
-
|
|
25
|
+
description(description: string): this {
|
|
26
|
+
super.set("description", description);
|
|
27
|
+
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
16
30
|
}
|
|
17
31
|
|
|
18
32
|
export interface JsonOperationOptions extends OS3Operation<JsonSchema, JsonParameter, JsonMap<JsonResponse>> {
|
|
@@ -24,6 +38,7 @@ export class JsonOperation extends JsonMap<JsonOperationOptions> {
|
|
|
24
38
|
$kind: string = "operation";
|
|
25
39
|
|
|
26
40
|
readonly operationPaths: Map<string, JsonMethodPath> = new Map();
|
|
41
|
+
|
|
27
42
|
#status: number;
|
|
28
43
|
#redirection: boolean = false;
|
|
29
44
|
|
|
@@ -199,14 +214,11 @@ export class JsonOperation extends JsonMap<JsonOperationOptions> {
|
|
|
199
214
|
this.set("produces", produces);
|
|
200
215
|
}
|
|
201
216
|
|
|
202
|
-
addOperationPath(method: string, path: string | RegExp
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
method,
|
|
206
|
-
path
|
|
207
|
-
});
|
|
217
|
+
addOperationPath(method: string, path: string | RegExp) {
|
|
218
|
+
const operationPath = new JsonMethodPath(method, path);
|
|
219
|
+
this.operationPaths.set(String(method) + String(path), operationPath);
|
|
208
220
|
|
|
209
|
-
return
|
|
221
|
+
return operationPath;
|
|
210
222
|
}
|
|
211
223
|
|
|
212
224
|
getAllowedOperationPath(allowedVerbs?: string[]) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {BodyParams} from "@tsed/platform-params";
|
|
2
2
|
|
|
3
|
+
import {OperationVerbs} from "../constants/OperationVerbs.js";
|
|
3
4
|
import {Name} from "../decorators/common/name.js";
|
|
4
5
|
import {Get} from "../decorators/operations/route.js";
|
|
5
6
|
import {JsonEntityStore} from "./JsonEntityStore.js";
|
|
6
|
-
import {JsonOperation} from "./JsonOperation.js";
|
|
7
|
+
import {JsonMethodPath, JsonOperation} from "./JsonOperation.js";
|
|
7
8
|
import {JsonOperationRoute} from "./JsonOperationRoute.js";
|
|
8
9
|
|
|
9
10
|
describe("JsonOperationRoute", () => {
|
|
@@ -17,14 +18,12 @@ describe("JsonOperationRoute", () => {
|
|
|
17
18
|
const operationRoute = new JsonOperationRoute({
|
|
18
19
|
token: Test,
|
|
19
20
|
endpoint,
|
|
20
|
-
operationPath:
|
|
21
|
+
operationPath: new JsonMethodPath("GET", "/"),
|
|
21
22
|
basePath: "/base"
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
expect(operationRoute.operationPath).toEqual(
|
|
25
|
-
|
|
26
|
-
path: "/"
|
|
27
|
-
});
|
|
25
|
+
expect(operationRoute.operationPath?.method).toEqual("GET");
|
|
26
|
+
expect(operationRoute.operationPath?.path).toEqual("/");
|
|
28
27
|
expect(operationRoute.method).toEqual("GET");
|
|
29
28
|
expect(operationRoute.path).toEqual("/");
|
|
30
29
|
expect(operationRoute.fullPath).toEqual("/base");
|
|
@@ -50,14 +49,12 @@ describe("JsonOperationRoute", () => {
|
|
|
50
49
|
const operationRoute = new JsonOperationRoute({
|
|
51
50
|
token: Test,
|
|
52
51
|
endpoint,
|
|
53
|
-
operationPath:
|
|
52
|
+
operationPath: new JsonMethodPath(OperationVerbs.GET, "/"),
|
|
54
53
|
basePath: "/base"
|
|
55
54
|
});
|
|
56
55
|
|
|
57
|
-
expect(operationRoute.operationPath).toEqual(
|
|
58
|
-
|
|
59
|
-
path: "/"
|
|
60
|
-
});
|
|
56
|
+
expect(operationRoute.operationPath?.method).toEqual("GET");
|
|
57
|
+
expect(operationRoute.operationPath?.path).toEqual("/");
|
|
61
58
|
expect(operationRoute.method).toEqual("GET");
|
|
62
59
|
expect(operationRoute.path).toEqual("/");
|
|
63
60
|
expect(operationRoute.fullPath).toEqual("/base");
|
|
@@ -82,14 +79,12 @@ describe("JsonOperationRoute", () => {
|
|
|
82
79
|
const operationRoute = new JsonOperationRoute({
|
|
83
80
|
token: Test,
|
|
84
81
|
endpoint,
|
|
85
|
-
operationPath:
|
|
82
|
+
operationPath: new JsonMethodPath("GET", "/"),
|
|
86
83
|
basePath: "/base"
|
|
87
84
|
});
|
|
88
85
|
|
|
89
|
-
expect(operationRoute.operationPath).toEqual(
|
|
90
|
-
|
|
91
|
-
path: "/"
|
|
92
|
-
});
|
|
86
|
+
expect(operationRoute.operationPath?.method).toEqual("GET");
|
|
87
|
+
expect(operationRoute.operationPath?.path).toEqual("/");
|
|
93
88
|
expect(operationRoute.method).toEqual("GET");
|
|
94
89
|
expect(operationRoute.path).toEqual("/");
|
|
95
90
|
expect(operationRoute.fullPath).toEqual("/base");
|