schema

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package schema defines config schemas for the relyx service.

Index

Constants

View Source
const (
	HTTPAuthSchemeBearer = "bearer"
	AuthorizationHeader  = "Authorization"
)

Variables

View Source
var (
	// ErrInvalidParameterLocation occurs when the parameter location is invalid.
	ErrInvalidParameterLocation = fmt.Errorf(
		"invalid ParameterLocation. Expected one of %v",
		SupportedParameterLocations(),
	)
	// ErrInvalidSecuritySchemeType occurs when the security scheme type is invalid.
	ErrInvalidSecuritySchemeType = fmt.Errorf(
		"invalid SecuritySchemeType. Expected one of %v",
		SupportedSecuritySchemeTypes(),
	)
	// ErrFieldRequired occurs when a field is required.
	ErrFieldRequired = errors.New("field is required")
	// ErrInvalidOAuthFlowType occurs when the OAuth flow type is invalid.
	ErrInvalidOAuthFlowType = fmt.Errorf(
		"invalid OAuthFlowType. Expected %v",
		enumValuesOAuthFlows,
	)
	// ErrOAuth2FlowRequired occurs when the OAuth flow is null or empty.
	ErrOAuth2FlowRequired = errors.New("require at least 1 flow for oauth2 security")
)

Functions

func RelyProxyDocumentToOAS3

func RelyProxyDocumentToOAS3(doc RelyProxyAPIDocument) *highv3.Document

RelyProxyDocumentToOAS3 converts a proxy document to OAS 3.

Types

type APIKeyAuthConfig

type APIKeyAuthConfig struct {
	Type  SecuritySchemeType      `json:"type" yaml:"type"`
	In    authscheme.AuthLocation `json:"in" yaml:"in"`
	Name  string                  `json:"name" yaml:"name"`
	Value goenvconf.EnvString     `json:"value" yaml:"value"`
}

APIKeyAuthConfig contains configurations for apiKey authentication

func NewAPIKeyAuthConfig

func NewAPIKeyAuthConfig(
	name string,
	in authscheme.AuthLocation,
	value goenvconf.EnvString,
) *APIKeyAuthConfig

NewAPIKeyAuthConfig creates a new APIKeyAuthConfig instance.

func (*APIKeyAuthConfig) GetType

GetType get the type of security scheme.

func (*APIKeyAuthConfig) Validate

func (j *APIKeyAuthConfig) Validate() error

Validate if the current instance is valid.

type BasicAuthConfig

type BasicAuthConfig struct {
	Type     SecuritySchemeType  `json:"type" yaml:"type"`
	Header   string              `json:"header" yaml:"header"`
	Username goenvconf.EnvString `json:"username" yaml:"username"`
	Password goenvconf.EnvString `json:"password" yaml:"password"`
}

BasicAuthConfig contains configurations for the basic authentication.

func NewBasicAuthConfig

func NewBasicAuthConfig(username, password goenvconf.EnvString) *BasicAuthConfig

NewBasicAuthConfig creates a new BasicAuthConfig instance.

func (*BasicAuthConfig) GetType

GetType get the type of security scheme.

func (*BasicAuthConfig) Validate

func (*BasicAuthConfig) Validate() error

Validate if the current instance is valid.

type CookieAuthConfig

type CookieAuthConfig struct {
	Type SecuritySchemeType `json:"type" yaml:"type"`
}

CookieAuthConfig represents a cookie authentication configuration.

func NewCookieAuthConfig

func NewCookieAuthConfig() *CookieAuthConfig

NewCookieAuthConfig creates a new CookieAuthConfig instance.

func (CookieAuthConfig) GetType

GetType get the type of security scheme.

func (CookieAuthConfig) Validate

func (CookieAuthConfig) Validate() error

Validate if the current instance is valid.

type Discriminator

type Discriminator struct {
	PropertyName   string                                 `json:"propertyName,omitempty" yaml:"propertyName,omitempty"`
	Mapping        *orderedmap.OrderedMap[string, string] `json:"mapping,omitempty" yaml:"mapping,omitempty"`
	DefaultMapping string                                 `json:"defaultMapping,omitempty" yaml:"defaultMapping,omitempty"` // OpenAPI 3.2+ defaultMapping for fallback schema
}

Discriminator is only used by OpenAPI 3+ documents, it represents a polymorphic discriminator used for schemas When request bodies or response payloads may be one of a number of different schemas, a discriminator object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the document of an alternative schema based on the value associated with it. When using the discriminator, inline schemas will not be considered.

func (Discriminator) JSONSchemaExtend

func (Discriminator) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend modifies the JSON schema afterwards.

type GraphQLVariableDefinition

type GraphQLVariableDefinition struct {
	Expression string            `json:"expression,omitempty" yaml:"expression,omitempty"`
	Default    *goenvconf.EnvAny `json:"default,omitempty" yaml:"default,omitempty"`
}

GraphQLVariableDefinition defines information of the GraphQL variable.

type HTTPAuthConfig

type HTTPAuthConfig struct {
	Type   SecuritySchemeType  `json:"type" yaml:"type"`
	Header string              `json:"header" yaml:"header"`
	Scheme string              `json:"scheme" yaml:"scheme"`
	Value  goenvconf.EnvString `json:"value" yaml:"value"`
}

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

func NewHTTPAuthConfig

func NewHTTPAuthConfig(scheme string, header string, value goenvconf.EnvString) *HTTPAuthConfig

NewHTTPAuthConfig creates a new HTTPAuthConfig instance.

func (*HTTPAuthConfig) GetType

GetType get the type of security scheme.

func (*HTTPAuthConfig) Validate

func (ss *HTTPAuthConfig) Validate() error

Validate if the current instance is valid.

type MutualTLSAuthConfig

type MutualTLSAuthConfig struct {
	Type SecuritySchemeType `json:"type" yaml:"type"`
}

MutualTLSAuthConfig represents a mutualTLS authentication configuration.

func NewMutualTLSAuthConfig

func NewMutualTLSAuthConfig() *MutualTLSAuthConfig

NewMutualTLSAuthConfig creates a new MutualTLSAuthConfig instance.

func (MutualTLSAuthConfig) GetType

GetType get the type of security scheme.

func (MutualTLSAuthConfig) Validate

func (MutualTLSAuthConfig) Validate() error

Validate if the current instance is valid.

type NewRelyProxyHandlerFunc

type NewRelyProxyHandlerFunc func(operation *RelyProxyOperation, options *NewRelyProxyHandlerOptions) (RelyProxyHandler, error)

NewRelyProxyHandlerFunc abstracts a function to create a new proxy handler.

type NewRelyProxyHandlerOptions

type NewRelyProxyHandlerOptions struct {
	Method     string
	Parameters []Parameter
	GetEnv     goenvconf.GetEnvFunc
}

NewRelyProxyHandlerOptions hold request options for the proxy handler.

func (NewRelyProxyHandlerOptions) GetEnvFunc

GetEnvFunc returns a function to get environment variables.

type OAuth2Config

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

OAuth2Config contains configurations for OAuth 2.0 API specification

func NewOAuth2Config

func NewOAuth2Config(flows map[OAuthFlowType]OAuthFlow) *OAuth2Config

NewOAuth2Config creates a new OAuth2Config instance.

func (OAuth2Config) GetType

func (ss OAuth2Config) GetType() SecuritySchemeType

GetType get the type of security scheme.

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         *goenvconf.EnvString           `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"`
	ClientID         *goenvconf.EnvString           `json:"clientId,omitempty"         mapstructure:"clientId"         yaml:"clientId,omitempty"`
	ClientSecret     *goenvconf.EnvString           `json:"clientSecret,omitempty"     mapstructure:"clientSecret"     yaml:"clientSecret,omitempty"`
	EndpointParams   map[string]goenvconf.EnvString `json:"endpointParams,omitempty"   mapstructure:"endpointParams"   yaml:"endpointParams,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.

type OpenIDConnectConfig

type OpenIDConnectConfig struct {
	Type             SecuritySchemeType `json:"type"             mapstructure:"type"             yaml:"type"`
	OpenIDConnectURL string             `json:"openIdConnectUrl" mapstructure:"openIdConnectUrl" yaml:"openIdConnectUrl"`
}

OpenIDConnectConfig contains configurations for OpenID Connect API specification

func NewOpenIDConnectConfig

func NewOpenIDConnectConfig(oidcURL string) *OpenIDConnectConfig

NewOpenIDConnectConfig creates a new OpenIDConnectConfig instance.

func (OpenIDConnectConfig) GetType

GetType get the type of security scheme.

func (OpenIDConnectConfig) Validate

func (ss OpenIDConnectConfig) Validate() error

Validate if the current instance is valid.

type Parameter

type Parameter struct {
	Name            string                                              `json:"name,omitempty" yaml:"name,omitempty"`
	In              ParameterLocation                                   `json:"in,omitempty" yaml:"in,omitempty"`
	Description     string                                              `json:"description,omitempty" yaml:"description,omitempty"`
	Required        *bool                                               `json:"required,omitempty" yaml:"required,omitempty"`
	Deprecated      bool                                                `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
	AllowEmptyValue bool                                                `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`
	Style           string                                              `json:"style,omitempty" yaml:"style,omitempty"`
	Explode         *bool                                               `json:"explode,omitempty" yaml:"explode,omitempty"`
	AllowReserved   bool                                                `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
	Schema          *RelyProxySchema                                    `json:"schema,omitempty" yaml:"schema,omitempty"`
	Content         *orderedmap.OrderedMap[string, *RelyProxyMediaType] `json:"content,omitempty" yaml:"content,omitempty"`
}

Parameter represents a high-level OpenAPI 3+ Parameter object, that is backed by a low-level one. A unique parameter is defined by a combination of a name and location. https://spec.openapis.org/oas/v3.1.0#parameter-object

func ExtractCommonParametersOfOperation

func ExtractCommonParametersOfOperation(
	pathParams []Parameter,
	operation *RelyProxyOperation,
) []Parameter

ExtractCommonParametersOfOperation extracts common parameters from operation's parameters.

func MergeParameters

func MergeParameters(dest []Parameter, src []Parameter) []Parameter

MergeParameters merge parameter slices by unique name and location.

func (Parameter) JSONSchemaExtend

func (Parameter) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend modifies the JSON schema afterwards.

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 SupportedParameterLocations

func SupportedParameterLocations() []ParameterLocation

SupportedParameterLocations returns supported parameter locations.

func (ParameterLocation) IsValid

func (j ParameterLocation) IsValid() bool

IsValid checks if the style enum is valid.

func (ParameterLocation) JSONSchema

func (ParameterLocation) JSONSchema() *jsonschema.Schema

JSONSchema defines a custom definition for JSON schema.

type PrimitiveType

type PrimitiveType string

PrimitiveType represents primitive data types.

const (
	// String represents text data types.
	String PrimitiveType = "string"
	// Number represents floating-point number data types.
	Number PrimitiveType = "number"
	// Integer represents integer number data types.
	Integer PrimitiveType = "integer"
	// Boolean represents boolean number data types.
	Boolean PrimitiveType = "boolean"
	// Array represents array data types.
	Array PrimitiveType = "array"
	// Object represents object data types.
	Object PrimitiveType = "object"
)

type RelyProxyAPIDocument

type RelyProxyAPIDocument struct {
	SchemaRef string `json:"$schema,omitempty" yaml:"$schema,omitempty"`
	// Global settings of the proxy.
	Settings RelyProxySettings `json:"settings" yaml:"settings"`
	// Info represents a specification Info definitions
	// Provides metadata about the API. The metadata MAY be used by tooling as required.
	// - https://spec.openapis.org/oas/v3.1.0#info-object
	Info *RelyProxyAPIDocumentInfo `json:"info,omitempty" yaml:"info,omitempty"`
	// Servers is a slice of Server instances which provide connectivity information to a target server.
	Servers []RelyProxyServer `json:"servers" yaml:"servers"`
	// Security contains global security requirements/roles for the specification
	// A declaration of which security mechanisms can be used across the API. The list of values includes alternative
	// security requirement objects that can be used. Only one of the security requirement objects need to be satisfied
	// to authorize a request. Individual operations can override this definition. To make security optional,
	// an empty security requirement ({}) can be included in the array.
	Security []SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`

	// Tags is a slice of Tag instances defined by the specification
	// A list of tags used by the document with additional metadata. The order of the tags can be used to reflect on
	// their order by the parsing tools. Not all tags that are used by the Operation Object must be declared.
	// The tags that are not declared MAY be organized randomly or based on the tools’ logic.
	// Each tag name in the list MUST be unique.
	Tags []RelyProxyTag `json:"tags,omitempty" yaml:"tags,omitempty"`

	// Paths contains all the PathItem definitions for the specification.
	// The available paths and operations for the API, The most important part of ths spec.
	Paths orderedmap.OrderedMap[string, *RelyProxyPathItem] `json:"paths" yaml:"paths"`
}

RelyProxyAPIDocument represents the structure of an API document.

func (RelyProxyAPIDocument) JSONSchemaExtend

func (RelyProxyAPIDocument) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend modifies the JSON schema afterwards.

type RelyProxyAPIDocumentInfo

type RelyProxyAPIDocumentInfo struct {
	Summary        string                           `json:"summary,omitempty" yaml:"summary,omitempty"`
	Title          string                           `json:"title,omitempty" yaml:"title,omitempty"`
	Description    string                           `json:"description,omitempty" yaml:"description,omitempty"`
	TermsOfService string                           `json:"termsOfService,omitempty" yaml:"termsOfService,omitempty"`
	Contact        *RelyProxyAPIDocumentInfoContact `json:"contact,omitempty" yaml:"contact,omitempty"`
	License        *RelyProxyAPIDocumentInfoLicense `json:"license,omitempty" yaml:"license,omitempty"`
	Version        string                           `json:"version,omitempty" yaml:"version,omitempty"`
}

RelyProxyAPIDocumentInfo represents a high-level Info object that provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience.

type RelyProxyAPIDocumentInfoContact

type RelyProxyAPIDocumentInfoContact struct {
	Name  string `json:"name,omitempty" yaml:"name,omitempty"`
	URL   string `json:"url,omitempty" yaml:"url,omitempty"`
	Email string `json:"email,omitempty" yaml:"email,omitempty"`
}

RelyProxyAPIDocumentInfoContact represents a high-level representation of the Contact definitions.

type RelyProxyAPIDocumentInfoLicense

type RelyProxyAPIDocumentInfoLicense struct {
	Name       string `json:"name,omitempty" yaml:"name,omitempty"`
	URL        string `json:"url,omitempty" yaml:"url,omitempty"`
	Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"`
}

RelyProxyAPIDocumentInfoLicense represents a high-level representation of the License definitions.

type RelyProxyAction

type RelyProxyAction struct {
	// Type of the proxy action.
	Type RelyProxyType `json:"type" yaml:"type"`
	// Overrides the request path. Use the original request path if empty.
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
	// Configurations for the proxy request.
	Request RelyProxyGraphQLRequestConfig `json:"request" yaml:"request"`
	// Configurations for evaluating graphql responses.
	Response RelyProxyGraphQLResponseConfig `json:"response" yaml:"response"`
}

RelyProxyAction represents a proxy action.

func (RelyProxyAction) JSONSchema

func (RelyProxyAction) JSONSchema() *jsonschema.Schema

JSONSchema defines a custom definition for JSON schema.

type RelyProxyComponents

type RelyProxyComponents struct {
}

RelyProxyComponents is an element to hold various schemas for the document.

type RelyProxyEncoding

type RelyProxyEncoding struct {
	ContentType   string                                           `json:"contentType,omitempty" yaml:"contentType,omitempty"`
	Headers       *orderedmap.OrderedMap[string, *RelyProxyHeader] `json:"headers,omitempty" yaml:"headers,omitempty"`
	Style         string                                           `json:"style,omitempty" yaml:"style,omitempty"`
	Explode       *bool                                            `json:"explode,omitempty" yaml:"explode,omitempty"`
	AllowReserved bool                                             `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
}

RelyProxyEncoding represents an OpenAPI 3+ Encoding object

func (RelyProxyEncoding) JSONSchemaExtend

func (RelyProxyEncoding) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend modifies the JSON schema afterwards.

type RelyProxyForwardHeadersConfig

type RelyProxyForwardHeadersConfig struct {
	// Defines header names to be forwarded from the client request.
	Request []string `json:"request,omitempty" yaml:"request,omitempty"`
	// Defines header names to be forwarded from the response.
	Response []string `json:"response,omitempty" yaml:"response,omitempty"`
}

RelyProxyForwardHeadersConfig contains configurations for headers forwarding,.

type RelyProxyGraphQLConfig

type RelyProxyGraphQLConfig struct {
	// ScalarTypeMapping configures the custom type mapping between GraphQL scalar types and primitive types for data conversion.
	// Default scalar types are supported. Other types which aren't configured will be forwarded directly
	// from the request parameters and body without serialization.
	ScalarTypeMapping map[string]PrimitiveType `json:"scalarTypeMapping,omitempty" yaml:"scalarTypeMapping,omitempty"`
}

RelyProxyGraphQLConfig contains configurations for GraphQL proxy.

type RelyProxyGraphQLRequestConfig

type RelyProxyGraphQLRequestConfig struct {
	// GraphQL query
	Query string `json:"query,omitempty" yaml:"query,omitempty"`
	// Definition of GraphQL variables.
	Variables *orderedmap.OrderedMap[string, *GraphQLVariableDefinition] `json:"variables,omitempty" yaml:"variables,omitempty"`
	// Definition of GraphQL extensions.
	Extensions *orderedmap.OrderedMap[string, *GraphQLVariableDefinition] `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

RelyProxyGraphQLRequestConfig represents configurations for the proxy request.

func (RelyProxyGraphQLRequestConfig) JSONSchema

JSONSchema defines a custom definition for JSON schema.

type RelyProxyGraphQLResponseConfig

type RelyProxyGraphQLResponseConfig struct {
	// HTTP error code will be used if the response body has errors.
	// If not set, forward the HTTP status from the GraphQL response which is usually 200 OK.
	HTTPErrorCode *int                                   `json:"httpErrorCode,omitempty" yaml:"httpErrorCode,omitempty" jsonschema:"min=400,max=599,default=400"`
	Transform     *gotransform.TemplateTransformerConfig `` //nolint:lll
	/* 198-byte string literal not displayed */
}

RelyProxyGraphQLResponseConfig represents configurations for the proxy response.

func (RelyProxyGraphQLResponseConfig) IsZero

func (conf RelyProxyGraphQLResponseConfig) IsZero() bool

IsZero checks if the configuration is empty.

type RelyProxyHandleOptions

type RelyProxyHandleOptions struct {
	HTTPClient     *loadbalancer.LoadBalancerClient
	Settings       *RelyProxySettings
	Path           string
	ParamValues    map[string]string
	DefaultHeaders map[string]string
}

RelyProxyHandleOptions hold request options for the proxy handler.

type RelyProxyHandler

type RelyProxyHandler interface {
	// Type returns type of the current handler.
	Type() RelyProxyType
	// Handle resolves the HTTP request and proxies that request to the remote server.
	Handle(
		ctx context.Context,
		request *http.Request,
		options *RelyProxyHandleOptions,
	) (*http.Response, any, error)
}

RelyProxyHandler abstracts the executor to proxy HTTP requests.

type RelyProxyHeader

type RelyProxyHeader struct {
	Description     string                                              `json:"description,omitempty" yaml:"description,omitempty"`
	Required        bool                                                `json:"required,omitempty" yaml:"required,omitempty"`
	Deprecated      bool                                                `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
	AllowEmptyValue bool                                                `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`
	Style           string                                              `json:"style,omitempty" yaml:"style,omitempty"`
	Explode         bool                                                `json:"explode,omitempty" yaml:"explode,omitempty"`
	AllowReserved   bool                                                `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
	Schema          *RelyProxySchema                                    `json:"schema,omitempty" yaml:"schema,omitempty"`
	Content         *orderedmap.OrderedMap[string, *RelyProxyMediaType] `json:"content,omitempty" yaml:"content,omitempty"`
}

RelyProxyHeader represents a high-level OpenAPI 3+ Header object that is backed by a low-level one.

func (RelyProxyHeader) JSONSchemaExtend

func (RelyProxyHeader) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend modifies the JSON schema afterwards.

type RelyProxyHealthCheckConfig

type RelyProxyHealthCheckConfig struct {
	// Configurations for health check through HTTP protocol.
	HTTP *loadbalancer.HTTPHealthCheckConfig `json:"http,omitempty" yaml:"http,omitempty"`
}

RelyProxyHealthCheckConfig holds health check configurations for server recovery.

type RelyProxyMediaType

type RelyProxyMediaType struct {
	Schema     *RelyProxySchema `json:"schema,omitempty" yaml:"schema,omitempty"`
	ItemSchema *RelyProxySchema `json:"itemSchema,omitempty" yaml:"itemSchema,omitempty"`
	// Example      *yaml.Node                             `json:"example,omitempty" yaml:"example,omitempty"`
	// Examples     *orderedmap.Map[string, *base.Example] `json:"examples,omitempty" yaml:"examples,omitempty"`
	Encoding     *orderedmap.OrderedMap[string, *RelyProxyEncoding] `json:"encoding,omitempty" yaml:"encoding,omitempty"`
	ItemEncoding *orderedmap.OrderedMap[string, *RelyProxyEncoding] `json:"itemEncoding,omitempty" yaml:"itemEncoding,omitempty"`
}

RelyProxyMediaType represents a high-level OpenAPI MediaType object that is backed by a low-level one.

Each Media Type Object provides schema and examples for the media type identified by its key.

func (RelyProxyMediaType) JSONSchemaExtend

func (RelyProxyMediaType) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend modifies the JSON schema afterwards.

type RelyProxyOperation

type RelyProxyOperation struct {
	// List of tags for this operation.
	Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
	// Summary information of the operation.
	Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
	// Description of the operation.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// ID of the operation. It should be unique.
	OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"`
	// Request parameters of the operation.
	Parameters []Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	// Request body information.
	RequestBody *RelyProxyRequestBody `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`
	// Responses   *highv3.Responses    `json:"responses,omitempty" yaml:"responses,omitempty"`
	// Defines whether this operation is deprecated.
	Deprecated *bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
	// Requires the security for this operation.
	Security SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`
	// Defines action information to proxy request to the remote server.
	Proxy RelyProxyAction `json:"proxy" yaml:"proxy"`
}

RelyProxyOperation represents the definition of an API operation.

type RelyProxyPathItem

type RelyProxyPathItem struct {
	// Description of the path item.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Summary of the path item.
	Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
	// Defines the operation information of the GET method.
	Get *RelyProxyOperation `json:"get,omitempty" yaml:"get,omitempty"`
	// Defines the operation information of the PUT method.
	Put *RelyProxyOperation `json:"put,omitempty" yaml:"put,omitempty"`
	// Defines the operation information of the POST method.
	Post *RelyProxyOperation `json:"post,omitempty" yaml:"post,omitempty"`
	// Defines the operation information of the DELETE method.
	Delete *RelyProxyOperation `json:"delete,omitempty" yaml:"delete,omitempty"`
	// Defines the operation information of the PATCH method.
	Patch *RelyProxyOperation `json:"patch,omitempty" yaml:"patch,omitempty"`
	// Common parameters of the path item.
	Parameters []Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
}

RelyProxyPathItem represents a definition object of an API path item.

type RelyProxyRequestBody

type RelyProxyRequestBody struct {
	Description string                                              `json:"description,omitempty" yaml:"description,omitempty"`
	Content     *orderedmap.OrderedMap[string, *RelyProxyMediaType] `json:"content,omitempty" yaml:"content,omitempty"`
	Required    *bool                                               `json:"required,omitempty" yaml:"required,omitempty"`
}

RelyProxyRequestBody represents a high-level OpenAPI 3+ RequestBody object, backed by a low-level one.

func (RelyProxyRequestBody) JSONSchemaExtend

func (RelyProxyRequestBody) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend modifies the JSON schema afterwards.

type RelyProxySchema

type RelyProxySchema struct {
	// 3.1 only, used to define a dialect for this schema, label is '$schema'.
	SchemaTypeRef string `json:"$schema,omitempty" yaml:"$schema,omitempty"`

	// Used to define a reference for this schema.
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`

	// In versions 2 and 3.0, this ExclusiveMaximum can only be a boolean.
	// In version 3.1, ExclusiveMaximum is a number.
	ExclusiveMaximum *float64 `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`

	// In versions 2 and 3.0, this ExclusiveMinimum can only be a boolean.
	// In version 3.1, ExclusiveMinimum is a number.
	ExclusiveMinimum *float64 `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`

	// In versions 2 and 3.0, this Type is a single value, so array will only ever have one value
	// in version 3.1, Type can be multiple values
	Type []string `json:"type,omitempty" yaml:"type,omitempty"`

	// Schemas are resolved on demand using a SchemaProxy
	AllOf []RelyProxySchema `json:"allOf,omitempty" yaml:"allOf,omitempty"`

	// Polymorphic Schemas are only available in version 3+
	OneOf         []RelyProxySchema `json:"oneOf,omitempty" yaml:"oneOf,omitempty"`
	AnyOf         []RelyProxySchema `json:"anyOf,omitempty" yaml:"anyOf,omitempty"`
	Discriminator *Discriminator    `json:"discriminator,omitempty" yaml:"discriminator,omitempty"`

	// in 3.1 prefixItems provides tuple validation support.
	PrefixItems []RelyProxySchema `json:"prefixItems,omitempty" yaml:"prefixItems,omitempty"`

	// 3.1 Specific properties
	Contains          *RelyProxySchema                                 `json:"contains,omitempty" yaml:"contains,omitempty"`
	MinContains       *int64                                           `json:"minContains,omitempty" yaml:"minContains,omitempty"`
	MaxContains       *int64                                           `json:"maxContains,omitempty" yaml:"maxContains,omitempty"`
	If                *RelyProxySchema                                 `json:"if,omitempty" yaml:"if,omitempty"`
	Else              *RelyProxySchema                                 `json:"else,omitempty" yaml:"else,omitempty"`
	Then              *RelyProxySchema                                 `json:"then,omitempty" yaml:"then,omitempty"`
	DependentSchemas  *orderedmap.OrderedMap[string, *RelyProxySchema] `json:"dependentSchemas,omitempty" yaml:"dependentSchemas,omitempty"`
	DependentRequired *orderedmap.OrderedMap[string, []string]         `json:"dependentRequired,omitempty" yaml:"dependentRequired,omitempty"`
	PatternProperties *orderedmap.OrderedMap[string, *RelyProxySchema] `json:"patternProperties,omitempty" yaml:"patternProperties,omitempty"`
	PropertyNames     *RelyProxySchema                                 `json:"propertyNames,omitempty" yaml:"propertyNames,omitempty"`
	UnevaluatedItems  *RelyProxySchema                                 `json:"unevaluatedItems,omitempty" yaml:"unevaluatedItems,omitempty"`

	// in 3.1 Items can be a Schema or a boolean
	Items *RelyProxySchema `json:"items,omitempty" yaml:"items,omitempty"`

	// 3.1 only, part of the JSON Schema spec provides a way to identify a sub-schema
	Anchor string `json:"$anchor,omitempty" yaml:"$anchor,omitempty"`

	// Compatible with all versions
	Not                  *RelyProxySchema                                 `json:"not,omitempty" yaml:"not,omitempty"`
	Properties           *orderedmap.OrderedMap[string, *RelyProxySchema] `json:"properties,omitempty" yaml:"properties,omitempty"`
	Title                string                                           `json:"title,omitempty" yaml:"title,omitempty"`
	MultipleOf           *float64                                         `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`
	Maximum              *float64                                         `json:"maximum,omitempty" yaml:"maximum,omitempty"`
	Minimum              *float64                                         `json:"minimum,omitempty" yaml:"minimum,omitempty"`
	MaxLength            *int64                                           `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
	MinLength            *int64                                           `json:"minLength,omitempty" yaml:"minLength,omitempty"`
	Pattern              string                                           `json:"pattern,omitempty" yaml:"pattern,omitempty"`
	Format               string                                           `json:"format,omitempty" yaml:"format,omitempty"`
	MaxItems             *int64                                           `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
	MinItems             *int64                                           `json:"minItems,omitempty" yaml:"minItems,omitempty"`
	UniqueItems          *bool                                            `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
	MaxProperties        *int64                                           `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"`
	MinProperties        *int64                                           `json:"minProperties,omitempty" yaml:"minProperties,omitempty"`
	Required             []string                                         `json:"required,omitempty" yaml:"required,omitempty"`
	Enum                 []any                                            `json:"enum,omitempty" yaml:"enum,omitempty"`
	AdditionalProperties *RelyProxySchema                                 `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty"`
	Description          string                                           `json:"description,omitempty" yaml:"description,omitempty"`
	Default              any                                              `json:"default,omitempty" yaml:"default,omitempty"`
	Const                any                                              `json:"const,omitempty" yaml:"const,omitempty"`
	Nullable             *bool                                            `json:"nullable,omitempty" yaml:"nullable,omitempty"`
	ReadOnly             *bool                                            `json:"readOnly,omitempty" yaml:"readOnly,omitempty"`
	WriteOnly            *bool                                            `json:"writeOnly,omitempty" yaml:"writeOnly,omitempty"`
	// XML                  *XML                                `json:"xml,omitempty" yaml:"xml,omitempty"`
	// ExternalDocs         *ExternalDoc                        `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
	// Example              *yaml.Node                          `json:"example,omitempty" yaml:"example,omitempty"`
	Deprecated *bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
}

RelyProxySchema represents a JSON Schema that support Swagger, OpenAPI 3 and OpenAPI 3.1

Until 3.1 OpenAPI had a strange relationship with JSON Schema. It's been a super-set/sub-set mix, which has been confusing. So, instead of building a bunch of different models, we have compressed all variations into a single model that makes it easy to support multiple spec types.

func (RelyProxySchema) JSONSchemaExtend

func (RelyProxySchema) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend modifies the JSON schema afterwards.

type RelyProxySecurityScheme

type RelyProxySecurityScheme struct {
	SecuritySchemer
}

RelyProxySecurityScheme contains authentication configurations. The schema follows OpenAPI 3 specification

func (RelyProxySecurityScheme) JSONSchema

JSONSchema defines a custom definition for JSON schema.

func (RelyProxySecurityScheme) MarshalJSON

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

MarshalJSON implements json.Marshaler.

func (RelyProxySecurityScheme) MarshalYAML

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

MarshalYAML implements the yaml.Marshaler interface.

func (*RelyProxySecurityScheme) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

func (*RelyProxySecurityScheme) UnmarshalYAML

func (j *RelyProxySecurityScheme) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

func (*RelyProxySecurityScheme) Validate

func (j *RelyProxySecurityScheme) Validate() error

Validate if the current instance is valid.

type RelyProxyServer

type RelyProxyServer struct {
	// Defines the server URL
	URL goenvconf.EnvString `json:"url" yaml:"url"`
	// An optional unique string to refer to the host designated by the URL.
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// Description of the server.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Defines custom headers to be injected to the remote server.
	// Merged with the global headers.
	Headers map[string]goenvconf.EnvString `json:"headers,omitempty" yaml:"headers,omitempty"`
	// Defines the weight of the server endpoint for load balancing.
	// Only take effect if there are many servers.
	Weight *int `json:"weight,omitempty" yaml:"weight,omitempty" jsonschema:"min=0,max=100"`
	// SecuritySchemes define security schemes that can be used by the operations.
	// Use global security schemes if empty.
	SecuritySchemes []RelyProxySecurityScheme `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"`
	// Security contains global security requirements/roles for the target.
	// Use global securities if empty.
	Security SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`
	// TLS configuration of the server. Used for mTLS authentication.
	TLS *httpconfig.TLSConfig `json:"tls,omitempty" mapstructure:"tls" yaml:"tls,omitempty"`
}

RelyProxyServer contains server configurations.

func (RelyProxyServer) OAS3

func (prs RelyProxyServer) OAS3() *highv3.Server

OAS3 converts the tag to OpenAPI model.

type RelyProxySettings

type RelyProxySettings struct {
	// Global settings for the HTTP client.
	HTTP *httpconfig.HTTPClientConfig `json:"http,omitempty" yaml:"http,omitempty"`
	// Headers define custom headers to be injected to the remote server.
	// Merged with the global headers.
	Headers map[string]goenvconf.EnvString `json:"headers,omitempty" yaml:"headers,omitempty"`
	// ForwardHeaders define configurations for headers forwarding
	ForwardHeaders *RelyProxyForwardHeadersConfig `json:"forwardHeaders,omitempty" yaml:"forwardHeaders,omitempty"`
	// SecuritySchemes define security schemes that can be used by the operations.
	SecuritySchemes []RelyProxySecurityScheme `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"`
	// HealthCheck define the health check policy for load balancer recovery.
	HealthCheck *RelyProxyHealthCheckConfig `json:"healthCheck,omitempty" yaml:"healthCheck,omitempty"`
}

RelyProxySettings hold settings of the rely proxy.

type RelyProxyTag

type RelyProxyTag struct {
	// Name of the tag.
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// Summary of the tag.
	Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
	// Description of the tag.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Parent tag.
	Parent string `json:"parent,omitempty" yaml:"parent,omitempty"`
	// Kind of the tag.
	Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
}

RelyProxyTag represents a high-level Tag instance for grouping and filtering.

func (RelyProxyTag) OAS

func (prt RelyProxyTag) OAS() *base.Tag

OAS converts the tag to OpenAPI model.

type RelyProxyType

type RelyProxyType string

RelyProxyType represents enums of proxy types.

const (
	ProxyTypeGraphQL RelyProxyType = "graphql"
	ProxyTypeREST    RelyProxyType = "rest"
)

type SecurityRequirement

type SecurityRequirement map[string][]string

SecurityRequirement wraps the security requirement specification.

func NewSecurityRequirement

func NewSecurityRequirement(name string, scopes []string) SecurityRequirement

NewSecurityRequirement creates a SecurityRequirement instance from name and scope.

func (SecurityRequirement) IsOptional

func (as SecurityRequirement) IsOptional() bool

IsOptional checks if the security is optional.

func (SecurityRequirement) Name

func (as SecurityRequirement) Name() string

Name returns the name of security requirement.

func (SecurityRequirement) Scopes

func (as SecurityRequirement) Scopes() []string

Scopes returns scopes of security requirement.

type SecurityRequirements

type SecurityRequirements []SecurityRequirement //nolint:recvcheck

SecurityRequirements wraps list of security requirements with helpers.

func (*SecurityRequirements) Add

Add adds a security with name and scope.

func (SecurityRequirements) First

First returns the first security.

func (SecurityRequirements) Get

Get gets a security by name.

func (SecurityRequirements) IsEmpty

func (ass SecurityRequirements) IsEmpty() bool

IsEmpty checks if there is no security.

func (SecurityRequirements) IsOptional

func (ass SecurityRequirements) IsOptional() bool

IsOptional checks if the security is optional.

type SecuritySchemeType

type SecuritySchemeType string

SecuritySchemeType represents the authentication scheme enum.

const (
	APIKeyScheme        SecuritySchemeType = "apiKey"
	BasicAuthScheme     SecuritySchemeType = "basic"
	CookieAuthScheme    SecuritySchemeType = "cookie"
	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 SupportedSecuritySchemeTypes

func SupportedSecuritySchemeTypes() []SecuritySchemeType

SupportedSecuritySchemeTypes return all supported security scheme types.

type SecuritySchemer

type SecuritySchemer interface {
	GetType() SecuritySchemeType
	Validate() error
}

SecuritySchemer abstracts an interface of SecurityScheme.

Jump to

Keyboard shortcuts

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