You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure of your issue processes, so please let me know if I need to do something else/different.
Issue
Including the entoas.Skip(true) annotation on a field or edge causes the generated handlers to not be able to compile:
# entdemo/ent/ogent
ent/ogent/ogent.go:35:20: req.Password undefined (type *CreateUserReq has no field or method Password)
ent/ogent/ogent.go:109:18: req.Password undefined (type *UpdateUserReq has no field or method Password)
ent/ogent/responses.go:14:6: ret.Password undefined (type UserCreate has no field or method Password)
ent/ogent/responses.go:43:6: ret.Password undefined (type UserList has no field or method Password)
ent/ogent/responses.go:72:6: ret.Password undefined (type UserRead has no field or method Password)
ent/ogent/responses.go:101:6: ret.Password undefined (type UserUpdate has no field or method Password)
ent/ogent/responses.go:130:6: ret.Password undefined (type UserChildrenList has no field or method Password)
ent/ogent/responses.go:159:6: ret.Password undefined (type UserParentRead has no field or method Password)
ent/ogent/responses.go:188:6: ret.Password undefined (type UserSecretChildrenList has no field or method Password)
ent/ogent/responses.go:217:6: ret.Password undefined (type UserSecretParentRead has no field or method Password)
ent/ogent/responses.go:217:6: too many errors
Fix
I have a branch on my fork that fixes this issue for ogent: https://github.com/swalkerhppr/ogent/tree/skip-fix
It fixes skipping fields, but skipping edges makes the resulting ogen server not fully implemented:
./main.go:24:29: cannot use ogent.NewOgentHandler(client) (value of type *ogent.OgentHandler) as ogent.Handler value in argument to ogent.NewServer: *ogent.OgentHandler does not implement ogent.Handler (missing method ListUserSecretChildren)
Which I believe is an entoas issue as the openapi.json schema still has secret_parent and secret_children in it. Further research is needed for that.
Code that causes the issue
// ent/schema/user.gopackage schema
import (
"entgo.io/contrib/entoas""entgo.io/ent""entgo.io/ent/schema/edge""entgo.io/ent/schema/field"
)
// User holds the schema definition for the User entity.typeUserstruct {
ent.Schema
}
// Fields of the User.func (User) Fields() []ent.Field {
return []ent.Field{
field.String("username"),
field.String("password").
Annotations(
entoas.Skip(true), // Skip the "password" field
),
}
}
// Edges of the User.func (User) Edges() []ent.Edge {
return []ent.Edge{
edge.To("secret_children", User.Type).
Annotations(
entoas.Skip(true), // Skip the "secret_children" edge
).
From("secret_parent").
Unique().
Annotations(
entoas.Skip(true), // Skip the "secret_parent" edge
),
edge.To("children", User.Type).
From("parent").
Unique(),
}
}
Update: My suspicions were correct, entoas was generating endpoints for skipped edges. I fixed the issue there and made a pull request to contrib to fix the issue: ent/contrib#574
Using my updated versions produces the expected behavior. I think you'd want to wait until the entoas change is resolved until you'd want to update it here. I will create a pull request once/if the updates are in.
I'm not sure of your issue processes, so please let me know if I need to do something else/different.
Issue
Including the
entoas.Skip(true)
annotation on a field or edge causes the generated handlers to not be able to compile:Fix
I have a branch on my fork that fixes this issue for ogent: https://github.com/swalkerhppr/ogent/tree/skip-fix
It fixes skipping fields, but skipping edges makes the resulting ogen server not fully implemented:
Which I believe is an entoas issue as the openapi.json schema still has secret_parent and secret_children in it. Further research is needed for that.
Code that causes the issue
Expected behavior
go generate ./...
grep -ir "password\|secret" ent/ogent
should show no references to password, secret_children nor secret_parentgo run .
should work compile/runThe text was updated successfully, but these errors were encountered: