model

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Operation

type Operation struct {
	Comment     string
	OperationID string
	APIMethodUC string // method upper case
	APIMethodLC string // method lower case
	APIPath     string
	Parameters  []Parameter

	Tags         []string
	HasAPIDocURL bool
	APIDocURL    string // doc's URL
}

type PackageInfo

type PackageInfo struct {
	Name        string `json:"name" short:"n" long:"pkg-name" description:"sdk name, required, default from swagger's info.x-package-name"`
	Version     string `json:"version" short:"v" long:"pkg-version" description:"sdk version, required, default from swagger's version"`
	Description string `json:"description" long:"pkg-description" description:"sdk description, default from swagger's info.description"`
	Author      struct {
		Name  string `json:"name" long:"pkg-author-name" description:"sdk author name, default from swagger's info.contact.name"`
		Email string `json:"email,omitempty" long:"pkg-author-email" description:"sdk author email, default from swagger's info.contact.email"`
	} `json:"author"`
	Homepage string `json:"homepage,omitempty" long:"pkg-homepage" description:"sdk homepage, default from swagger's info.x-homepage"`
	License  string `json:"license,omitempty" long:"pkg-license" description:"sdk license, default from swagger's info.license"`
}

type PackageJSON

type PackageJSON struct {
	PackageInfo
	Main     string          `json:"main"`
	Module   string          `json:"module"`
	Scripts  json.RawMessage `json:"scripts"`
	Keywords []string        `json:"keywords"`
}

func (*PackageJSON) FromSwagger

func (p *PackageJSON) FromSwagger(pkgConf PackageInfo, swag *Swagger) error

func (*PackageJSON) ID

func (p *PackageJSON) ID() string

func (*PackageJSON) NpmID

func (p *PackageJSON) NpmID() string

func (*PackageJSON) TarName

func (p *PackageJSON) TarName() string

func (*PackageJSON) URL

func (p *PackageJSON) URL(base *url.URL) string

type Parameter

type Parameter struct {
	Name    string
	Names   []ParameterName // with normalized name, in camel case
	Comment string
	Type    ParameterType
	TypeIs  struct {
		Header, Path, Query, Body, FormData bool
	}
}

type ParameterName

type ParameterName struct {
	Swagger, JS string
}

func (ParameterName) SwaggerVarInPath

func (p ParameterName) SwaggerVarInPath() string

type ParameterType

type ParameterType string
const (
	ParameterTypeHeader ParameterType = "header"
	ParameterTypePath   ParameterType = "path"
	ParameterTypeQuery  ParameterType = "query"
	ParameterTypeBody   ParameterType = "body"
	ParameterTypeForm   ParameterType = "formData"
)

type Swagger

type Swagger struct {
	GenConf SwaggerGenConf // config options

	PkgJSON PackageJSON // lib's package.json

	UI       SwaggerUI
	Info     SwaggerInfo
	FileType SwaggerFileType

	Operations []Operation

	RawContent []byte
}

func (*Swagger) SetUrlRefInComment

func (swag *Swagger) SetUrlRefInComment() error

SetUrlRefInComment set UrlRefInComment in Swagger.GenConf as true and

type SwaggerFileType

type SwaggerFileType int
const (
	SwaggerFileTypeJSON SwaggerFileType = iota
	SwaggerFileTypeYAML
)

func (SwaggerFileType) String

func (t SwaggerFileType) String() string

type SwaggerGenConf

type SwaggerGenConf struct {
	CommonJS        bool // set to true to output cjs, otherwise ejs
	UrlRefInComment bool // set swagger UI deep link url in js comment, like https://petstore.swagger.io/#/pet/getPetById
}

type SwaggerInfo

type SwaggerInfo struct {
	Description string `json:"description" yaml:"description"`
	Version     string `json:"version" yaml:"version"`
	Title       string `json:"title" yaml:"title"`
	Contact     struct {
		Name  string `json:"name" yaml:"name"` // ext: contact's name
		Email string `json:"email" yaml:"email"`
	} `json:"contact" yaml:"contact"`
	License struct {
		Name string `json:"name" yaml:"name"`
	} `json:"license" yaml:"license"`
	Homepage    string `json:"x-homepage" yaml:"x-homepage"`       // ext: swagger UI homepage
	PackageName string `json:"x-package-name" yaml:"package-name"` // ext: js package name
}

type SwaggerUI

type SwaggerUI struct {
	Version string
	CDN     SwaggerUICdn
}

func (*SwaggerUI) BundleJS

func (u *SwaggerUI) BundleJS() string

func (*SwaggerUI) CSS

func (u *SwaggerUI) CSS() string

func (*SwaggerUI) Norm

func (u *SwaggerUI) Norm()

type SwaggerUICdn

type SwaggerUICdn string
const (
	SwaggerUICdnJsCdn     SwaggerUICdn = "https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/"
	SwaggerUICdnBootCdn   SwaggerUICdn = "https://cdn.bootcdn.net/ajax/libs/swagger-ui/"
	SwaggerUICdnWebStatic SwaggerUICdn = "https://cdnjs.webstatic.cn/ajax/libs/swagger-ui/"
)

Jump to

Keyboard shortcuts

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