mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
fix: add missing client variant schema fields (#1880)
* refactor: format file * fix: use correct variants schema reference * fix: add missing client variant schema fields
This commit is contained in:
parent
d922ea1225
commit
666ca1935c
@ -16,6 +16,14 @@ test('clientFeaturesSchema required fields', () => {
|
||||
name: 'some-name',
|
||||
enabled: false,
|
||||
impressionData: false,
|
||||
variants: [
|
||||
{
|
||||
name: 'a',
|
||||
weight: 1,
|
||||
weightType: 'b',
|
||||
stickiness: 'c',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -27,102 +35,101 @@ test('clientFeaturesSchema required fields', () => {
|
||||
|
||||
test('clientFeaturesSchema java-sdk expected response', () => {
|
||||
const json = `{
|
||||
"version": 2,
|
||||
"segments": [
|
||||
"version": 2,
|
||||
"segments": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "some-name",
|
||||
"description": null,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "some-name",
|
||||
"operator": "IN",
|
||||
"value": "name",
|
||||
"inverted": false,
|
||||
"caseInsensitive": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"features": [
|
||||
"id": 1,
|
||||
"name": "some-name",
|
||||
"description": null,
|
||||
"constraints": [
|
||||
{
|
||||
"name": "Test.old",
|
||||
"description": "No variants here!",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
],
|
||||
"variants": null,
|
||||
"createdAt": "2019-01-24T10:38:10.370Z"
|
||||
},
|
||||
{
|
||||
"name": "Test.variants",
|
||||
"description": null,
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"segments": [
|
||||
1
|
||||
]
|
||||
}
|
||||
],
|
||||
"variants": [
|
||||
{
|
||||
"name": "variant1",
|
||||
"weight": 50
|
||||
},
|
||||
{
|
||||
"name": "variant2",
|
||||
"weight": 50
|
||||
}
|
||||
],
|
||||
"createdAt": "2019-01-24T10:41:45.236Z"
|
||||
},
|
||||
{
|
||||
"name": "featureX",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "featureY",
|
||||
"enabled": false,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "baz",
|
||||
"parameters": {
|
||||
"foo": "bar"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"name": "featureZ",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"name": "hola",
|
||||
"parameters": {
|
||||
"name": "val"
|
||||
},
|
||||
"segments": [1]
|
||||
}
|
||||
]
|
||||
|
||||
"contextName": "some-name",
|
||||
"operator": "IN",
|
||||
"value": "name",
|
||||
"inverted": false,
|
||||
"caseInsensitive": true
|
||||
}
|
||||
]
|
||||
}
|
||||
`;
|
||||
]
|
||||
}
|
||||
],
|
||||
"features": [
|
||||
{
|
||||
"name": "Test.old",
|
||||
"description": "No variants here!",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
],
|
||||
"variants": null,
|
||||
"createdAt": "2019-01-24T10:38:10.370Z"
|
||||
},
|
||||
{
|
||||
"name": "Test.variants",
|
||||
"description": null,
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"segments": [
|
||||
1
|
||||
]
|
||||
}
|
||||
],
|
||||
"variants": [
|
||||
{
|
||||
"name": "variant1",
|
||||
"weight": 50
|
||||
},
|
||||
{
|
||||
"name": "variant2",
|
||||
"weight": 50
|
||||
}
|
||||
],
|
||||
"createdAt": "2019-01-24T10:41:45.236Z"
|
||||
},
|
||||
{
|
||||
"name": "featureX",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "featureY",
|
||||
"enabled": false,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "baz",
|
||||
"parameters": {
|
||||
"foo": "bar"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "featureZ",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"name": "hola",
|
||||
"parameters": {
|
||||
"name": "val"
|
||||
},
|
||||
"segments": [
|
||||
1
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}`;
|
||||
|
||||
expect(
|
||||
validateSchema(
|
||||
@ -134,102 +141,101 @@ test('clientFeaturesSchema java-sdk expected response', () => {
|
||||
|
||||
test('clientFeaturesSchema unleash-proxy expected response', () => {
|
||||
const json = `{
|
||||
"version": 2,
|
||||
"segments": [
|
||||
"version": 2,
|
||||
"segments": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "some-name",
|
||||
"description": null,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "some-name",
|
||||
"operator": "IN",
|
||||
"value": "name",
|
||||
"inverted": false,
|
||||
"caseInsensitive": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"features": [
|
||||
"id": 1,
|
||||
"name": "some-name",
|
||||
"description": null,
|
||||
"constraints": [
|
||||
{
|
||||
"name": "Test.old",
|
||||
"description": "No variants here!",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
],
|
||||
"variants": null,
|
||||
"createdAt": "2019-01-24T10:38:10.370Z"
|
||||
},
|
||||
{
|
||||
"name": "Test.variants",
|
||||
"description": null,
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"segments": [
|
||||
1
|
||||
]
|
||||
}
|
||||
],
|
||||
"variants": [
|
||||
{
|
||||
"name": "variant1",
|
||||
"weight": 50
|
||||
},
|
||||
{
|
||||
"name": "variant2",
|
||||
"weight": 50
|
||||
}
|
||||
],
|
||||
"createdAt": "2019-01-24T10:41:45.236Z"
|
||||
},
|
||||
{
|
||||
"name": "featureX",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "featureY",
|
||||
"enabled": false,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "baz",
|
||||
"parameters": {
|
||||
"foo": "bar"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"name": "featureZ",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"name": "hola",
|
||||
"parameters": {
|
||||
"name": "val"
|
||||
},
|
||||
"segments": [1]
|
||||
}
|
||||
]
|
||||
|
||||
"contextName": "some-name",
|
||||
"operator": "IN",
|
||||
"value": "name",
|
||||
"inverted": false,
|
||||
"caseInsensitive": true
|
||||
}
|
||||
]
|
||||
}
|
||||
`;
|
||||
]
|
||||
}
|
||||
],
|
||||
"features": [
|
||||
{
|
||||
"name": "Test.old",
|
||||
"description": "No variants here!",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
],
|
||||
"variants": null,
|
||||
"createdAt": "2019-01-24T10:38:10.370Z"
|
||||
},
|
||||
{
|
||||
"name": "Test.variants",
|
||||
"description": null,
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"segments": [
|
||||
1
|
||||
]
|
||||
}
|
||||
],
|
||||
"variants": [
|
||||
{
|
||||
"name": "variant1",
|
||||
"weight": 50
|
||||
},
|
||||
{
|
||||
"name": "variant2",
|
||||
"weight": 50
|
||||
}
|
||||
],
|
||||
"createdAt": "2019-01-24T10:41:45.236Z"
|
||||
},
|
||||
{
|
||||
"name": "featureX",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "featureY",
|
||||
"enabled": false,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "baz",
|
||||
"parameters": {
|
||||
"foo": "bar"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "featureZ",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"name": "hola",
|
||||
"parameters": {
|
||||
"name": "val"
|
||||
},
|
||||
"segments": [
|
||||
1
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}`;
|
||||
|
||||
expect(
|
||||
validateSchema(
|
||||
@ -241,150 +247,163 @@ test('clientFeaturesSchema unleash-proxy expected response', () => {
|
||||
|
||||
test('clientFeaturesSchema client specification test 15', () => {
|
||||
const json = `{
|
||||
"version": 2,
|
||||
"features": [
|
||||
{
|
||||
"name": "F9.globalSegmentOn",
|
||||
"description": "With global segment referencing constraint in on state",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"parameters": {},
|
||||
"segments": [1]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "F9.globalSegmentOff",
|
||||
"description": "With global segment referencing constraint in off state",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"parameters": {},
|
||||
"segments": [2]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "F9.globalSegmentAndConstraint",
|
||||
"description": "With global segment and constraint both on",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"parameters": {},
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_EQ",
|
||||
"value": "1.2.2"
|
||||
}
|
||||
],
|
||||
"segments": [1]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "F9.withExtraParams",
|
||||
"description": "With global segment that doesn't exist",
|
||||
"enabled": true,
|
||||
"project": "some-project",
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"parameters": {},
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_EQ",
|
||||
"value": "1.2.2"
|
||||
}
|
||||
],
|
||||
"segments": [3]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "F9.withSeveralConstraintsAndSegments",
|
||||
"description": "With several segments and constraints",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"parameters": {},
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "customNumber",
|
||||
"operator": "NUM_LT",
|
||||
"value": "10"
|
||||
},
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_LT",
|
||||
"value": "3.2.2"
|
||||
}
|
||||
],
|
||||
"segments": [1, 4, 5]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"segments": [
|
||||
{
|
||||
"id": 1,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_EQ",
|
||||
"value": "1.2.2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_EQ",
|
||||
"value": "3.1.4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_EQ",
|
||||
"value": "3.1.4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "customName",
|
||||
"operator": "STR_CONTAINS",
|
||||
"values": ["Pi"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "slicesLeft",
|
||||
"operator": "NUM_LTE",
|
||||
"value": "4"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
`;
|
||||
"version": 2,
|
||||
"features": [
|
||||
{
|
||||
"name": "F9.globalSegmentOn",
|
||||
"description": "With global segment referencing constraint in on state",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"parameters": {},
|
||||
"segments": [
|
||||
1
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "F9.globalSegmentOff",
|
||||
"description": "With global segment referencing constraint in off state",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"parameters": {},
|
||||
"segments": [
|
||||
2
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "F9.globalSegmentAndConstraint",
|
||||
"description": "With global segment and constraint both on",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"parameters": {},
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_EQ",
|
||||
"value": "1.2.2"
|
||||
}
|
||||
],
|
||||
"segments": [
|
||||
1
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "F9.withExtraParams",
|
||||
"description": "With global segment that doesn't exist",
|
||||
"enabled": true,
|
||||
"project": "some-project",
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"parameters": {},
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_EQ",
|
||||
"value": "1.2.2"
|
||||
}
|
||||
],
|
||||
"segments": [
|
||||
3
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "F9.withSeveralConstraintsAndSegments",
|
||||
"description": "With several segments and constraints",
|
||||
"enabled": true,
|
||||
"strategies": [
|
||||
{
|
||||
"name": "default",
|
||||
"parameters": {},
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "customNumber",
|
||||
"operator": "NUM_LT",
|
||||
"value": "10"
|
||||
},
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_LT",
|
||||
"value": "3.2.2"
|
||||
}
|
||||
],
|
||||
"segments": [
|
||||
1,
|
||||
4,
|
||||
5
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"segments": [
|
||||
{
|
||||
"id": 1,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_EQ",
|
||||
"value": "1.2.2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_EQ",
|
||||
"value": "3.1.4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "version",
|
||||
"operator": "SEMVER_EQ",
|
||||
"value": "3.1.4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "customName",
|
||||
"operator": "STR_CONTAINS",
|
||||
"values": [
|
||||
"Pi"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"constraints": [
|
||||
{
|
||||
"contextName": "slicesLeft",
|
||||
"operator": "NUM_LTE",
|
||||
"value": "4"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}`;
|
||||
|
||||
expect(
|
||||
validateSchema(
|
||||
|
@ -6,8 +6,8 @@ import { environmentSchema } from './environment-schema';
|
||||
import { overrideSchema } from './override-schema';
|
||||
import { parametersSchema } from './parameters-schema';
|
||||
import { featureStrategySchema } from './feature-strategy-schema';
|
||||
import { variantSchema } from './variant-schema';
|
||||
import { clientFeatureSchema } from './client-feature-schema';
|
||||
import { clientVariantSchema } from './client-variant-schema';
|
||||
|
||||
export const clientFeaturesSchema = {
|
||||
$id: '#/components/schemas/clientFeaturesSchema',
|
||||
@ -43,7 +43,7 @@ export const clientFeaturesSchema = {
|
||||
overrideSchema,
|
||||
parametersSchema,
|
||||
featureStrategySchema,
|
||||
variantSchema,
|
||||
clientVariantSchema,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
@ -12,6 +12,12 @@ export const clientVariantSchema = {
|
||||
weight: {
|
||||
type: 'number',
|
||||
},
|
||||
weightType: {
|
||||
type: 'string',
|
||||
},
|
||||
stickiness: {
|
||||
type: 'string',
|
||||
},
|
||||
payload: {
|
||||
type: 'object',
|
||||
required: ['type', 'value'],
|
||||
|
@ -660,9 +660,15 @@ Object {
|
||||
],
|
||||
"type": "object",
|
||||
},
|
||||
"stickiness": Object {
|
||||
"type": "string",
|
||||
},
|
||||
"weight": Object {
|
||||
"type": "number",
|
||||
},
|
||||
"weightType": Object {
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"required": Array [
|
||||
"name",
|
||||
|
Loading…
Reference in New Issue
Block a user