diff --git a/openapi3/ref.go b/openapi3/ref.go index e0d3f03a..71f79601 100644 --- a/openapi3/ref.go +++ b/openapi3/ref.go @@ -1,5 +1,9 @@ package openapi3 +import ( + "context" +) + //go:generate go run refsgenerator.go // Ref is specified by OpenAPI/Swagger 3.0 standard. @@ -8,3 +12,9 @@ type Ref struct { Ref string `json:"$ref" yaml:"$ref"` Extensions map[string]any `json:"extensions,omitempty" yaml:"$ref,omitempty"` } + +// Validate returns an error if Extensions does not comply with the OpenAPI spec. +func (e *Ref) Validate(ctx context.Context, opts ...ValidationOption) error { + ctx = WithValidationOptions(ctx, opts...) + return validateExtensions(ctx, e.Extensions) +}