Comments (2)
I wonder if it's possible to catch the issue, and not render the schema link for specific objects that suffer from this issue? Or is there an alterantive mechanism to construct the schema links?
from huma.
@steeling here's a basic repro. This panics:
type Foo struct {
Field string `json:"field"`
}
func (f Foo) Method() string {
return "bar"
}
// GreetingOutput represents the greeting operation response.
type GreetingOutput struct {
Body struct {
Foo
Message string `json:"message" example:"Hello, world!" doc:"Greeting message"`
}
}
This works (note the pointer method receiver):
type Foo struct {
Field string `json:"field"`
}
func (f *Foo) Method() string {
return "bar"
}
// GreetingOutput represents the greeting operation response.
type GreetingOutput struct {
Body struct {
Foo
Message string `json:"message" example:"Hello, world!" doc:"Greeting message"`
}
}
Apparently this is a long-standing known issue in Go: golang/go#15924. It's unclear right now if it can be worked around since it's a problem with the underlying language support for reflection.
In the meantime, you can use pointer method receivers or disable the transformer:
config := huma.DefaultConfig("My API", "1.0.0")
config.CreateHooks = []func(Config) Config{}
// api := ... use config ...
from huma.
Related Issues (20)
- Error return for huma.StreamResponse.Body HOT 1
- Schema(r huma.Registry) *huma.Schema not working on Pointer
- Validation errors localization HOT 2
- Question: Is there a way to add comments to fields? HOT 1
- Version Chi v4 Into Separate Release
- Removing schema reference in response HOT 2
- Multiline doc description for struct fields
- Bug: API doc hidden is not *real* hidden HOT 1
- Allow custom query param types.
- Required query parameter not going through validation when it is omitted HOT 1
- Generating Huma Code from OpenAPI Spec HOT 2
- Generating the openapi.json offline HOT 2
- Defining Servers Causes 404 from OpenAPI Endpoint HOT 1
- Unexported Fields in Schemas are Not Considered for Schema Generation HOT 2
- Any sample code to get http.Request.RemoteAddr in huma.context
- The validation of format:"email" is not perfect. HOT 3
- The default error response field value in openapi docs is "DEFAULT" HOT 2
- Support multiple query parameters with the same name
- Accessing validation results in the request pipeline
- Need to explicitly call PrecomputeMessages() when using custom RequestBody
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 huma.