From f452d6e43680db92f33e4118a21874a501ac4fac Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 17 Jan 2020 22:39:37 +0100 Subject: [PATCH] fixup --- src/functions/__tests__/typedEnum.test.ts | 10 --------- src/rulesets/oas/__tests__/typed-enum.ts | 8 +++---- src/rulesets/oas/index.json | 26 +++++++++++------------ 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/functions/__tests__/typedEnum.test.ts b/src/functions/__tests__/typedEnum.test.ts index a8f3af086..71749d87e 100644 --- a/src/functions/__tests__/typedEnum.test.ts +++ b/src/functions/__tests__/typedEnum.test.ts @@ -73,16 +73,6 @@ describe('typedEnum', () => { }); describe('types', () => { - /* - - string (this includes dates and files) - number - integer - boolean - array - object - - */ const testCases: Array<[string, unknown[], unknown]> = [ ['string', ['Hello', 'world!'], 12], ['number', [-2147483648, 17.13], 'Hello'], diff --git a/src/rulesets/oas/__tests__/typed-enum.ts b/src/rulesets/oas/__tests__/typed-enum.ts index d8709a4b0..2f1d5f903 100644 --- a/src/rulesets/oas/__tests__/typed-enum.ts +++ b/src/rulesets/oas/__tests__/typed-enum.ts @@ -21,7 +21,7 @@ describe('typed-enum', () => { expect(results).toEqual([]); }); - test('does not report anything when all the definitions are valid', async () => { + test('does not report anything when the model valid', async () => { const doc = { swagger: '2.0', definitions: { @@ -37,7 +37,7 @@ describe('typed-enum', () => { expect(results).toEqual([]); }); - test('should indentify enum values that do not respect the format', async () => { + test('should indentify enum values that do not respect the type', async () => { const doc = { swagger: '2.0', definitions: { @@ -80,7 +80,7 @@ describe('typed-enum', () => { expect(results).toEqual([]); }); - test('does not report anything when all the definitions are valid', async () => { + test('does not report anything when the model is valid', async () => { const doc = { openapi: '3.0.0', components: { @@ -98,7 +98,7 @@ describe('typed-enum', () => { expect(results).toEqual([]); }); - test('should indentify enum values that do not respect the format', async () => { + test('should indentify enum values that do not respect the type', async () => { const doc = { openapi: '3.0.0', components: { diff --git a/src/rulesets/oas/index.json b/src/rulesets/oas/index.json index fd53d94f9..62c9f48e5 100644 --- a/src/rulesets/oas/index.json +++ b/src/rulesets/oas/index.json @@ -134,19 +134,6 @@ } } }, - "typed-enum": { - "description": "Enum values should respect the specified type.", - "message": "{{error}}", - "recommended": true, - "type": "validation", - "given": "$..[?(@.enum && @.type)]", - "then": { - "function": "typedEnum", - "functionOptions": { - "reportingThreshold": 3 - } - } - }, "info-contact": { "description": "Info object should contain `contact` object.", "recommended": true, @@ -429,6 +416,19 @@ "api" ] }, + "typed-enum": { + "description": "Enum values should respect the specified type.", + "message": "{{error}}", + "recommended": true, + "type": "validation", + "given": "$..[?(@.enum && @.type)]", + "then": { + "function": "typedEnum", + "functionOptions": { + "reportingThreshold": 3 + } + } + }, "oas2-api-host": { "description": "OpenAPI `host` must be present and non-empty string.", "recommended": true,