diff --git a/integrations/openapi/src/parser/spec.test.ts b/integrations/openapi/src/parser/spec.test.ts index 793621a92..9fa449154 100644 --- a/integrations/openapi/src/parser/spec.test.ts +++ b/integrations/openapi/src/parser/spec.test.ts @@ -22,7 +22,7 @@ describe('#divideOpenAPISpecSchema', () => { it('respects the tags', async () => { const schema = await dereferenceOpenAPISpec(rawSpec); // Change the order of tags - schema.tags = [{ name: 'store' }, { name: 'pet' }]; + schema.tags = [{ name: 'store' }, { name: 'pet' }, { name: 'unknown' }]; const groups = divideOpenAPISpecSchema(schema); expect(groups).toHaveLength(2); expect(groups[0].id).toBe('store'); diff --git a/integrations/openapi/src/parser/spec.ts b/integrations/openapi/src/parser/spec.ts index 5a604c654..bd03faedf 100644 --- a/integrations/openapi/src/parser/spec.ts +++ b/integrations/openapi/src/parser/spec.ts @@ -133,11 +133,13 @@ export function divideOpenAPISpecSchema(schema: OpenAPIV3.Document): OpenAPIGrou // If the schema has tags, use this order to sort the groups. if (schema.tags) { - return schema.tags.map((tag) => { + return schema.tags.reduce((tagGroups, tag) => { const group = groups.find((group) => group.id === tag.name); - assert(group, `Group not found for tag ${tag.name}`); - return group; - }); + if (group) { + tagGroups.push(group); + } + return tagGroups; + }, []); } return groups;