From 3aa1f029a87a13e8c4817a72fcb25f7c74ab507b Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Tue, 27 Aug 2024 03:36:43 -0700 Subject: [PATCH] Possible fix for failing test that checks for validaiton methods --- openapi3/ref.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) +}