types

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncodingWwwUrlencode = "application/x-www-form-urlencoded"
	EncodingJSON         = "application/json"
	EncodingJSONText     = "text/json"
	EncodingXML          = "application/xml"
	EncodingXMLText      = "text/xml"
	EncodingFormData     = "multipart/form-data"
	EncodingPHP          = "php"
)
View Source
const (
	// LanguageCurl curl
	LanguageCurl  = Language("curl")
	LanguagePhp   = Language("php")
	LanguageJS    = Language("js")
	LanguageEmpty = Language("")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeSample

type CodeSample struct {
	Lang   Language `yaml:"lang" json:"lang"`     // language of the sample
	Source string   `yaml:"source" json:"source"` // the actual source code
	Label  string   `yaml:"label" json:"label"`   // displayed language name
}

CodeSample represents a single code example

type Encoder

type Encoder interface {
	EnocdeValue(ref string, value interface{}, meta *FormattingMeta) (string, error)
	EnocdeParameter(name string, value interface{}) (string, error)
}

Encoder defines an interface for encoding

type Extractor

type Extractor interface {
	GetParameters(params openapi3.Parameters) (Parameters, error)
	GetPathExample(path string, params []*Parameter) string
	GetURL(operation *openapi3.Operation, pathItem *openapi3.PathItem, document *openapi3.T) string
	GetRequestBody(body *openapi3.RequestBody) (value interface{}, format string, err error)
	GetExampleValueForSchema(schema *openapi3.Schema, format string) (interface{}, error)
	GetSecurity(operation *openapi3.Operation, document *openapi3.T) (params Parameters, basicAuth bool, err error)
}

Extractor defines an interface for feature extractors

type FormattingMeta

type FormattingMeta struct {
	Format   string
	FormData struct {
		OuterBoundary *string
	}
}

FormattingMeta holds meta data for formatting

type Generator

type Generator interface {
	GetSample(httpVerb string, path string, operation *openapi3.Operation, pathItem *openapi3.PathItem, document *openapi3.T) (*CodeSample, error)
}

Generator is an interface for language specific generators to adopt

type Language

type Language string

Language enum

func StringToLanguage

func StringToLanguage(value string) Language

StringToLanguage maps a string value to it's corresponding language type

type Parameter

type Parameter struct {
	Name  string
	Value interface{}
}

Parameter holds a parameter and example value

type Parameters

type Parameters struct {
	Query  []*Parameter
	Header []*Parameter
	Cookie []*Parameter
	Path   []*Parameter
}

Parameters defines all available parameters

Jump to

Keyboard shortcuts

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