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

Guid uri template path/query parameter values should be normalized to string #160

Closed
baywet opened this issue Mar 19, 2024 · 2 comments · Fixed by #188
Closed

Guid uri template path/query parameter values should be normalized to string #160

baywet opened this issue Mar 19, 2024 · 2 comments · Fixed by #188
Assignees
Labels
bug A broken experience Standard GitHub label Issue caused by core project dependency modules or library WIP

Comments

@baywet
Copy link
Member

baywet commented Mar 19, 2024

the std uri template library does not handle guids, and wont because it's not a standard API across languages and they don't want to bring on additional dependencies.
We should normalize the value to string (no curlies) before we pass it to the uri template engine.
Originally reported:
std-uritemplate/std-uritemplate#140
microsoft/kiota#4335

Example implementation https://github.com/microsoft/kiota-abstractions-dotnet/blob/5a93d126e9ce30ae332e65f30df7b941e7d7c265/src/RequestInformation.cs#L123

@baywet baywet added bug A broken experience Standard GitHub label Issue caused by core project dependency modules or library labels Mar 19, 2024
@github-project-automation github-project-automation bot moved this to Todo in Kiota Mar 19, 2024
@michaeldcanady
Copy link

@baywet what about using go-querystring? it has support for custom encoders. Then any instance of uuid.UUID can be converted to the following type:

type EncodableUUID struct {
	uuid.UUID
}

func (id EncodableUUID) EncodeValues(key string, v *url.Values) error {
	strId := id.String()
	strId = strings.ReplaceAll(strId, "{", "")
	strId = strings.ReplaceAll(strId, "}", "")
	v.Add(key, strId)

	return nil
}

only point of concern I can see if they use the tag "url" instead of "uriparametername".

@baywet
Copy link
Member Author

baywet commented Nov 10, 2024

Thanks for following up on this. This is actually already properly handled by the enum case in the normalization.
I have authored #188 to add unit tests that demonstrate it it working as expected.

@github-project-automation github-project-automation bot moved this from Todo 📃 to Done ✔️ in Kiota Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A broken experience Standard GitHub label Issue caused by core project dependency modules or library WIP
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants