Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
fix #13: support string valued properties
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Dec 1, 2021
1 parent 5186da9 commit 17712da
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions bundlegen/generateapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 17712da

Please sign in to comment.