test

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApiKeyAuthAuthenticationHandler = simba.APIKeyAuth[ApiKeyParams, User](
	ApiKeyAuthFunc,
	simba.APIKeyAuthConfig{
		Name:        "User",
		FieldName:   "sessionid",
		In:          openapi.InCookie,
		Description: "Session cookie",
	})
View Source
var BasicAuthAuthenticationHandler = simba.BasicAuth[BasicAuthParams, User](
	BasicAuthFunc,
	simba.BasicAuthConfig{
		Name:        "admin",
		Description: "admin access only",
	})
View Source
var BearerAuthAuthenticationHandler = simba.BearerAuth[BearerTokenParams, User](
	BearerAuthFunc,
	simba.BearerAuthConfig{
		Name:        "admin",
		Format:      "jwt",
		Description: "Bearer token",
	})

Functions

func ApiKeyAuthHandler added in v0.12.3

func ApiKeyAuthHandler(ctx context.Context, req *simba.Request[simba.NoBody, simba.NoParams], auth *User) (*simba.Response[simba.NoBody], error)

ApiKeyAuthHandler A dummy function to test the OpenAPI generation with api key auth. @ID apiKeyAuthHandler @Summary api key handler @Description this is a multiline

description for the handler

@Error 409 Resource already exists

func BasicAuthHandler added in v0.12.3

func BasicAuthHandler(ctx context.Context, req *simba.Request[simba.NoBody, simba.NoParams], auth *User) (*simba.Response[simba.NoBody], error)

BasicAuthHandler A dummy function to test the OpenAPI generation with basic auth. @ID basicAuthHandler @Summary basic auth handler @Description this is a multiline

description for the handler

@Error 409 Resource already exists

func BearerTokenAuthHandler added in v0.12.3

func BearerTokenAuthHandler(ctx context.Context, req *simba.Request[simba.NoBody, simba.NoParams], auth *User) (*simba.Response[simba.NoBody], error)

BearerTokenAuthHandler A dummy function to test the OpenAPI generation with bearer token auth. @ID bearerTokenAuthHandler @Summary bearer token handler @Description this is a multiline

description for the handler

@Error 409 Resource already exists

func NoTagsHandler added in v0.12.3

NoTagsHandler A dummy function to test the OpenAPI generation without any tags in the comment.

func TagsHandler added in v0.12.3

TagsHandler A dummy function to test the OpenAPI generation with tags in the comment. @ID testHandler @Deprecated @Tag Test @Tag User @Summary test handler @Description this is a multiline

description for the handler @Error 409 Resource already exists

Types

type ApiKeyParams added in v0.13.0

type ApiKeyParams struct {
	APIKey string `header:"Authorization" description:"API key"`
}

type AuthParams added in v0.13.0

type AuthParams struct {
	Token string `header:"Authorization" validate:"required"`
}

type AuthRequestBody added in v0.13.0

type AuthRequestBody struct {
	Token string `json:"token" validate:"required"`
}

AuthRequestBody is a test struct for authenticated request body

type BasicAuthParams added in v0.13.0

type BasicAuthParams struct {
	Credentials string `header:"Authorization" description:"Basic auth username"`
}

type BearerTokenParams added in v0.13.0

type BearerTokenParams struct {
	Token string `header:"Authorization" description:"Bearer token"`
}

type Params

type Params struct {
	ID        uuid.UUID `path:"id" description:"ID of the user" example:"1"`
	Gender    string    `query:"gender" description:"Gender of the user" example:"male"`
	RequestID string    `header:"X-Request-ID" description:"Request ID" example:"1234"`
	Active    bool      `query:"active" description:"Active status of the user" example:"true"`
	Page      int       `query:"page" description:"Page number" example:"1" default:"1"`
	Size      int64     `query:"size" description:"Page size" example:"10" default:"10"`
	Score     float64   `query:"score" description:"User score" example:"9.5" default:"10.0"`
}

type Receiver added in v0.12.3

type Receiver struct{}

Receiver A dummy struct to test the OpenAPI generation with receiver functions.

func (*Receiver) NoTagsHandler added in v0.12.3

NoTagsHandler A dummy function to test the OpenAPI generation without any tags in the comment.

func (*Receiver) TagsHandler added in v0.12.3

TagsHandler A dummy function to test the OpenAPI generation with tags in the comment with receiver functions. @ID testHandler @Deprecated @Tag Test @Tag User @Summary test handler @Description this is a multiline

description for the handler @Error 409 Resource already exists

type RequestBody

type RequestBody struct {
	Name        string `json:"name" description:"Name of the user" example:"John Doe" validate:"required"`
	Age         int    `json:"age" description:"Age of the user" example:"30"`
	Description string `json:"description" description:"description of the user" example:"A test user"`
}

type ResponseBody added in v0.12.3

type ResponseBody struct {
	ID          uuid.UUID `json:"id" description:"ID of the user" example:"1"`
	Name        string    `json:"name" description:"Name of the user" example:"John Doe"`
	Age         int       `json:"age" description:"Age of the user" example:"30"`
	Description string    `json:"description" description:"description of the user" example:"A test user"`
}

type User

type User struct {
	ID   int    `json:"id" description:"ID of the user" example:"1"`
	Name string `json:"name" description:"Name of the user" example:"John Doe"`
	Role string `json:"role" description:"Role of the user" example:"admin"`
}

func ApiKeyAuthFunc added in v0.12.3

func ApiKeyAuthFunc(ctx context.Context, req *simba.AuthRequest[ApiKeyParams]) (*User, error)

ApiKeyAuthFunc A dummy function to test the OpenAPI generation with api key auth. @APIKeyAuth "User" "sessionid" "cookie" "Session cookie"

func BasicAuthFunc added in v0.12.3

func BasicAuthFunc(ctx context.Context, req *simba.AuthRequest[BasicAuthParams]) (*User, error)

BasicAuthFunc A dummy function to test the OpenAPI generation with basic auth. @BasicAuth "admin" "admin access only"

func BearerAuthFunc added in v0.12.3

func BearerAuthFunc(ctx context.Context, req *simba.AuthRequest[BearerTokenParams]) (*User, error)

BearerAuthFunc A dummy function to test the OpenAPI generation with bearer token auth. @BearerAuth "admin" "jwt" "Bearer token"

Jump to

Keyboard shortcuts

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