diff --git a/packages/core/src/__tests__/__fixtures__/gh-658/URIError.yaml b/packages/core/src/__tests__/__fixtures__/gh-658/URIError.yaml index 4d545fa39..062e6d78b 100644 --- a/packages/core/src/__tests__/__fixtures__/gh-658/URIError.yaml +++ b/packages/core/src/__tests__/__fixtures__/gh-658/URIError.yaml @@ -28,6 +28,8 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" + "404": + $ref: './lib.yaml#/components/responses/NotFoundResponse' "500": description: No Bueno. content: diff --git a/packages/core/src/__tests__/__fixtures__/gh-658/lib.yaml b/packages/core/src/__tests__/__fixtures__/gh-658/lib.yaml index be265ae0c..64b75aebf 100644 --- a/packages/core/src/__tests__/__fixtures__/gh-658/lib.yaml +++ b/packages/core/src/__tests__/__fixtures__/gh-658/lib.yaml @@ -22,3 +22,26 @@ components: type: string test: $ref: ./URIError.yaml#/components/schemas/Foo + NotFound: + oneOf: + - $ref: '#/components/schemas/DoesntExist' + - $ref: '#/components/schemas/JustCantFindIt' + DoesntExist: + type: object + properties: + id: + type: string + JustCantFindIt: + type: object + properties: + name: + type: string + + responses: + NotFoundResponse: + description: Not Found. + content: + application/json: + schema: + $ref: '#/components/schemas/NotFound' + diff --git a/packages/core/src/__tests__/spectral.jest.test.ts b/packages/core/src/__tests__/spectral.jest.test.ts index 38a8984a4..40ebc4d42 100644 --- a/packages/core/src/__tests__/spectral.jest.test.ts +++ b/packages/core/src/__tests__/spectral.jest.test.ts @@ -190,7 +190,7 @@ describe('Spectral', () => { const results = await s.run(new Document(fs.readFileSync(documentUri, 'utf8'), Parsers.Yaml, documentUri)); - expect(results.length).toEqual(3); + expect(results.length).toEqual(5); return expect(results).toEqual([ expect.objectContaining({ @@ -208,6 +208,36 @@ describe('Spectral', () => { }, }), + expect.objectContaining({ + path: ['components', 'schemas', 'DoesntExist', 'properties', 'id'], + source: expect.stringContaining('/src/__tests__/__fixtures__/gh-658/lib.yaml'), + range: { + end: { + character: 22, + line: 32, + }, + start: { + character: 11, + line: 31, + }, + }, + }), + + expect.objectContaining({ + path: ['components', 'schemas', 'JustCantFindIt', 'properties', 'name'], + source: expect.stringContaining('/src/__tests__/__fixtures__/gh-658/lib.yaml'), + range: { + end: { + character: 22, + line: 37, + }, + start: { + character: 13, + line: 36, + }, + }, + }), + expect.objectContaining({ path: ['paths', '/test', 'get', 'responses', '200', 'content', 'application/json', 'schema'], source: expect.stringContaining('/src/__tests__/__fixtures__/gh-658/URIError.yaml'), @@ -229,11 +259,11 @@ describe('Spectral', () => { range: { end: { character: 18, - line: 43, + line: 45, }, start: { character: 8, - line: 42, + line: 44, }, }, }),