persona-community-5/.pnpm-store/v3/files/bc/ad9100a11875f9854d897083cbaf68e1f9bb998f16807001124c4ae7261d41070133387f48a6cce7e5d3ee661ee9fcec7e2d7a3d3cae777a4ec74739cbbf43
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

59 lines
1.6 KiB
Plaintext

import { outdent } from 'outdent';
import { lintDocument } from '../../../lint';
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
import { BaseResolver } from '../../../resolve';
describe('no-identical-paths', () => {
it('should report on identical paths', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
paths:
'/good/{id}':
get:
summary: List all pets
'/good/last':
get:
summary: List all pets
'/bad/{id}':
get:
summary: List all pets
'/good/{hash}':
get:
summary: List all pets
'/{id}/valid':
get:
summary: List all pets
'/valid/{id}':
get:
summary: List all pets
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ rules: { 'no-identical-paths': 'error' } }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
[
{
"location": [
{
"pointer": "#/paths/~1good~1{hash}",
"reportOnKey": true,
"source": "foobar.yaml",
},
],
"message": "The path already exists which differs only by path parameter name(s): \`/good/{id}\` and \`/good/{hash}\`.",
"ruleId": "no-identical-paths",
"severity": "error",
"suggest": [],
},
]
`);
});
});