Skip to content

Commit

Permalink
fix: omit $ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Sociosarbis authored and zoubingwu committed Apr 20, 2023
1 parent b3f6073 commit 262ac61
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function resolve(schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject, api
if (isReference(schema)) {
if (resolvingRefs.includes(schema.$ref)) {
console.warn(`circular reference for path ${[...resolvingRefs, schema.$ref].join(' -> ')} found`);
return schema as OpenAPIV3.SchemaObject;
return {};
}
resolvingRefs.push(schema.$ref);
}
Expand Down
3 changes: 2 additions & 1 deletion test/generate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import get from 'lodash/get';
import keys from 'lodash/keys';
import { OpenAPIV3 } from 'openapi-types';
import { beforeAll, describe, it, expect } from 'vitest';

Expand Down Expand Up @@ -49,6 +50,6 @@ describe('generate:generateOperationCollection', () => {
'allOf',
0,
]);
expect(creatorBaseEntity).toMatchObject({ $ref: '#/components/schemas/BaseEntity' });
expect(keys(creatorBaseEntity).length).toEqual(0);
});
});

0 comments on commit 262ac61

Please sign in to comment.