if your req
used for keep body params/headers only and underhood it implement ClientRequestWriter
interface for create actual request (where request created from your object is used for: https://github.com/go-openapi/runtime/blob/da56347e36dc1a470118d4306d2821572c3ad14f/client/request.go#L107), if so, you can decorate WriteToRequest
method (from ClientRequestWriter interface):
type decoratedRequest struct {
SomeOperationRequest // it must be same type for which defined WriteToRequest method, probably it will be pointer to SomeOperationRequest type
// here you can add custom headers params if you want
}
func (r *decoratedRequest) WriteToRequest(req ClientRequest, reg strfmt.Registry) error
if err := r.SomeOperationRequest.WriteToRequest(req, reg); err != nil {
return err
}
//here you manualy edit actual request to the server
return req.SetHeaderParam("your-header", "your-value")
}
and production code will look like:
res, err := s.client.MyApi.
SomeOperation(context.Background(), id).
SomeOperationRequest(decoratedRequest{SomeOperationRequest: req}).
Execute()
PS: in your case to make the actual request to the server may be used another interface, but idea is the same
PSS: this will be work, but idiomatic way would be to edit openapi.yaml