Closed ArujReis closed 1 month ago
Works! Thanks for the quick fix!
As a side note, it still doesn't work if jsonschema.Struct
is passed directly, rather than being embedded in a struct, since the check doesn't check the input itself:
refl.WalkFieldsRecursively(reflect.ValueOf(input), func(v reflect.Value, _ reflect.StructField, _ []reflect.StructField) {
if v.Type() == reflect.TypeOf(jsonschema.Struct{}) {
hasJSONSchemaStruct = true
}
}
I.e. this works:
type Req struct {
jsonschema.Struct
}
req := Req{}
...
oc.AddReqStructure(*req, reqOpts...)
This does't:
req := jsonschema.Struct{}
...
oc.AddReqStructure(*req, reqOpts...)
It doesn't impact my use case, but the behavior is not very intuitive. Thanks again.
Describe the bug When a
jsonschema.Struct
is passed tosetupRequest
it doesn't work. For example, when used withoc.AddReqStructure
. As far as I can tell, it happens becauserefl.HasTaggedFields
(called fromReflectRequestBody
) works on theStruct
's fields instead of theField
elements.To Reproduce Here is an example for
HasTaggedFields
returning an incorrect answer.Expected behavior
setupRequest
should work onjsonschema.Struct
the same waysetupResponse
does.Additional context I'm trying to add an OpenAPI schema to an existing APIs. I don't want to rewrite all the input structs, but wanted to extend them to include the URL params. Unfortunately, this didn't work due the aforementioned issue.