Major surgery on the index and resolver. A complete flip in design.

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2023-10-14 12:36:38 -04:00
parent de85651414
commit 511843e4df
29 changed files with 592 additions and 354 deletions

View File

@@ -24,7 +24,6 @@ import (
v3high "github.com/pb33f/libopenapi/datamodel/high/v3"
v2low "github.com/pb33f/libopenapi/datamodel/low/v2"
v3low "github.com/pb33f/libopenapi/datamodel/low/v3"
"github.com/pb33f/libopenapi/resolver"
"github.com/pb33f/libopenapi/utils"
what_changed "github.com/pb33f/libopenapi/what-changed"
"github.com/pb33f/libopenapi/what-changed/model"
@@ -44,6 +43,10 @@ type Document interface {
// allowing remote or local references, as well as a BaseURL to allow for relative file references.
SetConfiguration(configuration *datamodel.DocumentConfiguration)
// GetConfiguration will return the configuration for the document. This allows for finer grained control over
// allowing remote or local references, as well as a BaseURL to allow for relative file references.
GetConfiguration() *datamodel.DocumentConfiguration
// BuildV2Model will build out a Swagger (version 2) model from the specification used to create the document
// If there are any issues, then no model will be returned, instead a slice of errors will explain all the
// problems that occurred. This method will only support version 2 specifications and will throw an error for
@@ -166,6 +169,10 @@ func (d *document) GetSpecInfo() *datamodel.SpecInfo {
return d.info
}
func (d *document) GetConfiguration() *datamodel.DocumentConfiguration {
return d.config
}
func (d *document) SetConfiguration(configuration *datamodel.DocumentConfiguration) {
d.config = configuration
}
@@ -254,7 +261,7 @@ func (d *document) BuildV2Model() (*DocumentModel[v2high.Swagger], []error) {
// Do not short-circuit on circular reference errors, so the client
// has the option of ignoring them.
for _, err := range errors {
if refErr, ok := err.(*resolver.ResolvingError); ok {
if refErr, ok := err.(*index.ResolvingError); ok {
if refErr.CircularReference == nil {
return nil, errors
}
@@ -297,7 +304,7 @@ func (d *document) BuildV3Model() (*DocumentModel[v3high.Document], []error) {
// Do not short-circuit on circular reference errors, so the client
// has the option of ignoring them.
for _, err := range errors {
if refErr, ok := err.(*resolver.ResolvingError); ok {
if refErr, ok := err.(*index.ResolvingError); ok {
if refErr.CircularReference == nil {
return nil, errors
}