ogen icon indicating copy to clipboard operation
ogen copied to clipboard

Custom types

Open happenslol opened this issue 1 year ago • 0 comments

Description

I use the google.UUID type for IDs in my application. While I can validate the format as uuid for fields, it would be great if I did not have to convert back and forth between strings and UUIDs, since I basically always have to do this:

// Convert for responses
myUUID := uuid.New()
apiUUID := api.UUID(myUUID.String())

// Convert from requests
myUUID := uuid.MustParse(string(params.SomeID))

Maybe I overlooked this and it's already possible. Otherwise, would there be something from preventing adding custom types through schema extensions? I could imagine something like this:

components:
  schemas:
    uuid:
      x-ogen-type: "uuid.UUID"
      x-ogen-type-import: "github.com/google/uuid"

happenslol avatar Mar 31 '24 16:03 happenslol