swagger

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToSwaggerResponse

func ConvertToSwaggerResponse(data interface{}) map[string]interface{}

ConvertToSwaggerResponse converts a struct to a swagger response.

func GetSwaggerType

func GetSwaggerType(goType string) string

GetSwaggerType returns the type of the swagger type that corresponds to the go type.

Types

type Contact

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

type ContentType

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

type Info

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

Info swagger info 根节点/**

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"`
	Host       string                     `json:"host"`
	BasePath   string                     `json:"basePath"`
	Schemes    []string                   `json:"schemes"`
	Servers    []Server                   `json:"servers"`
	Tags       []Tag                      `json:"tags"`
	Paths      map[string]map[string]Path `json:"paths"`
	Components map[string]interface{}     `json:"components"`
	Security   []map[string][]string      `json:"security"`
}

func NewOpenApi

func NewOpenApi(baseUri string, info Info) *OpenApi

func (*OpenApi) AddSecurityApiKey

func (openapi *OpenApi) AddSecurityApiKey(name string)

func (*OpenApi) AddSecurityBasicAuth

func (openapi *OpenApi) AddSecurityBasicAuth()

func (*OpenApi) AddSecurityBearerAuth

func (openapi *OpenApi) AddSecurityBearerAuth()

type Parameters

type Parameters struct {
	Name        string `json:"name"`
	In          string `json:"in"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
	Schema      struct {
		Type string `json:"type"`
	} `json:"schema,omitempty"`
}

type Path

type Path struct {
	Tags        []string                 `json:"tags"`
	Summary     string                   `json:"summary"`
	Description string                   `json:"description"`
	OperationId string                   `json:"operationId"`
	Parameters  interface{}              `json:"parameters,omitempty"`
	RequestBody RequestBody              `json:"requestBody,omitempty"`
	Responses   map[string]ResponsesItem `json:"responses"`
	Security    []Security               `json:"security"`
}

type Property

type Property struct {
	Description string `json:"description"`
	Type        string `json:"type"`
	Format      string `json:"format,omitempty"`
}

type RequestBody

type RequestBody struct {
	Content map[string]ContentType `json:"content,omitempty"`
}

type ResponsesItem

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

type Schema

type Schema struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties"`
	Required   []string            `json:"required"`
}

type Security

type Security struct {
	PetstoreAuth []string `json:"petstore_auth"`
}

type Server

type Server struct {
	Url string `json:"url"`
}

type Tag

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

Jump to

Keyboard shortcuts

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