vovk 3.0.0-draft.83 → 3.0.0-draft.85

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,77 @@ 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
+ required: handlerSchema.validation?.query.required
15
+ ? handlerSchema.validation.query.required.includes(propName)
16
+ : false,
17
+ schema: propSchema,
18
+ }))
19
+ : null;
20
+ const pathParameters = handlerSchema?.validation?.params &&
21
+ 'type' in handlerSchema.validation.params &&
22
+ 'properties' in handlerSchema.validation.params
23
+ ? Object.entries(handlerSchema.validation.params.properties).map(([propName, propSchema]) => ({
24
+ name: propName,
25
+ in: 'path',
26
+ required: handlerSchema.validation?.params.required
27
+ ? handlerSchema.validation.params.required.includes(propName)
28
+ : false,
29
+ schema: propSchema,
30
+ }))
31
+ : null;
32
+ return {
33
+ ...handlerSchema,
34
+ openapi: {
35
+ ...handlerSchema?.openapi,
36
+ ...(handlerSchema?.validation?.output &&
37
+ 'type' in handlerSchema.validation.output &&
38
+ 'properties' in handlerSchema.validation.output
39
+ ? {
40
+ responses: {
41
+ 200: {
42
+ description: 'description' in handlerSchema.validation.output
43
+ ? handlerSchema.validation.output.description
44
+ : 'Success',
45
+ content: {
46
+ 'application/json': {
47
+ schema: handlerSchema.validation.output,
48
+ },
23
49
  },
24
50
  },
25
51
  },
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,
52
+ }
53
+ : {}),
54
+ ...(handlerSchema?.validation?.body &&
55
+ 'type' in handlerSchema.validation.body &&
56
+ 'properties' in handlerSchema.validation.body
57
+ ? {
58
+ requestBody: {
59
+ description: 'description' in handlerSchema.validation.body
60
+ ? handlerSchema.validation.body.description
61
+ : 'Request body',
62
+ required: true,
63
+ content: {
64
+ 'application/json': {
65
+ schema: handlerSchema.validation.body,
66
+ },
41
67
  },
42
68
  },
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
- });
69
+ }
70
+ : {}),
71
+ ...(queryParameters || pathParameters
72
+ ? { parameters: [...(queryParameters || []), ...(pathParameters || [])] }
73
+ : {}),
74
+ ...openAPIOperationObject,
75
+ },
76
+ };
77
+ };
83
78
  });
84
79
  exports.openapi = openapiDecorator;
85
80
  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.85",
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": {