Skip to content

Commit

Permalink
fix: remove conflicted and redundant error check for ParamsOneOf (#84)
Browse files Browse the repository at this point in the history
Change-Id: I5b904255a6ba4d2094b530fa94318d6645744232
  • Loading branch information
shentongmartin authored Feb 25, 2025
1 parent f2f2f5e commit 124d713
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
15 changes: 0 additions & 15 deletions schema/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package schema

import (
"fmt"

"github.com/getkin/kin-openapi/openapi3"
)

Expand Down Expand Up @@ -119,19 +117,6 @@ func (p *ParamsOneOf) ToOpenAPIV3() (*openapi3.Schema, error) {
return nil, nil
}

var (
useParameterInfo = p.params != nil
useOpenAPIV3 = p.openAPIV3 != nil
)

if !useParameterInfo && !useOpenAPIV3 {
return nil, fmt.Errorf("ParamsOneOf needs to have at least one method to describe the parameters")
}

if useParameterInfo && useOpenAPIV3 {
return nil, fmt.Errorf("ParamsOneOf can only have one method to describe the parameters, but not multiple methods")
}

if p.params != nil {
sc := &openapi3.Schema{
Properties: make(map[string]*openapi3.SchemaRef, len(p.params)),
Expand Down
14 changes: 0 additions & 14 deletions schema/tool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ func TestParamsOneOfToJSONSchema(t *testing.T) {
err error
)

convey.Convey("user provides no option if ParamsOneOf", func() {
_, err = oneOf.ToOpenAPIV3()
convey.So(err, convey.ShouldNotBeNil)
convey.So(err.Error(), convey.ShouldContainSubstring, "ParamsOneOf needs to have at least one method to describe the parameters")
})

convey.Convey("user provides multiple options in ParamsOneOf", func() {
oneOf.params = make(map[string]*ParameterInfo)
oneOf.openAPIV3 = &openapi3.Schema{}
_, err = oneOf.ToOpenAPIV3()
convey.So(err, convey.ShouldNotBeNil)
convey.So(err.Error(), convey.ShouldContainSubstring, "ParamsOneOf can only have one method to describe the parameters, but not multiple methods")
})

convey.Convey("user provides openAPIV3.0 json schema directly, use what the user provides", func() {
oneOf.openAPIV3 = &openapi3.Schema{
Type: openapi3.TypeString,
Expand Down

0 comments on commit 124d713

Please sign in to comment.