Skip to content

Commit

Permalink
Circular ref check was not happening before model build.
Browse files Browse the repository at this point in the history
This was causing a stack overflow on certain specs. Provides resolution for: pb33f/libopenapi#229

Signed-off-by: quobix <dave@quobix.com>
  • Loading branch information
daveshanley committed Jan 13, 2024
1 parent 61b63de commit ffe5198
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions motor/rule_applicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ func ApplyRulesToRuleSet(execution *RuleSetExecution) *RuleSetExecutionResult {

// avoid building the index, we don't need it to run yet.
indexConfig.AvoidBuildIndex = true
indexConfig.AvoidCircularReferenceCheck = true
//indexConfig.AvoidCircularReferenceCheck = true

docConfig := datamodel.NewDocumentConfiguration()
docConfig.SkipCircularReferenceCheck = true
//docConfig.SkipCircularReferenceCheck = true

// add new pretty logger.
if execution.Logger == nil {
Expand Down Expand Up @@ -337,7 +337,7 @@ func ApplyRulesToRuleSet(execution *RuleSetExecution) *RuleSetExecutionResult {
specUnresolved = rolodexUnresolved.GetRootIndex().GetRootNode()

if rolodexResolved != nil && rolodexResolved.GetRootIndex() != nil {
resolvingErrors = rolodexResolved.GetRootIndex().GetResolver().GetResolvingErrors()
//resolvingErrors = rolodexResolved.GetRootIndex().GetResolver().GetResolvingErrors()
circularReferences = rolodexResolved.GetRootIndex().GetResolver().GetCircularReferences()
}

Expand Down
2 changes: 1 addition & 1 deletion motor/rule_applicator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1882,7 +1882,7 @@ components:
assert.Len(t, results.Errors, 0)

assert.NotNil(t, results)
assert.Equal(t, "infinite circular reference detected: #/components/schemas/one: one -> two -> one [14:7]",
assert.Equal(t, "infinite circular reference detected: one: one -> two -> one [14:7]",
results.Results[0].Message)
assert.Equal(t, "resolving-references", results.Results[0].RuleId)
}
Expand Down

0 comments on commit ffe5198

Please sign in to comment.