Skip to content

Commit 7de3b58

Browse files
fix: fix schema is undefined when mark schema
1 parent 7c1aa76 commit 7de3b58

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.changeset/young-fireants-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openapi-ts-request': patch
3+
---
4+
5+
fix: fix schema is undefined when mark schema

src/generator/serviceGenarator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ export default class ServiceGenerator {
367367
// 判断哪些 schema 需要添加进 type, schemas 渲染数组
368368
if (
369369
isEmpty(this.config.allowedTags) ||
370-
(schema as ICustomSchemaObject).isAllowed
370+
(schema as ICustomSchemaObject)?.isAllowed
371371
) {
372372
const isEnum = result.isEnum as boolean;
373373
const typeName = resolveTypeName(schemaKey);

src/generator/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ export function markAllowSchema(
412412
refPaths[refPaths.length - 1]
413413
] as ICustomSchemaObject;
414414

415-
if (!schema?.isAllowed) {
415+
if (schema && !schema.isAllowed) {
416416
schema.isAllowed = true;
417417
markAllowSchema(JSON.stringify(schema), schemas);
418418
}

0 commit comments

Comments
 (0)