{"modulePath":"github.com/maclav3/oapi-codegen","version":"v1.5.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testutil\n\nCopyright 2019 DeepMap, 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```\nThis 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```\nShortcut for response code\n\n```go\nfunc (c *CompletedRequest) DisallowUnknownFields()\n```\n\n```go\nfunc (c *CompletedRequest) UnmarshalBodyToObject(obj interface{}) error\n```\nThis function 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```\nThis function 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```\nThis structure 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```\nThis function 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) 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```\nCookie operations\n\n```go\nfunc (r *RequestBuilder) WithCookieNameValue(name, value string) *RequestBuilder\n```\n\n```go\nfunc (r *RequestBuilder) WithHeader(header, value string) *RequestBuilder\n```\nHeader operations\n\n```go\nfunc (r *RequestBuilder) WithJsonBody(obj interface{}) *RequestBuilder\n```\nThis function 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```\nPath operations\n\n```go\ntype ResponseHandler func(contentType string, raw io.Reader, obj interface{}, strict bool) error\n```\n\n","path":"github.com/maclav3/oapi-codegen/pkg/testutil","name":"testutil","synopsis":"","isRedistributable":true}
