1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-10 17:53:36 +02:00

fix: simplify OAS for state service

It feels unesessary to define support for boolean, string and number
to define a bool value. The API will accepts all, but the specification
should push the user in to use the most approriate type.

This also ease the down-convertion to SWagger 2.0.
This commit is contained in:
Ivar Conradi Østhus 2022-12-23 10:46:53 +01:00
parent 2d16730cc2
commit f074bfdbfc
No known key found for this signature in database
GPG Key ID: 14F51E4841AF1DE1
3 changed files with 14 additions and 146 deletions

View File

@ -15,19 +15,8 @@ export const exportQueryParameters = [
name: 'download', name: 'download',
schema: { schema: {
default: false, default: false,
anyOf: [
{
type: 'boolean', type: 'boolean',
}, },
{
type: 'string',
minLength: 1,
},
{
type: 'number',
},
],
},
description: 'Whether exported data should be downloaded as a file.', description: 'Whether exported data should be downloaded as a file.',
in: 'query', in: 'query',
}, },
@ -35,19 +24,8 @@ export const exportQueryParameters = [
name: 'strategies', name: 'strategies',
schema: { schema: {
default: true, default: true,
anyOf: [
{
type: 'boolean', type: 'boolean',
}, },
{
type: 'string',
minLength: 1,
},
{
type: 'number',
},
],
},
description: description:
'Whether strategies should be included in the exported data.', 'Whether strategies should be included in the exported data.',
in: 'query', in: 'query',
@ -55,18 +33,7 @@ export const exportQueryParameters = [
{ {
name: 'featureToggles', name: 'featureToggles',
schema: { schema: {
anyOf: [
{
type: 'boolean', type: 'boolean',
},
{
type: 'string',
minLength: 1,
},
{
type: 'number',
},
],
default: true, default: true,
}, },
description: description:
@ -76,18 +43,7 @@ export const exportQueryParameters = [
{ {
name: 'projects', name: 'projects',
schema: { schema: {
anyOf: [
{
type: 'boolean', type: 'boolean',
},
{
type: 'string',
minLength: 1,
},
{
type: 'number',
},
],
default: true, default: true,
}, },
description: description:
@ -97,18 +53,7 @@ export const exportQueryParameters = [
{ {
name: 'tags', name: 'tags',
schema: { schema: {
anyOf: [
{
type: 'boolean', type: 'boolean',
},
{
type: 'string',
minLength: 1,
},
{
type: 'number',
},
],
default: true, default: true,
}, },
description: description:
@ -118,18 +63,7 @@ export const exportQueryParameters = [
{ {
name: 'environments', name: 'environments',
schema: { schema: {
anyOf: [
{
type: 'boolean', type: 'boolean',
},
{
type: 'string',
minLength: 1,
},
{
type: 'number',
},
],
default: true, default: true,
}, },
description: description:

View File

@ -44,14 +44,14 @@ test('exports strategies and features as yaml', async () => {
test('exports only features as yaml', async () => { test('exports only features as yaml', async () => {
return app.request return app.request
.get('/api/admin/state/export?format=yaml&featureToggles=1') .get('/api/admin/state/export?format=yaml&featureToggles=true')
.expect('Content-Type', /yaml/) .expect('Content-Type', /yaml/)
.expect(200); .expect(200);
}); });
test('exports strategies and features as attachment', async () => { test('exports strategies and features as attachment', async () => {
return app.request return app.request
.get('/api/admin/state/export?download=1') .get('/api/admin/state/export?download=true')
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
.expect('Content-Disposition', /attachment/) .expect('Content-Disposition', /attachment/)
.expect(200); .expect(200);

View File

@ -6622,19 +6622,8 @@ If the provided project does not exist, the list of events will be empty.",
"in": "query", "in": "query",
"name": "download", "name": "download",
"schema": { "schema": {
"anyOf": [
{
"type": "boolean",
},
{
"minLength": 1,
"type": "string",
},
{
"type": "number",
},
],
"default": false, "default": false,
"type": "boolean",
}, },
}, },
{ {
@ -6642,19 +6631,8 @@ If the provided project does not exist, the list of events will be empty.",
"in": "query", "in": "query",
"name": "strategies", "name": "strategies",
"schema": { "schema": {
"anyOf": [
{
"type": "boolean",
},
{
"minLength": 1,
"type": "string",
},
{
"type": "number",
},
],
"default": true, "default": true,
"type": "boolean",
}, },
}, },
{ {
@ -6662,19 +6640,8 @@ If the provided project does not exist, the list of events will be empty.",
"in": "query", "in": "query",
"name": "featureToggles", "name": "featureToggles",
"schema": { "schema": {
"anyOf": [
{
"type": "boolean",
},
{
"minLength": 1,
"type": "string",
},
{
"type": "number",
},
],
"default": true, "default": true,
"type": "boolean",
}, },
}, },
{ {
@ -6682,19 +6649,8 @@ If the provided project does not exist, the list of events will be empty.",
"in": "query", "in": "query",
"name": "projects", "name": "projects",
"schema": { "schema": {
"anyOf": [
{
"type": "boolean",
},
{
"minLength": 1,
"type": "string",
},
{
"type": "number",
},
],
"default": true, "default": true,
"type": "boolean",
}, },
}, },
{ {
@ -6702,19 +6658,8 @@ If the provided project does not exist, the list of events will be empty.",
"in": "query", "in": "query",
"name": "tags", "name": "tags",
"schema": { "schema": {
"anyOf": [
{
"type": "boolean",
},
{
"minLength": 1,
"type": "string",
},
{
"type": "number",
},
],
"default": true, "default": true,
"type": "boolean",
}, },
}, },
{ {
@ -6722,19 +6667,8 @@ If the provided project does not exist, the list of events will be empty.",
"in": "query", "in": "query",
"name": "environments", "name": "environments",
"schema": { "schema": {
"anyOf": [
{
"type": "boolean",
},
{
"minLength": 1,
"type": "string",
},
{
"type": "number",
},
],
"default": true, "default": true,
"type": "boolean",
}, },
}, },
], ],