Skip to content

Commit

Permalink
avoid panic when empty parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
rucciva committed Jun 20, 2024
1 parent e673999 commit a159836
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/proxy/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"path/filepath"

"github.com/pb33f/libopenapi"
"github.com/pb33f/libopenapi/datamodel/high/base"
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/telkomindonesia/oapik/internal/util"
Expand Down Expand Up @@ -219,6 +220,18 @@ func (pe *ProxyExtension) compile() (err error) {

// copy operation
opParam := util.CopyParameters(op.Parameters, params...)
if len(opParam) == 0 {
opParam = append(opParam, &v3.Parameter{
Name: "-",
In: "query",
Description: "IGNORE: workaround to prevent libopenapi from panicking",
Schema: base.CreateSchemaProxy(&base.Schema{
Type: []string{"string"},
}),
Deprecated: true,
AllowEmptyValue: true,
})
}
opID := op.OperationId
opSecurity := op.Security
opExt := op.Extensions
Expand Down

0 comments on commit a159836

Please sign in to comment.