Skip to content

Conversation

@NicoleStrel
Copy link

Addresses #868

Since uuid is a standard format, I added format: uuid so 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

Copilot AI review requested due to automatic review settings July 31, 2025 12:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.UUID type to automatically generate schemas with format: 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{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@danielgtaylor danielgtaylor added the dependencies Pull requests that update a dependency file label Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants