api

package
v0.0.0-...-b5fa026 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 11 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.3.0 DO NOT EDIT.

Index

Constants

View Source
const (
	CookieAuthScopes = "cookieAuth.Scopes"
)

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 fiber.Router, si ServerInterface)

RegisterHandlers creates http.Handler with routing matching OpenAPI spec.

func RegisterHandlersWithOptions

func RegisterHandlersWithOptions(router fiber.Router, si ServerInterface, options FiberServerOptions)

RegisterHandlersWithOptions creates http.Handler with additional options

Types

type Error

type Error struct {
	// Code Error code
	Code int32 `json:"code"`

	// Message Error message
	Message string `json:"message"`
}

Error defines model for Error.

type ErrorResponse

type ErrorResponse = Error

ErrorResponse defines model for ErrorResponse.

type FiberServerOptions

type FiberServerOptions struct {
	BaseURL     string
	Middlewares []MiddlewareFunc
}

FiberServerOptions provides options for the Fiber server.

type MiddlewareFunc

type MiddlewareFunc fiber.Handler

type PoemRequest

type PoemRequest struct {
	CreatedAt time.Time          `json:"created_at"`
	Id        openapi_types.UUID `json:"id"`
	Poem      *string            `json:"poem,omitempty"`
	Prompt    string             `json:"prompt"`
	Status    PoemRequestStatus  `json:"status"`
	UpdatedAt time.Time          `json:"updated_at"`
	UserId    openapi_types.UUID `json:"user_id"`
}

PoemRequest defines model for PoemRequest.

type PoemRequestInput

type PoemRequestInput struct {
	Prompt string `json:"prompt"`
}

PoemRequestInput defines model for PoemRequestInput.

type PoemRequestStatus

type PoemRequestStatus string

PoemRequestStatus defines model for PoemRequest.Status.

const (
	Completed PoemRequestStatus = "completed"
	Failed    PoemRequestStatus = "failed"
	Pending   PoemRequestStatus = "pending"
)

Defines values for PoemRequestStatus.

type RequestPoemJSONRequestBody

type RequestPoemJSONRequestBody = PoemRequestInput

RequestPoemJSONRequestBody defines body for RequestPoem for application/json ContentType.

type ServerInterface

type ServerInterface interface {
	// Callback from Auth0
	// (GET /auth/callback)
	Callback(c *fiber.Ctx) error
	// Logs user into the system via Auth0
	// (GET /auth/login)
	Login(c *fiber.Ctx) error
	// Logs out current logged in user session
	// (GET /logout)
	Logout(c *fiber.Ctx) error
	// Get user's poem requests
	// (GET /poems)
	GetUserPoemRequests(c *fiber.Ctx) error
	// Request a new poem
	// (POST /poems)
	RequestPoem(c *fiber.Ctx) error
	// Get user information
	// (GET /user)
	GetUser(c *fiber.Ctx) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) Callback

func (siw *ServerInterfaceWrapper) Callback(c *fiber.Ctx) error

Callback operation middleware

func (*ServerInterfaceWrapper) GetUser

func (siw *ServerInterfaceWrapper) GetUser(c *fiber.Ctx) error

GetUser operation middleware

func (*ServerInterfaceWrapper) GetUserPoemRequests

func (siw *ServerInterfaceWrapper) GetUserPoemRequests(c *fiber.Ctx) error

GetUserPoemRequests operation middleware

func (*ServerInterfaceWrapper) Login

func (siw *ServerInterfaceWrapper) Login(c *fiber.Ctx) error

Login operation middleware

func (*ServerInterfaceWrapper) Logout

func (siw *ServerInterfaceWrapper) Logout(c *fiber.Ctx) error

Logout operation middleware

func (*ServerInterfaceWrapper) RequestPoem

func (siw *ServerInterfaceWrapper) RequestPoem(c *fiber.Ctx) error

RequestPoem operation middleware

type User

type User struct {
	// Auth0Id Auth0 ID
	Auth0Id string `json:"auth0_id"`

	// CreatedAt Account creation timestamp
	CreatedAt *time.Time `json:"created_at,omitempty"`

	// Email User email
	Email string `json:"email"`

	// EmailVerified Email verification status
	EmailVerified *bool `json:"email_verified,omitempty"`

	// Id User ID
	Id openapi_types.UUID `json:"id"`

	// LastLogin Last login timestamp
	LastLogin *time.Time `json:"last_login,omitempty"`

	// Name User name
	Name *string `json:"name,omitempty"`

	// Nickname User nickname
	Nickname *string `json:"nickname,omitempty"`

	// Picture User avatar
	Picture *string `json:"picture,omitempty"`

	// UpdatedAt Last update timestamp
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

User defines model for User.

Jump to

Keyboard shortcuts

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