Skip to content

Commit

Permalink
make update (#252)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <[email protected]>
  • Loading branch information
fenollp authored Oct 30, 2024
1 parent 90c819c commit 2c74cea
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 125 deletions.
2 changes: 1 addition & 1 deletion Tagfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.48.23
0.49.0
47 changes: 24 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
module github.com/FuzzyMonkeyCo/monkey

go 1.18
go 1.21

toolchain go1.23.2

require (
github.com/alecthomas/chroma/v2 v2.8.0
github.com/bazelbuild/buildtools v0.0.0-20230713145820-b31f2c13c407
github.com/alecthomas/chroma/v2 v2.14.0
github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44
github.com/chzyer/readline v1.5.1
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
github.com/fatih/color v1.15.0
github.com/getkin/kin-openapi v0.118.0
github.com/fatih/color v1.18.0
github.com/getkin/kin-openapi v0.128.0
github.com/google/gnostic v0.7.0
github.com/google/uuid v1.3.1
github.com/google/uuid v1.6.0
github.com/hashicorp/logutils v1.0.0
github.com/mitchellh/mapstructure v1.5.0
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/superhawk610/bar v0.0.2
github.com/xeipuuv/gojsonschema v1.2.0
go.starlark.net v0.0.0-20230731234521-9b46791399bf
golang.org/x/sync v0.4.0
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.31.0
go.starlark.net v0.0.0-20240925182052-1207426daebd
golang.org/x/sync v0.8.0
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.35.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/dlclark/regexp2 v1.11.4 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/invopop/yaml v0.3.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-tty v0.0.5 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-tty v0.0.7 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/superhawk610/terminal v0.1.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
golang.org/x/net v0.16.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
119 changes: 52 additions & 67 deletions go.sum

Large diffs are not rendered by default.

31 changes: 11 additions & 20 deletions pkg/modeler/openapiv3/ir_openapi3.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func newSpecFromOA3(doc *openapi3.T) (vald *validator, err error) {
log.Println("[DBG] normalizing spec from OpenAPIv3")

docPaths, docSchemas := doc.Paths, doc.Components.Schemas
vald = newValidator(len(docPaths), len(docSchemas))
vald = newValidator(docPaths.Len(), len(docSchemas))
log.Println("[DBG] seeding schemas")
//TODO: use docPath as root of base
if err = vald.schemasFromOA3(docSchemas); err != nil {
Expand All @@ -47,16 +47,16 @@ func (vald *validator) schemasFromOA3(docSchemas map[string]*openapi3.SchemaRef)
return vald.seed(oa3ComponentsSchemas, schemas)
}

func (vald *validator) endpointsFromOA3(basePath string, docPaths openapi3.Paths) {
paths := make([]string, 0, len(docPaths))
for path := range docPaths {
func (vald *validator) endpointsFromOA3(basePath string, docPaths *openapi3.Paths) {
paths := make([]string, 0, docPaths.Len())
for path := range docPaths.Map() {
paths = append(paths, path)
}
sort.Strings(paths)

i := 0
for _, path := range paths {
docOps := docPaths[path].Operations()
docOps := docPaths.Value(path).Operations()
methods := make([]string, 0, len(docOps))
for docMethod := range docOps {
methods = append(methods, docMethod)
Expand Down Expand Up @@ -153,18 +153,18 @@ func (vald *validator) inputsFromOA3(inputs *[]*fm.ParamJSON, docParams openapi3
}
}

func (vald *validator) outputsFromOA3(docResponses openapi3.Responses) (
func (vald *validator) outputsFromOA3(docResponses *openapi3.Responses) (
outputs map[uint32]sid,
) {
outputs = make(map[uint32]sid)
codes := make([]string, 0, len(docResponses))
for code := range docResponses {
codes := make([]string, 0, docResponses.Len())
for code := range docResponses.Map() {
codes = append(codes, code)
}
sort.Strings(codes)

for _, code := range codes {
responseRef := docResponses[code]
responseRef := docResponses.Value(code)
xxx := makeXXXFromOA3(code)
// NOTE: Responses MAY have a schema
if len(responseRef.Value.Content) == 0 {
Expand Down Expand Up @@ -206,8 +206,8 @@ func (vald *validator) schemaFromOA3(s *openapi3.Schema) (schema schemaJSON) {
schema["type"] = []string{"null"}
}
// "type"
if sType := s.Type; sType != "" {
schema["type"] = ensureSchemaType(schema["type"], sType)
if sTypes := s.Type.Slice(); len(sTypes) != 0 {
schema["type"] = sTypes
}

// "format"
Expand Down Expand Up @@ -414,15 +414,6 @@ func makeXXXFromOA3(code string) uint32 {
return uint32(i)
}

func makeXXXToOA3(xxx uint32) string {
for k, v := range xxx2uint32 {
if v == xxx {
return k
}
}
return strconv.FormatUint(uint64(xxx), 10)
}

func isInputBody(input *fm.ParamJSON) bool {
return input.GetName() == "" && input.GetKind() == fm.ParamJSON_body
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/modeler/openapiv3/ir_openapi3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (sm schemap) schemasToOA3(doc *openapi3.T) {
}

func (sm schemap) endpointsToOA3(doc *openapi3.T, es map[eid]*fm.Endpoint) {
doc.Paths = make(openapi3.Paths, len(es))
paths := make([]openapi3.NewPathsOption, 0, len(es))
for _, e := range es {
endpoint := e.GetJson()
url := pathToOA3(endpoint.GetPathPartials())
Expand All @@ -152,11 +152,11 @@ func (sm schemap) endpointsToOA3(doc *openapi3.T, es map[eid]*fm.Endpoint) {
Parameters: params,
Responses: sm.outputsToOA3(endpoint.GetOutputs()),
}
if doc.Paths[url] == nil {
doc.Paths[url] = &openapi3.PathItem{}
}
methodToOA3(endpoint.GetMethod(), op, doc.Paths[url])
pathItem := &openapi3.PathItem{}
methodToOA3(endpoint.GetMethod(), op, pathItem)
paths = append(paths, openapi3.WithPath(url, pathItem))
}
doc.Paths = openapi3.NewPaths(paths...)
}

func (sm schemap) inputBodyToOA3(inputs []*fm.ParamJSON) (reqBodyRef *openapi3.RequestBodyRef) {
Expand Down Expand Up @@ -205,17 +205,17 @@ func (sm schemap) inputsToOA3(inputs []*fm.ParamJSON) (params openapi3.Parameter
return
}

func (sm schemap) outputsToOA3(outs map[uint32]sid) openapi3.Responses {
responses := make(openapi3.Responses, len(outs))
func (sm schemap) outputsToOA3(outs map[uint32]sid) *openapi3.Responses {
responses := make([]openapi3.NewResponsesOption, 0, len(outs))
for xxx, SID := range outs {
XXX := makeXXXToOA3(xxx)
responses[XXX] = &openapi3.ResponseRef{
response := &openapi3.ResponseRef{
Value: &openapi3.Response{Description: &someDescription}}
if SID != 0 {
responses[XXX].Value.Content = sm.contentToOA3(SID)
response.Value.Content = sm.contentToOA3(SID)
}
responses = append(responses, openapi3.WithStatus(int(xxx), response))
}
return responses
return openapi3.NewResponses(responses...)
}

func (sm schemap) contentToOA3(SID sid) openapi3.Content {
Expand Down
10 changes: 10 additions & 0 deletions pkg/runtime/exec_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ var starlarkExtendedUniverse = map[string][]string{
},

"set": {
"add",
"clear",
"difference",
"discard",
"intersection",
"issubset",
"issuperset",
"pop",
"remove",
"symmetric_difference",
"union",
},
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/runtime/fmt_warnings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func TestFmtWarnings(t *testing.T) {
"git-repository",
"http-archive",
"load",
"load-on-top",
"module-docstring",
"native-android",
"native-build",
Expand All @@ -35,14 +34,12 @@ func TestFmtWarnings(t *testing.T) {
"native-package",
"native-proto",
"native-py",
"out-of-order-load",
"output-group",
"package-name",
"package-on-top",
"provider-params",
"repository-name",
"rule-impl-return",
"same-origin-load",
}
require.Subset(t, warn.AllWarnings, deny)
require.IsIncreasing(t, deny)
Expand Down

0 comments on commit 2c74cea

Please sign in to comment.