-
Notifications
You must be signed in to change notification settings - Fork 1
/
entities.go
4280 lines (3332 loc) · 104 KB
/
entities.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by github.com/swaggest/go-code-builder, DO NOT EDIT.
package swagger
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"regexp"
)
// SwaggerSchema structure is generated from "#".
//
// A JSON Schema for Swagger 2.0 API.
type SwaggerSchema struct {
// General information about the API.
// Required.
Info Info `json:"info"`
// The host (name or ip) of the API. Example: 'swagger.io'.
// Value must match pattern: `^[^{}/ :\\]+(?::\d+)?$`.
Host string `json:"host,omitempty"`
// The base path to the API. Example: '/api'.
// Value must match pattern: `^/`.
BasePath string `json:"basePath,omitempty"`
Schemes []SchemesListItems `json:"schemes,omitempty"` // The transfer protocol of the API.
Consumes []string `json:"consumes,omitempty"` // A list of MIME types accepted by the API.
Produces []string `json:"produces,omitempty"` // A list of MIME types the API can produce.
// Relative paths to the individual endpoints. They must be relative to the 'basePath'.
// Required.
Paths Paths `json:"paths"`
Definitions map[string]Schema `json:"definitions,omitempty"` // One or more JSON objects describing the schemas being consumed and produced by the API.
Parameters map[string]Parameter `json:"parameters,omitempty"` // One or more JSON representations for parameters.
Responses map[string]Response `json:"responses,omitempty"` // One or more JSON representations for parameters.
Security []map[string][]string `json:"security,omitempty"`
SecurityDefinitions map[string]SecurityDefinitionsAdditionalProperties `json:"securityDefinitions,omitempty"`
Tags []Tag `json:"tags,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` // Information about external documentation.
MapOfAnything map[string]interface{} `json:"-"` // Key must match pattern: `^x-`.
}
type marshalSwaggerSchema SwaggerSchema
var knownKeysSwaggerSchema = []string{
"info",
"host",
"basePath",
"schemes",
"consumes",
"produces",
"paths",
"definitions",
"parameters",
"responses",
"security",
"securityDefinitions",
"tags",
"externalDocs",
"swagger",
}
var requireKeysSwaggerSchema = []string{
"swagger",
"info",
"paths",
}
// UnmarshalJSON decodes JSON.
func (s *SwaggerSchema) UnmarshalJSON(data []byte) error {
var err error
ms := marshalSwaggerSchema(*s)
err = json.Unmarshal(data, &ms)
if err != nil {
return err
}
var rawMap map[string]json.RawMessage
err = json.Unmarshal(data, &rawMap)
if err != nil {
rawMap = nil
}
for _, key := range requireKeysSwaggerSchema {
if _, found := rawMap[key]; !found {
return errors.New("required key missing: " + key)
}
}
if v, exists := rawMap["swagger"]; exists && string(v) != `"2.0"` {
return fmt.Errorf(`bad const value for "swagger" ("2.0" expected, %s received)`, v)
}
delete(rawMap, "swagger")
for _, key := range knownKeysSwaggerSchema {
delete(rawMap, key)
}
for key, rawValue := range rawMap {
matched := false
if regexX.MatchString(key) {
matched = true
if ms.MapOfAnything == nil {
ms.MapOfAnything = make(map[string]interface{}, 1)
}
var val interface{}
err = json.Unmarshal(rawValue, &val)
if err != nil {
return err
}
ms.MapOfAnything[key] = val
}
if matched {
delete(rawMap, key)
}
}
if len(rawMap) != 0 {
offendingKeys := make([]string, 0, len(rawMap))
for key := range rawMap {
offendingKeys = append(offendingKeys, key)
}
return fmt.Errorf("additional properties not allowed in SwaggerSchema: %v", offendingKeys)
}
*s = SwaggerSchema(ms)
return nil
}
var (
// constSwaggerSchema is unconditionally added to JSON.
constSwaggerSchema = json.RawMessage(`{"swagger":"2.0"}`)
)
// MarshalJSON encodes JSON.
func (s SwaggerSchema) MarshalJSON() ([]byte, error) {
return marshalUnion(constSwaggerSchema, marshalSwaggerSchema(s), s.MapOfAnything)
}
// Info structure is generated from "#/definitions/info".
//
// General information about the API.
type Info struct {
// A unique and precise title of the API.
// Required.
Title string `json:"title"`
// A semantic version number of the API.
// Required.
Version string `json:"version"`
Description string `json:"description,omitempty"` // A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed.
TermsOfService string `json:"termsOfService,omitempty"` // The terms of service for the API.
Contact *Contact `json:"contact,omitempty"` // Contact information for the owners of the API.
License *License `json:"license,omitempty"`
MapOfAnything map[string]interface{} `json:"-"` // Key must match pattern: `^x-`.
}
type marshalInfo Info
var knownKeysInfo = []string{
"title",
"version",
"description",
"termsOfService",
"contact",
"license",
}
var requireKeysInfo = []string{
"version",
"title",
}
// UnmarshalJSON decodes JSON.
func (i *Info) UnmarshalJSON(data []byte) error {
var err error
mi := marshalInfo(*i)
err = json.Unmarshal(data, &mi)
if err != nil {
return err
}
var rawMap map[string]json.RawMessage
err = json.Unmarshal(data, &rawMap)
if err != nil {
rawMap = nil
}
for _, key := range requireKeysInfo {
if _, found := rawMap[key]; !found {
return errors.New("required key missing: " + key)
}
}
for _, key := range knownKeysInfo {
delete(rawMap, key)
}
for key, rawValue := range rawMap {
matched := false
if regexX.MatchString(key) {
matched = true
if mi.MapOfAnything == nil {
mi.MapOfAnything = make(map[string]interface{}, 1)
}
var val interface{}
err = json.Unmarshal(rawValue, &val)
if err != nil {
return err
}
mi.MapOfAnything[key] = val
}
if matched {
delete(rawMap, key)
}
}
if len(rawMap) != 0 {
offendingKeys := make([]string, 0, len(rawMap))
for key := range rawMap {
offendingKeys = append(offendingKeys, key)
}
return fmt.Errorf("additional properties not allowed in Info: %v", offendingKeys)
}
*i = Info(mi)
return nil
}
// MarshalJSON encodes JSON.
func (i Info) MarshalJSON() ([]byte, error) {
return marshalUnion(marshalInfo(i), i.MapOfAnything)
}
// Contact structure is generated from "#/definitions/contact".
//
// Contact information for the owners of the API.
type Contact struct {
Name string `json:"name,omitempty"` // The identifying name of the contact person/organization.
// The URL pointing to the contact information.
// Format: uri.
URL string `json:"url,omitempty"`
// The email address of the contact person/organization.
// Format: email.
Email string `json:"email,omitempty"`
MapOfAnything map[string]interface{} `json:"-"` // Key must match pattern: `^x-`.
}
type marshalContact Contact
var knownKeysContact = []string{
"name",
"url",
"email",
}
// UnmarshalJSON decodes JSON.
func (c *Contact) UnmarshalJSON(data []byte) error {
var err error
mc := marshalContact(*c)
err = json.Unmarshal(data, &mc)
if err != nil {
return err
}
var rawMap map[string]json.RawMessage
err = json.Unmarshal(data, &rawMap)
if err != nil {
rawMap = nil
}
for _, key := range knownKeysContact {
delete(rawMap, key)
}
for key, rawValue := range rawMap {
matched := false
if regexX.MatchString(key) {
matched = true
if mc.MapOfAnything == nil {
mc.MapOfAnything = make(map[string]interface{}, 1)
}
var val interface{}
err = json.Unmarshal(rawValue, &val)
if err != nil {
return err
}
mc.MapOfAnything[key] = val
}
if matched {
delete(rawMap, key)
}
}
if len(rawMap) != 0 {
offendingKeys := make([]string, 0, len(rawMap))
for key := range rawMap {
offendingKeys = append(offendingKeys, key)
}
return fmt.Errorf("additional properties not allowed in Contact: %v", offendingKeys)
}
*c = Contact(mc)
return nil
}
// MarshalJSON encodes JSON.
func (c Contact) MarshalJSON() ([]byte, error) {
return marshalUnion(marshalContact(c), c.MapOfAnything)
}
// License structure is generated from "#/definitions/license".
type License struct {
// The name of the license type. It's encouraged to use an OSI compatible license.
// Required.
Name string `json:"name"`
// The URL pointing to the license.
// Format: uri.
URL string `json:"url,omitempty"`
MapOfAnything map[string]interface{} `json:"-"` // Key must match pattern: `^x-`.
}
type marshalLicense License
var knownKeysLicense = []string{
"name",
"url",
}
var requireKeysLicense = []string{
"name",
}
// UnmarshalJSON decodes JSON.
func (l *License) UnmarshalJSON(data []byte) error {
var err error
ml := marshalLicense(*l)
err = json.Unmarshal(data, &ml)
if err != nil {
return err
}
var rawMap map[string]json.RawMessage
err = json.Unmarshal(data, &rawMap)
if err != nil {
rawMap = nil
}
for _, key := range requireKeysLicense {
if _, found := rawMap[key]; !found {
return errors.New("required key missing: " + key)
}
}
for _, key := range knownKeysLicense {
delete(rawMap, key)
}
for key, rawValue := range rawMap {
matched := false
if regexX.MatchString(key) {
matched = true
if ml.MapOfAnything == nil {
ml.MapOfAnything = make(map[string]interface{}, 1)
}
var val interface{}
err = json.Unmarshal(rawValue, &val)
if err != nil {
return err
}
ml.MapOfAnything[key] = val
}
if matched {
delete(rawMap, key)
}
}
if len(rawMap) != 0 {
offendingKeys := make([]string, 0, len(rawMap))
for key := range rawMap {
offendingKeys = append(offendingKeys, key)
}
return fmt.Errorf("additional properties not allowed in License: %v", offendingKeys)
}
*l = License(ml)
return nil
}
// MarshalJSON encodes JSON.
func (l License) MarshalJSON() ([]byte, error) {
return marshalUnion(marshalLicense(l), l.MapOfAnything)
}
// Paths structure is generated from "#/definitions/paths".
//
// Relative paths to the individual endpoints. They must be relative to the 'basePath'.
type Paths struct {
MapOfAnything map[string]interface{} `json:"-"` // Key must match pattern: `^x-`.
MapOfPathItemValues map[string]PathItem `json:"-"` // Key must match pattern: `^/`.
}
// UnmarshalJSON decodes JSON.
func (p *Paths) UnmarshalJSON(data []byte) error {
var err error
var rawMap map[string]json.RawMessage
err = json.Unmarshal(data, &rawMap)
if err != nil {
rawMap = nil
}
for key, rawValue := range rawMap {
matched := false
if regexX.MatchString(key) {
matched = true
if p.MapOfAnything == nil {
p.MapOfAnything = make(map[string]interface{}, 1)
}
var val interface{}
err = json.Unmarshal(rawValue, &val)
if err != nil {
return err
}
p.MapOfAnything[key] = val
}
if regex.MatchString(key) {
matched = true
if p.MapOfPathItemValues == nil {
p.MapOfPathItemValues = make(map[string]PathItem, 1)
}
var val PathItem
err = json.Unmarshal(rawValue, &val)
if err != nil {
return err
}
p.MapOfPathItemValues[key] = val
}
if matched {
delete(rawMap, key)
}
}
if len(rawMap) != 0 {
offendingKeys := make([]string, 0, len(rawMap))
for key := range rawMap {
offendingKeys = append(offendingKeys, key)
}
return fmt.Errorf("additional properties not allowed in Paths: %v", offendingKeys)
}
return nil
}
// MarshalJSON encodes JSON.
func (p Paths) MarshalJSON() ([]byte, error) {
return marshalUnion(p.MapOfAnything, p.MapOfPathItemValues)
}
// PathItem structure is generated from "#/definitions/pathItem".
type PathItem struct {
Ref string `json:"$ref,omitempty"`
Get *Operation `json:"get,omitempty"`
Put *Operation `json:"put,omitempty"`
Post *Operation `json:"post,omitempty"`
Delete *Operation `json:"delete,omitempty"`
Options *Operation `json:"options,omitempty"`
Head *Operation `json:"head,omitempty"`
Patch *Operation `json:"patch,omitempty"`
Parameters []ParametersListItems `json:"parameters,omitempty"` // The parameters needed to send a valid API call.
MapOfAnything map[string]interface{} `json:"-"` // Key must match pattern: `^x-`.
}
type marshalPathItem PathItem
var knownKeysPathItem = []string{
"$ref",
"get",
"put",
"post",
"delete",
"options",
"head",
"patch",
"parameters",
}
// UnmarshalJSON decodes JSON.
func (p *PathItem) UnmarshalJSON(data []byte) error {
var err error
mp := marshalPathItem(*p)
err = json.Unmarshal(data, &mp)
if err != nil {
return err
}
var rawMap map[string]json.RawMessage
err = json.Unmarshal(data, &rawMap)
if err != nil {
rawMap = nil
}
for _, key := range knownKeysPathItem {
delete(rawMap, key)
}
for key, rawValue := range rawMap {
matched := false
if regexX.MatchString(key) {
matched = true
if mp.MapOfAnything == nil {
mp.MapOfAnything = make(map[string]interface{}, 1)
}
var val interface{}
err = json.Unmarshal(rawValue, &val)
if err != nil {
return err
}
mp.MapOfAnything[key] = val
}
if matched {
delete(rawMap, key)
}
}
if len(rawMap) != 0 {
offendingKeys := make([]string, 0, len(rawMap))
for key := range rawMap {
offendingKeys = append(offendingKeys, key)
}
return fmt.Errorf("additional properties not allowed in PathItem: %v", offendingKeys)
}
*p = PathItem(mp)
return nil
}
// MarshalJSON encodes JSON.
func (p PathItem) MarshalJSON() ([]byte, error) {
return marshalUnion(marshalPathItem(p), p.MapOfAnything)
}
// Operation structure is generated from "#/definitions/operation".
type Operation struct {
Tags []string `json:"tags,omitempty"`
Summary string `json:"summary,omitempty"` // A brief summary of the operation.
Description string `json:"description,omitempty"` // A longer description of the operation, GitHub Flavored Markdown is allowed.
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` // Information about external documentation.
ID string `json:"operationId,omitempty"` // A unique identifier of the operation.
Produces []string `json:"produces,omitempty"` // A list of MIME types the API can produce.
Consumes []string `json:"consumes,omitempty"` // A list of MIME types the API can consume.
Parameters []ParametersListItems `json:"parameters,omitempty"` // The parameters needed to send a valid API call.
// Response objects names can either be any valid HTTP status code or 'default'.
// Required.
Responses Responses `json:"responses"`
Schemes []SchemesListItems `json:"schemes,omitempty"` // The transfer protocol of the API.
Deprecated bool `json:"deprecated,omitempty"`
Security []map[string][]string `json:"security,omitempty"`
MapOfAnything map[string]interface{} `json:"-"` // Key must match pattern: `^x-`.
}
type marshalOperation Operation
var knownKeysOperation = []string{
"tags",
"summary",
"description",
"externalDocs",
"operationId",
"produces",
"consumes",
"parameters",
"responses",
"schemes",
"deprecated",
"security",
}
var requireKeysOperation = []string{
"responses",
}
// UnmarshalJSON decodes JSON.
func (o *Operation) UnmarshalJSON(data []byte) error {
var err error
mo := marshalOperation(*o)
err = json.Unmarshal(data, &mo)
if err != nil {
return err
}
var rawMap map[string]json.RawMessage
err = json.Unmarshal(data, &rawMap)
if err != nil {
rawMap = nil
}
for _, key := range requireKeysOperation {
if _, found := rawMap[key]; !found {
return errors.New("required key missing: " + key)
}
}
for _, key := range knownKeysOperation {
delete(rawMap, key)
}
for key, rawValue := range rawMap {
matched := false
if regexX.MatchString(key) {
matched = true
if mo.MapOfAnything == nil {
mo.MapOfAnything = make(map[string]interface{}, 1)
}
var val interface{}
err = json.Unmarshal(rawValue, &val)
if err != nil {
return err
}
mo.MapOfAnything[key] = val
}
if matched {
delete(rawMap, key)
}
}
if len(rawMap) != 0 {
offendingKeys := make([]string, 0, len(rawMap))
for key := range rawMap {
offendingKeys = append(offendingKeys, key)
}
return fmt.Errorf("additional properties not allowed in Operation: %v", offendingKeys)
}
*o = Operation(mo)
return nil
}
// MarshalJSON encodes JSON.
func (o Operation) MarshalJSON() ([]byte, error) {
return marshalUnion(marshalOperation(o), o.MapOfAnything)
}
// ExternalDocs structure is generated from "#/definitions/externalDocs".
//
// information about external documentation.
type ExternalDocs struct {
Description string `json:"description,omitempty"`
// Format: uri.
// Required.
URL string `json:"url"`
MapOfAnything map[string]interface{} `json:"-"` // Key must match pattern: `^x-`.
}
type marshalExternalDocs ExternalDocs
var knownKeysExternalDocs = []string{
"description",
"url",
}
var requireKeysExternalDocs = []string{
"url",
}
// UnmarshalJSON decodes JSON.
func (e *ExternalDocs) UnmarshalJSON(data []byte) error {
var err error
me := marshalExternalDocs(*e)
err = json.Unmarshal(data, &me)
if err != nil {
return err
}
var rawMap map[string]json.RawMessage
err = json.Unmarshal(data, &rawMap)
if err != nil {
rawMap = nil
}
for _, key := range requireKeysExternalDocs {
if _, found := rawMap[key]; !found {
return errors.New("required key missing: " + key)
}
}
for _, key := range knownKeysExternalDocs {
delete(rawMap, key)
}
for key, rawValue := range rawMap {
matched := false
if regexX.MatchString(key) {
matched = true
if me.MapOfAnything == nil {
me.MapOfAnything = make(map[string]interface{}, 1)
}
var val interface{}
err = json.Unmarshal(rawValue, &val)
if err != nil {
return err
}
me.MapOfAnything[key] = val
}
if matched {
delete(rawMap, key)
}
}
if len(rawMap) != 0 {
offendingKeys := make([]string, 0, len(rawMap))
for key := range rawMap {
offendingKeys = append(offendingKeys, key)
}
return fmt.Errorf("additional properties not allowed in ExternalDocs: %v", offendingKeys)
}
*e = ExternalDocs(me)
return nil
}
// MarshalJSON encodes JSON.
func (e ExternalDocs) MarshalJSON() ([]byte, error) {
return marshalUnion(marshalExternalDocs(e), e.MapOfAnything)
}
// BodyParameter structure is generated from "#/definitions/bodyParameter".
type BodyParameter struct {
Description string `json:"description,omitempty"` // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed.
// The name of the parameter.
// Required.
Name string `json:"name"`
Required bool `json:"required,omitempty"` // Determines whether or not this parameter is required or optional.
// A deterministic version of a JSON Schema object.
// Required.
Schema Schema `json:"schema"`
MapOfAnything map[string]interface{} `json:"-"` // Key must match pattern: `^x-`.
}
type marshalBodyParameter BodyParameter
var knownKeysBodyParameter = []string{
"description",
"name",
"required",
"schema",
"in",
}
var requireKeysBodyParameter = []string{
"name",
"in",
"schema",
}
// UnmarshalJSON decodes JSON.
func (b *BodyParameter) UnmarshalJSON(data []byte) error {
var err error
mb := marshalBodyParameter(*b)
err = json.Unmarshal(data, &mb)
if err != nil {
return err
}
var rawMap map[string]json.RawMessage
err = json.Unmarshal(data, &rawMap)
if err != nil {
rawMap = nil
}
for _, key := range requireKeysBodyParameter {
if _, found := rawMap[key]; !found {
return errors.New("required key missing: " + key)
}
}
if v, exists := rawMap["in"]; exists && string(v) != `"body"` {
return fmt.Errorf(`bad const value for "in" ("body" expected, %s received)`, v)
}
delete(rawMap, "in")
for _, key := range knownKeysBodyParameter {
delete(rawMap, key)
}
for key, rawValue := range rawMap {
matched := false
if regexX.MatchString(key) {
matched = true
if mb.MapOfAnything == nil {
mb.MapOfAnything = make(map[string]interface{}, 1)
}
var val interface{}
err = json.Unmarshal(rawValue, &val)
if err != nil {
return err
}
mb.MapOfAnything[key] = val
}
if matched {
delete(rawMap, key)
}
}
if len(rawMap) != 0 {
offendingKeys := make([]string, 0, len(rawMap))
for key := range rawMap {
offendingKeys = append(offendingKeys, key)
}
return fmt.Errorf("additional properties not allowed in BodyParameter: %v", offendingKeys)
}
*b = BodyParameter(mb)
return nil
}
var (
// constBodyParameter is unconditionally added to JSON.
constBodyParameter = json.RawMessage(`{"in":"body"}`)
)
// MarshalJSON encodes JSON.
func (b BodyParameter) MarshalJSON() ([]byte, error) {
return marshalUnion(constBodyParameter, marshalBodyParameter(b), b.MapOfAnything)
}
// Schema structure is generated from "#/definitions/schema".
//
// A deterministic version of a JSON Schema object.
type Schema struct {
Ref string `json:"$ref,omitempty"`
Format string `json:"format,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Default *interface{} `json:"default,omitempty"`
MultipleOf float64 `json:"multipleOf,omitempty"`
Maximum float64 `json:"maximum,omitempty"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`
Minimum float64 `json:"minimum,omitempty"`
ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`
MaxLength int64 `json:"maxLength,omitempty"`
MinLength int64 `json:"minLength,omitempty"`
Pattern string `json:"pattern,omitempty"` // Format: regex.
MaxItems int64 `json:"maxItems,omitempty"`
MinItems int64 `json:"minItems,omitempty"`
UniqueItems bool `json:"uniqueItems,omitempty"`
MaxProperties int64 `json:"maxProperties,omitempty"`
MinProperties int64 `json:"minProperties,omitempty"`
Required []string `json:"required,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
AdditionalProperties *SchemaAdditionalProperties `json:"additionalProperties,omitempty"`
Type *HTTPJSONSchemaOrgDraft04SchemaPropertiesType `json:"type,omitempty"`
Items *SchemaItems `json:"items,omitempty"`
AllOf []Schema `json:"allOf,omitempty"`
Properties map[string]Schema `json:"properties,omitempty"`
Discriminator string `json:"discriminator,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
XML *XML `json:"xml,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` // Information about external documentation.
Example *interface{} `json:"example,omitempty"`
MapOfAnything map[string]interface{} `json:"-"` // Key must match pattern: `^x-`.
}
type marshalSchema Schema
var knownKeysSchema = []string{
"$ref",
"format",
"title",
"description",
"default",
"multipleOf",
"maximum",
"exclusiveMaximum",
"minimum",
"exclusiveMinimum",
"maxLength",
"minLength",
"pattern",
"maxItems",
"minItems",
"uniqueItems",
"maxProperties",
"minProperties",
"required",
"enum",
"additionalProperties",
"type",
"items",
"allOf",