@redocly/openapi-core
Version:
See https://github.com/Redocly/redocly-cli
64 lines (57 loc) • 1.74 kB
text/typescript
import { outdent } from 'outdent';
import { lintDocument } from '../../../lint';
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
import { BaseResolver } from '../../../resolve';
describe('Oas3 license-url', () => {
it('should report on info.license with no url', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
info:
license:
name: MIT
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ 'info-license-url': 'error' }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [
Object {
"location": Array [
Object {
"pointer": "#/info/license/url",
"reportOnKey": true,
"source": "foobar.yaml",
},
],
"message": "License object should contain \`url\` field.",
"ruleId": "info-license-url",
"severity": "error",
"suggest": Array [],
},
]
`);
});
it('should not report on info.license with url', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
info:
license:
name: MIT
url: google.com
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ 'info-license-url': 'error' }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
});
});