schema

package
v0.0.0-...-82013dc Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeHeader            = "Content-Type"
	ContentTypeJSON              = "application/json"
	ContentTypeNdJSON            = "application/x-ndjson"
	ContentTypeXML               = "application/xml"
	ContentTypeFormURLEncoded    = "application/x-www-form-urlencoded"
	ContentTypeMultipartFormData = "multipart/form-data"
	ContentTypeTextPlain         = "text/plain"
	ContentTypeTextHTML          = "text/html"
)
View Source
const BodyKey = "body"

Variables

This section is empty.

Functions

func IsDefaultScalar

func IsDefaultScalar(name string) bool

IsDefaultScalar checks if the scalar name is

func ReplaceEnvTemplates

func ReplaceEnvTemplates(input string, envTemplates []EnvTemplate) string

ReplaceEnvTemplates replaces env templates in the input string with values

Types

type APIKeyAuthConfig

type APIKeyAuthConfig struct {
	In   APIKeyLocation `json:"in"   mapstructure:"in"   yaml:"in"`
	Name string         `json:"name" mapstructure:"name" yaml:"name"`
}

APIKeyAuthConfig contains configurations for apiKey authentication

func (APIKeyAuthConfig) Validate

func (ss APIKeyAuthConfig) Validate() error

Validate if the current instance is valid

type APIKeyLocation

type APIKeyLocation string

ApiKeyLocation represents the location enum for apiKey auth

const (
	APIKeyInHeader APIKeyLocation = "header"
	APIKeyInQuery  APIKeyLocation = "query"
	APIKeyInCookie APIKeyLocation = "cookie"
)

func ParseAPIKeyLocation

func ParseAPIKeyLocation(value string) (APIKeyLocation, error)

ParseAPIKeyLocation parses APIKeyLocation from string

func (APIKeyLocation) JSONSchema

func (j APIKeyLocation) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (*APIKeyLocation) UnmarshalJSON

func (j *APIKeyLocation) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ArgumentInfo

type ArgumentInfo struct {
	schema.ArgumentInfo `yaml:",inline"`

	// The request parameter information of the REST request
	Rest *RequestParameter `json:"rest,omitempty" mapstructure:"rest" yaml:"rest,omitempty"`
}

ArgumentInfo the information of REST request argument

func (*ArgumentInfo) UnmarshalJSON

func (j *ArgumentInfo) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type AuthSecurities

type AuthSecurities []AuthSecurity

AuthSecurities wraps list of security requirements with helpers

func (*AuthSecurities) Add

func (ass *AuthSecurities) Add(item AuthSecurity)

Add adds a security with name and scope

func (AuthSecurities) First

func (ass AuthSecurities) First() AuthSecurity

First returns the first security

func (AuthSecurities) Get

func (ass AuthSecurities) Get(name string) AuthSecurity

Get gets a security by name

func (AuthSecurities) IsEmpty

func (ass AuthSecurities) IsEmpty() bool

IsEmpty checks if there is no security

func (AuthSecurities) IsOptional

func (ass AuthSecurities) IsOptional() bool

IsOptional checks if the security is optional

type AuthSecurity

type AuthSecurity map[string][]string

AuthSecurity wraps the raw security requirement with helpers

func NewAuthSecurity

func NewAuthSecurity(name string, scopes []string) AuthSecurity

NewAuthSecurity creates an AuthSecurity instance from name and scope

func (AuthSecurity) IsOptional

func (as AuthSecurity) IsOptional() bool

IsOptional checks if the security is optional

func (AuthSecurity) Name

func (as AuthSecurity) Name() string

Name returns the name of security requirement

func (AuthSecurity) Scopes

func (as AuthSecurity) Scopes() []string

Scopes returns scopes of security requirement

type EncodingObject

type EncodingObject struct {
	// Describes how a specific property value will be serialized depending on its type.
	// See Parameter Object for details on the style property.
	// The behavior follows the same values as query parameters, including default values.
	// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data.
	// If a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored
	Style ParameterEncodingStyle `json:"style,omitempty" mapstructure:"style" yaml:"style,omitempty"`
	// When this is true, property values of type array or object generate separate parameters for each value of the array, or key-value-pair of the map.
	// For other types of properties this property has no effect. When style is form, the default value is true. For all other styles, the default value is false.
	// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data.
	// If a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored
	Explode *bool `json:"explode,omitempty" mapstructure:"explode" yaml:"explode,omitempty"`
	// By default, reserved characters :/?#[]@!$&'()*+,;= in form field values within application/x-www-form-urlencoded bodies are percent-encoded when sent.
	// AllowReserved allows these characters to be sent as is:
	AllowReserved bool `json:"allowReserved,omitempty" mapstructure:"allowReserved" yaml:"allowReserved,omitempty"`
	// For more complex scenarios, such as nested arrays or JSON in form data, use the contentType keyword to specify the media type for encoding the value of a complex field.
	ContentType []string `json:"contentType,omitempty" mapstructure:"contentType" yaml:"contentType,omitempty"`
	// A map allowing additional information to be provided as headers, for example Content-Disposition.
	// Content-Type is described separately and SHALL be ignored in this section.
	// This property SHALL be ignored if the request body media type is not a multipart.
	Headers map[string]RequestParameter `json:"headers,omitempty" mapstructure:"headers" yaml:"headers,omitempty"`
}

EncodingObject represents the Encoding Object that contains serialization strategy for application/x-www-form-urlencoded

func (*EncodingObject) GetHeader

func (eo *EncodingObject) GetHeader(key string) *RequestParameter

GetHeader gets the encoding header by key

func (*EncodingObject) SetHeader

func (eo *EncodingObject) SetHeader(key string, param RequestParameter)

SetHeader sets the encoding header

type EnvBoolean

type EnvBoolean struct {
	EnvTemplate
	// contains filtered or unexported fields
}

EnvBoolean implements the boolean environment encoder and decoder

func NewEnvBooleanTemplate

func NewEnvBooleanTemplate(template EnvTemplate) *EnvBoolean

NewEnvBooleanTemplate creates an EnvBoolean from template

func NewEnvBooleanValue

func NewEnvBooleanValue(value bool) *EnvBoolean

NewEnvBooleanValue creates an EnvBoolean from value

func (EnvBoolean) Equal

func (et EnvBoolean) Equal(target EnvBoolean) bool

Equal checks if the current value equals the target

func (EnvBoolean) JSONSchema

func (j EnvBoolean) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (EnvBoolean) MarshalJSON

func (j EnvBoolean) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (EnvBoolean) MarshalYAML

func (j EnvBoolean) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler interface

func (EnvBoolean) String

func (et EnvBoolean) String() string

String implements the Stringer interface

func (*EnvBoolean) UnmarshalJSON

func (j *EnvBoolean) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*EnvBoolean) UnmarshalText

func (j *EnvBoolean) UnmarshalText(text []byte) error

UnmarshalText decodes boolean from string

func (*EnvBoolean) UnmarshalYAML

func (j *EnvBoolean) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

func (*EnvBoolean) Value

func (et *EnvBoolean) Value() (*bool, error)

Value returns the value which is retrieved from system or the default value if exist

func (EnvBoolean) WithValue

func (j EnvBoolean) WithValue(value bool) *EnvBoolean

WithValue returns a new EnvBoolean instance with new value

type EnvInt

type EnvInt struct {
	EnvTemplate
	// contains filtered or unexported fields
}

EnvInt implements the integer environment encoder and decoder

func NewEnvIntTemplate

func NewEnvIntTemplate(template EnvTemplate) *EnvInt

NewEnvIntTemplate creates an EnvInt from template

func NewEnvIntValue

func NewEnvIntValue(value int64) *EnvInt

NewEnvIntValue creates an EnvInt from value

func (EnvInt) Equal

func (et EnvInt) Equal(target EnvInt) bool

Equal checks if the current value equals the target

func (EnvInt) JSONSchema

func (j EnvInt) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (EnvInt) MarshalJSON

func (j EnvInt) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (EnvInt) MarshalYAML

func (j EnvInt) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler interface

func (EnvInt) String

func (et EnvInt) String() string

String implements the Stringer interface

func (*EnvInt) UnmarshalJSON

func (j *EnvInt) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*EnvInt) UnmarshalText

func (j *EnvInt) UnmarshalText(text []byte) error

UnmarshalText decodes the integer slice from string

func (*EnvInt) UnmarshalYAML

func (j *EnvInt) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

func (*EnvInt) Value

func (et *EnvInt) Value() (*int64, error)

Value returns the value which is retrieved from system or the default value if exist

func (EnvInt) WithValue

func (j EnvInt) WithValue(value int64) *EnvInt

WithValue returns a new EnvInt instance with new value

type EnvInts

type EnvInts struct {
	EnvTemplate
	// contains filtered or unexported fields
}

EnvInts implements the integer environment encoder and decoder

func NewEnvIntsTemplate

func NewEnvIntsTemplate(template EnvTemplate) *EnvInts

NewEnvIntsTemplate creates EnvInts from template

func NewEnvIntsValue

func NewEnvIntsValue(value []int64) *EnvInts

NewEnvIntsValue creates EnvInts from value

func (EnvInts) Equal

func (et EnvInts) Equal(target EnvInts) bool

Equal checks if the current value equals the target

func (EnvInts) JSONSchema

func (j EnvInts) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (EnvInts) MarshalJSON

func (j EnvInts) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (EnvInts) MarshalYAML

func (j EnvInts) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler.

func (EnvInts) String

func (et EnvInts) String() string

String implements the Stringer interface

func (*EnvInts) UnmarshalJSON

func (j *EnvInts) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*EnvInts) UnmarshalText

func (j *EnvInts) UnmarshalText(text []byte) error

UnmarshalText decodes the integer slice from string

func (*EnvInts) UnmarshalYAML

func (j *EnvInts) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

func (*EnvInts) Value

func (et *EnvInts) Value() ([]int64, error)

Value returns the value which is retrieved from system or the default value if exist

func (EnvInts) WithValue

func (j EnvInts) WithValue(value []int64) *EnvInts

WithValue returns a new EnvInts instance with new value

type EnvString

type EnvString struct {
	EnvTemplate
	// contains filtered or unexported fields
}

EnvString implements the environment encoding and decoding value

func NewEnvStringTemplate

func NewEnvStringTemplate(template EnvTemplate) *EnvString

NewEnvStringTemplate creates an EnvString from template

func NewEnvStringValue

func NewEnvStringValue(value string) *EnvString

NewEnvStringValue creates an EnvString from value

func (EnvString) Equal

func (et EnvString) Equal(target EnvString) bool

Equal checks if the current value equals the target

func (EnvString) JSONSchema

func (j EnvString) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (EnvString) MarshalJSON

func (j EnvString) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (EnvString) MarshalYAML

func (j EnvString) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler interface

func (EnvString) String

func (et EnvString) String() string

String implements the Stringer interface

func (*EnvString) UnmarshalJSON

func (j *EnvString) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*EnvString) UnmarshalText

func (j *EnvString) UnmarshalText(text []byte) error

UnmarshalText decodes the integer slice from string

func (*EnvString) UnmarshalYAML

func (j *EnvString) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

func (*EnvString) Value

func (et *EnvString) Value() *string

Value returns the value which is retrieved from system or the default value if exist

func (EnvString) WithValue

func (j EnvString) WithValue(value string) *EnvString

WithValue returns a new EnvString instance with new value

type EnvStrings

type EnvStrings struct {
	EnvTemplate
	// contains filtered or unexported fields
}

EnvStrings implements the string slice environment encoder and decoder

func NewEnvStringsTemplate

func NewEnvStringsTemplate(template EnvTemplate) *EnvStrings

NewEnvStringsTemplate creates EnvStrings from template

func NewEnvStringsValue

func NewEnvStringsValue(value []string) *EnvStrings

NewEnvStringsValue creates EnvStrings from value

func (EnvStrings) Equal

func (et EnvStrings) Equal(target EnvStrings) bool

Equal checks if the current value equals the target

func (EnvStrings) JSONSchema

func (j EnvStrings) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (EnvStrings) MarshalJSON

func (j EnvStrings) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (EnvStrings) MarshalYAML

func (j EnvStrings) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler.

func (EnvStrings) String

func (et EnvStrings) String() string

String implements the Stringer interface

func (*EnvStrings) UnmarshalJSON

func (j *EnvStrings) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*EnvStrings) UnmarshalText

func (j *EnvStrings) UnmarshalText(text []byte) error

UnmarshalText decodes the integer slice from string

func (*EnvStrings) UnmarshalYAML

func (j *EnvStrings) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

func (*EnvStrings) Value

func (et *EnvStrings) Value() ([]string, error)

Value returns the value which is retrieved from system or the default value if exist

func (EnvStrings) WithValue

func (j EnvStrings) WithValue(value []string) *EnvStrings

WithValue returns a new EnvStrings instance with new value

type EnvTemplate

type EnvTemplate struct {
	Name         string
	DefaultValue *string
}

EnvTemplate represents an environment variable template

func FindAllEnvTemplates

func FindAllEnvTemplates(input string) []EnvTemplate

FindAllEnvTemplates finds all unique environment templates from string

func FindEnvTemplate

func FindEnvTemplate(input string) *EnvTemplate

FindEnvTemplate finds one environment template from string

func NewEnvTemplate

func NewEnvTemplate(name string) EnvTemplate

NewEnvTemplate creates an EnvTemplate without default value

func NewEnvTemplateWithDefault

func NewEnvTemplateWithDefault(name string, defaultValue string) EnvTemplate

NewEnvTemplateWithDefault creates an EnvTemplate with a default value

func (EnvTemplate) IsEmpty

func (et EnvTemplate) IsEmpty() bool

IsEmpty checks if env template is empty

func (EnvTemplate) MarshalJSON

func (j EnvTemplate) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (EnvTemplate) MarshalYAML

func (j EnvTemplate) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler interface

func (EnvTemplate) String

func (et EnvTemplate) String() string

String implements the Stringer interface

func (*EnvTemplate) UnmarshalJSON

func (j *EnvTemplate) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*EnvTemplate) UnmarshalYAML

func (j *EnvTemplate) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler interface

func (EnvTemplate) Value

func (et EnvTemplate) Value() (string, bool)

Value returns the value which is retrieved from system or the default value if exist

type HTTPAuthConfig

type HTTPAuthConfig struct {
	Header string `json:"header" mapstructure:"header" yaml:"header"`
	Scheme string `json:"scheme" mapstructure:"scheme" yaml:"scheme"`
}

HTTPAuthConfig contains configurations for http authentication If the scheme is basic or bearer, the authenticator follows OpenAPI 3 specification.

func (HTTPAuthConfig) Validate

func (ss HTTPAuthConfig) Validate() error

Validate if the current instance is valid

type NDCRestSchema

type NDCRestSchema struct {
	SchemaRef string           `json:"$schema,omitempty"  mapstructure:"$schema"  yaml:"$schema,omitempty"`
	Settings  *NDCRestSettings `json:"settings,omitempty" mapstructure:"settings" yaml:"settings,omitempty"`

	// Functions (i.e. collections which return a single column and row)
	Functions map[string]OperationInfo `json:"functions" mapstructure:"functions" yaml:"functions"`

	// A list of object types which can be used as the types of arguments, or return
	// types of procedures. Names should not overlap with scalar type names.
	ObjectTypes map[string]ObjectType `json:"object_types" mapstructure:"object_types" yaml:"object_types"`

	// Procedures which are available for execution as part of mutations
	Procedures map[string]OperationInfo `json:"procedures" mapstructure:"procedures" yaml:"procedures"`

	// A list of scalar types which will be used as the types of collection columns
	ScalarTypes schema.SchemaResponseScalarTypes `json:"scalar_types" mapstructure:"scalar_types" yaml:"scalar_types"`
}

NDCRestSchema extends the [NDC SchemaResponse] with OpenAPI REST information

func NewNDCRestSchema

func NewNDCRestSchema() *NDCRestSchema

NewNDCRestSchema creates a NDCRestSchema instance

func (NDCRestSchema) GetFunction

func (rm NDCRestSchema) GetFunction(name string) *OperationInfo

GetFunction gets the NDC function by name

func (NDCRestSchema) GetProcedure

func (rm NDCRestSchema) GetProcedure(name string) *OperationInfo

GetProcedure gets the NDC procedure by name

func (NDCRestSchema) ToSchemaResponse

func (ndc NDCRestSchema) ToSchemaResponse() *schema.SchemaResponse

ToSchemaResponse converts the instance to NDC schema.SchemaResponse

type NDCRestSettings

type NDCRestSettings struct {
	Servers []ServerConfig       `json:"servers"           mapstructure:"servers" yaml:"servers"`
	Headers map[string]EnvString `json:"headers,omitempty" mapstructure:"headers" yaml:"headers,omitempty"`
	// configure the request timeout in seconds, default 30s
	Timeout         *EnvInt                   `json:"timeout,omitempty"         mapstructure:"timeout"         yaml:"timeout,omitempty"`
	Retry           *RetryPolicySetting       `json:"retry,omitempty"           mapstructure:"retry"           yaml:"retry,omitempty"`
	SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty" mapstructure:"securitySchemes" yaml:"securitySchemes,omitempty"`
	Security        AuthSecurities            `json:"security,omitempty"        mapstructure:"security"        yaml:"security,omitempty"`
	Version         string                    `json:"version,omitempty"         mapstructure:"version"         yaml:"version,omitempty"`
}

NDCRestSettings represent global settings of the REST API, including base URL, headers, etc...

func (*NDCRestSettings) UnmarshalJSON

func (j *NDCRestSettings) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (NDCRestSettings) Validate

func (rs NDCRestSettings) Validate() error

Validate if the current instance is valid

type OAuth2Config

type OAuth2Config struct {
	Flows map[OAuthFlowType]OAuthFlow `json:"flows" mapstructure:"flows" yaml:"flows"`
}

OAuth2Config contains configurations for OAuth 2.0 API specification

func (OAuth2Config) Validate

func (ss OAuth2Config) Validate() error

Validate if the current instance is valid

type OAuthFlow

type OAuthFlow struct {
	AuthorizationURL string            `json:"authorizationUrl,omitempty" mapstructure:"authorizationUrl" yaml:"authorizationUrl,omitempty"`
	TokenURL         string            `json:"tokenUrl,omitempty"         mapstructure:"tokenUrl"         yaml:"tokenUrl,omitempty"`
	RefreshURL       string            `json:"refreshUrl,omitempty"       mapstructure:"refreshUrl"       yaml:"refreshUrl,omitempty"`
	Scopes           map[string]string `json:"scopes,omitempty"           mapstructure:"scopes"           yaml:"scopes,omitempty"`
}

OAuthFlow contains flow configurations for OAuth 2.0 API specification

func (OAuthFlow) Validate

func (ss OAuthFlow) Validate(flowType OAuthFlowType) error

Validate if the current instance is valid

type OAuthFlowType

type OAuthFlowType string

OAuthFlowType represents the OAuth flow type enum

const (
	AuthorizationCodeFlow OAuthFlowType = "authorizationCode"
	ImplicitFlow          OAuthFlowType = "implicit"
	PasswordFlow          OAuthFlowType = "password"
	ClientCredentialsFlow OAuthFlowType = "clientCredentials"
)

func ParseOAuthFlowType

func ParseOAuthFlowType(value string) (OAuthFlowType, error)

ParseOAuthFlowType parses OAuthFlowType from string

func (*OAuthFlowType) UnmarshalJSON

func (j *OAuthFlowType) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ObjectField

type ObjectField struct {
	schema.ObjectField `yaml:",inline"`

	// The field schema information of the REST request
	Rest *TypeSchema `json:"rest,omitempty" mapstructure:"rest" yaml:"rest,omitempty"`
}

ObjectField defined on this object type

func (ObjectField) Schema

func (of ObjectField) Schema() schema.ObjectField

Schema returns schema the object field

func (*ObjectField) UnmarshalJSON

func (j *ObjectField) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ObjectType

type ObjectType struct {
	// Description of this type
	Description *string `json:"description,omitempty" mapstructure:"description,omitempty" yaml:"description,omitempty"`
	// Fields defined on this object type
	Fields map[string]ObjectField `json:"fields" mapstructure:"fields" yaml:"fields"`
}

ObjectType represents the object type of rest schema

func (ObjectType) Schema

func (of ObjectType) Schema() schema.ObjectType

Schema returns schema the object field

type OpenIDConfig

type OpenIDConfig struct {
	OpenIDConnectURL string `json:"openIdConnectUrl" mapstructure:"openIdConnectUrl" yaml:"openIdConnectUrl"`
}

OpenIDConfig contains configurations for OpenID Connect API specification

func (OpenIDConfig) Validate

func (ss OpenIDConfig) Validate() error

Validate if the current instance is valid

type OperationInfo

type OperationInfo struct {
	Request *Request `json:"request" mapstructure:"request" yaml:"request"`
	// Any arguments that this collection requires
	Arguments map[string]ArgumentInfo `json:"arguments" mapstructure:"arguments" yaml:"arguments"`
	// Column description
	Description *string `json:"description,omitempty" mapstructure:"description,omitempty" yaml:"description,omitempty"`
	// The name of the result type
	ResultType schema.Type `json:"result_type" mapstructure:"result_type" yaml:"result_type"`
}

OperationInfo extends connector command operation with OpenAPI REST information

func (OperationInfo) FunctionSchema

func (j OperationInfo) FunctionSchema(name string) schema.FunctionInfo

Schema returns the connector schema of the function

func (OperationInfo) ProcedureSchema

func (j OperationInfo) ProcedureSchema(name string) schema.ProcedureInfo

Schema returns the connector schema of the function

func (*OperationInfo) UnmarshalJSON

func (j *OperationInfo) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ParameterEncodingStyle

type ParameterEncodingStyle string

ParameterEncodingStyle represents the encoding style of the parameter. style defines how multiple values are delimited. Possible styles depend on the parameter location – path, query, header or cookie.

const (
	// EncodingStyleSimple (default of query) comma-separated values. Corresponds to the {param_name} URI template.
	EncodingStyleSimple ParameterEncodingStyle = "simple"
	// EncodingStyleLabel dot-prefixed values, also known as label expansion. Corresponds to the {.param_name} URI template.
	EncodingStyleLabel ParameterEncodingStyle = "label"
	// EncodingStyleMatrix semicolon-prefixed values, also known as path-style expansion. Corresponds to the {;param_name} URI template.
	EncodingStyleMatrix ParameterEncodingStyle = "matrix"
	// EncodingStyleForm ampersand-separated values, also known as form-style query expansion. Corresponds to the {?param_name} URI template.
	EncodingStyleForm ParameterEncodingStyle = "form"
	// EncodingStyleSpaceDelimited space-separated array values. Same as collectionFormat: ssv in OpenAPI 2.0.
	// Has effect only for non-exploded arrays (explode: false), that is, the space separates the array values if the array is a single parameter, as in arr=a b c.
	EncodingStyleSpaceDelimited ParameterEncodingStyle = "spaceDelimited"
	// EncodingStylePipeDelimited pipeline-separated array values. Same as collectionFormat: pipes in OpenAPI 2.0.
	// Has effect only for non-exploded arrays (explode: false), that is, the pipe separates the array values if the array is a single parameter, as in arr=a|b|c.
	EncodingStylePipeDelimited ParameterEncodingStyle = "pipeDelimited"
	// EncodingStyleDeepObject simple non-nested objects are serialized as paramName[prop1]=value1&paramName[prop2]=value2&....
	// The behavior for nested objects and arrays is undefined.
	EncodingStyleDeepObject ParameterEncodingStyle = "deepObject"
)

func ParseParameterEncodingStyle

func ParseParameterEncodingStyle(input string) (ParameterEncodingStyle, error)

ParseParameterEncodingStyle parses ParameterEncodingStyle from string

func (ParameterEncodingStyle) IsValid

func (j ParameterEncodingStyle) IsValid() bool

IsEmpty checks if the style enum is valid

func (ParameterEncodingStyle) JSONSchema

func (j ParameterEncodingStyle) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (*ParameterEncodingStyle) UnmarshalJSON

func (j *ParameterEncodingStyle) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ParameterLocation

type ParameterLocation string

ParameterLocation is the location of the parameter. Possible values are "query", "header", "path" or "cookie".

const (
	InQuery    ParameterLocation = "query"
	InHeader   ParameterLocation = "header"
	InPath     ParameterLocation = "path"
	InCookie   ParameterLocation = "cookie"
	InBody     ParameterLocation = "body"
	InFormData ParameterLocation = "formData"
)

func ParseParameterLocation

func ParseParameterLocation(input string) (ParameterLocation, error)

ParseParameterLocation parses ParameterLocation from string

func (ParameterLocation) IsValid

func (j ParameterLocation) IsValid() bool

IsEmpty checks if the style enum is valid

func (ParameterLocation) JSONSchema

func (j ParameterLocation) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (*ParameterLocation) UnmarshalJSON

func (j *ParameterLocation) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Request

type Request struct {
	URL      string               `json:"url,omitempty"      mapstructure:"url"                                              yaml:"url,omitempty"`
	Method   string               `` /* 139-byte string literal not displayed */
	Type     RequestType          `json:"type,omitempty"     mapstructure:"type"                                             yaml:"type,omitempty"`
	Headers  map[string]EnvString `json:"headers,omitempty"  mapstructure:"headers"                                          yaml:"headers,omitempty"`
	Security AuthSecurities       `json:"security,omitempty" mapstructure:"security"                                         yaml:"security,omitempty"`
	// configure the request timeout in seconds, default 30s
	Timeout     uint           `json:"timeout,omitempty"     mapstructure:"timeout"     yaml:"timeout,omitempty"`
	Servers     []ServerConfig `json:"servers,omitempty"     mapstructure:"servers"     yaml:"servers,omitempty"`
	RequestBody *RequestBody   `json:"requestBody,omitempty" mapstructure:"requestBody" yaml:"requestBody,omitempty"`
	Response    Response       `json:"response"              mapstructure:"response"    yaml:"response"`
	Retry       *RetryPolicy   `json:"retry,omitempty"       mapstructure:"retry"       yaml:"retry,omitempty"`
}

Request represents the HTTP request information of the webhook

func (Request) Clone

func (r Request) Clone() *Request

Clone copies this instance to a new one

type RequestBody

type RequestBody struct {
	ContentType string                    `json:"contentType,omitempty" mapstructure:"contentType" yaml:"contentType,omitempty"`
	Encoding    map[string]EncodingObject `json:"encoding,omitempty"    mapstructure:"encoding"    yaml:"encoding,omitempty"`
}

RequestBody defines flexible request body with content types

type RequestParameter

type RequestParameter struct {
	EncodingObject `yaml:",inline"`
	Name           string            `json:"name,omitempty"         mapstructure:"name"                   yaml:"name,omitempty"`
	ArgumentName   string            `json:"argumentName,omitempty" mapstructure:"argumentName,omitempty" yaml:"argumentName,omitempty"`
	In             ParameterLocation `json:"in,omitempty"           mapstructure:"in"                     yaml:"in,omitempty"`
	Schema         *TypeSchema       `json:"schema,omitempty"       mapstructure:"schema"                 yaml:"schema,omitempty"`
}

RequestParameter represents an HTTP request parameter

type RequestType

type RequestType string

RequestType represents the request type enum

const (
	RequestTypeREST RequestType = "rest"
)

func ParseRequestType

func ParseRequestType(value string) (RequestType, error)

ParseRequestType parses RequestType from string

func (*RequestType) UnmarshalJSON

func (j *RequestType) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Response

type Response struct {
	ContentType string `json:"contentType" mapstructure:"contentType" yaml:"contentType"`
}

type RetryPolicy

type RetryPolicy struct {
	// Number of retry times
	Times uint `json:"times,omitempty" mapstructure:"times" yaml:"times,omitempty"`
	// Delay retry delay in milliseconds
	Delay uint `json:"delay,omitempty" mapstructure:"delay" yaml:"delay,omitempty"`
	// HTTPStatus retries if the remote service returns one of these http status
	HTTPStatus []int `json:"httpStatus,omitempty" mapstructure:"httpStatus" yaml:"httpStatus,omitempty"`
}

RetryPolicy represents the retry policy of request

type RetryPolicySetting

type RetryPolicySetting struct {
	// Number of retry times
	Times EnvInt `json:"times,omitempty" mapstructure:"times" yaml:"times,omitempty"`
	// Delay retry delay in milliseconds
	Delay EnvInt `json:"delay,omitempty" mapstructure:"delay" yaml:"delay,omitempty"`
	// HTTPStatus retries if the remote service returns one of these http status
	HTTPStatus EnvInts `json:"httpStatus,omitempty" mapstructure:"httpStatus" yaml:"httpStatus,omitempty"`
}

RetryPolicySetting represents retry policy settings

func (RetryPolicySetting) Validate

func (rs RetryPolicySetting) Validate() error

Validate if the current instance is valid

type ScalarName

type ScalarName string

ScalarName defines supported scalar name enums of the OpenAPI spec

const (
	ScalarBoolean     ScalarName = "Boolean"
	ScalarString      ScalarName = "String"
	ScalarInt32       ScalarName = "Int32"
	ScalarInt64       ScalarName = "Int64"
	ScalarFloat32     ScalarName = "Float32"
	ScalarFloat64     ScalarName = "Float64"
	ScalarBigDecimal  ScalarName = "BigDecimal"
	ScalarUUID        ScalarName = "UUID"
	ScalarDate        ScalarName = "Date"
	ScalarTimestampTZ ScalarName = "TimestampTZ"
	ScalarBytes       ScalarName = "Bytes"
	ScalarBinary      ScalarName = "Binary"
	ScalarJSON        ScalarName = "JSON"
	ScalarUnixTime    ScalarName = "UnixTime"
	ScalarEmail       ScalarName = "Email"
	ScalarURI         ScalarName = "URI"
	ScalarIPV4        ScalarName = "IPv4"
	ScalarIPV6        ScalarName = "IPv6"
)

type SchemaFileFormat

type SchemaFileFormat string

SchemaFileFormat represents the file format enum for NDC REST schema file

const (
	SchemaFileJSON SchemaFileFormat = "json"
	SchemaFileYAML SchemaFileFormat = "yaml"
)

func ParseSchemaFileFormat

func ParseSchemaFileFormat(extension string) (SchemaFileFormat, error)

ParseSchemaFileFormat parses SchemaFileFormat from file extension

func (SchemaFileFormat) IsValid

func (j SchemaFileFormat) IsValid() bool

IsEmpty checks if the style enum is valid

func (SchemaFileFormat) JSONSchema

func (j SchemaFileFormat) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (*SchemaFileFormat) UnmarshalJSON

func (j *SchemaFileFormat) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type SchemaSpecType

type SchemaSpecType string

SchemaSpecType represents the spec enum of schema

const (
	OpenAPIv3Spec SchemaSpecType = "openapi3"
	OpenAPIv2Spec SchemaSpecType = "openapi2"
	OAS3Spec      SchemaSpecType = "oas3"
	OAS2Spec      SchemaSpecType = "oas2"
	NDCSpec       SchemaSpecType = "ndc"
)

func ParseSchemaSpecType

func ParseSchemaSpecType(value string) (SchemaSpecType, error)

ParseSchemaSpecType parses SchemaSpecType from string

func (SchemaSpecType) JSONSchema

func (j SchemaSpecType) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (*SchemaSpecType) UnmarshalJSON

func (j *SchemaSpecType) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type SecurityScheme

type SecurityScheme struct {
	Type              SecuritySchemeType `json:"type"            mapstructure:"type"  yaml:"type"`
	Value             *EnvString         `json:"value,omitempty" mapstructure:"value" yaml:"value,omitempty"`
	*APIKeyAuthConfig `yaml:",inline"`
	*HTTPAuthConfig   `yaml:",inline"`
	*OAuth2Config     `yaml:",inline"`
	*OpenIDConfig     `yaml:",inline"`
}

SecurityScheme contains authentication configurations. The schema follows OpenAPI 3 specification

func (SecurityScheme) JSONSchema

func (j SecurityScheme) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (*SecurityScheme) UnmarshalJSON

func (j *SecurityScheme) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (SecurityScheme) Validate

func (ss SecurityScheme) Validate() error

Validate if the current instance is valid

type SecuritySchemeType

type SecuritySchemeType string

SecuritySchemeType represents the authentication scheme enum

const (
	APIKeyScheme        SecuritySchemeType = "apiKey"
	HTTPAuthScheme      SecuritySchemeType = "http"
	OAuth2Scheme        SecuritySchemeType = "oauth2"
	OpenIDConnectScheme SecuritySchemeType = "openIdConnect"
	MutualTLSScheme     SecuritySchemeType = "mutualTLS"
)

func ParseSecuritySchemeType

func ParseSecuritySchemeType(value string) (SecuritySchemeType, error)

ParseSecuritySchemeType parses SecurityScheme from string

func (SecuritySchemeType) JSONSchema

func (j SecuritySchemeType) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema

func (*SecuritySchemeType) UnmarshalJSON

func (j *SecuritySchemeType) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ServerConfig

type ServerConfig struct {
	URL     EnvString            `json:"url"               mapstructure:"url"     yaml:"url"`
	ID      string               `json:"id,omitempty"      mapstructure:"id"      yaml:"id,omitempty"`
	Headers map[string]EnvString `json:"headers,omitempty" mapstructure:"headers" yaml:"headers,omitempty"`
	// configure the request timeout in seconds, default 30s
	Timeout         *EnvInt                   `json:"timeout,omitempty"         mapstructure:"timeout"         yaml:"timeout,omitempty"`
	Retry           *RetryPolicySetting       `json:"retry,omitempty"           mapstructure:"retry"           yaml:"retry,omitempty"`
	SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty" mapstructure:"securitySchemes" yaml:"securitySchemes,omitempty"`
	Security        AuthSecurities            `json:"security,omitempty"        mapstructure:"security"        yaml:"security,omitempty"`
	TLS             *TLSConfig                `json:"tls,omitempty"             mapstructure:"tls"             yaml:"tls,omitempty"`
}

ServerConfig contains server configurations

func (ServerConfig) Validate

func (ss ServerConfig) Validate() error

Validate if the current instance is valid

type TLSConfig

type TLSConfig struct {
	// Path to the TLS cert to use for TLS required connections.
	CertFile *EnvString `json:"certFile,omitempty" mapstructure:"certFile" yaml:"certFile,omitempty"`
	// Alternative to cert_file. Provide the certificate contents as a string instead of a filepath.
	CertPem *EnvString `json:"certPem,omitempty" mapstructure:"certPem" yaml:"certPem,omitempty"`
	// Path to the TLS key to use for TLS required connections.
	KeyFile *EnvString `json:"keyFile,omitempty" mapstructure:"keyFile" yaml:"keyFile,omitempty"`
	// Alternative to key_file. Provide the key contents as a string instead of a filepath.
	KeyPem *EnvString `json:"keyPem,omitempty" mapstructure:"keyPem" yaml:"keyPem,omitempty"`
	// Path to the CA cert. For a client this verifies the server certificate. For a server this verifies client certificates.
	// If empty uses system root CA.
	CAFile *EnvString `json:"caFile,omitempty" mapstructure:"caFile" yaml:"caFile,omitempty"`
	// Alternative to ca_file. Provide the CA cert contents as a string instead of a filepath.
	CAPem *EnvString `json:"caPem,omitempty" mapstructure:"caPem" yaml:"caPem,omitempty"`
	// Additionally you can configure TLS to be enabled but skip verifying the server's certificate chain.
	InsecureSkipVerify *EnvBoolean `json:"insecureSkipVerify,omitempty" mapstructure:"insecureSkipVerify" yaml:"insecureSkipVerify,omitempty"`
	// Whether to load the system certificate authorities pool alongside the certificate authority.
	IncludeSystemCACertsPool *EnvBoolean `json:"includeSystemCACertsPool,omitempty" mapstructure:"includeSystemCACertsPool" yaml:"includeSystemCACertsPool,omitempty"`
	// Minimum acceptable TLS version.
	MinVersion *EnvString `json:"minVersion,omitempty" mapstructure:"minVersion" yaml:"minVersion,omitempty"`
	// Maximum acceptable TLS version.
	MaxVersion *EnvString `json:"maxVersion,omitempty" mapstructure:"maxVersion" yaml:"maxVersion,omitempty"`
	// Explicit cipher suites can be set. If left blank, a safe default list is used.
	// See https://go.dev/src/crypto/tls/cipher_suites.go for a list of supported cipher suites.
	CipherSuites *EnvStrings `json:"cipherSuites,omitempty" mapstructure:"cipherSuites" yaml:"cipherSuites,omitempty"`
	// Specifies the duration after which the certificate will be reloaded. If not set, it will never be reloaded.
	// The interval unit is minute
	ReloadInterval *EnvInt `json:"reloadInterval,omitempty" mapstructure:"reloadInterval" yaml:"reloadInterval,omitempty"`
}

TLSConfig represents the transport layer security (LTS) configuration for the mutualTLS authentication

func (TLSConfig) Validate

func (ss TLSConfig) Validate() error

Validate if the current instance is valid

type TypeSchema

type TypeSchema struct {
	Type        []string    `json:"type"                mapstructure:"type"      yaml:"type"`
	Format      string      `json:"format,omitempty"    mapstructure:"format"    yaml:"format,omitempty"`
	Pattern     string      `json:"pattern,omitempty"   mapstructure:"pattern"   yaml:"pattern,omitempty"`
	Maximum     *float64    `json:"maximum,omitempty"   mapstructure:"maximum"   yaml:"maximum,omitempty"`
	Minimum     *float64    `json:"minimum,omitempty,"  mapstructure:"minimum"   yaml:"minimum,omitempty"`
	MaxLength   *int64      `json:"maxLength,omitempty" mapstructure:"maxLength" yaml:"maxLength,omitempty"`
	MinLength   *int64      `json:"minLength,omitempty" mapstructure:"minLength" yaml:"minLength,omitempty"`
	Items       *TypeSchema `json:"items,omitempty"     mapstructure:"items"     yaml:"items,omitempty"`
	Description string      `json:"-"                   yaml:"-"`
	ReadOnly    bool        `json:"-"                   yaml:"-"`
	WriteOnly   bool        `json:"-"                   yaml:"-"`
}

TypeSchema represents a serializable object of OpenAPI schema that is used for validation

Jump to

Keyboard shortcuts

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