From 5bae11a3fb36daa3a12068da346d2927babc85d2 Mon Sep 17 00:00:00 2001 From: olav Date: Tue, 21 Jun 2022 10:33:03 +0200 Subject: [PATCH] fix: avoid 400s for unknown request body fields (#1737) --- src/lib/openapi/spec/create-api-token-schema.ts | 1 - src/lib/openapi/spec/create-strategy-schema.ts | 1 - src/lib/openapi/spec/update-api-token-schema.ts | 1 - src/lib/openapi/spec/update-tag-type-schema.ts | 1 - src/lib/openapi/spec/upsert-context-field-schema.ts | 1 - src/lib/openapi/spec/validate-tag-type-schema.ts | 1 - .../e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap | 6 ------ 7 files changed, 12 deletions(-) diff --git a/src/lib/openapi/spec/create-api-token-schema.ts b/src/lib/openapi/spec/create-api-token-schema.ts index 15f004538d..04d5a3fc20 100644 --- a/src/lib/openapi/spec/create-api-token-schema.ts +++ b/src/lib/openapi/spec/create-api-token-schema.ts @@ -4,7 +4,6 @@ import { ApiTokenType } from '../../types/models/api-token'; export const createApiTokenSchema = { $id: '#/components/schemas/createApiTokenSchema', type: 'object', - additionalProperties: false, required: ['username', 'type'], properties: { secret: { diff --git a/src/lib/openapi/spec/create-strategy-schema.ts b/src/lib/openapi/spec/create-strategy-schema.ts index fecae9ae9e..177c194352 100644 --- a/src/lib/openapi/spec/create-strategy-schema.ts +++ b/src/lib/openapi/spec/create-strategy-schema.ts @@ -5,7 +5,6 @@ import { constraintSchema } from './constraint-schema'; export const createStrategySchema = { $id: '#/components/schemas/createStrategySchema', type: 'object', - additionalProperties: false, required: ['name'], properties: { name: { diff --git a/src/lib/openapi/spec/update-api-token-schema.ts b/src/lib/openapi/spec/update-api-token-schema.ts index bff8cfc73e..13a9d70ebe 100644 --- a/src/lib/openapi/spec/update-api-token-schema.ts +++ b/src/lib/openapi/spec/update-api-token-schema.ts @@ -3,7 +3,6 @@ import { FromSchema } from 'json-schema-to-ts'; export const updateApiTokenSchema = { $id: '#/components/schemas/updateApiTokenSchema', type: 'object', - additionalProperties: false, required: ['expiresAt'], properties: { expiresAt: { diff --git a/src/lib/openapi/spec/update-tag-type-schema.ts b/src/lib/openapi/spec/update-tag-type-schema.ts index a6606a3bd0..c814a2d7c8 100644 --- a/src/lib/openapi/spec/update-tag-type-schema.ts +++ b/src/lib/openapi/spec/update-tag-type-schema.ts @@ -3,7 +3,6 @@ import { FromSchema } from 'json-schema-to-ts'; export const updateTagTypeSchema = { $id: '#/components/schemas/updateTagTypeSchema', type: 'object', - additionalProperties: false, properties: { description: { type: 'string', diff --git a/src/lib/openapi/spec/upsert-context-field-schema.ts b/src/lib/openapi/spec/upsert-context-field-schema.ts index 78c16c6175..eaaae807f8 100644 --- a/src/lib/openapi/spec/upsert-context-field-schema.ts +++ b/src/lib/openapi/spec/upsert-context-field-schema.ts @@ -4,7 +4,6 @@ import { legalValueSchema } from './legal-value-schema'; export const upsertContextFieldSchema = { $id: '#/components/schemas/upsertContextFieldSchema', type: 'object', - additionalProperties: false, required: ['name'], properties: { name: { diff --git a/src/lib/openapi/spec/validate-tag-type-schema.ts b/src/lib/openapi/spec/validate-tag-type-schema.ts index 9346941901..1d669eab82 100644 --- a/src/lib/openapi/spec/validate-tag-type-schema.ts +++ b/src/lib/openapi/spec/validate-tag-type-schema.ts @@ -4,7 +4,6 @@ import { tagTypeSchema } from './tag-type-schema'; export const validateTagTypeSchema = { $id: '#/components/schemas/validateTagTypeSchema', type: 'object', - additionalProperties: false, required: ['valid', 'tagType'], properties: { valid: { diff --git a/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap b/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap index 2d9ac09ea1..9c6dd8f606 100644 --- a/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap +++ b/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap @@ -261,7 +261,6 @@ Object { "type": "array", }, "createApiTokenSchema": Object { - "additionalProperties": false, "properties": Object { "environment": Object { "type": "string", @@ -318,7 +317,6 @@ Object { "type": "object", }, "createStrategySchema": Object { - "additionalProperties": false, "properties": Object { "constraints": Object { "items": Object { @@ -1101,7 +1099,6 @@ Object { "type": "object", }, "updateApiTokenSchema": Object { - "additionalProperties": false, "properties": Object { "expiresAt": Object { "format": "date-time", @@ -1175,7 +1172,6 @@ Object { "type": "object", }, "updateTagTypeSchema": Object { - "additionalProperties": false, "properties": Object { "description": Object { "type": "string", @@ -1187,7 +1183,6 @@ Object { "type": "object", }, "upsertContextFieldSchema": Object { - "additionalProperties": false, "properties": Object { "description": Object { "type": "string", @@ -1214,7 +1209,6 @@ Object { "type": "object", }, "validateTagTypeSchema": Object { - "additionalProperties": false, "properties": Object { "tagType": Object { "$ref": "#/components/schemas/tagTypeSchema",