Skip to content

Commit e1758c3

Browse files
docs: fix more linting issues, disable rule that breaks examples
Signed-off-by: Jonathan Norris <jonathan@taplytics.com>
1 parent ff7c484 commit e1758c3

2 files changed

Lines changed: 56 additions & 136 deletions

File tree

‎.spectral.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
extends:
22
- spectral:oas
3+
rules:
4+
oas3-valid-media-example: off

‎service/openapi.yaml‎

Lines changed: 54 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -53,102 +53,52 @@ paths:
5353
description: The unique identifier (key) of the feature flag
5454
schema:
5555
type: string
56-
examples:
57-
discountBanner:
58-
value: discount-banner
59-
newCheckoutFlow:
60-
value: new-checkout-flow
61-
experimentalFeature:
62-
value: experimental-feature
56+
example: discount-banner
6357
requestBody:
6458
required: true
6559
description: Evaluation request containing the context for flag evaluation
6660
content:
6761
application/json:
6862
schema:
6963
$ref: "#/components/schemas/evaluationRequest"
70-
examples:
71-
userContext:
72-
summary: User context example
73-
value:
74-
context:
75-
targetingKey: user-123
76-
email: user@example.com
77-
custom-plan: premium
78-
serviceContext:
79-
summary: Service context example
80-
value:
81-
context:
82-
targetingKey: configuration-service
83-
version: 1.2.3
84-
region: us-east-1
64+
example:
65+
context:
66+
targetingKey: user-123
67+
email: user@example.com
68+
custom-plan: premium
69+
country: CA
8570
responses:
8671
"200":
8772
description: Successful flag evaluation. Returns the evaluated flag value with metadata.
8873
content:
8974
application/json:
9075
schema:
9176
$ref: "#/components/schemas/serverEvaluationSuccess"
92-
examples:
93-
booleanFlag:
94-
summary: Boolean flag evaluation
95-
value:
96-
key: discount-banner
97-
value: true
98-
reason: TARGETING_MATCH
99-
variant: enabled
100-
metadata:
101-
team: marketing
102-
businessPurpose: promotion
103-
stringFlag:
104-
summary: String flag evaluation
105-
value:
106-
key: theme-color
107-
value: "blue"
108-
reason: STATIC
109-
variant: default
110-
metadata:
111-
team: design
112-
codeDefault:
113-
summary: Code default flag (no value property)
114-
value:
115-
key: experimental-feature
116-
reason: DISABLED
117-
variant: off
118-
metadata:
119-
team: engineering
77+
example:
78+
key: discount-banner
79+
value: true
80+
reason: TARGETING_MATCH
81+
variant: enabled
12082
"400":
12183
description: Bad evaluation request. The request is malformed or contains invalid context.
12284
content:
12385
application/json:
12486
schema:
12587
$ref: "#/components/schemas/evaluationFailure"
126-
examples:
127-
invalidContext:
128-
summary: Invalid context error
129-
value:
130-
key: my-flag
131-
errorCode: INVALID_CONTEXT
132-
errorDetails: "Context is missing required targetingKey property"
133-
targetingKeyMissing:
134-
summary: Missing targeting key
135-
value:
136-
key: my-flag
137-
errorCode: TARGETING_KEY_MISSING
138-
errorDetails: "targetingKey is required for evaluation"
88+
example:
89+
key: my-flag
90+
errorCode: INVALID_CONTEXT
91+
errorDetails: "Context is missing required targetingKey property"
13992
"404":
14093
description: Flag not found. The specified flag key does not exist in the flag management system.
14194
content:
14295
application/json:
14396
schema:
14497
$ref: "#/components/schemas/flagNotFound"
145-
examples:
146-
flagNotFound:
147-
summary: Flag not found
148-
value:
149-
key: non-existent-flag
150-
errorCode: FLAG_NOT_FOUND
151-
errorDetails: "Flag 'non-existent-flag' was not found"
98+
example:
99+
key: non-existent-flag
100+
errorCode: FLAG_NOT_FOUND
101+
errorDetails: "Flag 'non-existent-flag' was not found"
152102
"401":
153103
description: Unauthorized. Authentication credentials are missing, invalid, or expired.
154104
"403":
@@ -161,27 +111,18 @@ paths:
161111
Indicates when to retry the request again. Can be either a date-time string
162112
or a number of seconds to wait.
163113
schema:
164-
oneOf:
165-
- type: string
166-
format: date-time
167-
- type: integer
168-
description: Number of seconds to wait before retrying
169-
examples:
170-
dateTime:
171-
value: "2024-02-07T12:00:00Z"
172-
seconds:
173-
value: 60
114+
type: string
115+
format: date-time
116+
examples:
117+
- "2024-02-07T12:00:00Z"
174118
"500":
175119
description: Internal Server Error. An unexpected error occurred on the server that prevented flag evaluation.
176120
content:
177121
application/json:
178122
schema:
179123
$ref: "#/components/schemas/generalErrorResponse"
180-
examples:
181-
serverError:
182-
summary: Internal server error
183-
value:
184-
errorDetails: "An internal server error occurred while processing the request"
124+
example:
125+
errorDetails: "An internal server error occurred while processing the request"
185126
/ofrep/v1/evaluate/flags:
186127
post:
187128
tags: [OFREP Core]
@@ -206,26 +147,19 @@ paths:
206147
schema:
207148
type: string
208149
required: false
209-
examples:
210-
strongEtag:
211-
value: '"abc123xyz"'
212-
weakEtag:
213-
value: 'W/"abc123xyz"'
150+
example: '"abc123xyz"'
214151
requestBody:
215152
required: true
216153
content:
217154
application/json:
218155
schema:
219156
$ref: "#/components/schemas/bulkEvaluationRequest"
220-
examples:
221-
clientContext:
222-
summary: Client-side user context
223-
value:
224-
context:
225-
targetingKey: user-456
226-
email: user@example.com
227-
plan: free
228-
country: CA
157+
example:
158+
context:
159+
targetingKey: user-456
160+
email: user@example.com
161+
plan: free
162+
country: CA
229163
responses:
230164
"200":
231165
description: Successful bulk evaluation.
@@ -237,33 +171,26 @@ paths:
237171
Entity tag (ETag) representing the current state of all flags. Clients should
238172
include this value in subsequent requests using the `If-None-Match` header for
239173
cache validation.
240-
examples:
241-
strongEtag:
242-
value: '"abc123xyz"'
243-
weakEtag:
244-
value: 'W/"abc123xyz"'
174+
example: '"abc123xyz"'
245175
content:
246176
application/json:
247177
schema:
248178
$ref: "#/components/schemas/bulkEvaluationSuccess"
249-
examples:
250-
bulkEvaluation:
251-
summary: Bulk evaluation with multiple flags
252-
value:
253-
flags:
254-
- key: discount-banner
255-
value: true
256-
reason: TARGETING_MATCH
257-
variant: enabled
258-
- key: theme-color
259-
value: "blue"
260-
reason: STATIC
261-
variant: default
262-
- key: non-existent-flag
263-
errorCode: FLAG_NOT_FOUND
264-
errorDetails: "Flag 'non-existent-flag' was not found"
265-
metadata:
266-
version: v12
179+
example:
180+
flags:
181+
- key: discount-banner
182+
value: true
183+
reason: TARGETING_MATCH
184+
variant: enabled
185+
- key: theme-color
186+
value: "blue"
187+
reason: STATIC
188+
variant: default
189+
- key: non-existent-flag
190+
errorCode: FLAG_NOT_FOUND
191+
errorDetails: "Flag 'non-existent-flag' was not found"
192+
metadata:
193+
version: v12
267194
"304":
268195
description: |
269196
Not Modified. The flags haven't changed since the last evaluation (ETag matches). No response body is returned.
@@ -273,17 +200,9 @@ paths:
273200
application/json:
274201
schema:
275202
$ref: "#/components/schemas/bulkEvaluationFailure"
276-
examples:
277-
invalidContext:
278-
summary: Invalid context error
279-
value:
280-
errorCode: INVALID_CONTEXT
281-
errorDetails: "Context is missing required targetingKey property"
282-
parseError:
283-
summary: Parse error
284-
value:
285-
errorCode: PARSE_ERROR
286-
errorDetails: "Failed to parse evaluation request"
203+
example:
204+
errorCode: INVALID_CONTEXT
205+
errorDetails: "Context is missing required targetingKey property"
287206
"401":
288207
description: Unauthorized. Authentication credentials are missing, invalid, or expired.
289208
"403":
@@ -296,9 +215,8 @@ paths:
296215
schema:
297216
type: string
298217
format: date-time
299-
examples:
300-
dateTime:
301-
value: "2024-02-07T12:00:00Z"
218+
example:
219+
"2024-02-07T12:00:00Z"
302220
"500":
303221
description: Internal server error. An unexpected error occurred on the server that prevented flag evaluation.
304222
content:

0 commit comments

Comments
 (0)