lrstanley / entrest

Extension that generates a compliant OpenAPI spec and server implementation
https://lrstanley.github.io/entrest/
MIT License
11 stars 2 forks source link

feature: Support schema with UUID type id field #69

Open akeelnazir opened 2 months ago

akeelnazir commented 2 months ago

✨ Describe the feature you'd like

When specifying an id field of type UUID, it is unable to generate the oapi.

Cause

func (Pet) Fields() []ent.Field {
    return []ent.Field{
        field.UUID("id", uuid.UUID{}).Default(uuid.New).Unique(),
        field.String("name").
            Annotations(
                entrest.WithExample("Kuro"),
                entrest.WithSortable(true),
                entrest.WithFilter(entrest.FilterGroupEqual|entrest.FilterGroupArray),
            ),
...

Error

panic: failed to generate schema for field ID: no openapi type exists for type "[16]byte" of field ID

🌧 Is your feature request related to a problem?

No response

🔎 Describe alternatives you've considered

NA

⚠ If implemented, do you think this feature will be a breaking change to users?

No

⚙ Additional context

No response

🤝 Requirements

akeelnazir commented 2 months ago

I found AllowClientUUIDs: true, flag in your source code, but it doesn't seem to work.

ex, err := entrest.NewExtension(&entrest.Config{
    SpecFromPath:     "../base-openapi.json",
    Handler:          entrest.HandlerStdlib,
    WithTesting:      true,
    StrictMutate:     true,
    AllowClientUUIDs: true,
})

I also removed field.UUID("id", uuid.UUID{}).Default(uuid.New).Unique(), from the pet schema def, but I'm still getting int16 column in my generates Postgres.