1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

openapi: enable allErrors and update snapshots (#3622)

## What

This PR changes our AJV configuration to return all errors it finds with
a schema instead of stopping at the first one.

Because of this, a number of the snapshot tests that we have must be
updated.

## Why

DX! As someone using an API: if I send a faulty request, I'd rather have
the API tell me about the five things that are wrong than for me to
learn about one thing, send a new request, learn about another thing,
send a new request, .... etc.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Thomas Heartman 2023-04-28 14:56:00 +02:00 committed by GitHub
parent 09621b8a4f
commit 80cf27476b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 253 additions and 0 deletions

View File

@ -12,6 +12,15 @@ exports[`apiTokenSchema empty 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'type'",
"params": {
"missingProperty": "type",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/apiTokenSchema", "schema": "#/components/schemas/apiTokenSchema",
} }

View File

@ -12,6 +12,15 @@ exports[`changePasswordSchema empty 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'password'",
"params": {
"missingProperty": "password",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/changePasswordSchema", "schema": "#/components/schemas/changePasswordSchema",
} }

View File

@ -12,6 +12,33 @@ exports[`clientApplicationSchema no fields 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'interval'",
"params": {
"missingProperty": "interval",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'started'",
"params": {
"missingProperty": "started",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'strategies'",
"params": {
"missingProperty": "strategies",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/clientApplicationSchema", "schema": "#/components/schemas/clientApplicationSchema",
} }

View File

@ -12,6 +12,15 @@ exports[`clientFeaturesSchema no fields 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'features'",
"params": {
"missingProperty": "features",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/clientFeaturesSchema", "schema": "#/components/schemas/clientFeaturesSchema",
} }

View File

@ -12,6 +12,15 @@ exports[`featureEnvironmentSchema empty 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'enabled'",
"params": {
"missingProperty": "enabled",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/featureEnvironmentSchema", "schema": "#/components/schemas/featureEnvironmentSchema",
} }

View File

@ -12,6 +12,33 @@ exports[`featureTypeSchema empty 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'name'",
"params": {
"missingProperty": "name",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'description'",
"params": {
"missingProperty": "description",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'lifetimeDays'",
"params": {
"missingProperty": "lifetimeDays",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/featureTypeSchema", "schema": "#/components/schemas/featureTypeSchema",
} }

View File

@ -12,6 +12,33 @@ exports[`meSchema empty 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'permissions'",
"params": {
"missingProperty": "permissions",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'feedback'",
"params": {
"missingProperty": "feedback",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'splash'",
"params": {
"missingProperty": "splash",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/meSchema", "schema": "#/components/schemas/meSchema",
} }
@ -29,6 +56,24 @@ exports[`meSchema missing permissions 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'feedback'",
"params": {
"missingProperty": "feedback",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'splash'",
"params": {
"missingProperty": "splash",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/meSchema", "schema": "#/components/schemas/meSchema",
} }

View File

@ -12,6 +12,24 @@ exports[`roleSchema 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'type'",
"params": {
"missingProperty": "type",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'name'",
"params": {
"missingProperty": "name",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/roleSchema", "schema": "#/components/schemas/roleSchema",
} }

View File

@ -12,6 +12,15 @@ exports[`setStrategySortOrderSchema missing id 1`] = `
}, },
"schemaPath": "#/items/required", "schemaPath": "#/items/required",
}, },
{
"instancePath": "/1",
"keyword": "required",
"message": "must have required property 'id'",
"params": {
"missingProperty": "id",
},
"schemaPath": "#/items/required",
},
], ],
"schema": "#/components/schemas/setStrategySortOrderSchema", "schema": "#/components/schemas/setStrategySortOrderSchema",
} }

View File

@ -12,6 +12,51 @@ exports[`strategySchema 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'displayName'",
"params": {
"missingProperty": "displayName",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'description'",
"params": {
"missingProperty": "description",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'editable'",
"params": {
"missingProperty": "editable",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'deprecated'",
"params": {
"missingProperty": "deprecated",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'parameters'",
"params": {
"missingProperty": "parameters",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/strategySchema", "schema": "#/components/schemas/strategySchema",
} }

View File

@ -12,6 +12,51 @@ exports[`tokenUserSchema 1`] = `
}, },
"schemaPath": "#/required", "schemaPath": "#/required",
}, },
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'name'",
"params": {
"missingProperty": "name",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'email'",
"params": {
"missingProperty": "email",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'token'",
"params": {
"missingProperty": "token",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'createdBy'",
"params": {
"missingProperty": "createdBy",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'role'",
"params": {
"missingProperty": "role",
},
"schemaPath": "#/required",
},
], ],
"schema": "#/components/schemas/tokenUserSchema", "schema": "#/components/schemas/tokenUserSchema",
} }

View File

@ -18,6 +18,7 @@ const ajv = new Ajv({
'date-time': true, 'date-time': true,
uri: true, uri: true,
}, },
allErrors: true,
}); });
export const addAjvSchema = (schemaObjects: any[]): any => { export const addAjvSchema = (schemaObjects: any[]): any => {