vovk 3.0.0-draft.83 → 3.0.0-draft.84

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.
@@ -4,82 +4,83 @@ exports.openapi = void 0;
4
4
  const createDecorator_1 = require("../createDecorator");
5
5
  const fromSchema_1 = require("./fromSchema");
6
6
  const openapiDecorator = (0, createDecorator_1.createDecorator)(null, (openAPIOperationObject = {}) => {
7
- return (handlerSchema) => ({
8
- ...handlerSchema,
9
- openapi: {
10
- ...handlerSchema?.openapi,
11
- ...(handlerSchema?.validation?.output &&
12
- 'type' in handlerSchema.validation.output &&
13
- 'properties' in handlerSchema.validation.output
14
- ? {
15
- responses: {
16
- 200: {
17
- description: 'description' in handlerSchema.validation.output
18
- ? handlerSchema.validation.output.description
19
- : 'Success',
20
- content: {
21
- 'application/json': {
22
- schema: handlerSchema.validation.output,
7
+ return (handlerSchema) => {
8
+ const queryParameters = handlerSchema?.validation?.query &&
9
+ 'type' in handlerSchema.validation.query &&
10
+ 'properties' in handlerSchema.validation.query
11
+ ? Object.entries(handlerSchema.validation.query.properties).map(([propName, propSchema]) => ({
12
+ name: propName,
13
+ in: 'query',
14
+ description: propSchema.description || '',
15
+ required: handlerSchema.validation?.query.required
16
+ ? handlerSchema.validation.query.required.includes(propName)
17
+ : false,
18
+ schema: {
19
+ type: 'string',
20
+ },
21
+ }))
22
+ : null;
23
+ const pathParameters = handlerSchema?.validation?.params &&
24
+ 'type' in handlerSchema.validation.params &&
25
+ 'properties' in handlerSchema.validation.params
26
+ ? Object.entries(handlerSchema.validation.params.properties).map(([propName, propSchema]) => ({
27
+ name: propName,
28
+ in: 'path',
29
+ description: propSchema.description || '',
30
+ required: handlerSchema.validation?.params.required
31
+ ? handlerSchema.validation.params.required.includes(propName)
32
+ : false,
33
+ schema: {
34
+ type: 'string',
35
+ },
36
+ }))
37
+ : null;
38
+ return {
39
+ ...handlerSchema,
40
+ openapi: {
41
+ ...handlerSchema?.openapi,
42
+ ...(handlerSchema?.validation?.output &&
43
+ 'type' in handlerSchema.validation.output &&
44
+ 'properties' in handlerSchema.validation.output
45
+ ? {
46
+ responses: {
47
+ 200: {
48
+ description: 'description' in handlerSchema.validation.output
49
+ ? handlerSchema.validation.output.description
50
+ : 'Success',
51
+ content: {
52
+ 'application/json': {
53
+ schema: handlerSchema.validation.output,
54
+ },
23
55
  },
24
56
  },
25
57
  },
26
- },
27
- }
28
- : {}),
29
- ...(handlerSchema?.validation?.body &&
30
- 'type' in handlerSchema.validation.body &&
31
- 'properties' in handlerSchema.validation.body
32
- ? {
33
- requestBody: {
34
- description: 'description' in handlerSchema.validation.body
35
- ? handlerSchema.validation.body.description
36
- : 'Request body',
37
- required: true,
38
- content: {
39
- 'application/json': {
40
- schema: handlerSchema.validation.body,
58
+ }
59
+ : {}),
60
+ ...(handlerSchema?.validation?.body &&
61
+ 'type' in handlerSchema.validation.body &&
62
+ 'properties' in handlerSchema.validation.body
63
+ ? {
64
+ requestBody: {
65
+ description: 'description' in handlerSchema.validation.body
66
+ ? handlerSchema.validation.body.description
67
+ : 'Request body',
68
+ required: true,
69
+ content: {
70
+ 'application/json': {
71
+ schema: handlerSchema.validation.body,
72
+ },
41
73
  },
42
74
  },
43
- },
44
- }
45
- : {}),
46
- ...(handlerSchema?.validation?.query &&
47
- 'type' in handlerSchema.validation.query &&
48
- 'properties' in handlerSchema.validation.query
49
- ? {
50
- parameters: Object.entries(handlerSchema.validation.query.properties).map(([propName, propSchema]) => ({
51
- name: propName,
52
- in: 'query',
53
- description: propSchema.description || '',
54
- required: handlerSchema.validation?.query.required
55
- ? handlerSchema.validation.query.required.includes(propName)
56
- : false,
57
- schema: {
58
- type: 'string',
59
- },
60
- })),
61
- }
62
- : {}),
63
- ...(handlerSchema?.validation?.params &&
64
- 'type' in handlerSchema.validation.params &&
65
- 'properties' in handlerSchema.validation.params
66
- ? {
67
- parameters: Object.entries(handlerSchema.validation.params.properties).map(([propName, propSchema]) => ({
68
- name: propName,
69
- in: 'path',
70
- description: propSchema.description || '',
71
- required: handlerSchema.validation?.params.required
72
- ? handlerSchema.validation.params.required.includes(propName)
73
- : false,
74
- schema: {
75
- type: 'string',
76
- },
77
- })),
78
- }
79
- : {}),
80
- ...openAPIOperationObject,
81
- },
82
- });
75
+ }
76
+ : {}),
77
+ ...(queryParameters || pathParameters
78
+ ? { parameters: [...(queryParameters || []), ...(pathParameters || [])] }
79
+ : {}),
80
+ ...openAPIOperationObject,
81
+ },
82
+ };
83
+ };
83
84
  });
84
85
  exports.openapi = openapiDecorator;
85
86
  exports.openapi.fromSchema = fromSchema_1.fromSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.83",
3
+ "version": "3.0.0-draft.84",
4
4
  "main": "dist/index.js",
5
5
  "description": "RESTful RPC for Next.js - Transforms Next.js into a powerful REST API platform with RPC capabilities.",
6
6
  "repository": {