From 5477b5b208b5968784265b4b828908e214256ec6 Mon Sep 17 00:00:00 2001 From: Raphael Simon Date: Sun, 22 Sep 2024 19:13:56 -0700 Subject: [PATCH] Property set request and response type UIDs When generated from a payload or result attribute. --- expr/http_body_types.go | 11 ++++++++++- go.mod | 16 +++++++++------- go.sum | 24 ++++++++++++------------ http/codegen/openapi/v3/example.go | 4 +++- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/expr/http_body_types.go b/expr/http_body_types.go index 5b0e43f18c..09724a19e9 100644 --- a/expr/http_body_types.go +++ b/expr/http_body_types.go @@ -128,6 +128,9 @@ func httpRequestBody(a *HTTPEndpointExpr) *AttributeExpr { if a.Body != nil { a.Body = DupAtt(a.Body) renameType(a.Body, name, suffix) + if ut, ok := a.Body.Type.(*UserTypeExpr); ok { + ut.UID = a.Service.Name() + "#" + name + } return a.Body } @@ -222,7 +225,7 @@ func httpStreamingBody(e *HTTPEndpointExpr) *AttributeExpr { ut := &UserTypeExpr{ AttributeExpr: DupAtt(att), TypeName: concat(e.Name(), "Streaming", "Body"), - UID: concat(e.Service.Name(), e.Name(), "Streaming", "Body"), + UID: e.Service.Name() + "#" + e.Name() + "StreamingBody", } appendSuffix(ut.Attribute().Type, suffix) @@ -282,6 +285,12 @@ func buildHTTPResponseBody(name string, attr *AttributeExpr, resp *HTTPResponseE } att := DupAtt(resp.Body) renameType(att, name, suffix) + if ut, ok := att.Type.(*UserTypeExpr); ok { + ut.UID = svc.Name() + "#" + name + } + if rt, ok := att.Type.(*ResultTypeExpr); ok { + rt.UID = svc.Name() + "#" + name + } return att } diff --git a/go.mod b/go.mod index 1db515b158..7da63e890c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module goa.design/goa/v3 -go 1.21.0 +go 1.22.0 + +toolchain go1.23.1 require ( github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598 @@ -12,8 +14,8 @@ require ( github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 golang.org/x/text v0.18.0 - golang.org/x/tools v0.24.0 - google.golang.org/grpc v1.66.1 + golang.org/x/tools v0.25.0 + google.golang.org/grpc v1.67.0 google.golang.org/protobuf v1.34.2 gopkg.in/yaml.v3 v3.0.1 ) @@ -29,9 +31,9 @@ require ( github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/perimeterx/marshmallow v1.1.5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/mod v0.20.0 // indirect - golang.org/x/net v0.28.0 // indirect + golang.org/x/mod v0.21.0 // indirect + golang.org/x/net v0.29.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.23.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a // indirect + golang.org/x/sys v0.25.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect ) diff --git a/go.sum b/go.sum index 2541c950ab..2c807418ed 100644 --- a/go.sum +++ b/go.sum @@ -46,22 +46,22 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= -golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a h1:hqK4+jJZXCU4pW7jsAdGOVFIfLHQeV7LaizZKnZ84HI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= -google.golang.org/grpc v1.66.1 h1:hO5qAXR19+/Z44hmvIM4dQFMSYX9XcWsByfoxutBpAM= -google.golang.org/grpc v1.66.1/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE= +golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw= +google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/http/codegen/openapi/v3/example.go b/http/codegen/openapi/v3/example.go index 35bd226e0c..e8f9e35563 100644 --- a/http/codegen/openapi/v3/example.go +++ b/http/codegen/openapi/v3/example.go @@ -1,6 +1,8 @@ package openapiv3 -import "goa.design/goa/v3/expr" +import ( + "goa.design/goa/v3/expr" +) type ( // exampler is the interface used to initialize the example of an