1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package models
20
21
22
23
24 import (
25 "context"
26 "encoding/json"
27
28 "github.com/go-openapi/errors"
29 "github.com/go-openapi/strfmt"
30 "github.com/go-openapi/swag"
31 "github.com/go-openapi/validate"
32 )
33
34
35
36
37
38
39 type JarV001Schema struct {
40
41
42
43 Archive *JarV001SchemaArchive `json:"archive"`
44
45
46 Signature *JarV001SchemaSignature `json:"signature,omitempty"`
47 }
48
49
50 func (m *JarV001Schema) Validate(formats strfmt.Registry) error {
51 var res []error
52
53 if err := m.validateArchive(formats); err != nil {
54 res = append(res, err)
55 }
56
57 if err := m.validateSignature(formats); err != nil {
58 res = append(res, err)
59 }
60
61 if len(res) > 0 {
62 return errors.CompositeValidationError(res...)
63 }
64 return nil
65 }
66
67 func (m *JarV001Schema) validateArchive(formats strfmt.Registry) error {
68
69 if err := validate.Required("archive", "body", m.Archive); err != nil {
70 return err
71 }
72
73 if m.Archive != nil {
74 if err := m.Archive.Validate(formats); err != nil {
75 if ve, ok := err.(*errors.Validation); ok {
76 return ve.ValidateName("archive")
77 } else if ce, ok := err.(*errors.CompositeError); ok {
78 return ce.ValidateName("archive")
79 }
80 return err
81 }
82 }
83
84 return nil
85 }
86
87 func (m *JarV001Schema) validateSignature(formats strfmt.Registry) error {
88 if swag.IsZero(m.Signature) {
89 return nil
90 }
91
92 if m.Signature != nil {
93 if err := m.Signature.Validate(formats); err != nil {
94 if ve, ok := err.(*errors.Validation); ok {
95 return ve.ValidateName("signature")
96 } else if ce, ok := err.(*errors.CompositeError); ok {
97 return ce.ValidateName("signature")
98 }
99 return err
100 }
101 }
102
103 return nil
104 }
105
106
107 func (m *JarV001Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
108 var res []error
109
110 if err := m.contextValidateArchive(ctx, formats); err != nil {
111 res = append(res, err)
112 }
113
114 if err := m.contextValidateSignature(ctx, formats); err != nil {
115 res = append(res, err)
116 }
117
118 if len(res) > 0 {
119 return errors.CompositeValidationError(res...)
120 }
121 return nil
122 }
123
124 func (m *JarV001Schema) contextValidateArchive(ctx context.Context, formats strfmt.Registry) error {
125
126 if m.Archive != nil {
127
128 if err := m.Archive.ContextValidate(ctx, formats); err != nil {
129 if ve, ok := err.(*errors.Validation); ok {
130 return ve.ValidateName("archive")
131 } else if ce, ok := err.(*errors.CompositeError); ok {
132 return ce.ValidateName("archive")
133 }
134 return err
135 }
136 }
137
138 return nil
139 }
140
141 func (m *JarV001Schema) contextValidateSignature(ctx context.Context, formats strfmt.Registry) error {
142
143 if m.Signature != nil {
144
145 if swag.IsZero(m.Signature) {
146 return nil
147 }
148
149 if err := m.Signature.ContextValidate(ctx, formats); err != nil {
150 if ve, ok := err.(*errors.Validation); ok {
151 return ve.ValidateName("signature")
152 } else if ce, ok := err.(*errors.CompositeError); ok {
153 return ce.ValidateName("signature")
154 }
155 return err
156 }
157 }
158
159 return nil
160 }
161
162
163 func (m *JarV001Schema) MarshalBinary() ([]byte, error) {
164 if m == nil {
165 return nil, nil
166 }
167 return swag.WriteJSON(m)
168 }
169
170
171 func (m *JarV001Schema) UnmarshalBinary(b []byte) error {
172 var res JarV001Schema
173 if err := swag.ReadJSON(b, &res); err != nil {
174 return err
175 }
176 *m = res
177 return nil
178 }
179
180
181
182
183 type JarV001SchemaArchive struct {
184
185
186
187 Content strfmt.Base64 `json:"content,omitempty"`
188
189
190 Hash *JarV001SchemaArchiveHash `json:"hash,omitempty"`
191 }
192
193
194 func (m *JarV001SchemaArchive) Validate(formats strfmt.Registry) error {
195 var res []error
196
197 if err := m.validateHash(formats); err != nil {
198 res = append(res, err)
199 }
200
201 if len(res) > 0 {
202 return errors.CompositeValidationError(res...)
203 }
204 return nil
205 }
206
207 func (m *JarV001SchemaArchive) validateHash(formats strfmt.Registry) error {
208 if swag.IsZero(m.Hash) {
209 return nil
210 }
211
212 if m.Hash != nil {
213 if err := m.Hash.Validate(formats); err != nil {
214 if ve, ok := err.(*errors.Validation); ok {
215 return ve.ValidateName("archive" + "." + "hash")
216 } else if ce, ok := err.(*errors.CompositeError); ok {
217 return ce.ValidateName("archive" + "." + "hash")
218 }
219 return err
220 }
221 }
222
223 return nil
224 }
225
226
227 func (m *JarV001SchemaArchive) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
228 var res []error
229
230 if err := m.contextValidateHash(ctx, formats); err != nil {
231 res = append(res, err)
232 }
233
234 if len(res) > 0 {
235 return errors.CompositeValidationError(res...)
236 }
237 return nil
238 }
239
240 func (m *JarV001SchemaArchive) contextValidateHash(ctx context.Context, formats strfmt.Registry) error {
241
242 if m.Hash != nil {
243
244 if swag.IsZero(m.Hash) {
245 return nil
246 }
247
248 if err := m.Hash.ContextValidate(ctx, formats); err != nil {
249 if ve, ok := err.(*errors.Validation); ok {
250 return ve.ValidateName("archive" + "." + "hash")
251 } else if ce, ok := err.(*errors.CompositeError); ok {
252 return ce.ValidateName("archive" + "." + "hash")
253 }
254 return err
255 }
256 }
257
258 return nil
259 }
260
261
262 func (m *JarV001SchemaArchive) MarshalBinary() ([]byte, error) {
263 if m == nil {
264 return nil, nil
265 }
266 return swag.WriteJSON(m)
267 }
268
269
270 func (m *JarV001SchemaArchive) UnmarshalBinary(b []byte) error {
271 var res JarV001SchemaArchive
272 if err := swag.ReadJSON(b, &res); err != nil {
273 return err
274 }
275 *m = res
276 return nil
277 }
278
279
280
281
282 type JarV001SchemaArchiveHash struct {
283
284
285
286
287 Algorithm *string `json:"algorithm"`
288
289
290
291 Value *string `json:"value"`
292 }
293
294
295 func (m *JarV001SchemaArchiveHash) Validate(formats strfmt.Registry) error {
296 var res []error
297
298 if err := m.validateAlgorithm(formats); err != nil {
299 res = append(res, err)
300 }
301
302 if err := m.validateValue(formats); err != nil {
303 res = append(res, err)
304 }
305
306 if len(res) > 0 {
307 return errors.CompositeValidationError(res...)
308 }
309 return nil
310 }
311
312 var jarV001SchemaArchiveHashTypeAlgorithmPropEnum []interface{}
313
314 func init() {
315 var res []string
316 if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
317 panic(err)
318 }
319 for _, v := range res {
320 jarV001SchemaArchiveHashTypeAlgorithmPropEnum = append(jarV001SchemaArchiveHashTypeAlgorithmPropEnum, v)
321 }
322 }
323
324 const (
325
326
327 JarV001SchemaArchiveHashAlgorithmSha256 string = "sha256"
328 )
329
330
331 func (m *JarV001SchemaArchiveHash) validateAlgorithmEnum(path, location string, value string) error {
332 if err := validate.EnumCase(path, location, value, jarV001SchemaArchiveHashTypeAlgorithmPropEnum, true); err != nil {
333 return err
334 }
335 return nil
336 }
337
338 func (m *JarV001SchemaArchiveHash) validateAlgorithm(formats strfmt.Registry) error {
339
340 if err := validate.Required("archive"+"."+"hash"+"."+"algorithm", "body", m.Algorithm); err != nil {
341 return err
342 }
343
344
345 if err := m.validateAlgorithmEnum("archive"+"."+"hash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
346 return err
347 }
348
349 return nil
350 }
351
352 func (m *JarV001SchemaArchiveHash) validateValue(formats strfmt.Registry) error {
353
354 if err := validate.Required("archive"+"."+"hash"+"."+"value", "body", m.Value); err != nil {
355 return err
356 }
357
358 return nil
359 }
360
361
362 func (m *JarV001SchemaArchiveHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
363 return nil
364 }
365
366
367 func (m *JarV001SchemaArchiveHash) MarshalBinary() ([]byte, error) {
368 if m == nil {
369 return nil, nil
370 }
371 return swag.WriteJSON(m)
372 }
373
374
375 func (m *JarV001SchemaArchiveHash) UnmarshalBinary(b []byte) error {
376 var res JarV001SchemaArchiveHash
377 if err := swag.ReadJSON(b, &res); err != nil {
378 return err
379 }
380 *m = res
381 return nil
382 }
383
384
385
386
387 type JarV001SchemaSignature struct {
388
389
390
391
392
393 Content strfmt.Base64 `json:"content"`
394
395
396
397 PublicKey *JarV001SchemaSignaturePublicKey `json:"publicKey"`
398 }
399
400
401 func (m *JarV001SchemaSignature) Validate(formats strfmt.Registry) error {
402 var res []error
403
404 if err := m.validateContent(formats); err != nil {
405 res = append(res, err)
406 }
407
408 if err := m.validatePublicKey(formats); err != nil {
409 res = append(res, err)
410 }
411
412 if len(res) > 0 {
413 return errors.CompositeValidationError(res...)
414 }
415 return nil
416 }
417
418 func (m *JarV001SchemaSignature) validateContent(formats strfmt.Registry) error {
419
420 if err := validate.Required("signature"+"."+"content", "body", strfmt.Base64(m.Content)); err != nil {
421 return err
422 }
423
424 return nil
425 }
426
427 func (m *JarV001SchemaSignature) validatePublicKey(formats strfmt.Registry) error {
428
429 if err := validate.Required("signature"+"."+"publicKey", "body", m.PublicKey); err != nil {
430 return err
431 }
432
433 if m.PublicKey != nil {
434 if err := m.PublicKey.Validate(formats); err != nil {
435 if ve, ok := err.(*errors.Validation); ok {
436 return ve.ValidateName("signature" + "." + "publicKey")
437 } else if ce, ok := err.(*errors.CompositeError); ok {
438 return ce.ValidateName("signature" + "." + "publicKey")
439 }
440 return err
441 }
442 }
443
444 return nil
445 }
446
447
448 func (m *JarV001SchemaSignature) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
449 var res []error
450
451 if err := m.contextValidateContent(ctx, formats); err != nil {
452 res = append(res, err)
453 }
454
455 if err := m.contextValidatePublicKey(ctx, formats); err != nil {
456 res = append(res, err)
457 }
458
459 if len(res) > 0 {
460 return errors.CompositeValidationError(res...)
461 }
462 return nil
463 }
464
465 func (m *JarV001SchemaSignature) contextValidateContent(ctx context.Context, formats strfmt.Registry) error {
466
467 if err := validate.ReadOnly(ctx, "signature"+"."+"content", "body", strfmt.Base64(m.Content)); err != nil {
468 return err
469 }
470
471 return nil
472 }
473
474 func (m *JarV001SchemaSignature) contextValidatePublicKey(ctx context.Context, formats strfmt.Registry) error {
475
476 if m.PublicKey != nil {
477
478 if err := m.PublicKey.ContextValidate(ctx, formats); err != nil {
479 if ve, ok := err.(*errors.Validation); ok {
480 return ve.ValidateName("signature" + "." + "publicKey")
481 } else if ce, ok := err.(*errors.CompositeError); ok {
482 return ce.ValidateName("signature" + "." + "publicKey")
483 }
484 return err
485 }
486 }
487
488 return nil
489 }
490
491
492 func (m *JarV001SchemaSignature) MarshalBinary() ([]byte, error) {
493 if m == nil {
494 return nil, nil
495 }
496 return swag.WriteJSON(m)
497 }
498
499
500 func (m *JarV001SchemaSignature) UnmarshalBinary(b []byte) error {
501 var res JarV001SchemaSignature
502 if err := swag.ReadJSON(b, &res); err != nil {
503 return err
504 }
505 *m = res
506 return nil
507 }
508
509
510
511
512 type JarV001SchemaSignaturePublicKey struct {
513
514
515
516
517 Content *strfmt.Base64 `json:"content"`
518 }
519
520
521 func (m *JarV001SchemaSignaturePublicKey) Validate(formats strfmt.Registry) error {
522 var res []error
523
524 if err := m.validateContent(formats); err != nil {
525 res = append(res, err)
526 }
527
528 if len(res) > 0 {
529 return errors.CompositeValidationError(res...)
530 }
531 return nil
532 }
533
534 func (m *JarV001SchemaSignaturePublicKey) validateContent(formats strfmt.Registry) error {
535
536 if err := validate.Required("signature"+"."+"publicKey"+"."+"content", "body", m.Content); err != nil {
537 return err
538 }
539
540 return nil
541 }
542
543
544 func (m *JarV001SchemaSignaturePublicKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
545 var res []error
546
547 if len(res) > 0 {
548 return errors.CompositeValidationError(res...)
549 }
550 return nil
551 }
552
553
554 func (m *JarV001SchemaSignaturePublicKey) MarshalBinary() ([]byte, error) {
555 if m == nil {
556 return nil, nil
557 }
558 return swag.WriteJSON(m)
559 }
560
561
562 func (m *JarV001SchemaSignaturePublicKey) UnmarshalBinary(b []byte) error {
563 var res JarV001SchemaSignaturePublicKey
564 if err := swag.ReadJSON(b, &res); err != nil {
565 return err
566 }
567 *m = res
568 return nil
569 }
570
View as plain text