Skip to content

Commit

Permalink
Update deps (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop authored Mar 18, 2024
1 parent eebc1f6 commit eaa1394
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/bool64/dev v0.2.34
github.com/stretchr/testify v1.8.2
github.com/swaggest/assertjson v1.9.0
github.com/swaggest/jsonschema-go v0.3.66
github.com/swaggest/jsonschema-go v0.3.70
github.com/swaggest/refl v1.3.0
gopkg.in/yaml.v2 v2.4.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ=
github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU=
github.com/swaggest/jsonschema-go v0.3.66 h1:4c5d7NRRqPLTswsbaypKqcMe3Z+CYHE3/lGsPIByp8o=
github.com/swaggest/jsonschema-go v0.3.66/go.mod h1:7N43/CwdaWgPUDfYV70K7Qm79tRqe/al7gLSt9YeGIE=
github.com/swaggest/jsonschema-go v0.3.70 h1:8Vx5nm5t/6DBFw2+WC0/Vp1ZVe9/4mpuA0tuAe0wwCI=
github.com/swaggest/jsonschema-go v0.3.70/go.mod h1:7N43/CwdaWgPUDfYV70K7Qm79tRqe/al7gLSt9YeGIE=
github.com/swaggest/refl v1.3.0 h1:PEUWIku+ZznYfsoyheF97ypSduvMApYyGkYF3nabS0I=
github.com/swaggest/refl v1.3.0/go.mod h1:3Ujvbmh1pfSbDYjC6JGG7nMgPvpG0ehQL4iNonnLNbg=
github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA=
Expand Down
50 changes: 50 additions & 0 deletions openapi31/reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1201,3 +1201,53 @@ func Test_Repro2(t *testing.T) {
}
}`, oarefl.SpecSchema())
}

type rawExposer func() ([]byte, error)

func (r rawExposer) JSONSchemaBytes() ([]byte, error) {
return r()
}

func TestReflector_AddOperation_rawSchema(t *testing.T) {
r := openapi31.NewReflector()
oc, err := r.NewOperationContext(http.MethodPost, "/foo")
require.NoError(t, err)

oc.AddRespStructure(rawExposer(func() ([]byte, error) {
return []byte(`{"type":"object","properties":{"foo":{"type":"integer"}}}`), nil
}), openapi.WithHTTPStatus(http.StatusAccepted))

oc.AddRespStructure(rawExposer(func() ([]byte, error) {
return []byte(`{"type":"object","properties":{"bar":{"type":"integer"}}}`), nil
}), openapi.WithHTTPStatus(http.StatusConflict))

require.NoError(t, r.AddOperation(oc))

assertjson.EqMarshal(t, `{
"openapi":"3.1.0","info":{"title":"","version":""},
"paths":{
"/foo":{
"post":{
"responses":{
"202":{
"description":"Accepted",
"content":{
"application/json":{
"schema":{"properties":{"foo":{"type":"integer"}},"type":"object"}
}
}
},
"409":{
"description":"Conflict",
"content":{
"application/json":{
"schema":{"properties":{"bar":{"type":"integer"}},"type":"object"}
}
}
}
}
}
}
}
}`, r.SpecSchema())
}

0 comments on commit eaa1394

Please sign in to comment.