Skip to content

Commit 30ddb72

Browse files
fix: fix allowTags repeat mark
1 parent 5b15e76 commit 30ddb72

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

.changeset/tall-forks-train.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 allowTags repeat mark

src/generator/util.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,18 @@ export function markAllowSchema(
404404
schemaStr: string,
405405
schemas: ComponentsObject['schemas']
406406
) {
407-
const refs = schemaStr.match(/#\/components\/schemas\/([A-Za-z0-9._-]+)/g);
407+
const refs = schemaStr?.match(/#\/components\/schemas\/([A-Za-z0-9._-]+)/g);
408408

409409
forEach(refs, (ref) => {
410410
const refPaths = ref.split('/');
411411
const schema = schemas?.[
412412
refPaths[refPaths.length - 1]
413413
] as ICustomSchemaObject;
414414

415-
if (schema) {
415+
if (!schema?.isAllowed) {
416416
schema.isAllowed = true;
417+
markAllowSchema(JSON.stringify(schema), schemas);
417418
}
418-
419-
markAllowSchema(JSON.stringify(schema), schemas);
420419
});
421420
}
422421

0 commit comments

Comments
 (0)