openapi-ts-request 1.6.0 → 1.6.1

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.
@@ -387,7 +387,8 @@ class ServiceGenerator {
387
387
  const newApi = api;
388
388
  try {
389
389
  const params = this.getParamsTP(newApi.parameters, newApi.path) || {};
390
- const body = this.getBodyTP(newApi.requestBody);
390
+ const body = this.getBodyTP(newApi.requestBody, this.config.namespace);
391
+ const bodyWithoutNamespace = this.getBodyTP(newApi.requestBody);
391
392
  const response = this.getResponseTP(newApi.responses);
392
393
  const file = this.getFileTP(newApi.requestBody);
393
394
  let formData = false;
@@ -405,7 +406,7 @@ class ServiceGenerator {
405
406
  const bodyName = (0, lodash_1.upperFirst)(`${functionName}Body`);
406
407
  this.interfaceTPConfigs.push({
407
408
  typeName: bodyName,
408
- type: body === null || body === void 0 ? void 0 : body.type,
409
+ type: bodyWithoutNamespace === null || bodyWithoutNamespace === void 0 ? void 0 : bodyWithoutNamespace.type,
409
410
  isEnum: false,
410
411
  props: [],
411
412
  });
@@ -584,7 +585,7 @@ class ServiceGenerator {
584
585
  const typeName = ((_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.hook) === null || _b === void 0 ? void 0 : _b.customTypeName) === null || _c === void 0 ? void 0 : _c.call(_b, data)) || this.getFunctionName(data);
585
586
  return (0, util_2.resolveTypeName)(`${namespace}${typeName !== null && typeName !== void 0 ? typeName : data.operationId}Params`);
586
587
  }
587
- getBodyTP(requestBody) {
588
+ getBodyTP(requestBody, namespace) {
588
589
  var _a;
589
590
  const reqBody = this.resolveRefObject(requestBody);
590
591
  if ((0, lodash_1.isEmpty)(reqBody)) {
@@ -604,14 +605,11 @@ class ServiceGenerator {
604
605
  const bodySchema = {
605
606
  mediaType,
606
607
  required,
607
- type: this.getType(schema, this.config.namespace),
608
+ type: this.getType(schema, namespace),
608
609
  isAnonymous: false,
609
610
  };
610
- // 具名 body 场景
611
- if ((0, util_2.isReferenceObject)(schema)) {
612
- bodySchema.type = `${bodySchema.type}`;
613
- }
614
- else {
611
+ // 匿名 body 场景
612
+ if (!(0, util_2.isReferenceObject)(schema)) {
615
613
  bodySchema.isAnonymous = true;
616
614
  }
617
615
  return bodySchema;
@@ -687,7 +685,7 @@ class ServiceGenerator {
687
685
  resContent[mediaType].schema ||
688
686
  config_2.DEFAULT_SCHEMA);
689
687
  }
690
- responseSchema.type = `${this.getType(schema, this.config.namespace)}`;
688
+ responseSchema.type = this.getType(schema, this.config.namespace);
691
689
  return responseSchema;
692
690
  }
693
691
  if ((0, util_2.isSchemaObject)(schema)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-ts-request",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Swagger2/OpenAPI3/Apifox to TypeScript/JavaScript, request client(support any client), request mock service, enum and enum translation, react-query/vue-query, type field label, JSON Schemas",
5
5
  "engines": {
6
6
  "node": ">=18.0.0",