Skip to content
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

Generating path for client is transforming all relevant types to string first. #977

Merged
merged 3 commits into from Dec 16, 2016

Conversation

rootpd
Copy link

@rootpd rootpd commented Dec 15, 2016

I have a feeling that it could be done with a bit less duplicity within initParams. Opened to any ideas (or just push a change) :).

PR is fixing issue #961, which was partially fixed yesterday.

@rootpd
Copy link
Author

rootpd commented Dec 15, 2016

I see the failing Travis. Going for christmas party, will take care tomorrow (central europe time). :)

@@ -334,13 +333,50 @@ func (g *Generator) generateResourceClient(pkgDir string, res *design.ResourceDe
}
}
}
initParams := func(att *design.AttributeDefinition) []*paramData {

This comment was marked as off-topic.

return fmt.Sprintf({{ printf "%q" (pathTemplate .) }}, {{ pathParamNames . }})
*/}}// {{ $funcName }} computes a request path to the {{ .Route.Parent.Name }} action of {{ .Route.Parent.Parent.Name }}.
func {{ $funcName }}({{ pathParams .Route }}) string {
var params []interface{}

This comment was marked as off-topic.

@raphael
Copy link
Member

raphael commented Dec 15, 2016

Thank you for doing this! looks great. I suggested a couple of tweaks in the comments. Have fun at the party :)

@rootpd
Copy link
Author

rootpd commented Dec 16, 2016

Thanks for the hints and patience! This time it even looks greener than the last time :).

@rootpd
Copy link
Author

rootpd commented Dec 16, 2016

Found one more bug with the order of generated params, expect one more commit. I've realized that initParams is iterating Object which is a randomized-order map. That means that also generated params are being generated in random order.

Route params need to be generated and used in Sprintf
in a correct order. As the AttributeDefinition.Type is always
a map, for route params we need to maintain this order by
other means. In this case by manufacturing AttributeDefinition
separately for each route param.
@raphael
Copy link
Member

raphael commented Dec 16, 2016

Thank you for the great PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants