document

package
v0.0.0-...-d309816 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

* @Author: tj * @Date: 2022-11-02 10:05:45 * @LastEditors: tj * @LastEditTime: 2022-11-21 16:51:40 * @FilePath: \createApiMarkdown\document\data.go

* @Author: tj * @Date: 2022-10-21 16:15:51 * @LastEditors: tj * @LastEditTime: 2022-11-21 16:53:53 * @FilePath: \createApiMarkdown\document\document.go

* @Author: tj * @Date: 2022-11-02 11:04:39 * @LastEditors: tj * @LastEditTime: 2022-11-04 15:35:32 * @FilePath: \createApiMarkdown\document\option.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocItem

type DocItem struct {
	Title     string      `json:"title"`     // 标题
	Url       string      `json:"url"`       // 接口地址
	Method    string      `json:"method"`    // 请求类型
	Author    string      `json:"author"`    // 作者
	Request   interface{} `json:"request"`   // 请求参数
	Response  interface{} `json:"response"`  // 返回参数
	ReqFields []*Field    `json:"reqFields"` // 字段列表
	RspFields []*Field    `json:"rspFields"` // 字段列表
}

type Document

type Document struct {
	Title     string            `json:"title"`     // 文档标题
	Headermap map[string]string `json:"headerMap"` // headerData: key -> condition of key
	Version   string            `json:"version"`   // 版本号
	Url       string            `json:"Url"`       // Url
	Items     []*DocItem        `json:"items"`     // 接口列表
	// contains filtered or unexported fields
}

func NewDocument

func NewDocument(url string, headerMap map[string]string, options ...Option) *Document

func (*Document) AddDocItem

func (d *Document) AddDocItem(item *DocItem) error

添加接口对象

func (*Document) GetItems

func (d *Document) GetItems() []*DocItem

获取接口列表

func (*Document) ParseReqOrRsp

func (d *Document) ParseReqOrRsp(param interface{}) ([]*Field, error)

解析接口的请求对象或者返回对象

type Field

type Field struct {
	Name        string   `json:"name"`        // 字段名称
	Kind        string   `json:"kind"`        // 字段类型
	Description string   `json:"description"` // 字段说明
	IsRequired  bool     `json:"required"`    // 是否必填
	List        []*Field `json:"list"`        // 字段列表
}

type Option

type Option func(*Document)

func WithMdKey

func WithMdKey(key string) Option

设置markdown鉴别标识

func WithParseReq

func WithParseReq(isNeedParseReq bool) Option

func WithParseRsq

func WithParseRsq(isNeedParseRsq bool) Option

func WithTitle

func WithTitle(title string) Option

func WithVersion

func WithVersion(version string) Option

Jump to

Keyboard shortcuts

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