@@ -231,6 +231,10 @@ func (callback *Callback) Value(key string) *PathItem
231
231
Value returns the callback for key or nil
232
232
233
233
type CallbackRef struct {
234
+ // Extensions only captures fields starting with 'x-' as no other fields
235
+ // are allowed by the openapi spec.
236
+ Extensions map[string]any
237
+
234
238
Ref string
235
239
Value *Callback
236
240
@@ -430,6 +434,10 @@ func (example *Example) Validate(ctx context.Context, opts ...ValidationOption)
430
434
Validate returns an error if Example does not comply with the OpenAPI spec.
431
435
432
436
type ExampleRef struct {
437
+ // Extensions only captures fields starting with 'x-' as no other fields
438
+ // are allowed by the openapi spec.
439
+ Extensions map[string]any
440
+
433
441
Ref string
434
442
Value *Example
435
443
@@ -528,6 +536,10 @@ func (header *Header) Validate(ctx context.Context, opts ...ValidationOption) er
528
536
Validate returns an error if Header does not comply with the OpenAPI spec.
529
537
530
538
type HeaderRef struct {
539
+ // Extensions only captures fields starting with 'x-' as no other fields
540
+ // are allowed by the openapi spec.
541
+ Extensions map[string]any
542
+
531
543
Ref string
532
544
Value *Header
533
545
@@ -641,6 +653,10 @@ func (link *Link) Validate(ctx context.Context, opts ...ValidationOption) error
641
653
Validate returns an error if Link does not comply with the OpenAPI spec.
642
654
643
655
type LinkRef struct {
656
+ // Extensions only captures fields starting with 'x-' as no other fields
657
+ // are allowed by the openapi spec.
658
+ Extensions map[string]any
659
+
644
660
Ref string
645
661
Value *Link
646
662
@@ -963,6 +979,10 @@ func (parameter *Parameter) WithRequired(value bool) *Parameter
963
979
func (parameter *Parameter) WithSchema(value *Schema) *Parameter
964
980
965
981
type ParameterRef struct {
982
+ // Extensions only captures fields starting with 'x-' as no other fields
983
+ // are allowed by the openapi spec.
984
+ Extensions map[string]any
985
+
966
986
Ref string
967
987
Value *Parameter
968
988
@@ -1207,6 +1227,10 @@ func (requestBody *RequestBody) WithSchema(value *Schema, consumes []string) *Re
1207
1227
func (requestBody *RequestBody) WithSchemaRef(value *SchemaRef, consumes []string) *RequestBody
1208
1228
1209
1229
type RequestBodyRef struct {
1230
+ // Extensions only captures fields starting with 'x-' as no other fields
1231
+ // are allowed by the openapi spec.
1232
+ Extensions map[string]any
1233
+
1210
1234
Ref string
1211
1235
Value *RequestBody
1212
1236
@@ -1282,6 +1306,10 @@ func (m ResponseBodies) JSONLookup(token string) (any, error)
1282
1306
https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
1283
1307
1284
1308
type ResponseRef struct {
1309
+ // Extensions only captures fields starting with 'x-' as no other fields
1310
+ // are allowed by the openapi spec.
1311
+ Extensions map[string]any
1312
+
1285
1313
Ref string
1286
1314
Value *Response
1287
1315
@@ -1588,6 +1616,10 @@ func (err *SchemaError) JSONPointer() []string
1588
1616
func (err SchemaError) Unwrap() error
1589
1617
1590
1618
type SchemaRef struct {
1619
+ // Extensions only captures fields starting with 'x-' as no other fields
1620
+ // are allowed by the openapi spec.
1621
+ Extensions map[string]any
1622
+
1591
1623
Ref string
1592
1624
Value *Schema
1593
1625
@@ -1748,6 +1780,10 @@ func (ss *SecurityScheme) WithScheme(value string) *SecurityScheme
1748
1780
func (ss *SecurityScheme) WithType(value string) *SecurityScheme
1749
1781
1750
1782
type SecuritySchemeRef struct {
1783
+ // Extensions only captures fields starting with 'x-' as no other fields
1784
+ // are allowed by the openapi spec.
1785
+ Extensions map[string]any
1786
+
1751
1787
Ref string
1752
1788
Value *SecurityScheme
1753
1789
@@ -1968,6 +2004,12 @@ type ValidationOption func(options *ValidationOptions)
1968
2004
ValidationOption allows the modification of how the OpenAPI document is
1969
2005
validated.
1970
2006
2007
+ func AllowExtensionsWithRef() ValidationOption
2008
+ AllowExtensionsWithRef allows extensions (fields starting with 'x-') as
2009
+ siblings for $ref fields. This is the default. Non-extension fields are
2010
+ prohibited unless allowed explicitly with the AllowExtraSiblingFields
2011
+ option.
2012
+
1971
2013
func AllowExtraSiblingFields(fields ...string) ValidationOption
1972
2014
AllowExtraSiblingFields called as AllowExtraSiblingFields("description")
1973
2015
makes Validate not return an error when said field appears next to a $ref.
@@ -2008,6 +2050,12 @@ func EnableSchemaPatternValidation() ValidationOption
2008
2050
DisableSchemaPatternValidation. By default, schema pattern validation is
2009
2051
enabled.
2010
2052
2053
+ func ProhibitExtensionsWithRef() ValidationOption
2054
+ ProhibitExtensionsWithRef causes the validation to return an error if
2055
+ extensions (fields starting with 'x-') are found as siblings for $ref
2056
+ fields. Non-extension fields are prohibited unless allowed explicitly with
2057
+ the AllowExtraSiblingFields option.
2058
+
2011
2059
type ValidationOptions struct {
2012
2060
// Has unexported fields.
2013
2061
}
0 commit comments