diff --git a/src/lib/db/feature-environment-store.ts b/src/lib/db/feature-environment-store.ts index da9aa7a8d0..fb4f816d79 100644 --- a/src/lib/db/feature-environment-store.ts +++ b/src/lib/db/feature-environment-store.ts @@ -120,6 +120,7 @@ export class FeatureEnvironmentStore implements IFeatureEnvironmentStore { enabled: r.enabled, featureName: r.feature_name, environment: r.environment, + variants: r.variants, })); } diff --git a/src/lib/openapi/spec/export-result-schema.test.ts b/src/lib/openapi/spec/export-result-schema.test.ts index 392d6e4db5..76d15dee46 100644 --- a/src/lib/openapi/spec/export-result-schema.test.ts +++ b/src/lib/openapi/spec/export-result-schema.test.ts @@ -5,15 +5,99 @@ test('exportResultSchema', () => { const data: ExportResultSchema = { features: [ { - name: 'test', + name: 'some-toggle1', + description: '', + type: 'release', + project: 'myproject', + stale: false, + impressionData: false, + archived: false, }, ], featureStrategies: [ { - name: 'test', - constraints: [], + name: 'default', + id: '784f2bc1-ba45-4a92-a6d6-a80e18a4e407', + featureName: 'some-toggle1', + parameters: {}, + constraints: [ + { + values: ['ew'], + inverted: false, + operator: 'IN', + contextName: 'appName', + caseInsensitive: false, + }, + { + values: ['e'], + inverted: false, + operator: 'IN', + contextName: 'userId', + caseInsensitive: false, + }, + ], + segments: [], }, ], + featureEnvironments: [ + { + enabled: true, + featureName: 'some-toggle1', + environment: 'development', + variants: [ + { + name: 'blue', + weight: 500, + overrides: [ + { values: ['best'], contextName: 'appName' }, + ], + stickiness: 'default', + weightType: 'variable', + }, + { + name: 'red', + weight: 500, + payload: { type: 'string', value: 'dsfsd' }, + overrides: [ + { values: ['worst'], contextName: 'appName' }, + ], + stickiness: 'default', + weightType: 'variable', + }, + ], + name: 'some-toggle1', + }, + ], + contextFields: [ + { + name: 'appName', + description: 'Allows you to constrain on application name', + stickiness: false, + sortOrder: 2, + legalValues: [], + }, + { + name: 'userId', + description: 'Allows you to constrain on userId', + stickiness: false, + sortOrder: 1, + legalValues: [], + }, + ], + featureTags: [ + { + featureName: 'some-toggle', + tagType: 'simple', + tagValue: 'best-tag', + }, + { featureName: 'wat', tagType: 'simple', tagValue: 'best-tag' }, + { + featureName: 'some-toggle1', + tagType: 'simple', + tagValue: 'best-tag', + }, + ], + segments: [], }; expect( diff --git a/src/lib/openapi/spec/feature-environment-schema.ts b/src/lib/openapi/spec/feature-environment-schema.ts index 47a96dd45e..0df5eb6a4f 100644 --- a/src/lib/openapi/spec/feature-environment-schema.ts +++ b/src/lib/openapi/spec/feature-environment-schema.ts @@ -2,6 +2,7 @@ import { FromSchema } from 'json-schema-to-ts'; import { constraintSchema } from './constraint-schema'; import { parametersSchema } from './parameters-schema'; import { featureStrategySchema } from './feature-strategy-schema'; +import { variantSchema } from './variant-schema'; export const featureEnvironmentSchema = { $id: '#/components/schemas/featureEnvironmentSchema', @@ -36,12 +37,19 @@ export const featureEnvironmentSchema = { $ref: '#/components/schemas/featureStrategySchema', }, }, + variants: { + type: 'array', + items: { + $ref: '#/components/schemas/variantSchema', + }, + }, }, components: { schemas: { constraintSchema, parametersSchema, featureStrategySchema, + variantSchema, }, }, } as const; 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 d180594fc3..3d0acb9fa2 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 @@ -1164,6 +1164,12 @@ exports[`should serve the OpenAPI spec 1`] = ` "variantCount": { "type": "number", }, + "variants": { + "items": { + "$ref": "#/components/schemas/variantSchema", + }, + "type": "array", + }, }, "required": [ "name",