Skip to content

Commit 321443f

Browse files
authored
private/model/api: Fix API doc being generated with wrong value (#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. The SDK was not considering the member's type when associating documentation with the member. Only parent struct name and member names was being used. V2 Port of aws/aws-sdk-go#2748
1 parent 8d7fdba commit 321443f

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

CHANGELOG_PENDING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
### SDK Enhancements
44

55
### SDK Bugs
6+
* `private/model/api`: Fix API doc being generated with wrong value ([#359](https://github.com/aws/aws-sdk-go-v2/pull/359))
7+
* 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.
8+
* V2 port of to v1 [aws/aws-sdk-go#2748](https://github.com/aws/aws-sdk-go/issues/2748)
69
* `aws/ec2rolecreds`: Fix security creds path to include trailing slash ([#356](https://github.com/aws/aws-sdk-go-v2/pull/356))
710
* Fixes the iamSecurityCredsPath var to include a trailing slash preventing redirects when making requests to the EC2 Instance Metadata service.
811
* Fixes [#351](https://github.com/aws/aws-sdk-go-v2/issues/351)

private/model/api/docstring.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
)
1818

1919
type apiDocumentation struct {
20-
*API
2120
Operations map[string]string
2221
Service string
2322
Shapes map[string]shapeDocumentation
@@ -30,7 +29,7 @@ type shapeDocumentation struct {
3029

3130
// AttachDocs attaches documentation from a JSON filename.
3231
func (a *API) AttachDocs(filename string) {
33-
d := apiDocumentation{API: a}
32+
var d apiDocumentation
3433

3534
f, err := os.Open(filename)
3635
defer f.Close()
@@ -42,39 +41,40 @@ func (a *API) AttachDocs(filename string) {
4241
panic(err)
4342
}
4443

45-
d.setup()
46-
44+
d.setup(a)
4745
}
4846

49-
func (d *apiDocumentation) setup() {
50-
d.API.Documentation = docstring(d.Service)
47+
func (d *apiDocumentation) setup(a *API) {
48+
a.Documentation = docstring(d.Service)
5149

5250
for opName, doc := range d.Operations {
53-
if _, ok := d.API.Operations[opName]; !ok {
51+
if _, ok := a.Operations[opName]; !ok {
5452
panic(fmt.Sprintf("%s, doc op %q not found in API op set",
55-
d.API.ServiceID(), opName),
53+
a.ServiceID(), opName),
5654
)
5755
}
58-
d.API.Operations[opName].Documentation = docstring(doc)
56+
a.Operations[opName].Documentation = docstring(doc)
5957
}
6058

61-
for shape, info := range d.Shapes {
62-
if sh := d.API.Shapes[shape]; sh != nil {
63-
sh.Documentation = docstring(info.Base)
59+
for shapeName, docShape := range d.Shapes {
60+
if s, ok := a.Shapes[shapeName]; ok {
61+
s.Documentation = docstring(docShape.Base)
6462
}
6563

66-
for ref, doc := range info.Refs {
64+
for ref, doc := range docShape.Refs {
6765
if doc == "" {
6866
continue
6967
}
7068

7169
parts := strings.Split(ref, "$")
7270
if len(parts) != 2 {
73-
fmt.Fprintf(os.Stderr, "Shape Doc %s has unexpected reference format, %q\n", shape, ref)
71+
fmt.Fprintf(os.Stderr,
72+
"Shape Doc %s has unexpected reference format, %q\n",
73+
shapeName, ref)
7474
continue
7575
}
76-
if sh := d.API.Shapes[parts[0]]; sh != nil {
77-
if m := sh.MemberRefs[parts[1]]; m != nil {
76+
if s, ok := a.Shapes[parts[0]]; ok && len(s.MemberRefs) != 0 {
77+
if m, ok := s.MemberRefs[parts[1]]; ok && m.ShapeName == shapeName {
7878
m.Documentation = docstring(doc)
7979
}
8080
}

service/kafka/api_op_CreateCluster.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)