Added uuid to have a default format: uuid#875
Added uuid to have a default format: uuid#875NicoleStrel wants to merge 1 commit intodanielgtaylor:mainfrom
format: uuid#875Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds automatic schema generation support for UUID types by setting the default format to "uuid" when github.com/google/uuid.UUID types are encountered. This eliminates the need to manually define schemas for this common type.
- Added support for
uuid.UUIDtype to automatically generate schemas withformat: uuid - Updated test coverage to verify the new UUID schema generation functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| schema.go | Added UUID type support with automatic "uuid" format assignment in schema generation |
| schema_test.go | Added test case to verify UUID schema generation produces correct format |
| ipAddrType = reflect.TypeOf(netip.Addr{}) | ||
| urlType = reflect.TypeOf(url.URL{}) | ||
| rawMessageType = reflect.TypeOf(json.RawMessage{}) | ||
| uuidType = reflect.TypeOf(uuid.UUID{}) |
There was a problem hiding this comment.
IMO users should be able to inform which uuid library they are using, as a google library might not be their first option. @NicoleStrel What do you think?
There was a problem hiding this comment.
Yeah @NicoleStrel this adds a dependency on the Google UUID library and we are trying to keep dependencies to a minimum. I'd be open to a PR which doesn't require additional dependencies.
For now you can just set format:"uuid" like this: https://go.dev/play/p/swjPaRjVQcx
Addresses #868
Since
uuidis a standard format, I addedformat: uuidso that you do not need to define a schema for this common type.Let me know if other built-in string types need default formats