postman2

package
v1.18.5 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SchemaURL210 = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	SchemaURL200 = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
)
View Source
const DefaultMediaTypePreferences string = `multipart/form-data,application/json,application/x-www-form-urlencoded,application/xml,text/plain`

Variables

This section is empty.

Functions

func APIURLOasToPostman added in v1.12.5

func APIURLOasToPostman(urlWithOasVars string) string

func DefaultMediaTypePreferencesSlice

func DefaultMediaTypePreferencesSlice() []string

Types

type Collection

type Collection struct {
	Info  CollectionInfo `json:"info"`
	Item  []*Item        `json:"item"`
	Event []Event        `json:"event,omitempty"`
}

func NewCollectionFromBytes

func NewCollectionFromBytes(data []byte) (Collection, error)

func ReadFile added in v1.17.0

func ReadFile(filename string) (Collection, error)

func (*Collection) GetOrNewFolder

func (col *Collection) GetOrNewFolder(folderName string) *Item

func (*Collection) Inflate

func (col *Collection) Inflate()

func (*Collection) InflateRawURLs

func (col *Collection) InflateRawURLs()

func (*Collection) SetFolder

func (col *Collection) SetFolder(newFolder *Item)

type CollectionInfo

type CollectionInfo struct {
	Name        string `json:"name,omitempty"`
	PostmanID   string `json:"_postman_id,omitempty"`
	Description string `json:"description,omitempty"`
	Schema      string `json:"schema,omitempty"`
}

type Description

type Description struct {
	Content string `json:"content,omitempty"`
	Type    string `json:"type,omitempty"`
	Version string `json:"version,omitempty"`
}

func (*Description) Inflate

func (desc *Description) Inflate()

type Event

type Event struct {
	Listen string `json:"listen"`
	Script Script `json:"script"`
}
type Header struct {
	Key         string `json:"key,omitempty"`
	Value       string `json:"value,omitempty"`
	Description string `json:"description,omitempty"`
}

func AddOperationReqResMediaTypeHeaders

func AddOperationReqResMediaTypeHeaders(headers []Header, operation *oas3.Operation, spec *openapi3.Spec, reqPreferences []string, resPreferences []string) ([]Header, string, string, error)

func AppendPostmanHeaderValueLower

func AppendPostmanHeaderValueLower(headers []Header, headerName string, options, preferenceOrder []string) ([]Header, string)

type Item

type Item struct {
	Name        string       `json:"name,omitempty"`                 // Folder,Operation
	Description *Description `json:"description,omitempty"`          // Folder
	Item        []*Item      `json:"item,omitempty"`                 // Folder
	IsSubFolder bool         `json:"_postman_isSubFolder,omitempty"` // Folder
	Event       []Event      `json:"event,omitempty"`                // Operation
	Request     *Request     `json:"request,omitempty"`              // Operation
}

Item can represent a folder or an API

func (*Item) UpsertSubItem

func (item *Item) UpsertSubItem(newItem *Item)

type Request

type Request struct {
	URL         *URL         `json:"url,omitempty"`
	Method      string       `json:"method,omitempty"`
	Header      []Header     `json:"header,omitempty"`
	Body        *RequestBody `json:"body,omitempty"`
	Description string       `json:"description,omitempty"`
}

type RequestBody

type RequestBody struct {
	Mode       string            `json:"mode,omitempty"` // `raw`, `urlencoded`, `formdata`,`file`,`graphql`
	Raw        string            `json:"raw,omitempty"`
	URLEncoded []URLEncodedParam `json:"urlencoded,omitempty"`
}

type Script

type Script struct {
	Type string   `json:"type,omitempty"`
	Exec []string `json:"exec,omitempty"`
}

type URL

type URL struct {
	Raw      string            `json:"raw,omitempty"`
	Protocol string            `json:"protocol,omitempty"`
	Auth     map[string]string `json:"auth,omitempty"`
	Host     []string          `json:"host,omitempty"`
	Path     []string          `json:"path,omitempty"`
	Query    []URLQuery        `json:"query,omitempty"`
	Variable []URLVariable     `json:"variable,omitempty"`
}

URL is the Postman URL used in the Postman 2.0 Collection Spec.

func NewURL

func NewURL(rawURL string) URL

func NewURLForGoURL added in v1.12.0

func NewURLForGoURL(goURL url.URL) URL

func (*URL) AddVariable

func (pmURL *URL) AddVariable(key string, value interface{})

AddVariable adds a Postman Variable to the struct.

func (*URL) IsRawOnly

func (pmURL *URL) IsRawOnly() bool

type URLEncodedParam

type URLEncodedParam struct {
	Key     string `json:"key,omitempty"`
	Value   string `json:"value,omitempty"`
	Type    string `json:"type,omitempty"`
	Enabled bool   `json:"enabled,omitempty"`
}

type URLParameters

type URLParameters struct {
	Query    []URLQuery    `json:"query,omitempty"`
	Variable []URLVariable `json:"variable,omitempty"`
}

URLParameters is a temp struct to hold parsed parameters.

func NewURLParameters

func NewURLParameters() URLParameters

NewURLParameters returns an initialized empty struct.

type URLQuery

type URLQuery struct {
	Key         string `json:"key,omitempty"`
	Value       string `json:"value,omitempty"`
	Description string `json:"description,omitempty"`
	Disabled    bool   `json:"disabled,omitempty"`
}

type URLVariable

type URLVariable struct {
	Key         string                 `json:"key,omitempty"`
	Value       interface{}            `json:"value,omitempty"`
	Description URLVariableDescription `json:"description,omitempty"`
	Disabled    bool                   `json:"disabled,omitempty"`
	ID          string                 `json:"id,omitempty"` // Old, pre 2.0.1
}

type URLVariableDescription

type URLVariableDescription struct {
	Content string `json:"content,omitempty"`
	Type    string `json:"type,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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