@tsed/schema 8.5.0 → 8.5.2

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.
@@ -1,5 +1,5 @@
1
1
  import { StoreSet, useDecorators } from "@tsed/core";
2
- import { Produces } from "./produces.js";
2
+ import { Consumes } from "./consumes.js";
3
3
  /**
4
4
  * Set a mime list which are acceptable and checks if the specified content types are acceptable, based on the request’s Accept HTTP header field.
5
5
  *
@@ -8,7 +8,7 @@ import { Produces } from "./produces.js";
8
8
  * export class MyCtrl {
9
9
  *
10
10
  * @Get('/')
11
- * @AcceptMime('application/json')
11
+ * @AcceptMime('application/x-www-form-urlencoded')
12
12
  * public getResource(){}
13
13
  * }
14
14
  * ```
@@ -19,6 +19,6 @@ import { Produces } from "./produces.js";
19
19
  * @response
20
20
  */
21
21
  export function AcceptMime(...mimes) {
22
- return useDecorators(Produces(...mimes), StoreSet("acceptMimes", mimes));
22
+ return useDecorators(Consumes(...mimes), StoreSet("acceptMimes", mimes));
23
23
  }
24
24
  //# sourceMappingURL=acceptMime.js.map
@@ -6,7 +6,7 @@
6
6
  * export class MyCtrl {
7
7
  *
8
8
  * @Get('/')
9
- * @AcceptMime('application/json')
9
+ * @AcceptMime('application/x-www-form-urlencoded')
10
10
  * public getResource(){}
11
11
  * }
12
12
  * ```
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.5.0",
5
+ "version": "8.5.2",
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.5.0",
40
+ "@tsed/openspec": "8.5.2",
41
41
  "change-case": "^5.4.4",
42
42
  "json-schema": "0.4.0",
43
43
  "picomatch": "4.0.2",
@@ -46,11 +46,11 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@apidevtools/swagger-parser": "10.1.0",
49
- "@tsed/barrels": "8.5.0",
50
- "@tsed/core": "8.5.0",
51
- "@tsed/hooks": "8.5.0",
52
- "@tsed/openspec": "8.5.0",
53
- "@tsed/typescript": "8.5.0",
49
+ "@tsed/barrels": "8.5.2",
50
+ "@tsed/core": "8.5.2",
51
+ "@tsed/hooks": "8.5.2",
52
+ "@tsed/openspec": "8.5.2",
53
+ "@tsed/typescript": "8.5.2",
54
54
  "@types/fs-extra": "11.0.4",
55
55
  "@types/json-schema": "7.0.15",
56
56
  "@types/picomatch": "3.0.2",
@@ -62,9 +62,9 @@
62
62
  "webpack": "^5.75.0"
63
63
  },
64
64
  "peerDependencies": {
65
- "@tsed/core": ">=8.5.0",
66
- "@tsed/hooks": ">=8.5.0",
67
- "@tsed/openspec": ">=8.5.0"
65
+ "@tsed/core": ">=8.5.2",
66
+ "@tsed/hooks": ">=8.5.2",
67
+ "@tsed/openspec": ">=8.5.2"
68
68
  },
69
69
  "peerDependenciesMeta": {
70
70
  "@tsed/core": {
@@ -1,12 +1,19 @@
1
- import {Get, getSpec, JsonMethodStore, SpecTypes} from "../../index.js";
1
+ import {BodyParams} from "@tsed/platform-params";
2
+
3
+ import {Get, getSpec, JsonMethodStore, Property, SpecTypes} from "../../index.js";
2
4
  import {AcceptMime} from "./acceptMime.js";
3
5
 
6
+ class Model {
7
+ @Property()
8
+ id: string;
9
+ }
10
+
4
11
  describe("AcceptMime", () => {
5
12
  it("should set metadata", () => {
6
13
  class Test {
7
14
  @Get("/")
8
15
  @AcceptMime("application/json")
9
- test() {}
16
+ test(@BodyParams() model: Model) {}
10
17
  }
11
18
 
12
19
  const endpoint = JsonMethodStore.get(Test, "test");
@@ -15,11 +22,33 @@ describe("AcceptMime", () => {
15
22
  const spec = getSpec(Test, {specType: SpecTypes.OPENAPI});
16
23
 
17
24
  expect(spec).toEqual({
25
+ components: {
26
+ schemas: {
27
+ Model: {
28
+ properties: {
29
+ id: {
30
+ type: "string"
31
+ }
32
+ },
33
+ type: "object"
34
+ }
35
+ }
36
+ },
18
37
  paths: {
19
38
  "/": {
20
39
  get: {
21
40
  operationId: "testTest",
22
41
  parameters: [],
42
+ requestBody: {
43
+ content: {
44
+ "application/json": {
45
+ schema: {
46
+ $ref: "#/components/schemas/Model"
47
+ }
48
+ }
49
+ },
50
+ required: false
51
+ },
23
52
  responses: {
24
53
  "200": {
25
54
  description: "Success"
@@ -1,6 +1,6 @@
1
1
  import {StoreSet, useDecorators} from "@tsed/core";
2
2
 
3
- import {Produces} from "./produces.js";
3
+ import {Consumes} from "./consumes.js";
4
4
 
5
5
  /**
6
6
  * Set a mime list which are acceptable and checks if the specified content types are acceptable, based on the request’s Accept HTTP header field.
@@ -10,7 +10,7 @@ import {Produces} from "./produces.js";
10
10
  * export class MyCtrl {
11
11
  *
12
12
  * @Get('/')
13
- * @AcceptMime('application/json')
13
+ * @AcceptMime('application/x-www-form-urlencoded')
14
14
  * public getResource(){}
15
15
  * }
16
16
  * ```
@@ -21,5 +21,5 @@ import {Produces} from "./produces.js";
21
21
  * @response
22
22
  */
23
23
  export function AcceptMime(...mimes: string[]): ClassDecorator & MethodDecorator {
24
- return useDecorators(Produces(...mimes), StoreSet("acceptMimes", mimes));
24
+ return useDecorators(Consumes(...mimes), StoreSet("acceptMimes", mimes));
25
25
  }