Skip to content

[oas/reducer] does not support circular path references #924

@erunion

Description

@erunion

If you have an operation schema that somewhere deep inside contains a $ref to another operation then when you reduce that operation it won't carry along the referenced operation, resulting in a corrupted schema.

For example:

Image

Reducing GET /anything in this case will exclude POST /anything, resulting in a corrupted schema for GET /anything.

There is a broken and skipped test for this use case now in

/**
* @see RM-10597
*/
// eslint-disable-next-line vitest/no-disabled-tests
it.skip('should preserve required data in a circular definition', async () => {
const circular = new Oas(circularPathSchema as OASDocument);
await circular.dereference();
const reduced = reducer(circular.api as any, { paths: { '/anything': ['get'] } });
expect(Object.keys(reduced.paths['/anything'])).toStrictEqual(['get', 'post']);
});
.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions