Fixed spec format setting for 3.1 in SpecInfo

This commit is contained in:
quobix
2024-05-16 17:29:54 -04:00
parent 0d9b1906d1
commit 338eaa3dac
2 changed files with 2 additions and 1 deletions

View File

@@ -114,6 +114,7 @@ func ExtractSpecInfoWithDocumentCheck(spec []byte, bypass bool) (*SpecInfo, erro
case "3.1.0", "3.1":
specInfo.VersionNumeric = 3.1
specInfo.APISchema = OpenAPI31SchemaData
specInfo.SpecFormat = OAS31
default:
specInfo.VersionNumeric = 3.0
specInfo.APISchema = OpenAPI3SchemaData

View File

@@ -296,7 +296,7 @@ func (d *document) BuildV3Model() (*DocumentModel[v3high.Document], []error) {
errs = append(errs, fmt.Errorf("unable to build document, no specification has been loaded"))
return nil, errs
}
if d.info.SpecFormat != datamodel.OAS3 {
if d.info.SpecFormat != datamodel.OAS3 && d.info.SpecFormat != datamodel.OAS31 {
errs = append(errs, fmt.Errorf("unable to build openapi document, "+
"supplied spec is a different version (%v). Try 'BuildV2Model()'", d.info.SpecFormat))
return nil, errs