openapi-ts-request 0.3.0 → 0.3.2

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.
@@ -107,6 +107,7 @@ class ServiceGenerator {
107
107
  namespace: this.config.namespace,
108
108
  interfaceFileName: config_1.interfaceFileName,
109
109
  schemaFileName: config_1.schemaFileName,
110
+ isGenJsonSchemas: this.config.isGenJsonSchemas,
110
111
  });
111
112
  if (this.config.isGenJsonSchemas) {
112
113
  // 处理重复的 schemaName
@@ -275,14 +275,14 @@ function resolveFunctionName(functionName, methodName) {
275
275
  exports.resolveFunctionName = resolveFunctionName;
276
276
  // 标记引用的 $ref 对应的schema
277
277
  function markAllowSchema(schemaStr, schemas) {
278
- const refs = schemaStr.match(/#\/components\/schemas\/([A-Za-z0-9._-]+)/g);
278
+ const refs = schemaStr === null || schemaStr === void 0 ? void 0 : schemaStr.match(/#\/components\/schemas\/([A-Za-z0-9._-]+)/g);
279
279
  (0, lodash_1.forEach)(refs, (ref) => {
280
280
  const refPaths = ref.split('/');
281
281
  const schema = schemas === null || schemas === void 0 ? void 0 : schemas[refPaths[refPaths.length - 1]];
282
- if (schema) {
282
+ if (!(schema === null || schema === void 0 ? void 0 : schema.isAllowed)) {
283
283
  schema.isAllowed = true;
284
+ markAllowSchema(JSON.stringify(schema), schemas);
284
285
  }
285
- markAllowSchema(JSON.stringify(schema), schemas);
286
286
  });
287
287
  }
288
288
  exports.markAllowSchema = markAllowSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-ts-request",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Swagger2/OpenAPI3 to TypeScript, request client, request mock service, enum, type field label, JSON Schemas",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,13 +1,18 @@
1
1
  /* eslint-disable */
2
2
  // @ts-ignore
3
3
  import * as {{ namespace }} from './{{ interfaceFileName }}';
4
+ {%- if isGenJsonSchemas %}
4
5
  import * as schemas from './{{ schemaFileName }}';
6
+ {%- endif %}
7
+
5
8
  {% for api in list -%}
6
9
  import * as {{ api.controllerName }} from './{{ api.fileName }}';
7
10
  {% endfor -%}
8
11
 
9
12
  export default {
13
+ {%- if isGenJsonSchemas %}
10
14
  schemas,
15
+ {%- endif %}
11
16
  {{ namespace }},
12
17
  {% for api in list -%}
13
18
  {{ api.controllerName }},