vovk 3.0.0-draft.33 → 3.0.0-draft.331

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 (196) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -96
  3. package/bin/index.mjs +8 -0
  4. package/{HttpException.d.ts → cjs/HttpException.d.ts} +2 -2
  5. package/{HttpException.js → cjs/HttpException.js} +3 -3
  6. package/cjs/JSONLinesResponse.d.ts +19 -0
  7. package/cjs/JSONLinesResponse.js +93 -0
  8. package/{VovkApp.d.ts → cjs/VovkApp.d.ts} +10 -9
  9. package/cjs/VovkApp.js +202 -0
  10. package/cjs/client/createRPC.d.ts +3 -0
  11. package/cjs/client/createRPC.js +90 -0
  12. package/cjs/client/defaultHandler.d.ts +6 -0
  13. package/cjs/client/defaultHandler.js +29 -0
  14. package/cjs/client/defaultStreamHandler.d.ts +9 -0
  15. package/{client → cjs/client}/defaultStreamHandler.js +25 -13
  16. package/cjs/client/fetcher.d.ts +14 -0
  17. package/cjs/client/fetcher.js +93 -0
  18. package/cjs/client/index.d.ts +4 -0
  19. package/cjs/client/index.js +10 -0
  20. package/cjs/client/progressive.d.ts +9 -0
  21. package/cjs/client/progressive.js +45 -0
  22. package/cjs/client/types.d.ts +123 -0
  23. package/{createVovkApp.d.ts → cjs/createVovkApp.d.ts} +12 -11
  24. package/cjs/createVovkApp.js +133 -0
  25. package/cjs/index.d.ts +65 -0
  26. package/cjs/index.js +38 -0
  27. package/cjs/openapi/error.d.ts +2 -0
  28. package/cjs/openapi/error.js +100 -0
  29. package/cjs/openapi/generateFnName.d.ts +23 -0
  30. package/cjs/openapi/generateFnName.js +81 -0
  31. package/cjs/openapi/index.d.ts +12 -0
  32. package/cjs/openapi/index.js +21 -0
  33. package/cjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +3 -0
  34. package/cjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +67 -0
  35. package/cjs/openapi/openAPIToVovkSchema/index.d.ts +4 -0
  36. package/cjs/openapi/openAPIToVovkSchema/index.js +192 -0
  37. package/cjs/openapi/openAPIToVovkSchema/inlineRefs.d.ts +10 -0
  38. package/cjs/openapi/openAPIToVovkSchema/inlineRefs.js +102 -0
  39. package/cjs/openapi/vovkSchemaToOpenAPI.d.ts +9 -0
  40. package/cjs/openapi/vovkSchemaToOpenAPI.js +233 -0
  41. package/cjs/types.d.ts +400 -0
  42. package/cjs/types.js +74 -0
  43. package/cjs/utils/camelCase.d.ts +6 -0
  44. package/cjs/utils/camelCase.js +37 -0
  45. package/cjs/utils/createCodeExamples.d.ts +19 -0
  46. package/cjs/utils/createCodeExamples.js +110 -0
  47. package/cjs/utils/createDecorator.d.ts +6 -0
  48. package/{createDecorator.js → cjs/utils/createDecorator.js} +26 -16
  49. package/cjs/utils/createLLMTools.d.ts +44 -0
  50. package/cjs/utils/createLLMTools.js +118 -0
  51. package/cjs/utils/createStandardValidation.d.ts +81 -0
  52. package/cjs/utils/createStandardValidation.js +33 -0
  53. package/cjs/utils/generateStaticAPI.d.ts +4 -0
  54. package/cjs/utils/generateStaticAPI.js +30 -0
  55. package/cjs/utils/getJSONSchemaExample.d.ts +8 -0
  56. package/cjs/utils/getJSONSchemaExample.js +234 -0
  57. package/cjs/utils/getJSONSchemaSample.d.ts +2 -0
  58. package/cjs/utils/getJSONSchemaSample.js +167 -0
  59. package/cjs/utils/getSchema.d.ts +21 -0
  60. package/cjs/utils/getSchema.js +38 -0
  61. package/cjs/utils/multitenant.d.ts +24 -0
  62. package/cjs/utils/multitenant.js +170 -0
  63. package/cjs/utils/parseQuery.d.ts +25 -0
  64. package/cjs/utils/parseQuery.js +156 -0
  65. package/{utils → cjs/utils}/reqForm.d.ts +1 -2
  66. package/cjs/utils/reqForm.js +33 -0
  67. package/{utils → cjs/utils}/reqMeta.d.ts +1 -2
  68. package/cjs/utils/reqQuery.d.ts +2 -0
  69. package/cjs/utils/reqQuery.js +10 -0
  70. package/cjs/utils/serializeQuery.d.ts +13 -0
  71. package/cjs/utils/serializeQuery.js +65 -0
  72. package/cjs/utils/setHandlerSchema.d.ts +4 -0
  73. package/cjs/utils/setHandlerSchema.js +15 -0
  74. package/cjs/utils/upperFirst.d.ts +1 -0
  75. package/cjs/utils/upperFirst.js +6 -0
  76. package/cjs/utils/withValidationLibrary.d.ts +76 -0
  77. package/cjs/utils/withValidationLibrary.js +123 -0
  78. package/mjs/HttpException.d.ts +7 -0
  79. package/mjs/HttpException.js +15 -0
  80. package/mjs/JSONLinesResponse.d.ts +19 -0
  81. package/mjs/JSONLinesResponse.js +93 -0
  82. package/mjs/VovkApp.d.ts +29 -0
  83. package/mjs/VovkApp.js +202 -0
  84. package/mjs/client/createRPC.d.ts +3 -0
  85. package/mjs/client/createRPC.js +90 -0
  86. package/mjs/client/defaultHandler.d.ts +6 -0
  87. package/mjs/client/defaultHandler.js +29 -0
  88. package/mjs/client/defaultStreamHandler.d.ts +9 -0
  89. package/mjs/client/defaultStreamHandler.js +94 -0
  90. package/mjs/client/fetcher.d.ts +14 -0
  91. package/mjs/client/fetcher.js +93 -0
  92. package/mjs/client/index.d.ts +4 -0
  93. package/mjs/client/index.js +10 -0
  94. package/mjs/client/progressive.d.ts +9 -0
  95. package/mjs/client/progressive.js +45 -0
  96. package/mjs/client/types.d.ts +123 -0
  97. package/mjs/createVovkApp.d.ts +63 -0
  98. package/mjs/createVovkApp.js +133 -0
  99. package/mjs/index.d.ts +65 -0
  100. package/mjs/index.js +38 -0
  101. package/mjs/openapi/error.d.ts +2 -0
  102. package/mjs/openapi/error.js +100 -0
  103. package/mjs/openapi/generateFnName.d.ts +23 -0
  104. package/mjs/openapi/generateFnName.js +81 -0
  105. package/mjs/openapi/index.d.ts +12 -0
  106. package/mjs/openapi/index.js +21 -0
  107. package/mjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +3 -0
  108. package/mjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +67 -0
  109. package/mjs/openapi/openAPIToVovkSchema/index.d.ts +4 -0
  110. package/mjs/openapi/openAPIToVovkSchema/index.js +192 -0
  111. package/mjs/openapi/openAPIToVovkSchema/inlineRefs.d.ts +10 -0
  112. package/mjs/openapi/openAPIToVovkSchema/inlineRefs.js +102 -0
  113. package/mjs/openapi/vovkSchemaToOpenAPI.d.ts +9 -0
  114. package/mjs/openapi/vovkSchemaToOpenAPI.js +233 -0
  115. package/mjs/types.d.ts +400 -0
  116. package/mjs/types.js +74 -0
  117. package/mjs/utils/camelCase.d.ts +6 -0
  118. package/mjs/utils/camelCase.js +37 -0
  119. package/mjs/utils/createCodeExamples.d.ts +19 -0
  120. package/mjs/utils/createCodeExamples.js +110 -0
  121. package/mjs/utils/createDecorator.d.ts +6 -0
  122. package/mjs/utils/createDecorator.js +48 -0
  123. package/mjs/utils/createLLMTools.d.ts +44 -0
  124. package/mjs/utils/createLLMTools.js +118 -0
  125. package/mjs/utils/createStandardValidation.d.ts +81 -0
  126. package/mjs/utils/createStandardValidation.js +33 -0
  127. package/mjs/utils/generateStaticAPI.d.ts +4 -0
  128. package/mjs/utils/generateStaticAPI.js +30 -0
  129. package/mjs/utils/getJSONSchemaExample.d.ts +8 -0
  130. package/mjs/utils/getJSONSchemaExample.js +234 -0
  131. package/mjs/utils/getJSONSchemaSample.d.ts +2 -0
  132. package/mjs/utils/getJSONSchemaSample.js +167 -0
  133. package/mjs/utils/getSchema.d.ts +21 -0
  134. package/mjs/utils/getSchema.js +38 -0
  135. package/mjs/utils/multitenant.d.ts +24 -0
  136. package/mjs/utils/multitenant.js +170 -0
  137. package/mjs/utils/parseQuery.d.ts +25 -0
  138. package/mjs/utils/parseQuery.js +156 -0
  139. package/mjs/utils/reqForm.d.ts +2 -0
  140. package/mjs/utils/reqForm.js +33 -0
  141. package/mjs/utils/reqMeta.d.ts +2 -0
  142. package/mjs/utils/reqMeta.js +13 -0
  143. package/mjs/utils/reqQuery.d.ts +2 -0
  144. package/mjs/utils/reqQuery.js +10 -0
  145. package/mjs/utils/serializeQuery.d.ts +13 -0
  146. package/mjs/utils/serializeQuery.js +65 -0
  147. package/mjs/utils/setHandlerSchema.d.ts +4 -0
  148. package/mjs/utils/setHandlerSchema.js +15 -0
  149. package/mjs/utils/shim.d.ts +1 -0
  150. package/mjs/utils/shim.js +18 -0
  151. package/mjs/utils/upperFirst.d.ts +1 -0
  152. package/mjs/utils/upperFirst.js +6 -0
  153. package/mjs/utils/withValidationLibrary.d.ts +76 -0
  154. package/mjs/utils/withValidationLibrary.js +123 -0
  155. package/package.json +29 -6
  156. package/.npmignore +0 -2
  157. package/StreamJSONResponse.d.ts +0 -17
  158. package/StreamJSONResponse.js +0 -54
  159. package/VovkApp.js +0 -185
  160. package/client/clientizeController.d.ts +0 -4
  161. package/client/clientizeController.js +0 -92
  162. package/client/defaultFetcher.d.ts +0 -4
  163. package/client/defaultFetcher.js +0 -49
  164. package/client/defaultHandler.d.ts +0 -2
  165. package/client/defaultHandler.js +0 -22
  166. package/client/defaultStreamHandler.d.ts +0 -4
  167. package/client/index.d.ts +0 -4
  168. package/client/index.js +0 -5
  169. package/client/types.d.ts +0 -100
  170. package/createDecorator.d.ts +0 -4
  171. package/createVovkApp.js +0 -118
  172. package/index.d.ts +0 -60
  173. package/index.js +0 -20
  174. package/types.d.ts +0 -157
  175. package/types.js +0 -65
  176. package/utils/generateStaticAPI.d.ts +0 -4
  177. package/utils/generateStaticAPI.js +0 -18
  178. package/utils/getSchema.d.ts +0 -8
  179. package/utils/getSchema.js +0 -38
  180. package/utils/reqForm.js +0 -13
  181. package/utils/reqQuery.d.ts +0 -3
  182. package/utils/reqQuery.js +0 -25
  183. package/utils/setClientValidatorsForHandler.d.ts +0 -5
  184. package/utils/setClientValidatorsForHandler.js +0 -25
  185. package/worker/index.d.ts +0 -3
  186. package/worker/index.js +0 -7
  187. package/worker/promisifyWorker.d.ts +0 -2
  188. package/worker/promisifyWorker.js +0 -141
  189. package/worker/types.d.ts +0 -31
  190. package/worker/worker.d.ts +0 -1
  191. package/worker/worker.js +0 -43
  192. /package/{client → cjs/client}/types.js +0 -0
  193. /package/{utils → cjs/utils}/reqMeta.js +0 -0
  194. /package/{utils → cjs/utils}/shim.d.ts +0 -0
  195. /package/{utils → cjs/utils}/shim.js +0 -0
  196. /package/{worker → mjs/client}/types.js +0 -0
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inlineRefs = inlineRefs;
4
+ /**
5
+ * Resolves $ref references at the first level only (except for components/schemas references)
6
+ * For arrays, checks each item at the first level
7
+ * @param obj - The object to process (may contain $ref properties)
8
+ * @param openAPIObject - The complete OpenAPI document containing definitions
9
+ * @returns The object with resolved references (except components/schemas)
10
+ */
11
+ function inlineRefs(obj, openAPIObject) {
12
+ // Handle null or undefined
13
+ if (obj === null || obj === undefined) {
14
+ return obj;
15
+ }
16
+ // Handle arrays - check each item for $ref at first level only
17
+ if (Array.isArray(obj)) {
18
+ return obj.map((item) => {
19
+ // Only resolve if item is an object with $ref
20
+ if (item && typeof item === 'object' && '$ref' in item && typeof item.$ref === 'string') {
21
+ // Skip components/schemas references
22
+ if (item.$ref.startsWith('#/components/schemas/')) {
23
+ return item;
24
+ }
25
+ // Resolve the reference
26
+ const resolved = resolveRef(item.$ref, openAPIObject);
27
+ // If resolution successful, return resolved value (with any additional properties merged)
28
+ if (resolved !== undefined) {
29
+ // If there are additional properties besides $ref, merge them
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ const { $ref: _$ref, ...additionalProps } = item;
32
+ if (Object.keys(additionalProps).length > 0) {
33
+ return { ...resolved, ...additionalProps };
34
+ }
35
+ return resolved;
36
+ }
37
+ }
38
+ // Return item as-is if not a resolvable $ref
39
+ return item;
40
+ });
41
+ }
42
+ // Handle non-objects (primitives)
43
+ if (typeof obj !== 'object') {
44
+ return obj;
45
+ }
46
+ // Check if object has a $ref property at the first level
47
+ if ('$ref' in obj && typeof obj.$ref === 'string') {
48
+ // Check if the reference points to components/schemas
49
+ if (obj.$ref.startsWith('#/components/schemas/')) {
50
+ // Return as-is for schema references
51
+ return obj;
52
+ }
53
+ // Resolve the reference
54
+ const resolved = resolveRef(obj.$ref, openAPIObject);
55
+ // If resolution successful, return resolved value (with any additional properties merged)
56
+ if (resolved !== undefined) {
57
+ // If there are additional properties besides $ref, merge them
58
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
59
+ const { $ref: _$ref, ...additionalProps } = obj;
60
+ if (Object.keys(additionalProps).length > 0) {
61
+ return { ...resolved, ...additionalProps };
62
+ }
63
+ return resolved;
64
+ }
65
+ }
66
+ // For regular objects without $ref, return as-is (no recursion)
67
+ return obj;
68
+ }
69
+ /**
70
+ * Resolves a JSON Reference ($ref) to its target value
71
+ * @param ref - The reference string (e.g., "#/components/parameters/id")
72
+ * @param openAPIObject - The complete OpenAPI document
73
+ * @returns The resolved value or undefined if not found
74
+ */
75
+ function resolveRef(ref, openAPIObject) {
76
+ // Handle only local references (starting with #)
77
+ if (!ref.startsWith('#/')) {
78
+ // eslint-disable-next-line no-console
79
+ console.warn(`External references are not supported: ${ref}`);
80
+ return undefined;
81
+ }
82
+ // Remove the leading # and split the path
83
+ const path = ref
84
+ .substring(1)
85
+ .split('/')
86
+ .filter((p) => p !== '');
87
+ // Navigate through the object following the path
88
+ let current = openAPIObject;
89
+ for (const segment of path) {
90
+ // Decode the segment (handles encoded characters like ~0 for ~ and ~1 for /)
91
+ const decodedSegment = segment.replace(/~1/g, '/').replace(/~0/g, '~');
92
+ if (current && typeof current === 'object' && decodedSegment in current) {
93
+ current = current[decodedSegment];
94
+ }
95
+ else {
96
+ // eslint-disable-next-line no-console
97
+ console.warn(`Could not resolve reference: ${ref}`);
98
+ return undefined;
99
+ }
100
+ }
101
+ return current;
102
+ }
@@ -0,0 +1,9 @@
1
+ import type { OpenAPIObject } from 'openapi3-ts/oas31';
2
+ import { type CodeSamplePackageJson } from '../utils/createCodeExamples';
3
+ import { type VovkSchema } from '../types';
4
+ export declare function vovkSchemaToOpenAPI({ rootEntry, schema: fullSchema, openAPIObject, package: packageJson, }: {
5
+ rootEntry: string;
6
+ schema: VovkSchema;
7
+ openAPIObject?: Partial<OpenAPIObject>;
8
+ package?: CodeSamplePackageJson;
9
+ }): OpenAPIObject;
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vovkSchemaToOpenAPI = vovkSchemaToOpenAPI;
4
+ const createCodeExamples_1 = require("../utils/createCodeExamples");
5
+ const types_1 = require("../types");
6
+ const getJSONSchemaSample_1 = require("../utils/getJSONSchemaSample");
7
+ function extractComponents(schema) {
8
+ if (!schema)
9
+ return [undefined, {}];
10
+ const components = {};
11
+ // Function to collect components and replace $refs recursively
12
+ const process = (obj, path = []) => {
13
+ if (!obj || typeof obj !== 'object')
14
+ return obj;
15
+ // Handle arrays
16
+ if (Array.isArray(obj)) {
17
+ return obj.map((item) => process(item, path));
18
+ }
19
+ // Create a copy to modify
20
+ const result = {};
21
+ Object.entries({ ...obj.definitions, ...obj.$defs }).forEach(([key, value]) => {
22
+ components[key] = process(value, [...path, key]);
23
+ });
24
+ // Process all properties
25
+ for (const [key, value] of Object.entries(obj ?? {})) {
26
+ // Skip already processed special properties
27
+ if (key === '$defs' || key === 'definitions')
28
+ continue;
29
+ if (key === '$ref' && typeof value === 'string') {
30
+ // Extract the component name from the reference
31
+ const refParts = value.split('/');
32
+ const refName = refParts[refParts.length - 1];
33
+ // Replace with component reference
34
+ result[key] = `#/components/schemas/${refName}`;
35
+ }
36
+ else {
37
+ // Recursively process other properties
38
+ result[key] = process(value, [...path, key]);
39
+ }
40
+ }
41
+ return result;
42
+ };
43
+ const processedSchema = process(schema);
44
+ return [processedSchema, components];
45
+ }
46
+ function vovkSchemaToOpenAPI({ rootEntry, schema: fullSchema, openAPIObject = {}, package: packageJson = { name: 'my-rpc-client' }, }) {
47
+ const paths = {};
48
+ const components = {};
49
+ for (const [segmentName, segmentSchema] of Object.entries(fullSchema.segments ?? {})) {
50
+ for (const c of Object.values(segmentSchema.controllers)) {
51
+ for (const [handlerName, h] of Object.entries(c.handlers ?? {})) {
52
+ if (h.openapi) {
53
+ const [queryValidation, queryComponents] = extractComponents(h?.validation?.query);
54
+ const [bodyValidation, bodyComponents] = extractComponents(h?.validation?.body);
55
+ const [paramsValidation, paramsComponents] = extractComponents(h?.validation?.params);
56
+ const [outputValidation, outputComponents] = extractComponents(h?.validation?.output);
57
+ const [iterationValidation, iterationComponents] = extractComponents(h?.validation?.iteration);
58
+ // TODO: Handle name conflicts?
59
+ Object.assign(components, queryComponents, bodyComponents, paramsComponents, outputComponents, iterationComponents);
60
+ const { ts, rs, py } = (0, createCodeExamples_1.createCodeExamples)({
61
+ package: packageJson,
62
+ handlerName,
63
+ handlerSchema: h,
64
+ controllerSchema: c,
65
+ });
66
+ const queryParameters = queryValidation && 'type' in queryValidation && 'properties' in queryValidation
67
+ ? Object.entries(queryValidation.properties ?? {}).map(([propName, propSchema]) => ({
68
+ name: propName,
69
+ in: 'query',
70
+ required: queryValidation.required ? queryValidation.required.includes(propName) : false,
71
+ schema: propSchema,
72
+ }))
73
+ : null;
74
+ const pathParameters = paramsValidation && 'type' in paramsValidation && 'properties' in paramsValidation
75
+ ? Object.entries(paramsValidation.properties ?? {}).map(([propName, propSchema]) => ({
76
+ name: propName,
77
+ in: 'path',
78
+ required: paramsValidation.required ? paramsValidation.required.includes(propName) : false,
79
+ schema: propSchema,
80
+ }))
81
+ : null;
82
+ const path = '/' + [rootEntry.replace(/^\/+|\/+$/g, ''), segmentName, c.prefix, h.path].filter(Boolean).join('/');
83
+ paths[path] = paths[path] ?? {};
84
+ const httpMethod = h.httpMethod.toLowerCase();
85
+ paths[path][httpMethod] ??= {};
86
+ paths[path][httpMethod] = {
87
+ ...h.openapi,
88
+ ...paths[path][httpMethod],
89
+ 'x-codeSamples': [
90
+ ...(paths[path][httpMethod]['x-codeSamples'] ?? []),
91
+ ...(h.openapi['x-codeSamples'] ?? []),
92
+ {
93
+ label: 'TypeScript RPC',
94
+ lang: 'typescript',
95
+ source: ts,
96
+ },
97
+ {
98
+ label: 'Python RPC',
99
+ lang: 'python',
100
+ source: py,
101
+ },
102
+ {
103
+ label: 'Rust RPC',
104
+ lang: 'rust',
105
+ source: rs,
106
+ },
107
+ ],
108
+ ...(queryParameters || pathParameters
109
+ ? {
110
+ parameters: h.openapi.parameters ?? [...(queryParameters || []), ...(pathParameters || [])],
111
+ }
112
+ : {}),
113
+ ...(paths[path][httpMethod].parameters
114
+ ? {
115
+ parameters: paths[path][httpMethod].parameters,
116
+ }
117
+ : {}),
118
+ ...(outputValidation && 'type' in outputValidation
119
+ ? {
120
+ responses: {
121
+ 200: {
122
+ description: 'description' in outputValidation ? outputValidation.description : 'Success',
123
+ content: {
124
+ 'application/json': {
125
+ schema: outputValidation,
126
+ },
127
+ },
128
+ },
129
+ ...h.openapi?.responses,
130
+ },
131
+ }
132
+ : {}),
133
+ ...(iterationValidation && 'type' in iterationValidation
134
+ ? {
135
+ responses: {
136
+ 200: {
137
+ description: 'description' in iterationValidation ? iterationValidation.description : 'JSON Lines response',
138
+ content: {
139
+ 'application/jsonl': {
140
+ schema: {
141
+ ...iterationValidation,
142
+ examples: iterationValidation.examples ?? [
143
+ [
144
+ JSON.stringify((0, getJSONSchemaSample_1.getJSONSchemaSample)(iterationValidation)),
145
+ JSON.stringify((0, getJSONSchemaSample_1.getJSONSchemaSample)(iterationValidation)),
146
+ JSON.stringify((0, getJSONSchemaSample_1.getJSONSchemaSample)(iterationValidation)),
147
+ ].join('\n'),
148
+ ],
149
+ },
150
+ },
151
+ },
152
+ },
153
+ ...h.openapi?.responses,
154
+ },
155
+ }
156
+ : {}),
157
+ ...(paths[path][httpMethod].responses
158
+ ? {
159
+ responses: paths[path][httpMethod].responses,
160
+ }
161
+ : {}),
162
+ ...(bodyValidation && 'type' in bodyValidation
163
+ ? {
164
+ requestBody: h.openapi?.requestBody ?? {
165
+ description: 'description' in bodyValidation ? bodyValidation.description : 'Request body',
166
+ required: true,
167
+ content: {
168
+ 'application/json': {
169
+ schema: bodyValidation,
170
+ },
171
+ },
172
+ },
173
+ }
174
+ : {}),
175
+ ...(paths[path][httpMethod].requestBody
176
+ ? {
177
+ requestBody: paths[path][httpMethod].requestBody,
178
+ }
179
+ : {}),
180
+ tags: paths[path][httpMethod].tags ?? h.openapi?.tags,
181
+ };
182
+ }
183
+ }
184
+ }
185
+ }
186
+ return {
187
+ ...openAPIObject,
188
+ openapi: '3.1.0',
189
+ info: {
190
+ title: packageJson?.description ?? 'API',
191
+ version: packageJson?.version ?? '0.0.1',
192
+ ...openAPIObject?.info,
193
+ },
194
+ components: {
195
+ schemas: {
196
+ ...(openAPIObject?.components?.schemas ?? components),
197
+ HttpStatus: {
198
+ type: 'integer',
199
+ description: 'HTTP status code',
200
+ enum: Object.keys(types_1.HttpStatus)
201
+ .map((k) => types_1.HttpStatus[k])
202
+ .filter(Boolean)
203
+ .filter((v) => typeof v === 'number'),
204
+ },
205
+ VovkErrorResponse: {
206
+ type: 'object',
207
+ description: 'Vovk error response',
208
+ properties: {
209
+ cause: {
210
+ description: 'Error cause of any shape',
211
+ },
212
+ statusCode: {
213
+ $ref: '#/components/schemas/HttpStatus',
214
+ },
215
+ message: {
216
+ type: 'string',
217
+ description: 'Error message',
218
+ },
219
+ isError: {
220
+ type: 'boolean',
221
+ const: true,
222
+ description: 'Indicates that this object represents an error',
223
+ },
224
+ },
225
+ required: ['statusCode', 'message', 'isError'],
226
+ additionalProperties: false,
227
+ },
228
+ ...openAPIObject?.components?.schemas,
229
+ },
230
+ },
231
+ paths,
232
+ };
233
+ }