openapi

package
v0.0.0-...-b640da5 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package openapi 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 PathToRawSpec

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

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

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type BadRequest

type BadRequest = Error

BadRequest defines model for BadRequest.

type BoardSide

type BoardSide struct {
	// Pits The pits of the board side
	Pits   []int64 `json:"pits"`
	Player Player  `json:"player"`

	// Store The store (big pit) of the board side
	Store int64 `json:"store"`
}

BoardSide A side of the board

type CreateGameJSONBody

type CreateGameJSONBody struct {
	Player1 string `json:"player1"`
	Player2 string `json:"player2"`
}

CreateGameJSONBody defines parameters for CreateGame.

type CreateGameJSONRequestBody

type CreateGameJSONRequestBody CreateGameJSONBody

CreateGameJSONRequestBody defines body for CreateGame for application/json ContentType.

type CreatePlayJSONBody

type CreatePlayJSONBody struct {
	PitIndex int64 `json:"pit_index"`
}

CreatePlayJSONBody defines parameters for CreatePlay.

type CreatePlayJSONRequestBody

type CreatePlayJSONRequestBody CreatePlayJSONBody

CreatePlayJSONRequestBody defines body for CreatePlay for application/json ContentType.

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type Error

type Error struct {
	Message string `json:"message"`
}

Error defines model for Error.

type Game

type Game struct {
	// BoardSide1 A side of the board
	BoardSide1 BoardSide `json:"board_side1"`

	// BoardSide2 A side of the board
	BoardSide2 BoardSide `json:"board_side2"`

	// Id The id of the game
	Id string `json:"id"`

	// Result The result of the game
	Result Result `json:"result"`

	// Turn The turn that needs to play next
	Turn Turn `json:"turn"`
}

Game defines model for Game.

type GameID

type GameID = string

GameID defines model for GameID.

type InternalServerError

type InternalServerError = Error

InternalServerError defines model for InternalServerError.

type NewGameBody

type NewGameBody struct {
	Player1 string `json:"player1"`
	Player2 string `json:"player2"`
}

NewGameBody defines model for NewGameBody.

type NewPlayBody

type NewPlayBody struct {
	PitIndex int64 `json:"pit_index"`
}

NewPlayBody defines model for NewPlayBody.

type NotFound

type NotFound = Error

NotFound defines model for NotFound.

type PlayCreated

type PlayCreated struct {
	Game           Game  `json:"game"`
	PlayedPitIndex int64 `json:"played_pit_index"`
}

PlayCreated defines model for PlayCreated.

type Player

type Player struct {
	// Name The name of the player
	Name string `json:"name"`

	// Score The score of the player
	Score int64 `json:"score"`
}

Player defines model for Player.

type Result

type Result string

Result The result of the game

const (
	Player1Wins Result = "Player1Wins"
	Player2Wins Result = "Player2Wins"
	Tie         Result = "Tie"
	Undefined   Result = "Undefined"
)

Defines values for Result.

type ServerInterface

type ServerInterface interface {
	// Render API docs page
	// (GET /docs)
	RenderDocs(ctx echo.Context) error
	// Render swagger JSON
	// (GET /swagger.json)
	RenderSwagger(ctx echo.Context) error
	// Create game
	// (POST /v1/games)
	CreateGame(ctx echo.Context) error
	// Show game
	// (GET /v1/games/{id})
	ShowGame(ctx echo.Context, id GameID) error
	// Perform next play
	// (POST /v1/games/{id}/plays)
	CreatePlay(ctx echo.Context, id GameID) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) CreateGame

func (w *ServerInterfaceWrapper) CreateGame(ctx echo.Context) error

CreateGame converts echo context to params.

func (*ServerInterfaceWrapper) CreatePlay

func (w *ServerInterfaceWrapper) CreatePlay(ctx echo.Context) error

CreatePlay converts echo context to params.

func (*ServerInterfaceWrapper) RenderDocs

func (w *ServerInterfaceWrapper) RenderDocs(ctx echo.Context) error

RenderDocs converts echo context to params.

func (*ServerInterfaceWrapper) RenderSwagger

func (w *ServerInterfaceWrapper) RenderSwagger(ctx echo.Context) error

RenderSwagger converts echo context to params.

func (*ServerInterfaceWrapper) ShowGame

func (w *ServerInterfaceWrapper) ShowGame(ctx echo.Context) error

ShowGame converts echo context to params.

type Turn

type Turn string

Turn The turn that needs to play next

const (
	TurnPlayer1 Turn = "TurnPlayer1"
	TurnPlayer2 Turn = "TurnPlayer2"
)

Defines values for Turn.

Jump to

Keyboard shortcuts

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