Documentation ¶
Overview ¶
Package types provides primitives to interact with the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen version v1.13.0 DO NOT EDIT.
Index ¶
- func GetSwagger() (swagger *openapi3.T, err error)
- func Handler(si ServerInterface) http.Handler
- func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler
- func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler
- func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler
- func NewCreateNewPostRequest(server string, body CreateNewPostJSONRequestBody) (*http.Request, error)
- func NewCreateNewPostRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
- func NewGetAllPostsRequest(server string) (*http.Request, error)
- func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)
- type ChiServerOptions
- type Client
- func (c *Client) CreateNewPost(ctx context.Context, body CreateNewPostJSONRequestBody, ...) (*http.Response, error)
- func (c *Client) CreateNewPostWithBody(ctx context.Context, contentType string, body io.Reader, ...) (*http.Response, error)
- func (c *Client) GetAllPosts(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
- type ClientInterface
- type ClientOption
- type ClientWithResponses
- func (c *ClientWithResponses) CreateNewPostWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, ...) (*CreateNewPostResponse, error)
- func (c *ClientWithResponses) CreateNewPostWithResponse(ctx context.Context, body CreateNewPostJSONRequestBody, ...) (*CreateNewPostResponse, error)
- func (c *ClientWithResponses) GetAllPostsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAllPostsResponse, error)
- type ClientWithResponsesInterface
- type Comment
- type CreateNewPostJSONBody
- type CreateNewPostJSONRequestBody
- type CreateNewPostResponse
- type CreatePost
- type GetAllPostsResponse
- type HttpRequestDoer
- type InvalidParamFormatError
- type MiddlewareFunc
- type Post
- type RequestEditorFn
- type RequiredHeaderError
- type RequiredParamError
- type ServerInterface
- type ServerInterfaceWrapper
- type State
- type TooManyValuesForParamError
- type UnescapedCookieParamError
- type UnmarshallingParamError
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSwagger ¶
GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.
func Handler ¶
func Handler(si ServerInterface) http.Handler
Handler creates http.Handler with routing matching OpenAPI spec.
func HandlerFromMux ¶
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler
HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
func HandlerFromMuxWithBaseURL ¶
func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler
func HandlerWithOptions ¶
func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler
HandlerWithOptions creates http.Handler with additional options
func NewCreateNewPostRequest ¶
func NewCreateNewPostRequest(server string, body CreateNewPostJSONRequestBody) (*http.Request, error)
NewCreateNewPostRequest calls the generic CreateNewPost builder with application/json body
func NewCreateNewPostRequestWithBody ¶
func NewCreateNewPostRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
NewCreateNewPostRequestWithBody generates requests for CreateNewPost with any type of body
func NewGetAllPostsRequest ¶
NewGetAllPostsRequest generates requests for GetAllPosts
Types ¶
type ChiServerOptions ¶
type ChiServerOptions struct { BaseURL string BaseRouter chi.Router Middlewares []MiddlewareFunc ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) }
type Client ¶
type Client struct { // The endpoint of the server conforming to this interface, with scheme, // https://api.deepmap.com for example. This can contain a path relative // to the server, such as https://api.deepmap.com/dev-test, and all the // paths in the swagger spec will be appended to the server. Server string // Doer for performing requests, typically a *http.Client with any // customized settings, such as certificate chains. Client HttpRequestDoer // A list of callbacks for modifying requests which are generated before sending over // the network. RequestEditors []RequestEditorFn }
Client which conforms to the OpenAPI3 specification for this service.
func NewClient ¶
func NewClient(server string, opts ...ClientOption) (*Client, error)
Creates a new Client, with reasonable defaults
func (*Client) CreateNewPost ¶
func (c *Client) CreateNewPost(ctx context.Context, body CreateNewPostJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
func (*Client) CreateNewPostWithBody ¶
func (*Client) GetAllPosts ¶
type ClientInterface ¶
type ClientInterface interface { // GetAllPosts request GetAllPosts(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) // CreateNewPost request with any body CreateNewPostWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) CreateNewPost(ctx context.Context, body CreateNewPostJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) }
The interface specification for the client above.
type ClientOption ¶
ClientOption allows setting custom parameters during construction
func WithHTTPClient ¶
func WithHTTPClient(doer HttpRequestDoer) ClientOption
WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.
func WithRequestEditorFn ¶
func WithRequestEditorFn(fn RequestEditorFn) ClientOption
WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.
type ClientWithResponses ¶
type ClientWithResponses struct {
ClientInterface
}
ClientWithResponses builds on ClientInterface to offer response payloads
func NewClientWithResponses ¶
func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)
NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling
func (*ClientWithResponses) CreateNewPostWithBodyWithResponse ¶
func (c *ClientWithResponses) CreateNewPostWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateNewPostResponse, error)
CreateNewPostWithBodyWithResponse request with arbitrary body returning *CreateNewPostResponse
func (*ClientWithResponses) CreateNewPostWithResponse ¶
func (c *ClientWithResponses) CreateNewPostWithResponse(ctx context.Context, body CreateNewPostJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateNewPostResponse, error)
func (*ClientWithResponses) GetAllPostsWithResponse ¶
func (c *ClientWithResponses) GetAllPostsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAllPostsResponse, error)
GetAllPostsWithResponse request returning *GetAllPostsResponse
type ClientWithResponsesInterface ¶
type ClientWithResponsesInterface interface { // GetAllPosts request GetAllPostsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAllPostsResponse, error) // CreateNewPost request with any body CreateNewPostWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateNewPostResponse, error) CreateNewPostWithResponse(ctx context.Context, body CreateNewPostJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateNewPostResponse, error) }
ClientWithResponsesInterface is the interface specification for the client with responses above.
type Comment ¶
type Comment struct { CreatedAt time.Time `json:"createdAt"` Description string `json:"description"` Id string `json:"id"` PostId int `json:"postId"` }
Comment defines model for Comment.
type CreateNewPostJSONBody ¶
type CreateNewPostJSONBody struct { Description string `json:"description"` IsAnon bool `json:"isAnon"` Title string `json:"title"` Type string `json:"type"` }
CreateNewPostJSONBody defines parameters for CreateNewPost.
type CreateNewPostJSONRequestBody ¶
type CreateNewPostJSONRequestBody CreateNewPostJSONBody
CreateNewPostJSONRequestBody defines body for CreateNewPost for application/json ContentType.
type CreateNewPostResponse ¶
func ParseCreateNewPostResponse ¶
func ParseCreateNewPostResponse(rsp *http.Response) (*CreateNewPostResponse, error)
ParseCreateNewPostResponse parses an HTTP response from a CreateNewPostWithResponse call
func (CreateNewPostResponse) Status ¶
func (r CreateNewPostResponse) Status() string
Status returns HTTPResponse.Status
func (CreateNewPostResponse) StatusCode ¶
func (r CreateNewPostResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type CreatePost ¶
type CreatePost struct { Description string `json:"description"` IsAnon bool `json:"isAnon"` Title string `json:"title"` Type string `json:"type"` }
CreatePost defines model for CreatePost.
type GetAllPostsResponse ¶
type GetAllPostsResponse struct { Body []byte HTTPResponse *http.Response JSON2XX *struct { Posts *[]Post `json:"posts,omitempty"` } }
func ParseGetAllPostsResponse ¶
func ParseGetAllPostsResponse(rsp *http.Response) (*GetAllPostsResponse, error)
ParseGetAllPostsResponse parses an HTTP response from a GetAllPostsWithResponse call
func (GetAllPostsResponse) Status ¶
func (r GetAllPostsResponse) Status() string
Status returns HTTPResponse.Status
func (GetAllPostsResponse) StatusCode ¶
func (r GetAllPostsResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type HttpRequestDoer ¶
Doer performs HTTP requests.
The standard http.Client implements this interface.
type InvalidParamFormatError ¶
func (*InvalidParamFormatError) Error ¶
func (e *InvalidParamFormatError) Error() string
func (*InvalidParamFormatError) Unwrap ¶
func (e *InvalidParamFormatError) Unwrap() error
type Post ¶
type Post struct { Comments *Comment `json:"comments,omitempty"` CreatedAt time.Time `json:"createdAt"` Description string `json:"description"` Id int `json:"id"` IsAnon bool `json:"isAnon"` Title string `json:"title"` Type int `json:"type"` UserId string `json:"userId"` }
Post defines model for Post.
type RequestEditorFn ¶
RequestEditorFn is the function signature for the RequestEditor callback function
type RequiredHeaderError ¶
func (*RequiredHeaderError) Error ¶
func (e *RequiredHeaderError) Error() string
func (*RequiredHeaderError) Unwrap ¶
func (e *RequiredHeaderError) Unwrap() error
type RequiredParamError ¶
type RequiredParamError struct {
ParamName string
}
func (*RequiredParamError) Error ¶
func (e *RequiredParamError) Error() string
type ServerInterface ¶
type ServerInterface interface { // Your GET endpoint // (GET /v1/posts) GetAllPosts(w http.ResponseWriter, r *http.Request) // Your POST endpoint // (POST /v1/posts) CreateNewPost(w http.ResponseWriter, r *http.Request) }
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct { Handler ServerInterface HandlerMiddlewares []MiddlewareFunc ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) }
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) CreateNewPost ¶
func (siw *ServerInterfaceWrapper) CreateNewPost(w http.ResponseWriter, r *http.Request)
CreateNewPost operation middleware
func (*ServerInterfaceWrapper) GetAllPosts ¶
func (siw *ServerInterfaceWrapper) GetAllPosts(w http.ResponseWriter, r *http.Request)
GetAllPosts operation middleware
type TooManyValuesForParamError ¶
func (*TooManyValuesForParamError) Error ¶
func (e *TooManyValuesForParamError) Error() string
type UnescapedCookieParamError ¶
func (*UnescapedCookieParamError) Error ¶
func (e *UnescapedCookieParamError) Error() string
func (*UnescapedCookieParamError) Unwrap ¶
func (e *UnescapedCookieParamError) Unwrap() error
type UnmarshallingParamError ¶
func (*UnmarshallingParamError) Error ¶
func (e *UnmarshallingParamError) Error() string
func (*UnmarshallingParamError) Unwrap ¶
func (e *UnmarshallingParamError) Unwrap() error
type User ¶
type User struct { // CreatedAt The date that the user was created. CreatedAt *openapi_types.Date `json:"createdAt,omitempty"` Email *openapi_types.Email `json:"email,omitempty"` FirstName string `json:"firstName"` // Id Unique identifier for the given user. Id string `json:"id"` IsVerified bool `json:"isVerified"` LastName string `json:"lastName"` State State `json:"state"` }
User defines model for User.