pave

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: GPL-2.0 Imports: 6 Imported by: 2

README

vlbeaudoin/pave

Markdown JSON API spec generator for https://codeberg.org/vlbeaudoin/voki based apps

Documentation

Overview

Package pave allows generating a markdown spec for an API server that uses https://codeberg.org/vlbeaudoin/voki for defining its input and output types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EchoRegister

func EchoRegister[r voki.Requester[R], R voki.Responder](e *echo.Group, p *Pave, prefix, method, endpoint, description, identifier string, handlerFunc echo.HandlerFunc) error

EchoRegister allows registering a route with pave and declare a corresponding echo handler

Types

type Pave

type Pave struct {
	// contains filtered or unexported fields
}

func New

func New() (pave Pave)

func (*Pave) AddRouteString

func (p *Pave) AddRouteString(routeString string) error

func (Pave) RouteStrings

func (p Pave) RouteStrings() []string

RouteStrings returns the markdown route specs

func (Pave) SortedRouteStrings

func (p Pave) SortedRouteStrings() (routeStrings []string)

SortedRouteStrings returns the sorted markdown route specs

func (Pave) Spec added in v1.1.0

func (p Pave) Spec(project, description, version string) ([]byte, error)

Spec returns a full markdown spec as a []byte and any error encountered

If parameters `project` and `version` are empty they will be changed to `project unkown` and `version unknown`, respectively.

type PaveRoute

type PaveRoute[r voki.Requester[R], R voki.Responder] struct {
	// contains filtered or unexported fields
}

func NewPaveRoute

func NewPaveRoute[r voki.Requester[R], R voki.Responder](prefix, method, endpoint, description, identifier string) (paveRoute PaveRoute[r, R], err error)

func (PaveRoute[r, R]) Complete

func (pr PaveRoute[r, R]) Complete() bool

func (PaveRoute[r, R]) Description

func (pr PaveRoute[r, R]) Description() string

func (PaveRoute[r, R]) Endpoint

func (pr PaveRoute[r, R]) Endpoint() string

func (PaveRoute[r, R]) Identifier

func (pr PaveRoute[r, R]) Identifier() string

func (PaveRoute[r, R]) Method

func (pr PaveRoute[r, R]) Method() string

func (PaveRoute[r, R]) Prefix

func (pr PaveRoute[r, R]) Prefix() string

func (PaveRoute[r, R]) Register

func (pr PaveRoute[r, R]) Register(p *Pave) error

Register adds the PaveRoute.String() to a pave as a RouteString

func (PaveRoute[r, R]) Request

func (pr PaveRoute[r, R]) Request() r

func (PaveRoute[r, R]) RequestString

func (pr PaveRoute[r, R]) RequestString() string

RequestString returns the PaveRoute.Request as indented JSON

func (PaveRoute[r, R]) Response

func (pr PaveRoute[r, R]) Response() R

func (PaveRoute[r, R]) ResponseString

func (pr PaveRoute[r, R]) ResponseString() string

ResponseString returns the PaveRoute.Response as indented JSON

func (*PaveRoute[r, R]) SetDescription

func (pr *PaveRoute[r, R]) SetDescription(description string) error

func (*PaveRoute[r, R]) SetEndpoint

func (pr *PaveRoute[r, R]) SetEndpoint(endpoint string) error

func (*PaveRoute[r, R]) SetIdentifier

func (pr *PaveRoute[r, R]) SetIdentifier(identifier string) error

func (*PaveRoute[r, R]) SetMethod

func (pr *PaveRoute[r, R]) SetMethod(method string) error

func (*PaveRoute[r, R]) SetPrefix

func (pr *PaveRoute[r, R]) SetPrefix(prefix string) error

func (*PaveRoute[r, R]) SetRequest

func (pr *PaveRoute[r, R]) SetRequest(request r) error

func (*PaveRoute[r, R]) SetResponse

func (pr *PaveRoute[r, R]) SetResponse(response R) error

func (PaveRoute[r, R]) String

func (pr PaveRoute[r, R]) String() (result string)

String returns the markdown spec for a PaveRoute

Jump to

Keyboard shortcuts

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