From 17712da1860ea8319ff4f9244007ec9cf090e427 Mon Sep 17 00:00:00 2001 From: srinandan Date: Wed, 1 Dec 2021 08:04:14 -0800 Subject: [PATCH] fix #13: support string valued properties --- bundlegen/generateapi.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bundlegen/generateapi.go b/bundlegen/generateapi.go index c5fa8b54..0d054be0 100644 --- a/bundlegen/generateapi.go +++ b/bundlegen/generateapi.go @@ -40,7 +40,7 @@ var generateOAuthPolicy, generateAPIKeyPolicy bool var doc *openapi3.T -func LoadDocumentFromFile(filePath string, validate bool) (string, []byte, error) { +func LoadDocumentFromFile(filePath string, validate bool, formatValidation bool) (string, []byte, error) { var err error var jsonContent []byte @@ -49,6 +49,13 @@ func LoadDocumentFromFile(filePath string, validate bool) (string, []byte, error return "", nil, err } + //add custom string definitions + openapi3.DefineStringFormat("uuid", openapi3.FormatOfStringForUUIDOfRFC4122) + + if !formatValidation { + openapi3.SchemaFormatValidationDisabled = true + } + if validate { if err = doc.Validate(openapi3.NewLoader().Context); err != nil { return "", nil, err @@ -67,7 +74,7 @@ func LoadDocumentFromFile(filePath string, validate bool) (string, []byte, error } } -func LoadDocumentFromURI(uri string, validate bool) (string, []byte, error) { +func LoadDocumentFromURI(uri string, validate bool, formatValidation bool) (string, []byte, error) { var err error var jsonContent []byte @@ -81,6 +88,13 @@ func LoadDocumentFromURI(uri string, validate bool) (string, []byte, error) { return "", nil, err } + //add custom string definitions + openapi3.DefineStringFormat("uuid", openapi3.FormatOfStringForUUIDOfRFC4122) + + if !formatValidation { + openapi3.SchemaFormatValidationDisabled = true + } + if validate { if err = doc.Validate(openapi3.NewLoader().Context); err != nil { return "", nil, err