oapi-codegen / nethttp-middleware

Apache License 2.0
10 stars 7 forks source link

application/merge-patch+json is not supported #16

Closed daniel-eichinger-bl closed 5 months ago

daniel-eichinger-bl commented 6 months ago

I'm unable to use oapi-codegen/nethttp-middleware for application/merge-patch+json Content-Types. I generated a strict server using: https://github.com/deepmap/oapi-codegen and used your middleware to validate requests.

The request cannot be validated as https://github.com/oapi-codegen/nethttp-middleware/blob/main/oapi_validate.go#L91 returns an error as the https://github.com/getkin/kin-openapi does not provide a decoder for application/merge-patch+json.

The maintainers of getkin-openapi made the JSON body decode public (https://github.com/getkin/kin-openapi/pull/896) so it should be possible to register new media types.

kogxi commented 5 months ago

Since openapi3filter.RegisterBodyDecoder is exported you should be able to workaround this issue by registering the openapi3filter.JSONBodyDecoder in your code. E.g., openapi3filter.RegisterBodyDecoder("application/merge-patch+json“, openapi3filter.JSONBodyDecoder) .

daniel-eichinger-bl commented 5 months ago

Closing therefore!