Skip to content

private/model/api: Fix API doc being generated with wrong value #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
### SDK Enhancements

### SDK Bugs
* `private/model/api`: Fix API doc being generated with wrong value ([#359](https://github.com/aws/aws-sdk-go-v2/pull/359))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add reference to the v1 git issue or create and reference v2 git issue?

* 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)
* `aws/ec2rolecreds`: Fix security creds path to include trailing slash ([#356](https://github.com/aws/aws-sdk-go-v2/pull/356))
* Fixes the iamSecurityCredsPath var to include a trailing slash preventing redirects when making requests to the EC2 Instance Metadata service.
* Fixes [#351](https://github.com/aws/aws-sdk-go-v2/issues/351)
32 changes: 16 additions & 16 deletions private/model/api/docstring.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
)

type apiDocumentation struct {
*API
Operations map[string]string
Service string
Shapes map[string]shapeDocumentation
Expand All @@ -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()
Expand All @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion service/kafka/api_op_CreateCluster.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.