Documentation ¶
Overview ¶
Package api provides primitives to interact with the openapi HTTP API.
Code generated by github.com/discord-gophers/goapi-gen version (devel) DO NOT EDIT.
Index ¶
- func GetSwagger() (swagger *openapi3.T, err error)
- func Handler(si ServerInterface, opts ...ServerOption) http.Handler
- func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)
- type AddPetJSONBody
- type AddPetJSONRequestBody
- type Error
- type FindPetsParams
- type InvalidParamFormatError
- type NewPet
- type ParameterError
- type Pet
- type PetStore
- func (p *PetStore) AddPet(w http.ResponseWriter, r *http.Request) *Response
- func (p *PetStore) DeletePet(w http.ResponseWriter, r *http.Request, id int64) *Response
- func (p *PetStore) FindPetByID(w http.ResponseWriter, r *http.Request, id int64) *Response
- func (p *PetStore) FindPets(w http.ResponseWriter, r *http.Request, params FindPetsParams) *Response
- type RequiredHeaderError
- type RequiredParamError
- type Response
- func AddPetJSON201Response(body Pet) *Response
- func AddPetJSONDefaultResponse(body Error) *Response
- func DeletePetJSONDefaultResponse(body Error) *Response
- func FindPetByIDJSON200Response(body Pet) *Response
- func FindPetByIDJSONDefaultResponse(body Error) *Response
- func FindPetsJSON200Response(body []Pet) *Response
- func FindPetsJSONDefaultResponse(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(code int) *Response
- type ServerInterface
- type ServerInterfaceWrapper
- func (siw *ServerInterfaceWrapper) AddPet(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) DeletePet(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) FindPetByID(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) FindPets(w http.ResponseWriter, r *http.Request)
- type ServerOption
- type ServerOptions
- type TooManyValuesForParamError
- type UnescapedCookieParamError
- type UnmarshalingParamError
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, opts ...ServerOption) http.Handler
Handler creates http.Handler with routing matching OpenAPI spec.
Types ¶
type AddPetJSONRequestBody ¶
type AddPetJSONRequestBody AddPetJSONBody
AddPetJSONRequestBody defines body for AddPet for application/json ContentType.
type Error ¶
type Error struct { // Error message Message string `json:"message"` }
Error defines model for Error.
type FindPetsParams ¶
type FindPetsParams struct { // tags to filter by Tags []string `json:"tags,omitempty"` // maximum number of results to return Limit *int32 `json:"limit,omitempty"` }
FindPetsParams defines parameters for FindPets.
type InvalidParamFormatError ¶
type InvalidParamFormatError struct {
// contains filtered or unexported fields
}
func (InvalidParamFormatError) Error ¶ added in v0.2.0
func (err InvalidParamFormatError) Error() string
Error implements error.
func (InvalidParamFormatError) ParamName ¶ added in v0.2.0
func (err InvalidParamFormatError) ParamName() string
func (InvalidParamFormatError) Unwrap ¶ added in v0.2.0
func (err InvalidParamFormatError) Unwrap() error
type NewPet ¶
type NewPet struct { // Name of the pet Name string `json:"name"` // Type of the pet Tag *string `json:"tag,omitempty"` }
NewPet defines model for NewPet.
type ParameterError ¶ added in v0.2.0
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 Pet ¶
type Pet struct { // Embedded struct due to allOf(#/components/schemas/NewPet) NewPet `yaml:",inline"` // Embedded fields due to inline allOf schema // Unique id of the pet ID int64 `json:"id"` }
Pet defines model for Pet.
type PetStore ¶
func NewPetStore ¶
func NewPetStore() *PetStore
func (*PetStore) FindPetByID ¶
func (*PetStore) FindPets ¶
func (p *PetStore) FindPets(w http.ResponseWriter, r *http.Request, params FindPetsParams) *Response
Here, we implement all of the handlers in the ServerInterface
type RequiredHeaderError ¶
type RequiredHeaderError struct {
// contains filtered or unexported fields
}
func (RequiredHeaderError) Error ¶ added in v0.2.0
func (err RequiredHeaderError) Error() string
Error implements error.
func (RequiredHeaderError) ParamName ¶ added in v0.2.0
func (err RequiredHeaderError) ParamName() string
type RequiredParamError ¶
type RequiredParamError struct {
// contains filtered or unexported fields
}
func (RequiredParamError) Error ¶ added in v0.2.0
func (err RequiredParamError) Error() string
Error implements error.
func (RequiredParamError) ParamName ¶ added in v0.2.0
func (err RequiredParamError) ParamName() string
func (RequiredParamError) Unwrap ¶ added in v0.2.0
func (err RequiredParamError) Unwrap() error
type Response ¶
type Response struct { Code int // 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. It may also be instantiated directly, for the purpose of responding with a single status code.
func AddPetJSON201Response ¶
AddPetJSON201Response is a constructor method for a AddPet response. A *Response is returned with the configured status code and content type from the spec.
func AddPetJSONDefaultResponse ¶
AddPetJSONDefaultResponse is a constructor method for a AddPet response. A *Response is returned with the configured status code and content type from the spec.
func DeletePetJSONDefaultResponse ¶
DeletePetJSONDefaultResponse is a constructor method for a DeletePet response. A *Response is returned with the configured status code and content type from the spec.
func FindPetByIDJSON200Response ¶
FindPetByIDJSON200Response is a constructor method for a FindPetByID response. A *Response is returned with the configured status code and content type from the spec.
func FindPetByIDJSONDefaultResponse ¶
FindPetByIDJSONDefaultResponse is a constructor method for a FindPetByID response. A *Response is returned with the configured status code and content type from the spec.
func FindPetsJSON200Response ¶
FindPetsJSON200Response is a constructor method for a FindPets response. A *Response is returned with the configured status code and content type from the spec.
func FindPetsJSONDefaultResponse ¶
FindPetsJSONDefaultResponse is a constructor method for a FindPets 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 ServerInterface ¶
type ServerInterface interface { // Returns all pets // (GET /pets) FindPets(w http.ResponseWriter, r *http.Request, params FindPetsParams) *Response // Creates a new pet // (POST /pets) AddPet(w http.ResponseWriter, r *http.Request) *Response // Deletes a pet by ID // (DELETE /pets/{id}) DeletePet(w http.ResponseWriter, r *http.Request, id int64) *Response // Returns a pet by ID // (GET /pets/{id}) FindPetByID(w http.ResponseWriter, r *http.Request, id int64) *Response }
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct { Handler ServerInterface ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) }
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) AddPet ¶
func (siw *ServerInterfaceWrapper) AddPet(w http.ResponseWriter, r *http.Request)
AddPet operation middleware
func (*ServerInterfaceWrapper) DeletePet ¶
func (siw *ServerInterfaceWrapper) DeletePet(w http.ResponseWriter, r *http.Request)
DeletePet operation middleware
func (*ServerInterfaceWrapper) FindPetByID ¶
func (siw *ServerInterfaceWrapper) FindPetByID(w http.ResponseWriter, r *http.Request)
FindPetByID operation middleware
func (*ServerInterfaceWrapper) FindPets ¶
func (siw *ServerInterfaceWrapper) FindPets(w http.ResponseWriter, r *http.Request)
FindPets operation middleware
type ServerOption ¶
type ServerOption func(*ServerOptions)
func WithErrorHandler ¶
func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err error)) ServerOption
func WithRouter ¶
func WithRouter(r chi.Router) ServerOption
func WithServerBaseURL ¶
func WithServerBaseURL(url string) ServerOption
type ServerOptions ¶
type TooManyValuesForParamError ¶
type TooManyValuesForParamError struct { NumValues int // contains filtered or unexported fields }
func (TooManyValuesForParamError) Error ¶ added in v0.2.0
func (err TooManyValuesForParamError) Error() string
Error implements error.
func (TooManyValuesForParamError) ParamName ¶ added in v0.2.0
func (err TooManyValuesForParamError) ParamName() string
type UnescapedCookieParamError ¶
type UnescapedCookieParamError struct {
// contains filtered or unexported fields
}
func (UnescapedCookieParamError) Error ¶ added in v0.2.0
func (err UnescapedCookieParamError) Error() string
Error implements error.
func (UnescapedCookieParamError) ParamName ¶ added in v0.2.0
func (err UnescapedCookieParamError) ParamName() string
func (UnescapedCookieParamError) Unwrap ¶ added in v0.2.0
func (err UnescapedCookieParamError) Unwrap() error
type UnmarshalingParamError ¶
type UnmarshalingParamError struct {
// contains filtered or unexported fields
}
func (UnmarshalingParamError) Error ¶ added in v0.2.0
func (err UnmarshalingParamError) Error() string
Error implements error.
func (UnmarshalingParamError) ParamName ¶ added in v0.2.0
func (err UnmarshalingParamError) ParamName() string
func (UnmarshalingParamError) Unwrap ¶ added in v0.2.0
func (err UnmarshalingParamError) Unwrap() error