oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

question: posibility of generating a mix of `StrictServerInterface` and `ServerInterface`

Open marmiha opened this issue 1 year ago • 0 comments

Is there a possibility of creating a combination of StrictServerInterface and ServerInterface. I sometimes run into problems, when I need the http.ResponseWriter and *http.Request. One example is for a Websocket endpoint definition ~ this endpoint then uses both of these to upgrade the connection.

For example is it possible to generate something in the sense of this:

type StrictServerInterface interface {
	// These are strict
	ListBuoys(ctx context.Context, request ListBuoysRequestObject) (ListBuoysResponseObject, error)
	DeleteCourse(ctx context.Context, request DeleteCourseRequestObject) (DeleteCourseResponseObject, error)

	// This one isn't
	WebsocketConnect(w http.ResponseWriter, r *http.Request)
}

This would make the interface flexible and would not restrict you to either the strict or non-strict server. I'm using chi for my routing.

There are probably workarounds for this, but I'm wondering if anyone already pondered on this issue and came up with a neat solution. If this was already asked - I'm sorry, I couldn't find any related issues regarding this.

marmiha avatar Jan 19 '24 08:01 marmiha