Comments (3)
I believe i'm impacted by a similar issue when trying to use field.JSON
and specifying []strings{}
in the field type. I've tried many permutations of annotations or other config but the failure message (super unhelpful) is:
running ent codegen: execute template "ogent/responses": template: response.tmpl:17:6: executing "ogent/responses" at <setFieldExpr $f $n "ret" "e">: error calling setFieldExpr: unexpected type: ""
I'm additionally confused why I'm unable to use ogen.String().AsArray()
even though it's in the declaration for the field.JSON
type: https://github.com/ent/contrib/blob/master/entoas/generator_test.go#L65
from ogent.
Agree with @matoszz, the only annotation that I've found will get field.JSON to work with entoas is something like:
type Model struct {
ent.Schema
}
func (Model) Fields() []ent.Field {
return []ent.Field{
field.Int("id"),
field.String("name"),
field.JSON("location", []byte{}).
Annotations(entoas.Schema(&ogen.Schema{
Type: "object",
Description: "Location",
Properties: []ogen.Property{
{Name: "latitude", Schema: ogen.Double()},
{Name: "longitude", Schema: ogen.Double()},
},
})),
}
}
as described here: ent/ent#3573 (comment)
Whilst that will generate an openapi.json file, it then causes issues in ogent with:
ent/ogent/ogent.go:35:16: cannot use req.Location (variable of type CreateModelReqLocation) as []uint8 value in argument to b.SetLocation
ent/ogent/ogent.go:103:17: cannot use v (variable of type UpdateModelReqLocation) as []uint8 value in argument to b.SetLocation
ent/ogent/responses.go:14:17: cannot use e.Location (variable of type []uint8) as ModelCreateLocation value in assignment
ent/ogent/responses.go:43:17: cannot use e.Location (variable of type []uint8) as ModelListLocation value in assignment
ent/ogent/responses.go:72:17: cannot use e.Location (variable of type []uint8) as ModelReadLocation value in assignment
ent/ogent/responses.go:101:17: cannot use e.Location (variable of type []uint8) as ModelUpdateLocation value in assignment
Is there a way to have JSON.field describe a json object that entoas and ogent are happy with?
from ogent.
running ent codegen: execute template "ogent/responses": template: response.tmpl:17:6: executing "ogent/responses" at <setFieldExpr $f $n "ret" "e">: error calling setFieldExpr: unexpected type: "" Is this the reason to use field.JSON?
from ogent.
Related Issues (14)
- feat: add restrictions to page and itemsPerPage HOT 1
- bug: go version 1.17 not supported HOT 1
- bug: support for overriding id field
- bug: autogenerated PATCH endpoints behave like PUT endpoints
- Add prefix to all rest calls HOT 2
- response.tmpl does not support nillable() fields
- Package `syncint64` is deprecated HOT 2
- No support of immutable fields HOT 1
- List sub incorrectly uses Node Type for Edge
- Unable to install ogent using module path from blog post HOT 1
- pkg.go.dev does not generate documentation for ogent because repository does not contain LICENSE file HOT 1
- Ogent doesn't work with ENUM types. HOT 3
- go.opentelemetry.io/otel/metric types change to different module HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ogent.