autodocs

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DocsRoute              = "/docs"
	DocsIndexRoute         = "/index"
	DocsSwaggerConfigRoute = "/swagger-config"
)

Docs constants

Variables

View Source
var (
	DocumentTitle       = "API Explorer"
	DocumentDescription = "API Explorer Document Description"
	DocumentVersion     = "0.0.1"
	OAuthURL            = ""
)

Functions

func IsDocsHandlerLoaded

func IsDocsHandlerLoaded() bool

IsDocsHandlerLoaded boolean

func LoadDocsHandler

func LoadDocsHandler(app router.Party, apiBaseRoute string, handlersManager DocsHandlersManager)

LoadDocsHandler docs handler, the method would affects unique load

func ParseResponseParameters

func ParseResponseParameters(valueType reflect.Type, fieldTagName string, paramPosition string) map[string]PropertyInfo

ParseResponseParameters as list of ParameterInfo

func SetControllerGroupDescription

func SetControllerGroupDescription(controllerName string, description string)

SetControllerGroupDescription for controller

func SetControllerHandlerDescription

func SetControllerHandlerDescription(controllerName string, handlerName string, description string)

SetControllerHandlerDescription for controller name and handler name

Types

type BasicAuthInfo

type BasicAuthInfo struct {
	Type   string `json:"type"`
	Name   string `json:"name,omitempty"`
	Scheme string `json:"scheme,omitempty"`
	In     string `json:"in,omitempty"`
}

BasicAuthInfo struct

type BearerAuthInfo

type BearerAuthInfo struct {
	Type         string `json:"type"`
	Name         string `json:"name"`
	In           string `json:"in"`
	Scheme       string `json:"scheme"`
	BearerFormat string `json:"bearerFormat,omitempty"`
}

BearerAuthInfo struct

type Components

type Components struct {
	SecuritySchemes SecurityDefinitions `json:"securitySchemes,omitempty"`
}

Components struct

type ContactInfo

type ContactInfo struct {
	Email     string `json:"email,omitempty"`
	Telephone string `json:"telephone,omitempty"`
}

ContactInfo contains email etc

type DefinitionInfo

type DefinitionInfo struct {
	Type       string                  `json:"type,omitempty"`
	Properties map[string]PropertyInfo `json:"properties"`
	Required   []string                `json:"required,omitempty"`
	XML        XMLInfo                 `json:"xml,omitempty"`
}

DefinitionInfo model definition information

type DocsHandler

type DocsHandler interface {
	GetGroup() string
	GetName() string
	GetRoutingKey() string
	GetSummary() string
	GetDescription() string
	GetOperationID() string
	GetAllowsMethod() string
	GetParametersDocsInfo() []ParameterInfo
	GetRequestBodyDocsInfo() RequestBodyInfo
	GetResponsesDocsInfo() map[string]ResponseContentInfo
}

DocsHandler interface of handler defination

type DocsHandlersManager

type DocsHandlersManager interface {
	AllDocHandlers() []DocsHandler
}

DocsHandlersManager interfaces of docs handler manager

type DocsInfo

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

DocsInfo document information object

type ExternalDocsInfo

type ExternalDocsInfo struct {
	Description string `json:"description,omitempty"`
	Url         string `json:"url,omitempty"`
}

ExternalDocsInfo external docs information

type LicenseInfo

type LicenseInfo struct {
	Name string `json:"name,omitempty"`
	Url  string `json:"url,omitempty"`
}

LicenseInfo license information

type ParameterInfo

type ParameterInfo struct {
	Type             string          `json:"type"`
	Name             string          `json:"name"`
	In               string          `json:"in"`
	Description      string          `json:"description,omitempty"`
	Required         bool            `json:"required,omitempty"`
	Format           string          `json:"format,omitempty"`
	Items            *PropertyInfo   `json:"items,omitempty"`
	CollectionFormat string          `json:"collectionFormat,omitempty"`
	Schema           *DefinitionInfo `json:"schema,omitempty"`
	Style            string          `json:"style,omitempty"`
}

ParameterInfo parameter information

func ParseParameters

func ParseParameters(valueType reflect.Type, fieldTagName string, paramPosition string) []ParameterInfo

ParseParameters as list of ParameterInfo

type PathInfo

type PathInfo struct {
	Summary     string     `json:"summary,omitempty"`
	Description string     `json:"description,omitempty"`
	OperationID string     `json:"operationId,omitempty"`
	Post        *QueryInfo `json:"post,omitempty"`
	Get         *QueryInfo `json:"get,omitempty"`
	Put         *QueryInfo `json:"put,omitempty"`
	Delete      *QueryInfo `json:"delete,omitempty"`
	Patch       *QueryInfo `json:"patch,omitempty"`
	Head        *QueryInfo `json:"head,omitempty"`
	Option      *QueryInfo `json:"option,omitempty"`
}

PathInfo path information

type PrestoreAuthInfo

type PrestoreAuthInfo struct {
	Type             string            `json:"type"`
	AuthorizationUrl string            `json:"authorizationUrl"`
	Flow             string            `json:"flow"`
	Scopes           map[string]string `json:"scopes,omitempty"`
}

PrestoreAuthInfo struct

type PropertyInfo

type PropertyInfo struct {
	Type        string                  `json:"type,omitempty"`
	Format      string                  `json:"format,omitempty"`
	Description string                  `json:"description,omitempty"`
	Enum        []string                `json:"enum,omitempty"`
	Reference   string                  `json:"$ref,omitempty"`
	Example     string                  `json:"example,omitempty"`
	Default     string                  `json:"default,omitempty"`
	XML         *XMLInfo                `json:"xml,omitempty"`
	Items       *PropertyInfo           `json:"items,omitempty"`
	Properties  map[string]PropertyInfo `json:"properties,omitempty"`
}

PropertyInfo property information

type QueryInfo

type QueryInfo struct {
	Tags        []string                       `json:"tags,omitempty"`
	Summary     string                         `json:"summary,omitempty"`
	Description string                         `json:"description,omitempty"`
	OperationID string                         `json:"operationId,omitempty"`
	Consumes    []string                       `json:"consumes,omitempty"`
	Produces    []string                       `json:"produces,omitempty"`
	Parameters  []ParameterInfo                `json:"parameters,omitempty"`
	RequestBody RequestBodyInfo                `json:"requestBody,omitempty"`
	Responses   map[string]ResponseContentInfo `json:"responses"`
	Security    []interface{}                  `json:"security,omitempty"`
	Deprecated  bool                           `json:"deprecated,omitempty"`
}

QueryInfo query information

type QuerySecurityAuthInfo

type QuerySecurityAuthInfo struct {
	APIKey       []string `json:"jwt,omitempty"`
	PrestoreAuth []string `json:"petstoreAuth,omitempty"`
}

QuerySecurityAuthInfo struct

type RequestBodyInfo

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

RequestBodyInfo parameter in body information

type ResponseContentInfo

type ResponseContentInfo struct {
	Description string                `json:"description,omitempty"`
	Content     map[string]SchemaInfo `json:"content,omitempty"`
}

ResponseContentInfo response content in body information

type SchemaInfo

type SchemaInfo struct {
	Description       string          `json:"description,omitempty"`
	Schema            *DefinitionInfo `json:"schema,omitempty"`
	SerializationType string          `json:"serializationType,omitempty"`
}

SchemaInfo response information

type SecurityDefinitions

type SecurityDefinitions struct {
	APIKey       *BasicAuthInfo    `json:"jwt,omitempty"`
	BasicAuth    *BasicAuthInfo    `json:"basicAuth,omitempty"`
	PrestoreAuth *PrestoreAuthInfo `json:"petstoreAuth,omitempty"`
}

SecurityDefinitions security definition

type ServerInfo

type ServerInfo struct {
	URL         string `json:"url"`
	Description string `json:"description,omitempty"`
}

ServerInfo server api base path

type SwaggerConfig

type SwaggerConfig struct {
	Swagger             string                    `json:"swagger,omitempty"`
	OpenAPI             string                    `json:"openapi,omitempty"`
	Info                DocsInfo                  `json:"info"`
	Host                string                    `json:"host"`
	BasePath            string                    `json:"basePath,omitempty"`
	Servers             []ServerInfo              `json:"servers,omitempty"`
	Tags                []TagInfo                 `json:"tags"`
	Schemes             []string                  `json:"schemes"`
	Paths               map[string]*PathInfo      `json:"paths"`
	SecurityDefinitions SecurityDefinitions       `json:"securityDefinitions,omitempty"`
	Definitions         map[string]DefinitionInfo `json:"definitions"`
	ExternalDocs        ExternalDocsInfo          `json:"externalDocs,omitempty"`
	Components          Components                `json:"components,omitempty"`
}

SwaggerConfig config of docs

type TagInfo

type TagInfo struct {
	Name         string           `json:"name,omitempty"`
	Description  string           `json:"description,omitempty"`
	ExternalDocs ExternalDocsInfo `json:"externalDocs,omitempty"`
}

TagInfo tag information

type XMLInfo

type XMLInfo struct {
	Name    string `json:"name,omitempty"`
	Wrapped bool   `json:"wrapped,omitempty"`
}

XMLInfo struct

Jump to

Keyboard shortcuts

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