@tsed/platform-test-sdk 7.79.4 → 7.80.1

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.
Files changed (102) hide show
  1. package/lib/cjs/tests/testHeaders.js +8 -24
  2. package/lib/cjs/tests/testHeaders.js.map +1 -1
  3. package/lib/cjs/tests/testInheritanceController.js +2 -1
  4. package/lib/cjs/tests/testInheritanceController.js.map +1 -1
  5. package/lib/cjs/tests/testMulter.js +5 -3
  6. package/lib/cjs/tests/testMulter.js.map +1 -1
  7. package/lib/cjs/tests/testRouting.js +4 -2
  8. package/lib/cjs/tests/testRouting.js.map +1 -1
  9. package/lib/cjs/tests/testStream.js +1 -1
  10. package/lib/esm/tests/testHeaders.js +8 -24
  11. package/lib/esm/tests/testHeaders.js.map +1 -1
  12. package/lib/esm/tests/testInheritanceController.js +2 -1
  13. package/lib/esm/tests/testInheritanceController.js.map +1 -1
  14. package/lib/esm/tests/testMulter.js +6 -4
  15. package/lib/esm/tests/testMulter.js.map +1 -1
  16. package/lib/esm/tests/testRouting.js +4 -2
  17. package/lib/esm/tests/testRouting.js.map +1 -1
  18. package/lib/esm/tests/testStream.js +1 -1
  19. package/lib/types-esm/components/PlatformTestSdk.d.ts +9 -0
  20. package/lib/types-esm/errors/CustomBadRequest.d.ts +8 -0
  21. package/lib/types-esm/errors/CustomInternalError.d.ts +8 -0
  22. package/lib/types-esm/interfaces/PlatformTestingSdkOpts.d.ts +8 -0
  23. package/lib/types-esm/modules/feature/FeatureModule.d.ts +2 -0
  24. package/lib/types-esm/modules/feature/controllers/FeatureController.d.ts +3 -0
  25. package/lib/types-esm/tests/exports.d.ts +2 -0
  26. package/lib/types-esm/tests/testAcceptMime.d.ts +2 -0
  27. package/lib/types-esm/tests/testAuth.d.ts +8 -0
  28. package/lib/types-esm/tests/testBodyParams.d.ts +3 -0
  29. package/lib/types-esm/tests/testCache.d.ts +2 -0
  30. package/lib/types-esm/tests/testChildrenControllers.d.ts +2 -0
  31. package/lib/types-esm/tests/testCookies.d.ts +11 -0
  32. package/lib/types-esm/tests/testCustom404.d.ts +2 -0
  33. package/lib/types-esm/tests/testDeepQueryParams.d.ts +3 -0
  34. package/lib/types-esm/tests/testErrors.d.ts +19 -0
  35. package/lib/types-esm/tests/testHandlers.d.ts +12 -0
  36. package/lib/types-esm/tests/testHeaderParams.d.ts +16 -0
  37. package/lib/types-esm/tests/testHeaders.d.ts +8 -0
  38. package/lib/types-esm/tests/testInheritanceController.d.ts +42 -0
  39. package/lib/types-esm/tests/testLocals.d.ts +2 -0
  40. package/lib/types-esm/tests/testLocation.d.ts +2 -0
  41. package/lib/types-esm/tests/testMiddlewares.d.ts +8 -0
  42. package/lib/types-esm/tests/testModule.d.ts +2 -0
  43. package/lib/types-esm/tests/testMulter.d.ts +21 -0
  44. package/lib/types-esm/tests/testPathParams.d.ts +2 -0
  45. package/lib/types-esm/tests/testQueryParams.d.ts +6 -0
  46. package/lib/types-esm/tests/testRedirect.d.ts +2 -0
  47. package/lib/types-esm/tests/testResponse.d.ts +16 -0
  48. package/lib/types-esm/tests/testResponseFilter.d.ts +2 -0
  49. package/lib/types-esm/tests/testRouting.d.ts +7 -0
  50. package/lib/types-esm/tests/testScopeRequest.d.ts +12 -0
  51. package/lib/types-esm/tests/testSession.d.ts +16 -0
  52. package/lib/types-esm/tests/testStatics.d.ts +2 -0
  53. package/lib/types-esm/tests/testStream.d.ts +2 -0
  54. package/lib/types-esm/tests/testView.d.ts +2 -0
  55. package/package.json +22 -20
  56. package/lib/cjs/package.json +0 -3
  57. package/lib/esm/package.json +0 -3
  58. package/lib/tsconfig.esm.tsbuildinfo +0 -1
  59. package/lib/tsconfig.tsbuildinfo +0 -1
  60. package/src/components/PlatformTestSdk.ts +0 -29
  61. package/src/data/file.txt +0 -1
  62. package/src/data/response.data.json +0 -3
  63. package/src/data/swagger.json +0 -32
  64. package/src/errors/CustomBadRequest.ts +0 -16
  65. package/src/errors/CustomInternalError.ts +0 -16
  66. package/src/interfaces/PlatformTestingSdkOpts.ts +0 -10
  67. package/src/modules/feature/FeatureModule.ts +0 -9
  68. package/src/modules/feature/controllers/FeatureController.ts +0 -11
  69. package/src/tests/exports.ts +0 -71
  70. package/src/tests/testAcceptMime.ts +0 -95
  71. package/src/tests/testAuth.ts +0 -339
  72. package/src/tests/testBodyParams.ts +0 -483
  73. package/src/tests/testCache.ts +0 -279
  74. package/src/tests/testChildrenControllers.ts +0 -55
  75. package/src/tests/testCookies.ts +0 -36
  76. package/src/tests/testCustom404.ts +0 -33
  77. package/src/tests/testDeepQueryParams.ts +0 -120
  78. package/src/tests/testErrors.ts +0 -226
  79. package/src/tests/testHandlers.ts +0 -90
  80. package/src/tests/testHeaderParams.ts +0 -152
  81. package/src/tests/testHeaders.ts +0 -91
  82. package/src/tests/testInheritanceController.ts +0 -200
  83. package/src/tests/testLocals.ts +0 -46
  84. package/src/tests/testLocation.ts +0 -37
  85. package/src/tests/testMiddlewares.ts +0 -159
  86. package/src/tests/testModule.ts +0 -46
  87. package/src/tests/testMulter.ts +0 -151
  88. package/src/tests/testPathParams.ts +0 -123
  89. package/src/tests/testQueryParams.ts +0 -233
  90. package/src/tests/testRedirect.ts +0 -124
  91. package/src/tests/testResponse.ts +0 -528
  92. package/src/tests/testResponseFilter.ts +0 -101
  93. package/src/tests/testRouting.ts +0 -65
  94. package/src/tests/testScopeRequest.ts +0 -111
  95. package/src/tests/testSession.ts +0 -103
  96. package/src/tests/testStatics.ts +0 -61
  97. package/src/tests/testStream.ts +0 -59
  98. package/src/tests/testView.ts +0 -68
  99. package/tsconfig.esm.json +0 -63
  100. package/tsconfig.json +0 -63
  101. /package/{src/index.ts → lib/types-esm/index.d.ts} +0 -0
  102. /package/{src/interfaces/index.ts → lib/types-esm/interfaces/index.d.ts} +0 -0
@@ -1,29 +0,0 @@
1
- import {PlatformTest} from "@tsed/common";
2
- import {PlatformTestingSdkOpts} from "../interfaces/index.js";
3
- import {specsContainer} from "../tests/exports.js";
4
-
5
- export class PlatformTestSdk {
6
- protected constructor(private options: PlatformTestingSdkOpts) {}
7
-
8
- static create(options: PlatformTestingSdkOpts) {
9
- return new PlatformTestSdk(options);
10
- }
11
-
12
- test(name: string, options: any = {}) {
13
- specsContainer.get(name)!({
14
- ...this.options,
15
- ...options
16
- });
17
- }
18
-
19
- bootstrap(options: any = {}) {
20
- return PlatformTest.bootstrap(this.options.server, {
21
- ...this.options,
22
- ...options
23
- });
24
- }
25
-
26
- reset() {
27
- return PlatformTest.reset;
28
- }
29
- }
package/src/data/file.txt DELETED
@@ -1 +0,0 @@
1
- test content
@@ -1,3 +0,0 @@
1
- {
2
- "id": "1"
3
- }
@@ -1,32 +0,0 @@
1
- {
2
- "openapi": "3.0.1",
3
- "info": {
4
- "version": "1.0.0",
5
- "description": "Swagger description",
6
- "title": "Swagger Title",
7
- "termsOfService": "http://swagger.io/terms/",
8
- "contact": {
9
- "email": "apiteam@swagger.io"
10
- },
11
- "license": {
12
- "name": "Apache 2.0",
13
- "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
14
- }
15
- },
16
- "components": {
17
- "securitySchemes": {
18
- "global_auth": {
19
- "type": "oauth2",
20
- "flows": {
21
- "implicit": {
22
- "authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
23
- "scopes": {
24
- "admin": "Admin access"
25
- }
26
- }
27
- }
28
- }
29
- }
30
- },
31
- "paths": {}
32
- }
@@ -1,16 +0,0 @@
1
- import {ResponseErrorObject} from "@tsed/common";
2
- import {BadRequest} from "@tsed/exceptions";
3
-
4
- export class CustomBadRequest extends BadRequest implements ResponseErrorObject {
5
- name = "CUSTOM_BAD_REQUEST";
6
- errors: any[];
7
- headers = {};
8
-
9
- constructor(message: string) {
10
- super(message);
11
- this.errors = ["test"];
12
- this.headers = {
13
- "X-HEADER-ERROR": "deny"
14
- };
15
- }
16
- }
@@ -1,16 +0,0 @@
1
- import {ResponseErrorObject} from "@tsed/common";
2
- import {InternalServerError} from "@tsed/exceptions";
3
-
4
- export class CustomInternalError extends InternalServerError implements ResponseErrorObject {
5
- name = "CUSTOM_INTERNAL_SERVER_ERROR";
6
- errors: any[];
7
- headers = {};
8
-
9
- constructor(message: string) {
10
- super(message);
11
- this.errors = ["test"];
12
- this.headers = {
13
- "X-HEADER-ERROR": "deny"
14
- };
15
- }
16
- }
@@ -1,10 +0,0 @@
1
- import {PlatformAdapter} from "@tsed/common";
2
- import {Type} from "@tsed/core";
3
-
4
- export interface PlatformTestingSdkOpts {
5
- rootDir: string;
6
- platform: Type<PlatformAdapter<any>>;
7
- server: Type<any>;
8
-
9
- [key: string]: any;
10
- }
@@ -1,9 +0,0 @@
1
- import {Module} from "@tsed/di";
2
- import {FeatureController} from "./controllers/FeatureController.js";
3
-
4
- @Module({
5
- mount: {
6
- "/rest": [FeatureController]
7
- }
8
- })
9
- export class FeatureModule {}
@@ -1,11 +0,0 @@
1
- import {Controller, Get} from "@tsed/common";
2
- import {Hidden} from "@tsed/swagger";
3
-
4
- @Hidden()
5
- @Controller("/features")
6
- export class FeatureController {
7
- @Get("/")
8
- get() {
9
- return "From feature";
10
- }
11
- }
@@ -1,71 +0,0 @@
1
- import {PlatformTestingSdkOpts} from "../interfaces/index.js";
2
- import {testAcceptMime} from "./testAcceptMime.js";
3
- import {testAuth} from "./testAuth.js";
4
- import {testBodyParams} from "./testBodyParams.js";
5
- import {testChildrenControllers} from "./testChildrenControllers.js";
6
- import {testCookies} from "./testCookies.js";
7
- import {testCustom404} from "./testCustom404.js";
8
- import {testDeepQueryParams} from "./testDeepQueryParams.js";
9
- import {testErrors} from "./testErrors.js";
10
- import {testHandlers} from "./testHandlers.js";
11
- import {testHeaderParams} from "./testHeaderParams.js";
12
- import {testHeaders} from "./testHeaders.js";
13
- import {testInheritanceController} from "./testInheritanceController.js";
14
- import {testLocals} from "./testLocals.js";
15
- import {testLocation} from "./testLocation.js";
16
- import {testMiddlewares} from "./testMiddlewares.js";
17
- import {testModule} from "./testModule.js";
18
- import {testMulter} from "./testMulter.js";
19
- import {testPathParams} from "./testPathParams.js";
20
- import {testQueryParams} from "./testQueryParams.js";
21
- import {testRedirect} from "./testRedirect.js";
22
- import {testResponse} from "./testResponse.js";
23
- import {testResponseFilter} from "./testResponseFilter.js";
24
- import {testRouting} from "./testRouting.js";
25
- import {testScopeRequest} from "./testScopeRequest.js";
26
- import {testSession} from "./testSession.js";
27
- import {testStatics} from "./testStatics.js";
28
- import {testStream} from "./testStream.js";
29
- import {testView} from "./testView.js";
30
- import {testCache} from "./testCache.js";
31
-
32
- export const specsContainer = new Map<string, (options: PlatformTestingSdkOpts) => void>();
33
-
34
- // HANDLERS AND MIDDLEWARES
35
- specsContainer.set("handlers", testHandlers);
36
- specsContainer.set("auth", testAuth);
37
- specsContainer.set("middlewares", testMiddlewares);
38
-
39
- // RESPONSES
40
- specsContainer.set("headers", testHeaders);
41
- specsContainer.set("acceptMime", testAcceptMime);
42
- specsContainer.set("location", testLocation);
43
- specsContainer.set("redirect", testRedirect);
44
- specsContainer.set("view", testView);
45
- specsContainer.set("errors", testErrors);
46
- specsContainer.set("response", testResponse);
47
- specsContainer.set("stream", testStream);
48
- specsContainer.set("responseFilter", testResponseFilter);
49
- specsContainer.set("custom404", testCustom404);
50
- specsContainer.set("statics", testStatics);
51
- specsContainer.set("cache", testCache);
52
-
53
- // INPUTS
54
- specsContainer.set("cookies", testCookies);
55
- specsContainer.set("session", testSession);
56
- specsContainer.set("headerParams", testHeaderParams);
57
- specsContainer.set("bodyParams", testBodyParams);
58
- specsContainer.set("pathParams", testPathParams);
59
- specsContainer.set("queryParams", testQueryParams);
60
- specsContainer.set("deepQueryParams", testDeepQueryParams);
61
- specsContainer.set("locals", testLocals);
62
- specsContainer.set("multer", testMulter);
63
-
64
- // ROUTING
65
- specsContainer.set("scopeRequest", testScopeRequest);
66
- specsContainer.set("routing", testRouting);
67
-
68
- // CODE ORGANIZATION
69
- specsContainer.set("childrenControllers", testChildrenControllers);
70
- specsContainer.set("inheritanceController", testInheritanceController);
71
- specsContainer.set("module", testModule);
@@ -1,95 +0,0 @@
1
- import {AcceptMime, Controller, Get, HeaderParams, PlatformTest, Post} from "@tsed/common";
2
- import {ContentType} from "@tsed/schema";
3
- import SuperTest from "supertest";
4
- import {PlatformTestingSdkOpts} from "../interfaces/index.js";
5
-
6
- @Controller("/accept-mime")
7
- class TestAcceptMimeCtrl {
8
- @Post("/scenario-1")
9
- @AcceptMime("application/json")
10
- scenario1(@HeaderParams("Accept") accept: string) {
11
- return {
12
- accept
13
- };
14
- }
15
-
16
- @Get("/scenario-2")
17
- @ContentType("text")
18
- @AcceptMime("text")
19
- public ping() {
20
- return "pong";
21
- }
22
- }
23
-
24
- export function testAcceptMime(options: PlatformTestingSdkOpts) {
25
- let request: SuperTest.Agent;
26
-
27
- beforeAll(
28
- PlatformTest.bootstrap(options.server, {
29
- ...options,
30
- mount: {
31
- "/rest": [TestAcceptMimeCtrl]
32
- }
33
- })
34
- );
35
- beforeAll(() => {
36
- request = SuperTest(PlatformTest.callback());
37
- });
38
- afterAll(PlatformTest.reset);
39
- describe("Scenario 1: POST /rest/accept-mime/scenario-1", () => {
40
- it('should return a 200 response when Accept header match with @AcceptMime("application/json")', async () => {
41
- const response = await request
42
- .post("/rest/accept-mime/scenario-1")
43
- .set({
44
- Accept: "application/json"
45
- })
46
- .expect(200);
47
-
48
- expect(response.body).toEqual({
49
- accept: "application/json"
50
- });
51
- });
52
- it('should return a 406 response when Accept header doesn\'t match with @AcceptMime("application/json")', async () => {
53
- const response = await request
54
- .post("/rest/accept-mime/scenario-1")
55
- .set({
56
- Accept: "application/xml"
57
- })
58
- .expect(406);
59
-
60
- expect(response.body).toEqual({
61
- name: "NOT_ACCEPTABLE",
62
- message: "You must accept content-type application/json",
63
- status: 406,
64
- errors: []
65
- });
66
- });
67
- });
68
- describe("Scenario 2: GET /rest/accept-mime/scenario-2", () => {
69
- it('should return a 200 response when Accept header match with @AcceptMime("text")', async () => {
70
- const response = await request
71
- .get("/rest/accept-mime/scenario-2")
72
- .set({
73
- Accept: "text/*, application/json"
74
- })
75
- .expect(200);
76
-
77
- expect(response.text).toEqual("pong");
78
- });
79
- it('should return a 406 response when Accept header doesn\'t match with @AcceptMime("text")', async () => {
80
- const response = await request
81
- .get("/rest/accept-mime/scenario-2")
82
- .set({
83
- Accept: "application/xml"
84
- })
85
- .expect(406);
86
-
87
- expect(response.body).toEqual({
88
- name: "NOT_ACCEPTABLE",
89
- message: "You must accept content-type text",
90
- status: 406,
91
- errors: []
92
- });
93
- });
94
- });
95
- }
@@ -1,339 +0,0 @@
1
- import {Context, Controller, Get, Inject, Injectable, Middleware, PlatformTest, Post, Req, UseAuth} from "@tsed/common";
2
- import {useDecorators} from "@tsed/core";
3
- import {BadRequest, Forbidden, Unauthorized} from "@tsed/exceptions";
4
- import {In, Returns, Security} from "@tsed/schema";
5
- import SuperTest from "supertest";
6
- import baseSpec from "../data/swagger.json";
7
- import {PlatformTestingSdkOpts} from "../interfaces/index.js";
8
-
9
- @Injectable()
10
- export class TokenService {
11
- private _token: string = "EMPTY";
12
-
13
- token(token?: string) {
14
- if (token) {
15
- this._token = token;
16
- }
17
-
18
- return this._token;
19
- }
20
-
21
- isValid(token: string | undefined) {
22
- return String(token).match(/token/);
23
- }
24
- }
25
-
26
- @Middleware()
27
- class OAuthMiddleware {
28
- @Inject()
29
- tokenService: TokenService;
30
-
31
- public use(@Context() ctx: Context) {
32
- const {endpoint, request} = ctx;
33
-
34
- const options = endpoint.get(OAuthMiddleware) || {};
35
-
36
- if (!request.get("authorization")) {
37
- throw new Unauthorized("Unauthorized");
38
- }
39
-
40
- if (!this.tokenService.isValid(request.get("authorization"))) {
41
- throw new BadRequest("Bad token format");
42
- }
43
-
44
- if (options && options.role === "admin" && request.get("authorization") !== "admin_token") {
45
- throw new Forbidden("Forbidden");
46
- }
47
-
48
- ctx.getRequest().user = {
49
- id: "id",
50
- name: "name"
51
- };
52
- }
53
- }
54
-
55
- export function OAuth(options: any = {}): Function {
56
- return useDecorators(
57
- UseAuth(OAuthMiddleware, options),
58
- Security("global_auth", ...(options.scopes || [])),
59
- In("header").Type(String).Name("Authorization").Required(),
60
- Returns(401).Description("Unauthorized"),
61
- Returns(403).Description("Forbidden")
62
- );
63
- }
64
-
65
- @Controller("/auth")
66
- class TestAuthCtrl {
67
- @Inject()
68
- tokenService: TokenService;
69
-
70
- @Post("/authorize")
71
- authorize() {
72
- this.tokenService.token("access_token");
73
-
74
- return {
75
- access_token: this.tokenService.token()
76
- };
77
- }
78
-
79
- @Get("/userinfo")
80
- @OAuth()
81
- token(@Req("user") user: any) {
82
- return user;
83
- }
84
-
85
- @Get("/admin")
86
- @OAuth({role: "admin", scopes: ["admin"]})
87
- admin() {
88
- return {
89
- granted: true
90
- };
91
- }
92
-
93
- @Post("/stepUp")
94
- stepUp() {
95
- this.tokenService.token("admin_token");
96
-
97
- return {
98
- access_token: this.tokenService.token()
99
- };
100
- }
101
- }
102
-
103
- export function testAuth(options: PlatformTestingSdkOpts) {
104
- let request: SuperTest.Agent;
105
-
106
- beforeAll(
107
- PlatformTest.bootstrap(options.server, {
108
- ...options,
109
- mount: {
110
- "/rest": [TestAuthCtrl]
111
- },
112
- swagger: [
113
- {
114
- path: "/doc",
115
- spec: baseSpec as any
116
- }
117
- ]
118
- })
119
- );
120
- beforeAll(() => {
121
- request = SuperTest.agent(PlatformTest.callback());
122
- });
123
- afterAll(PlatformTest.reset);
124
-
125
- describe("Scenario 1: Create token, test token and stepup token", () => {
126
- it("should create a token, call /userinfo to get userinfo and try admin route", async () => {
127
- await request.get("/rest/auth/userinfo").expect(401);
128
- await request
129
- .get("/rest/auth/userinfo")
130
- .set({
131
- Authorization: "wrong"
132
- })
133
- .expect(400);
134
-
135
- const {body} = await request.post("/rest/auth/authorize").expect(200);
136
-
137
- expect(body.access_token).toEqual("access_token");
138
-
139
- const {body: userInfo} = await request
140
- .get("/rest/auth/userinfo")
141
- .set({
142
- Authorization: body.access_token
143
- })
144
- .expect(200);
145
-
146
- expect(userInfo).toEqual({
147
- id: "id",
148
- name: "name"
149
- });
150
-
151
- await request
152
- .get("/rest/auth/admin")
153
- .set({
154
- Authorization: body.access_token
155
- })
156
- .expect(403);
157
-
158
- const {
159
- body: {access_token}
160
- } = await request.post("/rest/auth/stepUp").expect(200);
161
-
162
- expect(access_token).toEqual("admin_token");
163
-
164
- const {body: result} = await request
165
- .get("/rest/auth/admin")
166
- .set({
167
- Authorization: access_token
168
- })
169
- .expect(200);
170
-
171
- expect(result).toEqual({
172
- granted: true
173
- });
174
- });
175
- });
176
-
177
- describe("Scenario 2: GET /swagger.json", () => {
178
- it("should generate the swagger.spec", async () => {
179
- const {body: spec} = await request.get("/doc/swagger.json").expect(200);
180
-
181
- expect(spec).toEqual({
182
- openapi: "3.0.1",
183
- info: {
184
- version: "1.0.0",
185
- title: "Swagger Title",
186
- description: "Swagger description",
187
- termsOfService: "http://swagger.io/terms/",
188
- contact: {email: "apiteam@swagger.io"},
189
- license: {name: "Apache 2.0", url: "http://www.apache.org/licenses/LICENSE-2.0.html"}
190
- },
191
- paths: {
192
- "/rest/auth/authorize": {
193
- post: {
194
- operationId: "testAuthCtrlAuthorize",
195
- responses: {"200": {description: "Success"}},
196
- parameters: [],
197
- tags: ["TestAuthCtrl"]
198
- }
199
- },
200
- "/rest/auth/userinfo": {
201
- get: {
202
- operationId: "testAuthCtrlToken",
203
- responses: {
204
- "401": {
205
- content: {"application/json": {schema: {$ref: "#/components/schemas/Unauthorized"}}},
206
- description: "Unauthorized"
207
- },
208
- "403": {
209
- content: {"application/json": {schema: {$ref: "#/components/schemas/Forbidden"}}},
210
- description: "Forbidden"
211
- }
212
- },
213
- security: [{global_auth: []}],
214
- parameters: [
215
- {
216
- name: "Authorization",
217
- required: true,
218
- in: "header",
219
- schema: {type: "string"}
220
- }
221
- ],
222
- tags: ["TestAuthCtrl"]
223
- }
224
- },
225
- "/rest/auth/admin": {
226
- get: {
227
- operationId: "testAuthCtrlAdmin",
228
- responses: {
229
- "401": {
230
- content: {"application/json": {schema: {$ref: "#/components/schemas/Unauthorized"}}},
231
- description: "Unauthorized"
232
- },
233
- "403": {
234
- content: {"application/json": {schema: {$ref: "#/components/schemas/Forbidden"}}},
235
- description: "Forbidden"
236
- }
237
- },
238
- security: [{global_auth: ["admin"]}],
239
- parameters: [
240
- {
241
- name: "Authorization",
242
- required: true,
243
- in: "header",
244
- schema: {type: "string"}
245
- }
246
- ],
247
- tags: ["TestAuthCtrl"]
248
- }
249
- },
250
- "/rest/auth/stepUp": {
251
- post: {
252
- operationId: "testAuthCtrlStepUp",
253
- responses: {"200": {description: "Success"}},
254
- parameters: [],
255
- tags: ["TestAuthCtrl"]
256
- }
257
- }
258
- },
259
- components: {
260
- securitySchemes: {
261
- global_auth: {
262
- type: "oauth2",
263
- flows: {
264
- implicit: {
265
- authorizationUrl: "http://petstore.swagger.io/oauth/dialog",
266
- scopes: {admin: "Admin access"}
267
- }
268
- }
269
- }
270
- },
271
- schemas: {
272
- Unauthorized: {
273
- type: "object",
274
- properties: {
275
- name: {
276
- type: "string",
277
- description: "The error name",
278
- minLength: 1,
279
- example: "UNAUTHORIZED",
280
- default: "UNAUTHORIZED"
281
- },
282
- message: {type: "string", description: "An error message", minLength: 1},
283
- status: {
284
- type: "number",
285
- description: "The status code of the exception",
286
- example: 401,
287
- default: 401
288
- },
289
- errors: {
290
- type: "array",
291
- items: {$ref: "#/components/schemas/GenericError"},
292
- description: "A list of related errors"
293
- },
294
- stack: {type: "string", description: "The stack trace (only in development mode)"}
295
- },
296
- required: ["name", "message", "status"]
297
- },
298
- GenericError: {
299
- type: "object",
300
- properties: {
301
- name: {type: "string", description: "The error name", minLength: 1},
302
- message: {type: "string", description: "An error message", minLength: 1}
303
- },
304
- additionalProperties: true,
305
- required: ["name", "message"]
306
- },
307
- Forbidden: {
308
- type: "object",
309
- properties: {
310
- name: {
311
- type: "string",
312
- description: "The error name",
313
- minLength: 1,
314
- example: "FORBIDDEN",
315
- default: "FORBIDDEN"
316
- },
317
- message: {type: "string", description: "An error message", minLength: 1},
318
- status: {
319
- type: "number",
320
- description: "The status code of the exception",
321
- example: 403,
322
- default: 403
323
- },
324
- errors: {
325
- type: "array",
326
- items: {$ref: "#/components/schemas/GenericError"},
327
- description: "A list of related errors"
328
- },
329
- stack: {type: "string", description: "The stack trace (only in development mode)"}
330
- },
331
- required: ["name", "message", "status"]
332
- }
333
- }
334
- },
335
- tags: [{name: "TestAuthCtrl"}]
336
- });
337
- });
338
- });
339
- }