{"modulePath":"github.com/ascendsoftware/oapi-codegen","version":"v1.0.12","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testutil\n\nCopyright 2019 ascendsoftware, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n## Functions\n\n```go\nfunc RegisterResponseHandler(mime string, handler ResponseHandler)\n```\n\n## Types\n\n```go\ntype CompletedRequest struct {\n\tRecorder *httptest.ResponseRecorder\n\n\t// When set to true, decoders will be more strict. In the default JSON\n\t// recorder, unknown fields will cause errors.\n\tStrict bool\n}\n```\nCompletedRequest is the result of calling Go() on the request builder. We're wrapping the ResponseRecorder with some nice helper functions.\n\n```go\nfunc (c *CompletedRequest) Code() int\n```\nCode is a shortcut for response code\n\n```go\nfunc (c *CompletedRequest) DisallowUnknownFields()\n```\n\n```go\nfunc (c *CompletedRequest) UnmarshalBodyToObject(obj interface{}) error\n```\nUnmarshalBodyToObject takes a destination object as input, and unmarshals the object in the response based on the Content-Type header.\n\n```go\nfunc (c *CompletedRequest) UnmarshalJsonToObject(obj interface{}) error\n```\nUnmarshalJsonToObject assumes that the response contains JSON and unmarshals it into the specified object.\n\n```go\ntype RequestBuilder struct {\n\tMethod  string\n\tPath    string\n\tHeaders map[string]string\n\tBody    []byte\n\tError   error\n\tCookies []*http.Cookie\n}\n```\nRequestBuilder caches request settings as we build up the request.\n\n```go\nfunc NewRequest() *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) Delete(path string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) Get(path string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) Go(t *testing.T, e *echo.Echo) *CompletedRequest\n```\nGo performs the request, it takes a pointer to a testing context to print messages, and a pointer to an echo context for request handling.\n\n```go\nfunc (r *RequestBuilder) GoWithHTTPHandler(t *testing.T, handler http.Handler) *CompletedRequest\n```\nGoWithHTTPHandler performs the request, it takes a pointer to a testing context to print messages, and a http handler for request handling.\n\n```go\nfunc (r *RequestBuilder) Patch(path string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) Post(path string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) Put(path string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) WithAccept(value string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) WithAcceptJson() *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) WithBody(body []byte) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) WithContentType(value string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) WithCookie(c *http.Cookie) *RequestBuilder\n```\nWithCookie sets a cookie\n\n```go\nfunc (r *RequestBuilder) WithCookieNameValue(name, value string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) WithHeader(header, value string) *RequestBuilder\n```\nWithHeader sets a header\n\n```go\nfunc (r *RequestBuilder) WithHost(value string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) WithJWSAuth(jws string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) WithJsonBody(obj interface{}) *RequestBuilder\n```\nWithJsonBody takes an object as input, marshals it to JSON, and sends it as the body with Content-Type: application/json\n\n```go\nfunc (r *RequestBuilder) WithJsonContentType() *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) WithMethod(method string, path string) *RequestBuilder\n```\nWithMethod sets the method and path\n\n```go\ntype ResponseHandler func(contentType string, raw io.Reader, obj interface{}, strict bool) error\n```\n\n","path":"github.com/ascendsoftware/oapi-codegen/pkg/testutil","name":"testutil","synopsis":"","isRedistributable":true}
