Open learning-go123 opened 1 week ago
@learning-go123 sorry I don't entirely understand the question. Do you have a runnable example or some input example vs. input struct where this fails and what you would prefer to see happen?
@danielgtaylor https://go.dev/play/p/58af3WgDFjg
@learning-go123 aaaaah now I understand. Thank you for the example! Here's how you can make it work: https://go.dev/play/p/7oVfLkGBmcJ. What I did was make sure the schema is generated with additionalProperties: true
rather than the default of false
for strict validation. See the docs here:
It's also possible to modify the schemas after generation, e.g. go through api.OpenAPI().Components.Schemas
and set the AdditionalProperties
field to true
manually wherever you need to, or to provide your own custom schema for a particular operation. Hope this helps!
Refer to this: https://github.com/danielgtaylor/huma/issues/285 I wrote the following code
There is a problem here. If the fields of params are more than the fields of the structure in v, it will not pass the validation. Turning off validation will introduce additional validators. Is there some better way to make the code more unified?