Skip to content

Commit 2dd5504

Browse files
committed
chore: validate specs on ci/cli
1 parent c016091 commit 2dd5504

File tree

7 files changed

+98
-88
lines changed

7 files changed

+98
-88
lines changed

scripts/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const LANGUAGES = [...new Set(Object.values(GENERATORS).map((gen) => gen.
7373

7474
// `crawler` is manually added so we can still bundled and validate the specs
7575
// the entry can be removed once at least one client is generated
76-
export const CLIENTS = [...new Set(Object.values(GENERATORS).map((gen) => gen.client)), 'crawler'];
76+
export const CLIENTS = [...new Set(Object.values(GENERATORS).map((gen) => gen.client)), 'crawler', 'abtesting-v3'];
7777

7878
export async function run(command: string, { errorMessage, cwd, language }: RunOptions = {}): Promise<string> {
7979
const realCwd = path.resolve(ROOT_DIR, cwd ?? '.');

specs/abtesting-v3/common/parameters.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ ID:
55
description: Unique A/B test identifier.
66
required: true
77
schema:
8-
$ref: "#/abTestID"
8+
$ref: '#/abTestID'
99

1010
# misc
1111
index:
1212
type: string
1313
description: Index name of the A/B test variant (case-sensitive).
14-
example: "delcourt_production"
14+
example: 'delcourt_production'
1515

1616
abTestID:
1717
type: integer
@@ -75,7 +75,7 @@ currencies:
7575
mean: 43.7
7676
standardDeviation: 10.3
7777
additionalProperties:
78-
$ref: "#/currency"
78+
$ref: '#/currency'
7979
x-additionalPropertiesName: currency code
8080

8181
currency:
@@ -84,7 +84,7 @@ currency:
8484
currency:
8585
type: string
8686
description: Currency code.
87-
example: "USD"
87+
example: 'USD'
8888
revenue:
8989
type: number
9090
format: double

specs/abtesting-v3/common/schemas/ABTest.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,39 @@ ABTests:
33
- type: array
44
description: A/B tests.
55
items:
6-
$ref: "#/ABTest"
7-
- type: "null"
6+
$ref: '#/ABTest'
7+
- type: 'null'
8+
9+
EmptySearch:
10+
type: object
11+
description: Configuration for handling empty searches.
12+
properties:
13+
exclude:
14+
type: boolean
15+
description: Whether to exclude empty searches when calculating A/B test results.
816

917
ABTest:
1018
type: object
1119
additionalProperties: false
1220
properties:
1321
abTestID:
14-
$ref: "../parameters.yml#/abTestID"
22+
$ref: '../parameters.yml#/abTestID'
1523
updatedAt:
16-
$ref: "../parameters.yml#/updatedAt"
24+
$ref: '../parameters.yml#/updatedAt'
1725
createdAt:
18-
$ref: "../parameters.yml#/createdAt"
26+
$ref: '../parameters.yml#/createdAt'
1927
endAt:
20-
$ref: "../parameters.yml#/endAt"
28+
$ref: '../parameters.yml#/endAt'
2129
name:
22-
$ref: "../parameters.yml#/name"
30+
$ref: '../parameters.yml#/name'
2331
status:
24-
$ref: "#/Status"
32+
$ref: '#/Status'
2533
variants:
26-
$ref: "Variant.yml#/variants"
34+
$ref: 'Variant.yml#/variants'
2735
configuration:
28-
$ref: "#/ABTestConfiguration"
36+
$ref: '#/ABTestConfiguration'
2937
migratedAbTestID:
30-
$ref: "#/MigratedABTestId"
38+
$ref: '#/MigratedABTestId'
3139
required:
3240
- status
3341
- name
@@ -59,11 +67,11 @@ ABTestConfiguration:
5967
description: A/B test configuration.
6068
properties:
6169
minimumDetectableEffect:
62-
$ref: "#/MinimumDetectableEffect"
70+
$ref: '#/MinimumDetectableEffect'
6371
filters:
64-
$ref: "#/MetricsFilters"
72+
$ref: '#/MetricsFilters'
6573
errorCorrection:
66-
$ref: "#/ErrorCorrectionType"
74+
$ref: '#/ErrorCorrectionType'
6775

6876
MinimumDetectableEffect:
6977
type: object
@@ -78,7 +86,7 @@ MinimumDetectableEffect:
7886
Smallest difference in an observable metric between variants.
7987
For example, to detect a 10% difference between variants, set this value to 0.1.
8088
metric:
81-
$ref: "#/EffectMetric"
89+
$ref: '#/EffectMetric'
8290
required:
8391
- size
8492
- metric
@@ -127,7 +135,7 @@ MetricsFilters:
127135
type: array
128136
description: List of metric filters applied to the test population.
129137
items:
130-
$ref: "#/MetricsFilter"
138+
$ref: '#/MetricsFilter'
131139

132140
ErrorCorrectionType:
133141
type: string

specs/abtesting-v3/common/schemas/Timeseries.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Timeseries:
33
additionalProperties: false
44
properties:
55
abTestID:
6-
$ref: "../parameters.yml#/abTestID"
6+
$ref: '../parameters.yml#/abTestID'
77
variants:
8-
$ref: "#/timeseriesVariants"
8+
$ref: '#/timeseriesVariants'
99
required:
1010
- abTestID
1111
- variants
@@ -18,18 +18,18 @@ timeseriesVariants:
1818
The first variant is your _control_ index, typically your production index.
1919
All of the additional variants are indexes with changed settings that you want to test against the control.
2020
items:
21-
$ref: "#/timeseriesVariant"
21+
$ref: '#/timeseriesVariant'
2222

2323
timeseriesVariant:
2424
type: object
2525
properties:
2626
dates:
27-
$ref: "#/metricDates"
27+
$ref: '#/metricDates'
2828

2929
metricDates:
3030
type: array
3131
items:
32-
$ref: "#/metricDate"
32+
$ref: '#/metricDate'
3333

3434
metricDate:
3535
type: object
@@ -40,4 +40,23 @@ metricDate:
4040
format: date
4141
example: 2025-06-15
4242
metrics:
43-
$ref: "Variant.yml#/metrics"
43+
$ref: 'Variant.yml#/metrics'
44+
45+
Metric:
46+
type: string
47+
enum:
48+
- search_count
49+
- tracked_search_count
50+
- user_count
51+
- tracked_user_count
52+
- no_result_count
53+
- add_to_cart_count
54+
- purchase_count
55+
- clicked_search_count
56+
- converted_search_count
57+
- click_through_rate
58+
- conversion_rate
59+
- add_to_cart_rate
60+
- purchase_rate
61+
- average_click_position
62+
- revenue

specs/abtesting-v3/paths/abtests.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,49 @@ post:
1616
additionalProperties: false
1717
properties:
1818
name:
19-
$ref: "../common/parameters.yml#/name"
19+
$ref: '../common/parameters.yml#/name'
2020
variants:
2121
type: array
2222
description: A/B test variants.
2323
minItems: 2
2424
items:
25-
$ref: "../common/schemas/AddABTestsVariant.yml#/AddABTestsVariant"
25+
$ref: '../common/schemas/AddABTestsVariant.yml#/AddABTestsVariant'
2626
metrics:
2727
type: array
2828
description: A/B test metrics involved in the test. Only these metrics will be considered when calculating results.
2929
items:
30-
$ref: "../common/parameters.yml#/metric"
30+
$ref: '../common/parameters.yml#/metric'
3131
configuration:
32-
$ref: "../common/schemas/ABTest.yml#/ABTestConfiguration"
32+
$ref: '../common/schemas/ABTest.yml#/ABTestConfiguration'
3333
endAt:
34-
$ref: "../common/parameters.yml#/endAt"
34+
$ref: '../common/parameters.yml#/endAt'
3535
required:
3636
- name
3737
- variants
3838
- metrics
3939
- endAt
4040
responses:
41-
"200":
41+
'200':
4242
description: OK
4343
headers:
4444
x-ratelimit-limit:
45-
$ref: "../../common/responses/rateLimit.yml#/x-ratelimit-limit"
45+
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-limit'
4646
x-ratelimit-remaining:
47-
$ref: "../../common/responses/rateLimit.yml#/x-ratelimit-remaining"
47+
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-remaining'
4848
x-ratelimit-reset:
49-
$ref: "../../common/responses/rateLimit.yml#/x-ratelimit-reset"
49+
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-reset'
5050
content:
5151
application/json:
5252
schema:
53-
$ref: "../common/schemas/ABTestResponse.yml#/ABTestResponse"
54-
"400":
55-
$ref: "../../common/responses/BadRequest.yml"
56-
"402":
57-
$ref: "../../common/responses/FeatureNotEnabled.yml"
58-
"403":
59-
$ref: "../../common/responses/MethodNotAllowed.yml"
60-
"404":
61-
$ref: "../../common/responses/IndexNotFound.yml"
53+
$ref: '../common/schemas/ABTestResponse.yml#/ABTestResponse'
54+
'400':
55+
$ref: '../../common/responses/BadRequest.yml'
56+
'402':
57+
$ref: '../../common/responses/FeatureNotEnabled.yml'
58+
'403':
59+
$ref: '../../common/responses/MethodNotAllowed.yml'
60+
'404':
61+
$ref: '../../common/responses/IndexNotFound.yml'
6262

6363
get:
6464
tags:
@@ -87,25 +87,25 @@ get:
8787
- name: indexPrefix
8888
in: query
8989
description: Index name prefix. Only A/B tests for indices starting with this string are included in the response.
90-
example: "dev_"
90+
example: 'dev_'
9191
schema:
9292
type: string
9393
- name: indexSuffix
9494
in: query
9595
description: Index name suffix. Only A/B tests for indices ending with this string are included in the response.
96-
example: "_development"
96+
example: '_development'
9797
schema:
9898
type: string
9999
responses:
100-
"200":
100+
'200':
101101
description: OK
102102
headers:
103103
x-ratelimit-limit:
104-
$ref: "../../common/responses/rateLimit.yml#/x-ratelimit-limit"
104+
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-limit'
105105
x-ratelimit-remaining:
106-
$ref: "../../common/responses/rateLimit.yml#/x-ratelimit-remaining"
106+
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-remaining'
107107
x-ratelimit-reset:
108-
$ref: "../../common/responses/rateLimit.yml#/x-ratelimit-reset"
108+
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-reset'
109109
content:
110110
application/json:
111111
schema:
@@ -114,7 +114,7 @@ get:
114114
additionalProperties: false
115115
properties:
116116
abtests:
117-
$ref: "../common/schemas/ABTest.yml#/ABTests"
117+
$ref: '../common/schemas/ABTest.yml#/ABTests'
118118
count:
119119
type: integer
120120
description: Number of A/B tests.
@@ -127,11 +127,11 @@ get:
127127
- abtests
128128
- count
129129
- total
130-
"400":
131-
$ref: "../../common/responses/BadRequest.yml"
132-
"402":
133-
$ref: "../../common/responses/FeatureNotEnabled.yml"
134-
"403":
135-
$ref: "../../common/responses/MethodNotAllowed.yml"
136-
"404":
137-
$ref: "../../common/responses/IndexNotFound.yml"
130+
'400':
131+
$ref: '../../common/responses/BadRequest.yml'
132+
'402':
133+
$ref: '../../common/responses/FeatureNotEnabled.yml'
134+
'403':
135+
$ref: '../../common/responses/MethodNotAllowed.yml'
136+
'404':
137+
$ref: '../../common/responses/IndexNotFound.yml'

specs/abtesting-v3/paths/timeseries.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,7 @@ get:
1616
schema:
1717
type: array
1818
items:
19-
type: string
20-
enum:
21-
- search_count
22-
- tracked_search_count
23-
- user_count
24-
- tracked_user_count
25-
- no_result_count
26-
- add_to_cart_count
27-
- purchase_count
28-
- clicked_search_count
29-
- converted_search_count
30-
- click_through_rate
31-
- conversion_rate
32-
- add_to_cart_rate
33-
- purchase_rate
34-
- average_click_position
35-
- revenue
36-
example: ["search_count", "click_through_rate", "conversion_rate"]
19+
$ref: '../common/schemas/Timeseries.yml#/Metric'
3720
responses:
3821
'200':
3922
description: OK

specs/abtesting-v3/spec.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ info:
5858
components:
5959
securitySchemes:
6060
appId:
61-
$ref: "../common/securitySchemes.yml#/appId"
61+
$ref: '../common/securitySchemes.yml#/appId'
6262
apiKey:
63-
$ref: "../common/securitySchemes.yml#/apiKey"
63+
$ref: '../common/securitySchemes.yml#/apiKey'
6464
servers:
6565
- url: https://analytics.{region}.algolia.com
6666
variables:
@@ -89,23 +89,23 @@ paths:
8989
# ### Custom request ###
9090
# ######################
9191
/{path}:
92-
$ref: "../common/paths/customRequest.yml"
92+
$ref: '../common/paths/customRequest.yml'
9393

9494
/3/abtests:
95-
$ref: "paths/abtests.yml"
95+
$ref: 'paths/abtests.yml'
9696
/3/abtests/{id}:
97-
$ref: "paths/abtest.yml"
97+
$ref: 'paths/abtest.yml'
9898
/3/abtests/{id}/stop:
99-
$ref: "paths/stopABTest.yml"
99+
$ref: 'paths/stopABTest.yml'
100100
/3/abtests/schedule:
101-
$ref: "paths/scheduleABTest.yml"
101+
$ref: 'paths/scheduleABTest.yml'
102102
/3/abtests/estimate:
103-
$ref: "paths/estimate.yml"
103+
$ref: 'paths/estimate.yml'
104104
/3/abtests/{id}/timeseries:
105-
$ref: "paths/timeseries.yml"
105+
$ref: 'paths/timeseries.yml'
106106

107107
# ###############
108108
# ### Helpers ###
109109
# ###############
110110
/setClientApiKey:
111-
$ref: "../common/helpers/setClientApiKey.yml#/method"
111+
$ref: '../common/helpers/setClientApiKey.yml#/method'

0 commit comments

Comments
 (0)