validator

package
v0.0.0-...-0d8d854 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncAPIDocument

type AsyncAPIDocument struct {
	AsyncAPI   string             `json:"asyncapi" yaml:"asyncapi"`
	Info       AsyncAPIInfo       `json:"info" yaml:"info"`
	Channels   map[string]Channel `json:"channels" yaml:"channels"`
	Components *Components        `json:"components,omitempty" yaml:"components,omitempty"`
	Servers    map[string]Server  `json:"servers,omitempty" yaml:"servers,omitempty"`
}

AsyncAPIDocument represents an AsyncAPI specification

type AsyncAPIInfo

type AsyncAPIInfo struct {
	Title       string `json:"title" yaml:"title"`
	Version     string `json:"version" yaml:"version"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

type AsyncAPIValidator

type AsyncAPIValidator struct {
	// contains filtered or unexported fields
}

AsyncAPIValidator handles AsyncAPI specification validation

func NewAsyncAPIValidator

func NewAsyncAPIValidator(logger *logrus.Logger) *AsyncAPIValidator

NewAsyncAPIValidator creates a new AsyncAPI validator instance

func (*AsyncAPIValidator) Validate

func (v *AsyncAPIValidator) Validate(specPath string) (*ValidationResult, error)

Validate validates an AsyncAPI specification

type BlueprintAction

type BlueprintAction struct {
	Name        string
	Method      string
	Description string
	Parameters  []BlueprintParameter
	Headers     map[string]string
	Examples    []BlueprintExample
}

BlueprintAction represents an API Blueprint action (HTTP method)

type BlueprintDocument

type BlueprintDocument struct {
	Format      string
	Version     string
	Host        string
	Title       string
	Description string
	Groups      []BlueprintResourceGroup
}

BlueprintDocument represents an API Blueprint document

type BlueprintExample

type BlueprintExample struct {
	Name        string
	Description string
	Request     BlueprintMessage
	Response    BlueprintMessage
}

BlueprintExample represents an API Blueprint request/response example

type BlueprintMessage

type BlueprintMessage struct {
	Headers map[string]string
	Body    string
}

BlueprintMessage represents an API Blueprint request or response

type BlueprintParameter

type BlueprintParameter struct {
	Name        string
	Type        string
	Required    bool
	Description string
}

BlueprintParameter represents an API Blueprint parameter

type BlueprintResource

type BlueprintResource struct {
	Name        string
	Description string
	URITemplate string
	Actions     []BlueprintAction
}

BlueprintResource represents an API Blueprint resource

type BlueprintResourceGroup

type BlueprintResourceGroup struct {
	Name        string
	Description string
	Resources   []BlueprintResource
}

BlueprintResourceGroup represents a group of resources in API Blueprint

type BlueprintValidator

type BlueprintValidator struct {
	// contains filtered or unexported fields
}

BlueprintValidator handles API Blueprint specification validation

func NewBlueprintValidator

func NewBlueprintValidator(logger *logrus.Logger) *BlueprintValidator

NewBlueprintValidator creates a new API Blueprint validator instance

func (*BlueprintValidator) Validate

func (v *BlueprintValidator) Validate(specPath string) (*ValidationResult, error)

Validate validates an API Blueprint specification

type Channel

type Channel struct {
	Description string     `json:"description,omitempty" yaml:"description,omitempty"`
	Subscribe   *Operation `json:"subscribe,omitempty" yaml:"subscribe,omitempty"`
	Publish     *Operation `json:"publish,omitempty" yaml:"publish,omitempty"`
}

type Components

type Components struct {
	Messages        map[string]Message        `json:"messages,omitempty" yaml:"messages,omitempty"`
	SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"`
}

type GraphQLValidator

type GraphQLValidator struct {
	// contains filtered or unexported fields
}

GraphQLValidator handles GraphQL schema validation

func NewGraphQLValidator

func NewGraphQLValidator(logger *logrus.Logger) *GraphQLValidator

NewGraphQLValidator creates a new GraphQL validator instance

func (*GraphQLValidator) Validate

func (v *GraphQLValidator) Validate(schemaPath string) (*ValidationResult, error)

Validate validates a GraphQL schema

type Message

type Message struct {
	Name        string                 `json:"name,omitempty" yaml:"name,omitempty"`
	Title       string                 `json:"title,omitempty" yaml:"title,omitempty"`
	Summary     string                 `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description string                 `json:"description,omitempty" yaml:"description,omitempty"`
	Payload     map[string]interface{} `json:"payload,omitempty" yaml:"payload,omitempty"`
}

type OAuthFlow

type OAuthFlow struct {
	Type             string
	AuthorizationURL string
	TokenURL         string
	RefreshURL       string
	Scopes           map[string]string
}

OAuthFlow represents OAuth flow configuration

type OpenAPI3Validator

type OpenAPI3Validator struct {
	// contains filtered or unexported fields
}

OpenAPI3Validator handles OpenAPI 3.0 specification validation

func NewOpenAPI3Validator

func NewOpenAPI3Validator(logger *logrus.Logger) *OpenAPI3Validator

NewOpenAPI3Validator creates a new OpenAPI 3.0 validator instance

func (*OpenAPI3Validator) Validate

func (v *OpenAPI3Validator) Validate(specPath string) (*ValidationResult, error)

Validate validates an OpenAPI 3.0 specification

type Operation

type Operation struct {
	Summary     string                `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description string                `json:"description,omitempty" yaml:"description,omitempty"`
	Message     *Message              `json:"message,omitempty" yaml:"message,omitempty"`
	Security    []map[string][]string `json:"security,omitempty" yaml:"security,omitempty"`
}

type RAMLDocument

type RAMLDocument struct {
	Title           string                    `yaml:"title"`
	Version         string                    `yaml:"version"`
	BaseURI         string                    `yaml:"baseUri"`
	MediaType       string                    `yaml:"mediaType"`
	SecuritySchemes map[string]SecurityScheme `yaml:"securitySchemes"`
	Types           map[string]interface{}    `yaml:"types"`
	Resources       map[string]RAMLResource   `yaml:"resources"`
}

RAMLDocument represents a RAML specification

type RAMLMethod

type RAMLMethod struct {
	Description string                  `yaml:"description"`
	Headers     map[string]interface{}  `yaml:"headers"`
	QueryParams map[string]interface{}  `yaml:"queryParameters"`
	Body        map[string]interface{}  `yaml:"body"`
	Responses   map[string]RAMLResponse `yaml:"responses"`
}

RAMLMethod represents a RAML method

type RAMLResource

type RAMLResource struct {
	Description string                  `yaml:"description"`
	Methods     map[string]RAMLMethod   `yaml:"methods"`
	Resources   map[string]RAMLResource `yaml:"resources"`
}

RAMLResource represents a RAML resource

type RAMLResponse

type RAMLResponse struct {
	Description string                 `yaml:"description"`
	Headers     map[string]interface{} `yaml:"headers"`
	Body        map[string]interface{} `yaml:"body"`
}

RAMLResponse represents a RAML response

type RAMLValidator

type RAMLValidator struct {
	// contains filtered or unexported fields
}

RAMLValidator handles RAML specification validation

func NewRAMLValidator

func NewRAMLValidator(logger *logrus.Logger) *RAMLValidator

NewRAMLValidator creates a new RAML validator instance

func (*RAMLValidator) Validate

func (v *RAMLValidator) Validate(specPath string) (*ValidationResult, error)

Validate validates a RAML specification

type SecurityScheme

type SecurityScheme struct {
	Type        string
	Name        string
	Description string
	Location    string
	Flows       []OAuthFlow
}

SecurityScheme represents a generic security scheme

type Server

type Server struct {
	URL         string                `json:"url" yaml:"url"`
	Protocol    string                `json:"protocol" yaml:"protocol"`
	Description string                `json:"description,omitempty" yaml:"description,omitempty"`
	Security    []map[string][]string `json:"security,omitempty" yaml:"security,omitempty"`
}

type SpecFormat

type SpecFormat string

SpecFormat represents the API specification format

const (
	FormatSwagger2  SpecFormat = "swagger2"
	FormatOpenAPI3  SpecFormat = "openapi3"
	FormatAsyncAPI  SpecFormat = "asyncapi"
	FormatGraphQL   SpecFormat = "graphql"
	FormatRAML      SpecFormat = "raml"
	FormatBlueprint SpecFormat = "blueprint"
)

type SpecInfo

type SpecInfo struct {
	Title       string
	Version     string
	Description string
	Format      SpecFormat
}

SpecInfo contains basic information about an API specification

type Swagger2Validator

type Swagger2Validator struct {
	// contains filtered or unexported fields
}

Swagger2Validator handles Swagger 2.0 specification validation

func NewSwagger2Validator

func NewSwagger2Validator(logger *logrus.Logger) *Swagger2Validator

NewSwagger2Validator creates a new Swagger 2.0 validator instance

func (*Swagger2Validator) Validate

func (v *Swagger2Validator) Validate(specPath string) (*ValidationResult, error)

Validate validates a Swagger 2.0 specification

type ValidationError

type ValidationError struct {
	Path        string
	Message     string
	Severity    string
	Suggestion  string
	LineNumber  int
	ColumnStart int
	ColumnEnd   int
}

ValidationError represents a validation error

type ValidationResult

type ValidationResult struct {
	Valid   bool
	Errors  []ValidationError
	Info    SpecInfo
	Paths   []string
	Methods []string
}

ValidationResult contains the results of specification validation

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator handles API specification validation

func New

func New(logger *logrus.Logger) *Validator

New creates a new Validator instance

func (*Validator) ValidateSpec

func (v *Validator) ValidateSpec(specPath string) error

ValidateSpec validates an API specification file

Jump to

Keyboard shortcuts

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