doclib

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 7 Imported by: 25

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BoolSchema *openapi3.SchemaRef

Functions

func AddSecuritySchema

func AddSecuritySchema(id, header, description string)

func AddTag

func AddTag(name, description string)

func AddWebhook

func AddWebhook(wdoc *WebhookDoc)

func Route

func Route(doc *Doc)

func SchemaInject

func SchemaInject(s any) openapi3gen.Option

func SetSchema

func SetSchema(new Openapi)

func Setup

func Setup()

Types

type Component

type Component struct {
	Schemas       map[string]any      `json:"schemas"`
	Security      map[string]Security `json:"securitySchemes"`
	RequestBodies map[string]ReqBody  `json:"requestBodies"`
}

type Contact

type Contact struct {
	Name  string `json:"name"`
	URL   string `json:"url"`
	Email string `json:"email"`
}

type Content

type Content struct {
	Schema any `json:"schema"`
}

type Doc

type Doc struct {
	Method      string
	Pattern     string
	OpId        string
	Summary     string
	Description string
	Params      []Parameter
	Tags        []string
	Req         any
	Resp        any
	RespName    string // Just in case resp cannot be used to derive the name
	AuthType    []string
}

Highlevel stuff

type Info

type Info struct {
	Title          string  `json:"title"`
	Description    string  `json:"description"`
	TermsOfService string  `json:"termsOfService"`
	Version        string  `json:"version"`
	Contact        Contact `json:"contact"`
	License        License `json:"license"`
}

type License

type License struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

type Openapi

type Openapi struct {
	OpenAPI    string                               `json:"openapi"`
	Info       Info                                 `json:"info"`
	Servers    []Server                             `json:"servers"`
	Components Component                            `json:"components"`
	Webhooks   *orderedmap.OrderedMap[string, Path] `json:"webhooks,omitempty"`
	Paths      *orderedmap.OrderedMap[string, Path] `json:"paths"`
	Tags       []Tag                                `json:"tags,omitempty"`
}

func GetSchema

func GetSchema() Openapi

type Operation

type Operation struct {
	Summary     string                `json:"summary"`
	Tags        []string              `json:"tags,omitempty"`
	Description string                `json:"description"`
	ID          string                `json:"operationId"`
	RequestBody *Schema               `json:"requestBody,omitempty"`
	Parameters  []Parameter           `json:"parameters"`
	Responses   map[string]Response   `json:"responses"`
	Security    []map[string][]string `json:"security,omitempty"`
	Servers     []Server              `json:"servers,omitempty"`
}

type Parameter

type Parameter struct {
	Name        string `json:"name"`
	In          string `json:"in"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
	Schema      any    `json:"schema"`
}

Parameter defines a openAPI parameter

type Path

type Path struct {
	Summary     string     `json:"summary"` // Danger do not use this
	Description string     `json:"description"`
	Head        *Operation `json:"head,omitempty"`
	Get         *Operation `json:"get,omitempty"`
	Post        *Operation `json:"post,omitempty"`
	Put         *Operation `json:"put,omitempty"`
	Patch       *Operation `json:"patch,omitempty"`
	Delete      *Operation `json:"delete,omitempty"`
}

type ReqBody

type ReqBody struct {
	Description string             `json:"description,omitempty"`
	Required    bool               `json:"required,omitempty"`
	Content     map[string]Content `json:"content"`
}

type Response

type Response struct {
	Description string                `json:"description"`
	Content     map[string]SchemaResp `json:"content"`
}

Represents a openAPI response

type Schema

type Schema struct {
	Ref        string         `json:"$ref,omitempty"`
	Type       string         `json:"type,omitempty"`
	Required   []string       `json:"required,omitempty"`
	Properties map[string]any `json:"properties,omitempty"`
}

type SchemaResp

type SchemaResp struct {
	Schema Schema `json:"schema"`
}

type Security

type Security struct {
	Type        string `json:"type"`
	Name        string `json:"name"`
	Description string `json:"description"`
	In          string `json:"in"` // must be apiKey for Popplio
}

type Server

type Server struct {
	URL         string         `json:"url"`
	Description string         `json:"description"`
	Variables   map[string]any `json:"variables"`
}

type SetupData

type SetupData struct {
	URL         string
	ErrorStruct any
	Info        Info
	// contains filtered or unexported fields
}
var (
	DocsSetupData *SetupData
)

type Tag

type Tag struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

type WebhookDoc

type WebhookDoc struct {
	Name   string
	Format any

	// Since format is usually a generic
	FormatName  string
	Summary     string
	Description string
	Tags        []string
}

Jump to

Keyboard shortcuts

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