-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
private/model/api: Generating useful examples #1309
Conversation
83050f9
to
ea62fbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is an issue with the generator not generating dynamodb.AttributeValue
s correctly. Looked at a few examples an noticed none of the nested structures were being generated. The example models include values though.
I didn't look at the other services to see if they had similar issues.
private/model/api/example.go
Outdated
|
||
switch v := shape.(type) { | ||
case bool: | ||
//return fmt.Sprintf("%s: aws.Bool(%t),\n", memName, v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these comments still needed?
private/model/api/example.go
Outdated
return parseTimeString(ref, memName, fmt.Sprintf("%d", v)) | ||
} else { | ||
return convertToCorrectType(memName, ref.Shape.MemberRefs[name].Shape.Type, fmt.Sprintf("%d", v)) | ||
//return fmt.Sprintf("%s: aws.Int64(%d),\n", memName, v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
} | ||
} | ||
|
||
func buildComplex(name, memName string, ref *ShapeRef, v map[string]interface{}) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed the buildComplex
doesn't handle slices is that just because we didn't have any list data in example model?
private/model/api/example.go
Outdated
memName := name | ||
if isMap { | ||
memName = fmt.Sprintf("%q", memName) | ||
} else if ref != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty conditional
private/model/api/example.go
Outdated
|
||
// buildShape will recursively build the referenced shape based on the json object | ||
// provided. | ||
func buildShape(ref *ShapeRef, shapes map[string]interface{}, isMap bool) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be helpful to document the isMap
parameter and what its expectations are
@@ -9133,7 +9133,7 @@ type Group struct { | |||
HealthCheckType *string `min:"1" type:"string" required:"true"` | |||
|
|||
// The EC2 instances associated with the group. | |||
Instances []*Instance `type:"list"` | |||
Instances []*InstanceDetails `type:"list"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this file should of changed.
service/s3/bucket_location_test.go
Outdated
if v := len(v); v != 0 { | ||
t.Errorf("expect no values, got %d", v) | ||
if l := len(v); l != 0 { | ||
t.Errorf("expect no values, got %d", l) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where these changes to this file intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, linter was complaining about v
being shadowed
service/dynamodb/examples_test.go
Outdated
func ExampleDynamoDB_BatchWriteItem_shared00() { | ||
svc := dynamodb.New(session.New()) | ||
input := &dynamodb.BatchWriteItemInput{ | ||
RequestItems: map[string][]*dynamodb.WriteRequest{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are missing nested values from the example model. Based on the description it sounds like there should be additional fields.
service/dynamodb/examples_test.go
Outdated
input := &dynamodb.DeleteItemInput{ | ||
Key: map[string]*dynamodb.AttributeValue{ | ||
"Artist": {}, | ||
"SongTitle": {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these have fields's AttributeValue have values?
service/dynamodb/examples_test.go
Outdated
Item: map[string]*dynamodb.AttributeValue{ | ||
"AlbumTitle": {}, | ||
"Artist": {}, | ||
"SongTitle": {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something in the example generator is preventing AttributeValue
fields from getting rendered. Or is these just missing from the model?
6e45f8d
to
6e12fba
Compare
4d800e3
to
c44370c
Compare
No description provided.