Skip to content

Commit

Permalink
resolved panic reported in #412
Browse files Browse the repository at this point in the history
Additional nil check added for params, headers and media types.

Signed-off-by: quobix <dave@quobix.com>
  • Loading branch information
daveshanley committed Jan 12, 2024
1 parent cfd43ea commit e908e72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ui/dist
go.work
go.work.sum:w
:q
12 changes: 6 additions & 6 deletions functions/openapi/examples_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ func (es ExamplesSchema) RunRule(_ []*yaml.Node, context model.RuleFunctionConte
for i := range context.DrDocument.Parameters {
p := context.DrDocument.Parameters[i]
wg.Go(func() {
if p.Value.Examples.Len() >= 1 {
if p.Value.Examples.Len() >= 1 && p.SchemaProxy != nil {
results = append(results, parseExamples(p.SchemaProxy.Schema, p, p.Value.Examples)...)
} else {
if p.Value.Example != nil {
if p.Value.Example != nil && p.SchemaProxy != nil {
results = append(results, parseExample(p.SchemaProxy.Schema, p.Value.Example)...)
}
}
Expand All @@ -178,10 +178,10 @@ func (es ExamplesSchema) RunRule(_ []*yaml.Node, context model.RuleFunctionConte
for i := range context.DrDocument.Headers {
h := context.DrDocument.Headers[i]
wg.Go(func() {
if h.Value.Examples.Len() >= 1 {
if h.Value.Examples.Len() >= 1 && h.SchemaProxy != nil {
results = append(results, parseExamples(h.SchemaProxy.Schema, h, h.Value.Examples)...)
} else {
if h.Value.Example != nil {
if h.Value.Example != nil && h.SchemaProxy != nil {
results = append(results, parseExample(h.SchemaProxy.Schema, h.Value.Example)...)
}
}
Expand All @@ -193,10 +193,10 @@ func (es ExamplesSchema) RunRule(_ []*yaml.Node, context model.RuleFunctionConte
for i := range context.DrDocument.MediaTypes {
mt := context.DrDocument.MediaTypes[i]
wg.Go(func() {
if mt.Value.Examples.Len() >= 1 {
if mt.Value.Examples.Len() >= 1 && mt.SchemaProxy != nil {
results = append(results, parseExamples(mt.SchemaProxy.Schema, mt, mt.Value.Examples)...)
} else {
if mt.Value.Example != nil {
if mt.Value.Example != nil && mt.SchemaProxy != nil {
results = append(results, parseExample(mt.SchemaProxy.Schema, mt.Value.Example)...)
}
}
Expand Down

0 comments on commit e908e72

Please sign in to comment.