api

package
v0.0.0-...-6ec1179 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, m ServeMux) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

Types

type Address

type Address struct {
	City   *string `fake:"{city}" json:"city,omitempty"`
	Street *string `fake:"{street}" json:"street,omitempty"`
	Zip    *string `fake:"{zip}" json:"zip,omitempty"`
}

Address defines model for Address.

type Contact

type Contact struct {
	Email *openapi_types.Email `fake:"{email}" json:"email,omitempty"`
	Phone *string              `fake:"{phone}" json:"phone,omitempty"`
}

Contact defines model for Contact.

type Count

type Count = int

Count defines model for Count.

type DelayParam

type DelayParam = int

DelayParam defines model for DelayParam.

type DeleteReturnParams

type DeleteReturnParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

DeleteReturnParams defines parameters for DeleteReturn.

type DeleteStatusCodeParams

type DeleteStatusCodeParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

DeleteStatusCodeParams defines parameters for DeleteStatusCode.

type FormatParam

type FormatParam string

FormatParam defines model for FormatParam.

const (
	FormatParamJson FormatParam = "json"
	FormatParamText FormatParam = "text"
)

Defines values for FormatParam.

type GetIpParams

type GetIpParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

GetIpParams defines parameters for GetIp.

type GetJsonRandomAddressParams

type GetJsonRandomAddressParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

GetJsonRandomAddressParams defines parameters for GetJsonRandomAddress.

type GetJsonRandomAddressesParams

type GetJsonRandomAddressesParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`

	// Count Number of entries to return (min: 1; max: 10000)
	Count *Count `default:"10" form:"count,omitempty" json:"count,omitempty" validate:"gt=1,lte=10000"`
}

GetJsonRandomAddressesParams defines parameters for GetJsonRandomAddresses.

type GetJsonRandomContactParams

type GetJsonRandomContactParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

GetJsonRandomContactParams defines parameters for GetJsonRandomContact.

type GetJsonRandomContactsParams

type GetJsonRandomContactsParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`

	// Count Number of entries to return (min: 1; max: 10000)
	Count *Count `default:"10" form:"count,omitempty" json:"count,omitempty" validate:"gt=1,lte=10000"`
}

GetJsonRandomContactsParams defines parameters for GetJsonRandomContacts.

type GetJsonRandomLogParams

type GetJsonRandomLogParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`

	// LogLevels Log levels to use (default: `debug,info,warn,error`)
	LogLevels *LogLevels `default:"[\" debug\",\" info\",\" warn\",\" error\" ]" form:"logLevels,omitempty" json:"logLevels,omitempty"`

	// LogLevelWeights Log level weights (default: `1,5,3,2`)
	LogLevelWeights *LogLevelWeights `default:"[1, 5, 3, 2]" form:"logLevelWeights,omitempty" json:"logLevelWeights,omitempty"`

	// Count Number of log entries to return (min: 1; max: 10000)
	Count *int `default:"10" form:"count,omitempty" json:"count,omitempty" validate:"gt=1,lte=10000"`
}

GetJsonRandomLogParams defines parameters for GetJsonRandomLog.

type GetJsonRandomParams

type GetJsonRandomParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`

	// MaxDepth Maximum depth of the JSON object
	MaxDepth *int `default:"3" form:"maxDepth,omitempty" json:"maxDepth,omitempty" validate:"gt=1,lte=5"`

	// MinDepth Minimum depth of the JSON object
	MinDepth *int `default:"1" form:"minDepth,omitempty" json:"minDepth,omitempty" validate:"gt=0,lte=3"`

	// MaxElems Maximum number of elements per JSON object
	MaxElems *int `default:"3" form:"maxElems,omitempty" json:"maxElems,omitempty" validate:"gt=0,lte=10"`
}

GetJsonRandomParams defines parameters for GetJsonRandom.

type GetJsonRandomUserParams

type GetJsonRandomUserParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

GetJsonRandomUserParams defines parameters for GetJsonRandomUser.

type GetJsonRandomUsersParams

type GetJsonRandomUsersParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`

	// Count Number of entries to return (min: 1; max: 10000)
	Count *Count `default:"10" form:"count,omitempty" json:"count,omitempty" validate:"gt=1,lte=10000"`
}

GetJsonRandomUsersParams defines parameters for GetJsonRandomUsers.

type GetPingParams

type GetPingParams struct {
	// Format Response format (default: `json`)
	Format *GetPingParamsFormat `default:"json" form:"format,omitempty" json:"format,omitempty" validate:"oneof=json text"`

	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

GetPingParams defines parameters for GetPing.

type GetPingParamsFormat

type GetPingParamsFormat string

GetPingParamsFormat defines parameters for GetPing.

const (
	GetPingParamsFormatJson GetPingParamsFormat = "json"
	GetPingParamsFormatText GetPingParamsFormat = "text"
)

Defines values for GetPingParamsFormat.

type GetReturnParams

type GetReturnParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

GetReturnParams defines parameters for GetReturn.

type GetStatusCodeParams

type GetStatusCodeParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

GetStatusCodeParams defines parameters for GetStatusCode.

type GetStreamJsonLogsParams

type GetStreamJsonLogsParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`

	// LogLevels Log levels to use (default: `debug,info,warn,error`)
	LogLevels *LogLevels `default:"[\" debug\",\" info\",\" warn\",\" error\" ]" form:"logLevels,omitempty" json:"logLevels,omitempty"`

	// LogLevelWeights Log level weights (default: `1,5,3,2`)
	LogLevelWeights *LogLevelWeights `default:"[1, 5, 3, 2]" form:"logLevelWeights,omitempty" json:"logLevelWeights,omitempty"`

	// Interval Interval in milliseconds between streamed responses (min: 0; max: 5000)
	Interval *StreamInterval `default:"250" form:"interval,omitempty" json:"interval,omitempty" validate:"gt=0,lte=5000"`
}

GetStreamJsonLogsParams defines parameters for GetStreamJsonLogs.

type GetStreamJsonUserParams

type GetStreamJsonUserParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`

	// Interval Interval in milliseconds between streamed responses (min: 0; max: 5000)
	Interval *StreamInterval `default:"250" form:"interval,omitempty" json:"interval,omitempty" validate:"gt=0,lte=5000"`
}

GetStreamJsonUserParams defines parameters for GetStreamJsonUser.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type Log

type Log struct {
	Level     *string    `fake:"{weighted:[debug,info,warn,error],[1,5,3,2]}" json:"level,omitempty"`
	Message   *string    `fake:"{hackerphrase}" json:"message,omitempty"`
	Timestamp *time.Time `json:"timestamp,omitempty"`
}

Log defines model for Log.

type LogLevelWeights

type LogLevelWeights = []float32

LogLevelWeights defines model for LogLevelWeights.

type LogLevels

type LogLevels = []string

LogLevels defines model for LogLevels.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type PatchReturnParams

type PatchReturnParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

PatchReturnParams defines parameters for PatchReturn.

type PatchStatusCodeParams

type PatchStatusCodeParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

PatchStatusCodeParams defines parameters for PatchStatusCode.

type PostReturnParams

type PostReturnParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

PostReturnParams defines parameters for PostReturn.

type PostStatusCodeParams

type PostStatusCodeParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

PostStatusCodeParams defines parameters for PostStatusCode.

type PutReturnParams

type PutReturnParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

PutReturnParams defines parameters for PutReturn.

type PutStatusCodeParams

type PutStatusCodeParams struct {
	// Delay Delay in milliseconds before the response is sent (min: 0; max: 10000)
	Delay *DelayParam `form:"delay,omitempty" json:"delay,omitempty"`
}

PutStatusCodeParams defines parameters for PutStatusCode.

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

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 ServeMux

type ServeMux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

ServeMux is an abstraction of http.ServeMux.

type ServerInterface

type ServerInterface interface {
	// Health check endpoint
	// (GET /health)
	GetHealth(w http.ResponseWriter, r *http.Request)
	// Returns the client's IP address
	// (GET /ip)
	GetIp(w http.ResponseWriter, r *http.Request, params GetIpParams)
	// Returns random JSON data.
	// (GET /json/random)
	GetJsonRandom(w http.ResponseWriter, r *http.Request, params GetJsonRandomParams)
	// Returns random address data.
	// (GET /json/random/address)
	GetJsonRandomAddress(w http.ResponseWriter, r *http.Request, params GetJsonRandomAddressParams)
	// Returns random address data.
	// (GET /json/random/addresses)
	GetJsonRandomAddresses(w http.ResponseWriter, r *http.Request, params GetJsonRandomAddressesParams)
	// Returns random contact data.
	// (GET /json/random/contact)
	GetJsonRandomContact(w http.ResponseWriter, r *http.Request, params GetJsonRandomContactParams)
	// Returns random contact data.
	// (GET /json/random/contacts)
	GetJsonRandomContacts(w http.ResponseWriter, r *http.Request, params GetJsonRandomContactsParams)
	// Returns random log data.
	// (GET /json/random/log)
	GetJsonRandomLog(w http.ResponseWriter, r *http.Request, params GetJsonRandomLogParams)
	// Returns random user data.
	// (GET /json/random/user)
	GetJsonRandomUser(w http.ResponseWriter, r *http.Request, params GetJsonRandomUserParams)
	// Returns random user data.
	// (GET /json/random/users)
	GetJsonRandomUsers(w http.ResponseWriter, r *http.Request, params GetJsonRandomUsersParams)
	// Returns "pong"
	// (GET /ping)
	GetPing(w http.ResponseWriter, r *http.Request, params GetPingParams)
	// Readiness check endpoint
	// (GET /ready)
	GetReady(w http.ResponseWriter, r *http.Request)
	// Returns the request data as JSON
	// (DELETE /return)
	DeleteReturn(w http.ResponseWriter, r *http.Request, params DeleteReturnParams)
	// Returns the request data as JSON
	// (GET /return)
	GetReturn(w http.ResponseWriter, r *http.Request, params GetReturnParams)
	// Returns the request data as JSON
	// (PATCH /return)
	PatchReturn(w http.ResponseWriter, r *http.Request, params PatchReturnParams)
	// Returns the request data as JSON
	// (POST /return)
	PostReturn(w http.ResponseWriter, r *http.Request, params PostReturnParams)
	// Returns the request data as JSON
	// (PUT /return)
	PutReturn(w http.ResponseWriter, r *http.Request, params PutReturnParams)
	// Returns the specified HTTP status code and status message
	// (DELETE /status/{code})
	DeleteStatusCode(w http.ResponseWriter, r *http.Request, code int, params DeleteStatusCodeParams)
	// Returns the specified HTTP status code and status message
	// (GET /status/{code})
	GetStatusCode(w http.ResponseWriter, r *http.Request, code int, params GetStatusCodeParams)
	// Returns the specified HTTP status code and status message
	// (PATCH /status/{code})
	PatchStatusCode(w http.ResponseWriter, r *http.Request, code int, params PatchStatusCodeParams)
	// Returns the specified HTTP status code and status message
	// (POST /status/{code})
	PostStatusCode(w http.ResponseWriter, r *http.Request, code int, params PostStatusCodeParams)
	// Returns the specified HTTP status code and status message
	// (PUT /status/{code})
	PutStatusCode(w http.ResponseWriter, r *http.Request, code int, params PutStatusCodeParams)
	// Streams JSON logs.
	// (GET /stream/json/logs)
	GetStreamJsonLogs(w http.ResponseWriter, r *http.Request, params GetStreamJsonLogsParams)
	// Streams JSON data.
	// (GET /stream/json/user)
	GetStreamJsonUser(w http.ResponseWriter, r *http.Request, params GetStreamJsonUserParams)
}

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) DeleteReturn

func (siw *ServerInterfaceWrapper) DeleteReturn(w http.ResponseWriter, r *http.Request)

DeleteReturn operation middleware

func (*ServerInterfaceWrapper) DeleteStatusCode

func (siw *ServerInterfaceWrapper) DeleteStatusCode(w http.ResponseWriter, r *http.Request)

DeleteStatusCode operation middleware

func (*ServerInterfaceWrapper) GetHealth

func (siw *ServerInterfaceWrapper) GetHealth(w http.ResponseWriter, r *http.Request)

GetHealth operation middleware

func (*ServerInterfaceWrapper) GetIp

GetIp operation middleware

func (*ServerInterfaceWrapper) GetJsonRandom

func (siw *ServerInterfaceWrapper) GetJsonRandom(w http.ResponseWriter, r *http.Request)

GetJsonRandom operation middleware

func (*ServerInterfaceWrapper) GetJsonRandomAddress

func (siw *ServerInterfaceWrapper) GetJsonRandomAddress(w http.ResponseWriter, r *http.Request)

GetJsonRandomAddress operation middleware

func (*ServerInterfaceWrapper) GetJsonRandomAddresses

func (siw *ServerInterfaceWrapper) GetJsonRandomAddresses(w http.ResponseWriter, r *http.Request)

GetJsonRandomAddresses operation middleware

func (*ServerInterfaceWrapper) GetJsonRandomContact

func (siw *ServerInterfaceWrapper) GetJsonRandomContact(w http.ResponseWriter, r *http.Request)

GetJsonRandomContact operation middleware

func (*ServerInterfaceWrapper) GetJsonRandomContacts

func (siw *ServerInterfaceWrapper) GetJsonRandomContacts(w http.ResponseWriter, r *http.Request)

GetJsonRandomContacts operation middleware

func (*ServerInterfaceWrapper) GetJsonRandomLog

func (siw *ServerInterfaceWrapper) GetJsonRandomLog(w http.ResponseWriter, r *http.Request)

GetJsonRandomLog operation middleware

func (*ServerInterfaceWrapper) GetJsonRandomUser

func (siw *ServerInterfaceWrapper) GetJsonRandomUser(w http.ResponseWriter, r *http.Request)

GetJsonRandomUser operation middleware

func (*ServerInterfaceWrapper) GetJsonRandomUsers

func (siw *ServerInterfaceWrapper) GetJsonRandomUsers(w http.ResponseWriter, r *http.Request)

GetJsonRandomUsers operation middleware

func (*ServerInterfaceWrapper) GetPing

GetPing operation middleware

func (*ServerInterfaceWrapper) GetReady

func (siw *ServerInterfaceWrapper) GetReady(w http.ResponseWriter, r *http.Request)

GetReady operation middleware

func (*ServerInterfaceWrapper) GetReturn

func (siw *ServerInterfaceWrapper) GetReturn(w http.ResponseWriter, r *http.Request)

GetReturn operation middleware

func (*ServerInterfaceWrapper) GetStatusCode

func (siw *ServerInterfaceWrapper) GetStatusCode(w http.ResponseWriter, r *http.Request)

GetStatusCode operation middleware

func (*ServerInterfaceWrapper) GetStreamJsonLogs

func (siw *ServerInterfaceWrapper) GetStreamJsonLogs(w http.ResponseWriter, r *http.Request)

GetStreamJsonLogs operation middleware

func (*ServerInterfaceWrapper) GetStreamJsonUser

func (siw *ServerInterfaceWrapper) GetStreamJsonUser(w http.ResponseWriter, r *http.Request)

GetStreamJsonUser operation middleware

func (*ServerInterfaceWrapper) PatchReturn

func (siw *ServerInterfaceWrapper) PatchReturn(w http.ResponseWriter, r *http.Request)

PatchReturn operation middleware

func (*ServerInterfaceWrapper) PatchStatusCode

func (siw *ServerInterfaceWrapper) PatchStatusCode(w http.ResponseWriter, r *http.Request)

PatchStatusCode operation middleware

func (*ServerInterfaceWrapper) PostReturn

func (siw *ServerInterfaceWrapper) PostReturn(w http.ResponseWriter, r *http.Request)

PostReturn operation middleware

func (*ServerInterfaceWrapper) PostStatusCode

func (siw *ServerInterfaceWrapper) PostStatusCode(w http.ResponseWriter, r *http.Request)

PostStatusCode operation middleware

func (*ServerInterfaceWrapper) PutReturn

func (siw *ServerInterfaceWrapper) PutReturn(w http.ResponseWriter, r *http.Request)

PutReturn operation middleware

func (*ServerInterfaceWrapper) PutStatusCode

func (siw *ServerInterfaceWrapper) PutStatusCode(w http.ResponseWriter, r *http.Request)

PutStatusCode operation middleware

type StatusCodeMessage

type StatusCodeMessage struct {
	// Message Status code message
	Message *string `json:"message,omitempty"`

	// Status Status code
	Status *int `json:"status,omitempty"`
}

StatusCodeMessage Status code and status message

type StdHTTPServerOptions

type StdHTTPServerOptions struct {
	BaseURL          string
	BaseRouter       ServeMux
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StreamInterval

type StreamInterval = int

StreamInterval defines model for StreamInterval.

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

type User

type User struct {
	Address   *Address    `json:"address,omitempty"`
	Age       *int        `fake:"{number:0,100}" json:"age,omitempty"`
	Contact   *Contact    `json:"contact,omitempty"`
	FirstName *string     `fake:"{firstname}" json:"firstName,omitempty"`
	Gender    *UserGender `fake:"{randomstring:[male,female,other]}" json:"gender,omitempty"`
	LastName  *string     `fake:"{lastname}" json:"lastName,omitempty"`
}

User defines model for User.

type UserGender

type UserGender string

UserGender defines model for User.Gender.

const (
	Female UserGender = "female"
	Male   UserGender = "male"
	Other  UserGender = "other"
)

Defines values for UserGender.

type ValidationError

type ValidationError struct {
	Errors     *ValidationMessages `json:"errors,omitempty"`
	Message    string              `json:"message"`
	StatusCode int                 `json:"status_code"`
}

ValidationError defines model for ValidationError.

type ValidationMessage

type ValidationMessage struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

ValidationMessage defines model for ValidationMessage.

type ValidationMessages

type ValidationMessages = []ValidationMessage

ValidationMessages defines model for ValidationMessages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL