Skip to content

Commit

Permalink
fix: fix allowTags repeat mark
Browse files Browse the repository at this point in the history
  • Loading branch information
rookie-luochao committed Jul 8, 2024
1 parent 5b15e76 commit 30ddb72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tall-forks-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openapi-ts-request': patch
---

fix: fix allowTags repeat mark
7 changes: 3 additions & 4 deletions src/generator/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,19 +404,18 @@ export function markAllowSchema(
schemaStr: string,
schemas: ComponentsObject['schemas']
) {
const refs = schemaStr.match(/#\/components\/schemas\/([A-Za-z0-9._-]+)/g);
const refs = schemaStr?.match(/#\/components\/schemas\/([A-Za-z0-9._-]+)/g);

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

if (schema) {
if (!schema?.isAllowed) {
schema.isAllowed = true;
markAllowSchema(JSON.stringify(schema), schemas);
}

markAllowSchema(JSON.stringify(schema), schemas);
});
}

Expand Down

0 comments on commit 30ddb72

Please sign in to comment.