oapi

package
v0.0.0-...-bf66428 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package oapi 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 GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

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, 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

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type BadRequest

type BadRequest = string

BadRequest defines model for BadRequest.

type CreatePostJSONRequestBody

type CreatePostJSONRequestBody = PostInput

CreatePostJSONRequestBody defines body for CreatePost for application/json ContentType.

type CreateUserJSONRequestBody

type CreateUserJSONRequestBody = UserInput

CreateUserJSONRequestBody defines body for CreateUser for application/json ContentType.

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 MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type Post

type Post struct {
	// Content Post content
	Content string `json:"content"`
	Id      *int64 `json:"id,omitempty"`

	// Title Short headline of your post
	Title  string `json:"title"`
	UserId int64  `json:"user_id"`
}

Post defines model for Post.

type PostBody

type PostBody = PostInput

PostBody defines model for PostBody.

type PostInput

type PostInput struct {
	// Content Post content
	Content string `json:"content"`

	// Title Short headline of your post
	Title  string `json:"title"`
	UserId int64  `json:"user_id"`
}

PostInput defines model for PostInput.

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 ResourceNotFound

type ResourceNotFound = string

ResourceNotFound defines model for ResourceNotFound.

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 {

	// (GET /posts)
	ListPosts(w http.ResponseWriter, r *http.Request)

	// (POST /posts)
	CreatePost(w http.ResponseWriter, r *http.Request)

	// (DELETE /posts/{id})
	DeletePost(w http.ResponseWriter, r *http.Request, id int64)

	// (GET /posts/{id})
	GetPost(w http.ResponseWriter, r *http.Request, id int64)

	// (PUT /posts/{id})
	UpdatePost(w http.ResponseWriter, r *http.Request, id int64)

	// (GET /users)
	ListUsers(w http.ResponseWriter, r *http.Request)

	// (POST /users)
	CreateUser(w http.ResponseWriter, r *http.Request)

	// (DELETE /users/{id})
	DeleteUser(w http.ResponseWriter, r *http.Request, id int64)

	// (GET /users/{id})
	GetUser(w http.ResponseWriter, r *http.Request, id int64)

	// (PUT /users/{id})
	UpdateUser(w http.ResponseWriter, r *http.Request, id int64)
}

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

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

CreatePost operation middleware

func (*ServerInterfaceWrapper) CreateUser

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

CreateUser operation middleware

func (*ServerInterfaceWrapper) DeletePost

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

DeletePost operation middleware

func (*ServerInterfaceWrapper) DeleteUser

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

DeleteUser operation middleware

func (*ServerInterfaceWrapper) GetPost

GetPost operation middleware

func (*ServerInterfaceWrapper) GetUser

GetUser operation middleware

func (*ServerInterfaceWrapper) ListPosts

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

ListPosts operation middleware

func (*ServerInterfaceWrapper) ListUsers

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

ListUsers operation middleware

func (*ServerInterfaceWrapper) UpdatePost

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

UpdatePost operation middleware

func (*ServerInterfaceWrapper) UpdateUser

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

UpdateUser operation middleware

type StdHTTPServerOptions

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

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 UpdatePostJSONRequestBody

type UpdatePostJSONRequestBody = PostInput

UpdatePostJSONRequestBody defines body for UpdatePost for application/json ContentType.

type UpdateUserJSONRequestBody

type UpdateUserJSONRequestBody = UserInput

UpdateUserJSONRequestBody defines body for UpdateUser for application/json ContentType.

type User

type User struct {
	// Email Users email address
	Email string `json:"email"`
	Id    int64  `json:"id"`

	// Name Users full name
	Name string `json:"name"`
}

User defines model for User.

type UserBody

type UserBody = UserInput

UserBody defines model for UserBody.

type UserInput

type UserInput struct {
	// Email Users email address
	Email string `json:"email"`

	// Name Users full name
	Name string `json:"name"`
}

UserInput defines model for UserInput.

Jump to

Keyboard shortcuts

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