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