persona-community-5/.pnpm-store/v3/files/d2/64a3f2495a360ebf7880d22a500d181ee527aeb2430854fd46f14bac8c265b0db51fbfa018281ba2d4e609f348ac968c0bb314f7229945df515c9c5ff2c41d
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

97 lines
2.8 KiB
Plaintext

import { outdent } from 'outdent';
import { lintDocument } from '../../../lint';
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
import { BaseResolver } from '../../../resolve';
describe('no-ambiguous-paths', () => {
it('should report on ambiguous 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
'/good/{id}/{pet}':
get:
summary: List all pets
'/good/last/{id}':
get:
summary: List all pets
'/{id}/ambiguous':
get:
summary: List all pets
'/ambiguous/{id}':
get:
summary: List all pets
'/pet/last':
get:
summary: List all pets
'/pet/first':
get:
summary: List all pets
'/{entity}/{id}/last':
get:
summary: List all pets
'/pet/first/{id}':
get:
summary: List all pets
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ rules: { 'no-ambiguous-paths': 'error' } }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
[
{
"location": [
{
"pointer": "#/paths/~1{id}~1ambiguous",
"reportOnKey": true,
"source": "foobar.yaml",
},
],
"message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/good/{id}\` and \`/{id}/ambiguous\`.",
"ruleId": "no-ambiguous-paths",
"severity": "error",
"suggest": [],
},
{
"location": [
{
"pointer": "#/paths/~1ambiguous~1{id}",
"reportOnKey": true,
"source": "foobar.yaml",
},
],
"message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/{id}/ambiguous\` and \`/ambiguous/{id}\`.",
"ruleId": "no-ambiguous-paths",
"severity": "error",
"suggest": [],
},
{
"location": [
{
"pointer": "#/paths/~1{entity}~1{id}~1last",
"reportOnKey": true,
"source": "foobar.yaml",
},
],
"message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/good/{id}/{pet}\` and \`/{entity}/{id}/last\`.",
"ruleId": "no-ambiguous-paths",
"severity": "error",
"suggest": [],
},
]
`);
});
});