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.
- package/dist/openapi/openapi.js +72 -71
- package/package.json +1 -1
package/dist/openapi/openapi.js
CHANGED
|
@@ -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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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