Skip to content

Commit

Permalink
fix: api token schema (#4633)
Browse files Browse the repository at this point in the history
## About the changes
Create api token schema can either provide the field `project` or its
plural: `projects` so the joi validation makes them optional:
https://github.com/Unleash/unleash/blob/2be77fb55ee85e18648afa455fbcee6b4d568f9d/src/lib/schema/api-token-schema.ts#L20-L24

This means that when returning the token, the response will either
contain `project` or `projects` depending on what was provided as input.
Therefore we need to make both fields optional in the response
  • Loading branch information
gastonfournier authored Sep 7, 2023
1 parent 2be77fb commit fe51b50
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
18 changes: 0 additions & 18 deletions src/lib/openapi/spec/__snapshots__/api-token-schema.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,6 @@ exports[`apiTokenSchema empty 1`] = `
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'project'",
"params": {
"missingProperty": "project",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
"message": "must have required property 'projects'",
"params": {
"missingProperty": "projects",
},
"schemaPath": "#/required",
},
{
"instancePath": "",
"keyword": "required",
Expand Down
9 changes: 1 addition & 8 deletions src/lib/openapi/spec/api-token-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ export const apiTokenSchema = {
$id: '#/components/schemas/apiTokenSchema',
type: 'object',
additionalProperties: false,
required: [
'secret',
'tokenName',
'type',
'project',
'projects',
'createdAt',
],
required: ['secret', 'tokenName', 'type', 'createdAt'],
description:
'An overview of an [Unleash API token](https://docs.getunleash.io/reference/api-tokens-and-client-keys).',
properties: {
Expand Down

0 comments on commit fe51b50

Please sign in to comment.