Documentation
¶
Overview ¶
Package oapi provides primitives to interact with the openapi HTTP API.
Code generated by github.com/discord-gophers/goapi-gen version (devel) DO NOT EDIT.
Index ¶
- Constants
- func GetSwagger() (swagger *openapi3.T, err error)
- func Handler(si ServerInterface, opts ...ServerOption) http.Handler
- func MustSwagger() *openapi3.T
- func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)
- func RegisterSecurity(f RegisterSecurityFunc) func(next http.Handler) http.Handler
- type CreatePostJSONBody
- type CreatePostJSONRequestBody
- type Error
- type FoodCategories
- type FoodPreferences
- type FormError
- type GetNextPostsParams
- type ID
- type InvalidParamFormatError
- type LikePostJSONBody
- type LikePostJSONRequestBody
- type LoginMetadata
- type LoginParams
- type NotFoundError
- type ParameterError
- type Post
- type PostListing
- type RegisterParams
- type RegisterSecurityFunc
- type RequiredHeaderError
- type RequiredParamError
- type Response
- func CreatePostJSON200Response(body Post) *Response
- func CreatePostJSON400Response(body Error) *Response
- func CreatePostJSON500Response(body Error) *Response
- func DeletePostJSON404Response(body FormError) *Response
- func DeletePostJSON500Response(body Error) *Response
- func GetAssetJSON404Response(body FormError) *Response
- func GetAssetJSON500Response(body Error) *Response
- func GetLikedPostsJSON200Response(body []Post) *Response
- func GetLikedPostsJSON500Response(body Error) *Response
- func GetNextPostsJSON200Response(body []PostListing) *Response
- func GetNextPostsJSON400Response(body FormError) *Response
- func GetNextPostsJSON500Response(body Error) *Response
- func GetPostJSON200Response(body PostListing) *Response
- func GetPostJSON404Response(body FormError) *Response
- func GetPostJSON500Response(body Error) *Response
- func GetSelfJSON200Response(body Self) *Response
- func GetSelfJSON500Response(body Error) *Response
- func GetUserJSON200Response(body User) *Response
- func GetUserJSON400Response(body FormError) *Response
- func GetUserJSON404Response(body FormError) *Response
- func GetUserJSON500Response(body Error) *Response
- func LikePostJSON400Response(body Error) *Response
- func LikePostJSON404Response(body FormError) *Response
- func LikePostJSON500Response(body Error) *Response
- func ListFoodsJSON200Response(body FoodCategories) *Response
- func ListFoodsJSON500Response(body Error) *Response
- func LoginJSON200Response(body Session) *Response
- func LoginJSON401Response(body Error) *Response
- func LoginJSON500Response(body Error) *Response
- func RegisterJSON200Response(body Session) *Response
- func RegisterJSON400Response(body FormError) *Response
- func RegisterJSON500Response(body Error) *Response
- func UploadAssetJSON200Response(body string) *Response
- func UploadAssetJSON400Response(body Error) *Response
- func UploadAssetJSON413Response(body Error) *Response
- func UploadAssetJSON500Response(body Error) *Response
- func (resp *Response) ContentType(contentType string) *Response
- func (resp *Response) MarshalJSON() ([]byte, error)
- func (resp *Response) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (resp *Response) Render(w http.ResponseWriter, r *http.Request) error
- func (resp *Response) Status(statusCode int) *Response
- type Self
- type ServerError
- type ServerInterface
- type ServerInterfaceWrapper
- func (siw *ServerInterfaceWrapper) CreatePost(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) DeletePost(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetAsset(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetLikedPosts(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetNextPosts(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetPost(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetSelf(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUser(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) LikePost(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) ListFoods(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) Login(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) Register(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) UploadAsset(w http.ResponseWriter, r *http.Request)
- type ServerOption
- func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err error)) ServerOption
- func WithMiddleware(key string, middleware func(http.Handler) http.Handler) ServerOption
- func WithMiddlewares(middlewares map[string]func(http.Handler) http.Handler) ServerOption
- func WithRouter(r chi.Router) ServerOption
- func WithServerBaseURL(url string) ServerOption
- type ServerOptions
- type Session
- type TooManyValuesForParamError
- type UnescapedCookieParamError
- type UnmarshalingParamError
- type User
- type UserError
Constants ¶
const (
BearerAuthScopes = "BearerAuth.Scopes"
)
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, opts ...ServerOption) http.Handler
Handler creates http.Handler with routing matching OpenAPI spec.
func PathToRawSpec ¶
Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
func RegisterSecurity ¶
func RegisterSecurity(f RegisterSecurityFunc) func(next http.Handler) http.Handler
RegisterSecurity registers the given security function to be used for verifying authentication and authorization.
Types ¶
type CreatePostJSONBody ¶
type CreatePostJSONBody Post
CreatePostJSONBody defines parameters for CreatePost.
type CreatePostJSONRequestBody ¶
type CreatePostJSONRequestBody CreatePostJSONBody
CreatePostJSONRequestBody defines body for CreatePost for application/json ContentType.
type Error ¶
type Error struct {
Message string `json:"message"`
}
Error object returned on any error.
type FoodCategories ¶
FoodCategories defines model for FoodCategories.
func (FoodCategories) Get ¶
func (a FoodCategories) Get(fieldName string) (value []string, found bool)
Getter for additional properties for FoodCategories. Returns the specified element and whether it was found
func (FoodCategories) MarshalJSON ¶
func (a FoodCategories) MarshalJSON() ([]byte, error)
Override default JSON handling for FoodCategories to handle AdditionalProperties
func (*FoodCategories) Set ¶
func (a *FoodCategories) Set(fieldName string, value []string)
Setter for additional properties for FoodCategories
func (*FoodCategories) UnmarshalJSON ¶
func (a *FoodCategories) UnmarshalJSON(b []byte) error
Override default JSON handling for FoodCategories to handle AdditionalProperties
type FoodPreferences ¶
type FoodPreferences struct { Likes []string `json:"likes"` Prefers FoodCategories `json:"prefers"` }
FoodPreferences defines model for FoodPreferences.
type FormError ¶
type FormError struct { // Embedded struct due to allOf(#/components/schemas/Error) Error `yaml:",inline"` // Embedded fields due to inline allOf schema FormID string `json:"form_id,omitempty"` }
FormError defines model for FormError.
type GetNextPostsParams ¶
type GetNextPostsParams struct { // The ID to start the pagination from, or empty to start from top. PrevID *ID `json:"prev_id,omitempty"` }
GetNextPostsParams defines parameters for GetNextPosts.
type InvalidParamFormatError ¶
type InvalidParamFormatError struct {
// contains filtered or unexported fields
}
func (InvalidParamFormatError) Error ¶
func (err InvalidParamFormatError) Error() string
Error implements error.
func (InvalidParamFormatError) ParamName ¶
func (err InvalidParamFormatError) ParamName() string
func (InvalidParamFormatError) Unwrap ¶
func (err InvalidParamFormatError) Unwrap() error
type LikePostJSONBody ¶
type LikePostJSONBody struct {
Like *bool `json:"like,omitempty"`
}
LikePostJSONBody defines parameters for LikePost.
type LikePostJSONRequestBody ¶
type LikePostJSONRequestBody LikePostJSONBody
LikePostJSONRequestBody defines body for LikePost for application/json ContentType.
type LoginMetadata ¶
type LoginMetadata struct { // The User-Agent used for logging in. UserAgent string `json:"user_agent,omitempty"` }
Optional metadata included on login.
type LoginParams ¶
LoginParams defines parameters for Login.
type ParameterError ¶
type ParameterError interface { error // ParamName is the name of the parameter that the error is referring to. ParamName() string }
ParameterName is an interface that is implemented by error types that are relevant to a specific parameter.
type Post ¶
type Post struct { CoverHash string `json:"cover_hash,omitempty"` Description string `json:"description"` // Snowflake ID. ID ID `json:"id"` Images []string `json:"images"` // Likes is the number of likes of this post. Likes int `json:"likes"` // Location is the location where the post was made. Location string `json:"location,omitempty"` Tags []string `json:"tags"` Username string `json:"username"` }
Post defines model for Post.
type PostListing ¶
type PostListing struct { // Embedded struct due to allOf(#/components/schemas/Post) Post `yaml:",inline"` // Embedded fields due to inline allOf schema Liked bool `json:"liked"` }
PostListing defines model for PostListing.
type RegisterParams ¶
RegisterParams defines parameters for Register.
type RegisterSecurityFunc ¶
type RegisterSecurityFunc struct { Func openapi3filter.AuthenticationFunc OnError func(w http.ResponseWriter, r *http.Request, err error) }
RegisterSecurityFunc is a structure containing 2 callbacks needed for RegisterSecurity.
type RequiredHeaderError ¶
type RequiredHeaderError struct {
// contains filtered or unexported fields
}
func (RequiredHeaderError) Error ¶
func (err RequiredHeaderError) Error() string
Error implements error.
func (RequiredHeaderError) ParamName ¶
func (err RequiredHeaderError) ParamName() string
type RequiredParamError ¶
type RequiredParamError struct {
// contains filtered or unexported fields
}
func (RequiredParamError) Error ¶
func (err RequiredParamError) Error() string
Error implements error.
func (RequiredParamError) ParamName ¶
func (err RequiredParamError) ParamName() string
func (RequiredParamError) Unwrap ¶
func (err RequiredParamError) Unwrap() error
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response is a common response struct for all the API calls. A Response object may be instantiated via functions for specific operation responses.
func CreatePostJSON200Response ¶
CreatePostJSON200Response is a constructor method for a CreatePost response. A *Response is returned with the configured status code and content type from the spec.
func CreatePostJSON400Response ¶
CreatePostJSON400Response is a constructor method for a CreatePost response. A *Response is returned with the configured status code and content type from the spec.
func CreatePostJSON500Response ¶
CreatePostJSON500Response is a constructor method for a CreatePost response. A *Response is returned with the configured status code and content type from the spec.
func DeletePostJSON404Response ¶
DeletePostJSON404Response is a constructor method for a DeletePost response. A *Response is returned with the configured status code and content type from the spec.
func DeletePostJSON500Response ¶
DeletePostJSON500Response is a constructor method for a DeletePost response. A *Response is returned with the configured status code and content type from the spec.
func GetAssetJSON404Response ¶
GetAssetJSON404Response is a constructor method for a GetAsset response. A *Response is returned with the configured status code and content type from the spec.
func GetAssetJSON500Response ¶
GetAssetJSON500Response is a constructor method for a GetAsset response. A *Response is returned with the configured status code and content type from the spec.
func GetLikedPostsJSON200Response ¶
GetLikedPostsJSON200Response is a constructor method for a GetLikedPosts response. A *Response is returned with the configured status code and content type from the spec.
func GetLikedPostsJSON500Response ¶
GetLikedPostsJSON500Response is a constructor method for a GetLikedPosts response. A *Response is returned with the configured status code and content type from the spec.
func GetNextPostsJSON200Response ¶
func GetNextPostsJSON200Response(body []PostListing) *Response
GetNextPostsJSON200Response is a constructor method for a GetNextPosts response. A *Response is returned with the configured status code and content type from the spec.
func GetNextPostsJSON400Response ¶
GetNextPostsJSON400Response is a constructor method for a GetNextPosts response. A *Response is returned with the configured status code and content type from the spec.
func GetNextPostsJSON500Response ¶
GetNextPostsJSON500Response is a constructor method for a GetNextPosts response. A *Response is returned with the configured status code and content type from the spec.
func GetPostJSON200Response ¶
func GetPostJSON200Response(body PostListing) *Response
GetPostJSON200Response is a constructor method for a GetPost response. A *Response is returned with the configured status code and content type from the spec.
func GetPostJSON404Response ¶
GetPostJSON404Response is a constructor method for a GetPost response. A *Response is returned with the configured status code and content type from the spec.
func GetPostJSON500Response ¶
GetPostJSON500Response is a constructor method for a GetPost response. A *Response is returned with the configured status code and content type from the spec.
func GetSelfJSON200Response ¶
GetSelfJSON200Response is a constructor method for a GetSelf response. A *Response is returned with the configured status code and content type from the spec.
func GetSelfJSON500Response ¶
GetSelfJSON500Response is a constructor method for a GetSelf response. A *Response is returned with the configured status code and content type from the spec.
func GetUserJSON200Response ¶
GetUserJSON200Response is a constructor method for a GetUser response. A *Response is returned with the configured status code and content type from the spec.
func GetUserJSON400Response ¶
GetUserJSON400Response is a constructor method for a GetUser response. A *Response is returned with the configured status code and content type from the spec.
func GetUserJSON404Response ¶
GetUserJSON404Response is a constructor method for a GetUser response. A *Response is returned with the configured status code and content type from the spec.
func GetUserJSON500Response ¶
GetUserJSON500Response is a constructor method for a GetUser response. A *Response is returned with the configured status code and content type from the spec.
func LikePostJSON400Response ¶
LikePostJSON400Response is a constructor method for a LikePost response. A *Response is returned with the configured status code and content type from the spec.
func LikePostJSON404Response ¶
LikePostJSON404Response is a constructor method for a LikePost response. A *Response is returned with the configured status code and content type from the spec.
func LikePostJSON500Response ¶
LikePostJSON500Response is a constructor method for a LikePost response. A *Response is returned with the configured status code and content type from the spec.
func ListFoodsJSON200Response ¶
func ListFoodsJSON200Response(body FoodCategories) *Response
ListFoodsJSON200Response is a constructor method for a ListFoods response. A *Response is returned with the configured status code and content type from the spec.
func ListFoodsJSON500Response ¶
ListFoodsJSON500Response is a constructor method for a ListFoods response. A *Response is returned with the configured status code and content type from the spec.
func LoginJSON200Response ¶
LoginJSON200Response is a constructor method for a Login response. A *Response is returned with the configured status code and content type from the spec.
func LoginJSON401Response ¶
LoginJSON401Response is a constructor method for a Login response. A *Response is returned with the configured status code and content type from the spec.
func LoginJSON500Response ¶
LoginJSON500Response is a constructor method for a Login response. A *Response is returned with the configured status code and content type from the spec.
func RegisterJSON200Response ¶
RegisterJSON200Response is a constructor method for a Register response. A *Response is returned with the configured status code and content type from the spec.
func RegisterJSON400Response ¶
RegisterJSON400Response is a constructor method for a Register response. A *Response is returned with the configured status code and content type from the spec.
func RegisterJSON500Response ¶
RegisterJSON500Response is a constructor method for a Register response. A *Response is returned with the configured status code and content type from the spec.
func UploadAssetJSON200Response ¶
UploadAssetJSON200Response is a constructor method for a UploadAsset response. A *Response is returned with the configured status code and content type from the spec.
func UploadAssetJSON400Response ¶
UploadAssetJSON400Response is a constructor method for a UploadAsset response. A *Response is returned with the configured status code and content type from the spec.
func UploadAssetJSON413Response ¶
UploadAssetJSON413Response is a constructor method for a UploadAsset response. A *Response is returned with the configured status code and content type from the spec.
func UploadAssetJSON500Response ¶
UploadAssetJSON500Response is a constructor method for a UploadAsset response. A *Response is returned with the configured status code and content type from the spec.
func (*Response) ContentType ¶
ContentType is a builder method to override the default content type for a response.
func (*Response) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. This is used to only marshal the body of the response.
func (*Response) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface. This is used to only marshal the body of the response.
type Self ¶
type Self struct { // Embedded struct due to allOf(#/components/schemas/User) User `yaml:",inline"` // Embedded struct due to allOf(#/components/schemas/FoodPreferences) FoodPreferences `yaml:",inline"` // Embedded fields due to inline allOf schema Birthday *openapi_types.Date `json:"birthday,omitempty"` }
Self defines model for Self.
type ServerInterface ¶
type ServerInterface interface { // Upload an asset // (POST /assets) UploadAsset(w http.ResponseWriter, r *http.Request) *Response // Get the file asset by the given ID. Note that assets are not separated by type; the user must assume the type from the context that the asset ID is from. // (GET /assets/{id}) GetAsset(w http.ResponseWriter, r *http.Request, id string) *Response // Get the list of all valid food categories and names. // (GET /food/list) ListFoods(w http.ResponseWriter, r *http.Request) *Response // Log in using username and password. A 401 is returned if the information is incorrect. // (POST /login) Login(w http.ResponseWriter, r *http.Request, params LoginParams) *Response // Get the next batch of posts // (GET /posts) GetNextPosts(w http.ResponseWriter, r *http.Request, params GetNextPostsParams) *Response // Create a new post // (POST /posts) CreatePost(w http.ResponseWriter, r *http.Request) *Response // Get the list of posts liked by the user // (GET /posts/like) GetLikedPosts(w http.ResponseWriter, r *http.Request) *Response // Delete the current user's posts by ID. A 401 is returned if the user tries to delete someone else's post. // (DELETE /posts/{id}) DeletePost(w http.ResponseWriter, r *http.Request, id ID) *Response // Get the post with the given ID. // (GET /posts/{id}) GetPost(w http.ResponseWriter, r *http.Request, id ID) *Response // Like or unlike the post // (POST /posts/{id}/like) LikePost(w http.ResponseWriter, r *http.Request, id ID) *Response // Register using username and password // (POST /register) Register(w http.ResponseWriter, r *http.Request, params RegisterParams) *Response // Get the current user // (GET /users/@self) GetSelf(w http.ResponseWriter, r *http.Request) *Response // Get a user by their username // (GET /users/{username}) GetUser(w http.ResponseWriter, r *http.Request, username string) *Response }
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct { Handler ServerInterface Middlewares map[string]func(http.Handler) http.Handler ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) }
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) CreatePost ¶
func (siw *ServerInterfaceWrapper) CreatePost(w http.ResponseWriter, r *http.Request)
CreatePost operation middleware
func (*ServerInterfaceWrapper) DeletePost ¶
func (siw *ServerInterfaceWrapper) DeletePost(w http.ResponseWriter, r *http.Request)
DeletePost operation middleware
func (*ServerInterfaceWrapper) GetAsset ¶
func (siw *ServerInterfaceWrapper) GetAsset(w http.ResponseWriter, r *http.Request)
GetAsset operation middleware
func (*ServerInterfaceWrapper) GetLikedPosts ¶
func (siw *ServerInterfaceWrapper) GetLikedPosts(w http.ResponseWriter, r *http.Request)
GetLikedPosts operation middleware
func (*ServerInterfaceWrapper) GetNextPosts ¶
func (siw *ServerInterfaceWrapper) GetNextPosts(w http.ResponseWriter, r *http.Request)
GetNextPosts operation middleware
func (*ServerInterfaceWrapper) GetPost ¶
func (siw *ServerInterfaceWrapper) GetPost(w http.ResponseWriter, r *http.Request)
GetPost operation middleware
func (*ServerInterfaceWrapper) GetSelf ¶
func (siw *ServerInterfaceWrapper) GetSelf(w http.ResponseWriter, r *http.Request)
GetSelf operation middleware
func (*ServerInterfaceWrapper) GetUser ¶
func (siw *ServerInterfaceWrapper) GetUser(w http.ResponseWriter, r *http.Request)
GetUser operation middleware
func (*ServerInterfaceWrapper) LikePost ¶
func (siw *ServerInterfaceWrapper) LikePost(w http.ResponseWriter, r *http.Request)
LikePost operation middleware
func (*ServerInterfaceWrapper) ListFoods ¶
func (siw *ServerInterfaceWrapper) ListFoods(w http.ResponseWriter, r *http.Request)
ListFoods operation middleware
func (*ServerInterfaceWrapper) Login ¶
func (siw *ServerInterfaceWrapper) Login(w http.ResponseWriter, r *http.Request)
Login operation middleware
func (*ServerInterfaceWrapper) Register ¶
func (siw *ServerInterfaceWrapper) Register(w http.ResponseWriter, r *http.Request)
Register operation middleware
func (*ServerInterfaceWrapper) UploadAsset ¶
func (siw *ServerInterfaceWrapper) UploadAsset(w http.ResponseWriter, r *http.Request)
UploadAsset operation middleware
type ServerOption ¶
type ServerOption func(*ServerOptions)
func WithErrorHandler ¶
func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err error)) ServerOption
func WithMiddleware ¶
func WithMiddlewares ¶
func WithRouter ¶
func WithRouter(r chi.Router) ServerOption
func WithServerBaseURL ¶
func WithServerBaseURL(url string) ServerOption
type ServerOptions ¶
type Session ¶
type Session struct { Expiry time.Time `json:"expiry"` // Optional metadata included on login. Metadata LoginMetadata `json:"metadata"` Token string `json:"token"` Username string `json:"username"` }
Session defines model for Session.
type TooManyValuesForParamError ¶
type TooManyValuesForParamError struct { NumValues int // contains filtered or unexported fields }
func (TooManyValuesForParamError) Error ¶
func (err TooManyValuesForParamError) Error() string
Error implements error.
func (TooManyValuesForParamError) ParamName ¶
func (err TooManyValuesForParamError) ParamName() string
type UnescapedCookieParamError ¶
type UnescapedCookieParamError struct {
// contains filtered or unexported fields
}
func (UnescapedCookieParamError) Error ¶
func (err UnescapedCookieParamError) Error() string
Error implements error.
func (UnescapedCookieParamError) ParamName ¶
func (err UnescapedCookieParamError) ParamName() string
func (UnescapedCookieParamError) Unwrap ¶
func (err UnescapedCookieParamError) Unwrap() error
type UnmarshalingParamError ¶
type UnmarshalingParamError struct {
// contains filtered or unexported fields
}
func (UnmarshalingParamError) Error ¶
func (err UnmarshalingParamError) Error() string
Error implements error.
func (UnmarshalingParamError) ParamName ¶
func (err UnmarshalingParamError) ParamName() string
func (UnmarshalingParamError) Unwrap ¶
func (err UnmarshalingParamError) Unwrap() error