vovk 3.0.0-draft.293 → 3.0.0-draft.294

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.
@@ -39,7 +39,7 @@ function applyComponents(schema, key, components, mixinName) {
39
39
  const componentName = $ref.replace(`#/${key}/`, '');
40
40
  if (components[componentName]) {
41
41
  newObj.$ref = `#/$defs/${componentName}`;
42
- newObj['tsType'] = `Mixins.${(0, lodash_1.capitalize)((0, camelCase_1.camelCase)(mixinName))}.${(0, lodash_1.capitalize)((0, camelCase_1.camelCase)(componentName))}`;
42
+ newObj['tsType'] ??= `Mixins.${(0, lodash_1.capitalize)((0, camelCase_1.camelCase)(mixinName))}.${(0, lodash_1.capitalize)((0, camelCase_1.camelCase)(componentName))}`;
43
43
  }
44
44
  else {
45
45
  delete newObj.$ref; // Remove $ref if component not found (Telegram API has Type $refs that is not defined in components)
@@ -187,12 +187,21 @@ function openAPIToVovkSchema({ apiRoot, source: { object: openAPIObject }, getMo
187
187
  const requestBodyContent = operation.requestBody?.content ?? {};
188
188
  const jsonBody = requestBodyContent['application/json']?.schema ?? null;
189
189
  const formDataBody = requestBodyContent['multipart/form-data']?.schema ?? null;
190
- const urlEncodedBody = requestBodyContent['application/x-www-form-urlencoded']?.schema ?? null;
190
+ let urlEncodedBody = requestBodyContent['application/x-www-form-urlencoded']?.schema ?? null;
191
+ if (formDataBody && urlEncodedBody && JSON.stringify(formDataBody) === JSON.stringify(urlEncodedBody)) {
192
+ urlEncodedBody = null; // Avoid duplication if both form-data and url-encoded bodies are the same
193
+ }
191
194
  if (formDataBody) {
192
- formDataBody['x-formData'] = true;
195
+ Object.assign(formDataBody, {
196
+ 'x-formData': true,
197
+ tsType: 'FormData',
198
+ });
193
199
  }
194
200
  if (urlEncodedBody) {
195
- urlEncodedBody['x-formData'] = true;
201
+ Object.assign(urlEncodedBody, {
202
+ 'x-formData': true,
203
+ tsType: 'FormData',
204
+ });
196
205
  }
197
206
  const bodySchemas = [jsonBody, formDataBody, urlEncodedBody].filter(Boolean);
198
207
  const body = !bodySchemas.length
package/cjs/types.d.ts CHANGED
@@ -339,6 +339,7 @@ type VovkUserConfig = {
339
339
  file: string;
340
340
  } | {
341
341
  url: string;
342
+ cache?: string;
342
343
  } | {
343
344
  object: OpenAPIObject;
344
345
  };
@@ -39,7 +39,7 @@ function applyComponents(schema, key, components, mixinName) {
39
39
  const componentName = $ref.replace(`#/${key}/`, '');
40
40
  if (components[componentName]) {
41
41
  newObj.$ref = `#/$defs/${componentName}`;
42
- newObj['tsType'] = `Mixins.${(0, lodash_1.capitalize)((0, camelCase_1.camelCase)(mixinName))}.${(0, lodash_1.capitalize)((0, camelCase_1.camelCase)(componentName))}`;
42
+ newObj['tsType'] ??= `Mixins.${(0, lodash_1.capitalize)((0, camelCase_1.camelCase)(mixinName))}.${(0, lodash_1.capitalize)((0, camelCase_1.camelCase)(componentName))}`;
43
43
  }
44
44
  else {
45
45
  delete newObj.$ref; // Remove $ref if component not found (Telegram API has Type $refs that is not defined in components)
@@ -187,12 +187,21 @@ function openAPIToVovkSchema({ apiRoot, source: { object: openAPIObject }, getMo
187
187
  const requestBodyContent = operation.requestBody?.content ?? {};
188
188
  const jsonBody = requestBodyContent['application/json']?.schema ?? null;
189
189
  const formDataBody = requestBodyContent['multipart/form-data']?.schema ?? null;
190
- const urlEncodedBody = requestBodyContent['application/x-www-form-urlencoded']?.schema ?? null;
190
+ let urlEncodedBody = requestBodyContent['application/x-www-form-urlencoded']?.schema ?? null;
191
+ if (formDataBody && urlEncodedBody && JSON.stringify(formDataBody) === JSON.stringify(urlEncodedBody)) {
192
+ urlEncodedBody = null; // Avoid duplication if both form-data and url-encoded bodies are the same
193
+ }
191
194
  if (formDataBody) {
192
- formDataBody['x-formData'] = true;
195
+ Object.assign(formDataBody, {
196
+ 'x-formData': true,
197
+ tsType: 'FormData',
198
+ });
193
199
  }
194
200
  if (urlEncodedBody) {
195
- urlEncodedBody['x-formData'] = true;
201
+ Object.assign(urlEncodedBody, {
202
+ 'x-formData': true,
203
+ tsType: 'FormData',
204
+ });
196
205
  }
197
206
  const bodySchemas = [jsonBody, formDataBody, urlEncodedBody].filter(Boolean);
198
207
  const body = !bodySchemas.length
package/mjs/types.d.ts CHANGED
@@ -339,6 +339,7 @@ type VovkUserConfig = {
339
339
  file: string;
340
340
  } | {
341
341
  url: string;
342
+ cache?: string;
342
343
  } | {
343
344
  object: OpenAPIObject;
344
345
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.293",
3
+ "version": "3.0.0-draft.294",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",