diff --git a/packages/cli/src/commands/validate/validate.test.ts b/packages/cli/src/commands/validate/validate.test.ts index c511e71b..7caf2f5a 100644 --- a/packages/cli/src/commands/validate/validate.test.ts +++ b/packages/cli/src/commands/validate/validate.test.ts @@ -18,7 +18,9 @@ describe('validate', () => { .setCwd(path.resolve('./')) .invoke(['validate', './packages/cli/src/commands/validate/invalid.json']) - logs.should.contain('Cannot find supported swagger/openapi version') + logs.should.contain( + 'Cannot find supported Swagger/OpenAPI version in specification, version must be a string.', + ) logs.should.not.contain('OpenAPI 3.1') expect(exitCode).toBe(1) }) diff --git a/packages/mock-server/src/lib/createMockServer.onRequest.test.ts b/packages/mock-server/src/lib/createMockServer.onRequest.test.ts index a124316b..a58c7429 100644 --- a/packages/mock-server/src/lib/createMockServer.onRequest.test.ts +++ b/packages/mock-server/src/lib/createMockServer.onRequest.test.ts @@ -5,7 +5,7 @@ import { createMockServer } from './createMockServer' describe('onRequest', () => { it('call custom onRequest hook', async () => { return new Promise(async (resolve) => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -21,7 +21,7 @@ describe('onRequest', () => { } const server = await createMockServer({ - openapi, + specification, onRequest({ context, operation }) { expect(context.req.method).toBe('GET') expect(context.req.path).toBe('/foobar') diff --git a/packages/mock-server/src/lib/createMockServer.openapi.test.ts b/packages/mock-server/src/lib/createMockServer.openapi.test.ts index cfc486ed..a499e846 100644 --- a/packages/mock-server/src/lib/createMockServer.openapi.test.ts +++ b/packages/mock-server/src/lib/createMockServer.openapi.test.ts @@ -4,7 +4,7 @@ import { createMockServer } from './createMockServer' describe('openapi.{json|yaml}', () => { it('GET /openapi.json (object)', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -14,17 +14,17 @@ describe('openapi.{json|yaml}', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/openapi.json') expect(response.status).toBe(200) - expect(await response.json()).toMatchObject(openapi) + expect(await response.json()).toMatchObject(specification) }) it('GET /openapi.json (JSON string)', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -34,17 +34,17 @@ describe('openapi.{json|yaml}', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/openapi.json') expect(response.status).toBe(200) - expect(await response.json()).toMatchObject(openapi) + expect(await response.json()).toMatchObject(specification) }) it.skip('GET /openapi.json (YAML string)', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -54,17 +54,17 @@ describe('openapi.{json|yaml}', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/openapi.json') expect(response.status).toBe(200) - expect(await response.json()).toMatchObject(openapi) + expect(await response.json()).toMatchObject(specification) }) it.skip('GET /openapi.yaml (object)', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -74,17 +74,17 @@ describe('openapi.{json|yaml}', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/openapi.yaml') expect(response.status).toBe(200) - expect(await response.json()).toMatchObject(openapi) + expect(await response.json()).toMatchObject(specification) }) it.skip('GET /openapi.yaml (YAML string)', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -94,17 +94,17 @@ describe('openapi.{json|yaml}', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/openapi.yaml') expect(response.status).toBe(200) - expect(await response.json()).toMatchObject(openapi) + expect(await response.json()).toMatchObject(specification) }) it.skip('GET /openapi.yaml (JSON string)', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -114,12 +114,12 @@ describe('openapi.{json|yaml}', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/openapi.yaml') expect(response.status).toBe(200) - expect(await response.json()).toMatchObject(openapi) + expect(await response.json()).toMatchObject(specification) }) }) diff --git a/packages/mock-server/src/lib/createMockServer.test.ts b/packages/mock-server/src/lib/createMockServer.test.ts index ef43f2e2..60c61ee0 100644 --- a/packages/mock-server/src/lib/createMockServer.test.ts +++ b/packages/mock-server/src/lib/createMockServer.test.ts @@ -4,7 +4,7 @@ import { createMockServer } from './createMockServer' describe('createMockServer', () => { it('GET /foobar -> example JSON', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -31,7 +31,7 @@ describe('createMockServer', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/foobar') @@ -43,7 +43,7 @@ describe('createMockServer', () => { }) it('POST /foobar -> example JSON', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -70,7 +70,7 @@ describe('createMockServer', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/foobar', { @@ -84,7 +84,7 @@ describe('createMockServer', () => { }) it('POST /foobar/{id} -> example JSON', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -111,7 +111,7 @@ describe('createMockServer', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/foobar/123') @@ -123,7 +123,7 @@ describe('createMockServer', () => { }) it('GET /foobar -> example from schema', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -156,7 +156,7 @@ describe('createMockServer', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/foobar') @@ -168,7 +168,7 @@ describe('createMockServer', () => { }) it('GET /foobar/{id} -> example from schema', async () => { - const openapi = { + const specification = { openapi: '3.1.0', info: { title: 'Hello World', @@ -201,7 +201,7 @@ describe('createMockServer', () => { } const server = await createMockServer({ - openapi, + specification, }) const response = await server.request('/foobar/123')