importer

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package importer provides functionality to import external API collections into yapi format

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnvironmentImportResult

type EnvironmentImportResult struct {
	Name             string            // Environment name from Postman
	ConfigVars       map[string]string // Non-secret vars for yapi.config.yml
	SecretVars       map[string]string // Secret vars for .env file
	SecretWarnings   []string          // Warnings about detected secrets
	UndefinedSecrets []string          // Current-only secrets (no initial value)
}

EnvironmentImportResult represents the result of importing a Postman environment

func ImportPostmanEnvironment

func ImportPostmanEnvironment(filePath string) (*EnvironmentImportResult, error)

ImportPostmanEnvironment imports a Postman environment file Returns structured data separating config vars from secrets

type ImportResult

type ImportResult struct {
	Files       map[string]config.ConfigV1 // relative path -> config
	Environment map[string]string          // environment variables
}

ImportResult represents the result of importing a collection

func ImportPostmanCollection

func ImportPostmanCollection(filePath string) (*ImportResult, error)

ImportPostmanCollection imports a Postman collection from a JSON file

type PostmanBody

type PostmanBody struct {
	Mode       string             `json:"mode"` // raw, urlencoded, formdata, etc.
	Raw        string             `json:"raw,omitempty"`
	URLEncoded []PostmanFormField `json:"urlencoded,omitempty"`
	FormData   []PostmanFormField `json:"formdata,omitempty"`
	Options    *PostmanOptions    `json:"options,omitempty"`
}

PostmanBody represents a request body

type PostmanCollection

type PostmanCollection struct {
	Info PostmanInfo   `json:"info"`
	Item []PostmanItem `json:"item"`
}

PostmanCollection represents a Postman Collection v2.1 schema

type PostmanEnvVariable

type PostmanEnvVariable struct {
	Key     string `json:"key"`
	Value   string `json:"value"`   // Current value (local, may be secret)
	Initial string `json:"initial"` // Initial value (exported, shareable)
	Enabled bool   `json:"enabled"`
	Type    string `json:"type,omitempty"` // "default", "secret", etc.
}

PostmanEnvVariable represents a single environment variable

type PostmanEnvironment

type PostmanEnvironment struct {
	ID     string               `json:"id"`
	Name   string               `json:"name"`
	Values []PostmanEnvVariable `json:"values"`
}

PostmanEnvironment represents a Postman environment file

type PostmanFormField

type PostmanFormField struct {
	Key      string `json:"key"`
	Value    string `json:"value"`
	Type     string `json:"type,omitempty"` // text or file
	Disabled bool   `json:"disabled,omitempty"`
}

PostmanFormField represents a form field in formdata or urlencoded body

type PostmanHeader

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

PostmanHeader represents a request header

type PostmanInfo

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

PostmanInfo contains metadata about the collection

type PostmanItem

type PostmanItem struct {
	Name    string          `json:"name"`
	Request *PostmanRequest `json:"request,omitempty"`
	Item    []PostmanItem   `json:"item,omitempty"` // For nested folders
}

PostmanItem represents either a folder or a request in the collection

type PostmanOptions

type PostmanOptions struct {
	Raw *PostmanRawOptions `json:"raw,omitempty"`
}

PostmanOptions contains body options like language

type PostmanQueryParam

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

PostmanQueryParam represents a URL query parameter

type PostmanRawOptions

type PostmanRawOptions struct {
	Language string `json:"language,omitempty"` // json, xml, text, etc.
}

PostmanRawOptions contains raw body options

type PostmanRequest

type PostmanRequest struct {
	Method string          `json:"method"`
	Header []PostmanHeader `json:"header,omitempty"`
	Body   *PostmanBody    `json:"body,omitempty"`
	URL    PostmanURL      `json:"url"`
}

PostmanRequest represents an HTTP request in Postman format

type PostmanURL

type PostmanURL struct {
	Raw      string              `json:"raw"`
	Protocol string              `json:"protocol,omitempty"`
	Host     []string            `json:"host,omitempty"`
	Path     []string            `json:"path,omitempty"`
	Query    []PostmanQueryParam `json:"query,omitempty"`
}

PostmanURL can be either a string or an object

func (*PostmanURL) UnmarshalJSON

func (u *PostmanURL) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for PostmanURL to handle both string and object formats

Jump to

Keyboard shortcuts

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