Skip to content

Commit d319e66

Browse files
fix: update JSON schema to allow null values for arrays in component descriptor V2
this is a fix for a common issue in decoding descriptors that have "null" values set in the JSON which was previously rejected. as this is semantically equivalent to empty slices we want to allow this. Signed-off-by: Jakob Möller <jakob.moeller@sap.com>
1 parent a4d8341 commit d319e66

File tree

2 files changed

+56
-35
lines changed

2 files changed

+56
-35
lines changed

api/ocm/compdesc/versions/v2/jsonscheme/bindata.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/component-descriptor-v2-schema.yaml

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,11 @@ $defs:
182182
digest:
183183
$ref: '#/$defs/digestSpec'
184184
resourceDigests:
185-
type: 'array'
186-
items:
187-
$ref: '#/$defs/nestedDigestSpec'
185+
oneOf:
186+
- type: 'array'
187+
items:
188+
$ref: '#/$defs/nestedDigestSpec'
189+
- type: 'null'
188190

189191
srcRef:
190192
type: 'object'
@@ -194,9 +196,11 @@ $defs:
194196
identitySelector:
195197
$ref: '#/$defs/identityAttribute'
196198
labels:
197-
type: 'array'
198-
items:
199-
$ref: '#/$defs/label'
199+
oneOf:
200+
- type: 'array'
201+
items:
202+
$ref: '#/$defs/label'
203+
- type: 'null'
200204

201205
componentReference:
202206
type: 'object'
@@ -217,9 +221,11 @@ $defs:
217221
version:
218222
$ref: '#/$defs/relaxedSemver'
219223
labels:
220-
type: 'array'
221-
items:
222-
$ref: '#/$defs/label'
224+
oneOf:
225+
- type: 'array'
226+
items:
227+
$ref: '#/$defs/label'
228+
- type: 'null'
223229
digest:
224230
oneOf:
225231
- type: 'null'
@@ -245,16 +251,20 @@ $defs:
245251
type:
246252
type: 'string'
247253
srcRefs:
248-
type: 'array'
249-
items:
250-
$ref: '#/$defs/srcRef'
254+
oneOf:
255+
- type: 'array'
256+
items:
257+
$ref: '#/$defs/srcRef'
258+
- type: 'null'
251259
relation:
252260
type: 'string'
253261
enum: ['local', 'external']
254262
labels:
255-
type: 'array'
256-
items:
257-
$ref: '#/$defs/label'
263+
oneOf:
264+
- type: 'array'
265+
items:
266+
$ref: '#/$defs/label'
267+
- type: 'null'
258268
access:
259269
$ref: '#/$defs/access'
260270
digest:
@@ -282,28 +292,35 @@ $defs:
282292
type: ['string', 'null']
283293
format: date-time
284294
repositoryContexts:
285-
type: 'array'
286-
items:
287-
$ref: '#/$defs/repositoryContext'
295+
oneOf:
296+
- type: 'array'
297+
items:
298+
$ref: '#/$defs/repositoryContext'
299+
- type: 'null'
288300
provider:
289301
type: 'string'
290302
labels:
291303
type: 'array'
292304
items:
293305
$ref: '#/$defs/label'
294306
sources:
295-
type: 'array'
296-
items:
297-
$ref: '#/$defs/sourceDefinition'
307+
oneOf:
308+
- type: 'array'
309+
items:
310+
$ref: '#/$defs/sourceDefinition'
311+
- type: 'null'
298312
componentReferences:
299-
type: 'array'
300-
items:
301-
$ref: '#/$defs/componentReference'
313+
oneOf:
314+
- type: 'array'
315+
items:
316+
$ref: '#/$defs/componentReference'
317+
- type: 'null'
302318
resources:
303-
type: 'array'
304-
items:
305-
$ref: '#/$defs/resourceDefinition'
306-
319+
oneOf:
320+
- type: 'array'
321+
items:
322+
$ref: '#/$defs/resourceDefinition'
323+
- type: 'null'
307324
type: 'object'
308325
required:
309326
- 'meta'
@@ -314,10 +331,14 @@ properties:
314331
component:
315332
$ref: '#/$defs/component'
316333
signatures:
317-
type: 'array'
318-
items:
319-
$ref: '#/$defs/signature'
334+
oneOf:
335+
- type: 'array'
336+
items:
337+
$ref: '#/$defs/signature'
338+
- type: 'null'
320339
nestedDigests:
321-
type: 'array'
322-
items:
323-
$ref: '#/$defs/nestedComponentDigests'
340+
oneOf:
341+
- type: 'array'
342+
items:
343+
$ref: '#/$defs/nestedComponentDigests'
344+
- type: 'null'

0 commit comments

Comments
 (0)