Skip to content

Commit

Permalink
private/model/api: Add custom doc blob doc string
Browse files Browse the repository at this point in the history
Adds custom doc string to blob types to document the fact the SDK will
automatically encode and decode the value as it goes across the wire.
Presenting the user with a raw binary []byte type. Without needing to
manually encode/decode the value.

Fix aws#559
  • Loading branch information
jasdel authored and xibz committed Apr 18, 2016
1 parent dc6cd2b commit 789fdfd
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions private/model/api/customization_passes.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package api

import (
"fmt"
"path/filepath"
"strings"
)
Expand All @@ -16,6 +17,34 @@ func (a *API) customizationPasses() {
if fn := svcCustomizations[a.PackageName()]; fn != nil {
fn(a)
}

blobDocStringCustomizations(a)
}

const base64MarshalDocStr = "// %s is automatically base64 encoded/decoded by the SDK.\n"

func blobDocStringCustomizations(a *API) {
for _, s := range a.Shapes {
payloadMemberName := s.Payload

for refName, ref := range s.MemberRefs {
if refName == payloadMemberName {
// Payload members have their own encoding and may
// be raw bytes or io.Reader
continue
}
if ref.Shape.Type == "blob" {
docStr := fmt.Sprintf(base64MarshalDocStr, refName)
if len(strings.TrimSpace(ref.Shape.Documentation)) != 0 {
ref.Shape.Documentation += "//\n" + docStr
} else if len(strings.TrimSpace(ref.Documentation)) != 0 {
ref.Documentation += "//\n" + docStr
} else {
ref.Documentation = docStr
}
}
}
}
}

// s3Customizations customizes the API generation to replace values specific to S3.
Expand Down

0 comments on commit 789fdfd

Please sign in to comment.