From 5b1f71c7a864d0245d27574aabf2363fcfc15102 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte Date: Mon, 19 Aug 2019 12:53:20 -0700 Subject: [PATCH 1/3] private/model/api: Fix API doc being generated with wrong value Fixes the SDK's generated API documentation for structure member being generated with the wrong documentation value when the member was included multiple times in the model doc-2.json file, but under different types. The SDK was not considering the member's type when associating documetation with the member. Only parent struct name and member names was being used. V2 Port of aws/aws-sdk-go#2748 --- private/model/api/docstring.go | 32 +++++++++++++-------------- service/kafka/api_op_CreateCluster.go | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/private/model/api/docstring.go b/private/model/api/docstring.go index a6ccbba480d..e13c4306162 100644 --- a/private/model/api/docstring.go +++ b/private/model/api/docstring.go @@ -17,7 +17,6 @@ import ( ) type apiDocumentation struct { - *API Operations map[string]string Service string Shapes map[string]shapeDocumentation @@ -30,7 +29,7 @@ type shapeDocumentation struct { // AttachDocs attaches documentation from a JSON filename. func (a *API) AttachDocs(filename string) { - d := apiDocumentation{API: a} + var d apiDocumentation f, err := os.Open(filename) defer f.Close() @@ -42,39 +41,40 @@ func (a *API) AttachDocs(filename string) { panic(err) } - d.setup() - + d.setup(a) } -func (d *apiDocumentation) setup() { - d.API.Documentation = docstring(d.Service) +func (d *apiDocumentation) setup(a *API) { + a.Documentation = docstring(d.Service) for opName, doc := range d.Operations { - if _, ok := d.API.Operations[opName]; !ok { + if _, ok := a.Operations[opName]; !ok { panic(fmt.Sprintf("%s, doc op %q not found in API op set", - d.API.ServiceID(), opName), + a.ServiceID(), opName), ) } - d.API.Operations[opName].Documentation = docstring(doc) + a.Operations[opName].Documentation = docstring(doc) } - for shape, info := range d.Shapes { - if sh := d.API.Shapes[shape]; sh != nil { - sh.Documentation = docstring(info.Base) + for shapeName, docShape := range d.Shapes { + if s, ok := a.Shapes[shapeName]; ok { + s.Documentation = docstring(docShape.Base) } - for ref, doc := range info.Refs { + for ref, doc := range docShape.Refs { if doc == "" { continue } parts := strings.Split(ref, "$") if len(parts) != 2 { - fmt.Fprintf(os.Stderr, "Shape Doc %s has unexpected reference format, %q\n", shape, ref) + fmt.Fprintf(os.Stderr, + "Shape Doc %s has unexpected reference format, %q\n", + shapeName, ref) continue } - if sh := d.API.Shapes[parts[0]]; sh != nil { - if m := sh.MemberRefs[parts[1]]; m != nil { + if s, ok := a.Shapes[parts[0]]; ok && len(s.MemberRefs) != 0 { + if m, ok := s.MemberRefs[parts[1]]; ok && m.ShapeName == shapeName { m.Documentation = docstring(doc) } } diff --git a/service/kafka/api_op_CreateCluster.go b/service/kafka/api_op_CreateCluster.go index b61c2f21225..502b1369650 100644 --- a/service/kafka/api_op_CreateCluster.go +++ b/service/kafka/api_op_CreateCluster.go @@ -44,7 +44,7 @@ type CreateClusterInput struct { // KafkaVersion is a required field KafkaVersion *string `locationName:"kafkaVersion" min:"1" type:"string" required:"true"` - // The number of broker nodes in the cluster. + // The number of Kafka broker nodes in the Amazon MSK cluster. // // NumberOfBrokerNodes is a required field NumberOfBrokerNodes *int64 `locationName:"numberOfBrokerNodes" min:"1" type:"integer" required:"true"` From d0a196ce1ca7223a824387e1208ee73ee488ae79 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte Date: Mon, 19 Aug 2019 12:58:34 -0700 Subject: [PATCH 2/3] add changelog --- CHANGELOG_PENDING.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 9ede26b5499..ce2328819ea 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -3,6 +3,5 @@ ### SDK Enhancements ### SDK Bugs -* `private/model`: Handles empty map vs unset map behavior in send request ([#337](https://github.com/aws/aws-sdk-go-v2/pull/337)) - * Updates shape marshal model to handle the empty map vs nil map behavior. Also adds a test case to assert behavior when a user sends an empty map vs unset map. - * Fixes [#332](https://github.com/aws/aws-sdk-go-v2/issues/332) +* `private/model/api`: Fix API doc being generated with wrong value ([#359](https://github.com/aws/aws-sdk-go-v2/pull/359)) + * Fixes the SDK's generated API documentation for structure member being generated with the wrong documentation value when the member was included multiple times in the model doc-2.json file, but under different types. From 14b3fa2122fa90536451b287ce7332439d2c90f0 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte Date: Tue, 20 Aug 2019 10:16:42 -0700 Subject: [PATCH 3/3] Add reference to v1 issue. --- CHANGELOG_PENDING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index ce2328819ea..de7fc097fd5 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -5,3 +5,4 @@ ### SDK Bugs * `private/model/api`: Fix API doc being generated with wrong value ([#359](https://github.com/aws/aws-sdk-go-v2/pull/359)) * Fixes the SDK's generated API documentation for structure member being generated with the wrong documentation value when the member was included multiple times in the model doc-2.json file, but under different types. + * V2 port of to v1 [aws/aws-sdk-go#2748](https://github.com/aws/aws-sdk-go/issues/2748)