parser

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Name            string                     // Channel name/identifier
	Description     string                     // Description of the channel
	Summary         string                     // Short summary of the channel
	Security        []map[string][]string      // Security requirements for the channel
	Parameters      []*Parameter               // Parameters for subscribing to the channel
	Messages        map[string]*Message        // Message types by direction (send/receive)
	Metadata        map[string]interface{}     // Additional metadata
	Tags            []string                   // Tags for categorizing the channel
	Extensions      map[string]interface{}     // AsyncAPI extensions
	Deprecated      bool                       // Whether the channel is deprecated
	Bindings        map[string]interface{}     // Protocol-specific bindings
	Schemas         []*Schema                  // Schemas for the channel
	SecuritySchemas map[string]*SecuritySchema // Security schemas for the channel
	Protected       bool                       // Whether the channel requires authentication
}

Channel represents a WebSocket channel/stream

type CorrelationId

type CorrelationId struct {
	Location    string // Location of the correlation ID in the message
	Description string // Description of the correlation ID
}

CorrelationId represents correlation ID for request-reply pattern

type Documentation

type Documentation struct {
	config.AsyncDocumentation
	Options map[string]string // Additional options for parsing
}

Documentation represents information about WebSocket API documentation

type HTTPDocumentParser

type HTTPDocumentParser interface {
	Parse(r io.Reader, urlEntity *config.URLEntity, protectedMethods []string) ([]Channel, error)
}

HTTPDocumentParser defines the interface for WebSocket HTTP document parsers

type HTTPParser

type HTTPParser struct {
	Name       string
	Client     *http.Client
	UseSamples bool
	SamplesDir string
	DocParser  HTTPDocumentParser
}

HTTPParser is an implementation of the Parser interface for HTTP-based WebSocket API documentation

func (*HTTPParser) Parse

func (p *HTTPParser) Parse(ctx context.Context, doc Documentation) ([]Channel, error)

Parse processes the WebSocket API documentation and returns the extracted channels

type Message

type Message struct {
	Title         string                 // Message title
	Description   string                 // Description of the message
	Payload       *Schema                // Message payload schema
	Headers       map[string]*Schema     // Message headers
	Examples      []interface{}          // Message examples
	Bindings      map[string]interface{} // Protocol-specific bindings
	Tags          []string               // Message tags
	Summary       string                 // Message summary
	CorrelationId *CorrelationId         // Correlation ID for the message
}

Message represents a WebSocket message

type Parameter

type Parameter struct {
	Name        string  // Parameter name
	Required    bool    // Whether the parameter is required
	Description string  // Description of the parameter
	Location    string  // Parameter location (path, query, header, etc.)
	Schema      *Schema // Parameter schema
}

Parameter represents a channel parameter

type Parser

type Parser interface {
	// Parse parses the documentation and returns WebSocket channels
	Parse(ctx context.Context, doc Documentation) ([]Channel, error)

	// CheckVersion checks if the documentation version has changed
	CheckVersion(ctx context.Context, doc Documentation) (bool, time.Time, error)
}

Parser defines the interface for WebSocket API documentation parsers

type Schema

type Schema struct {
	OneOf       []*Schema     `json:"oneOf,omitempty"`
	Type        string        `json:"type,omitempty"`
	Title       string        `json:"title,omitempty"`
	Format      string        `json:"format,omitempty"`
	Description string        `json:"description,omitempty"`
	Enum        []interface{} `json:"enum,omitempty"`
	Const       interface{}   `json:"const,omitempty"`
	Default     interface{}   `json:"default,omitempty"`
	Example     interface{}   `json:"example,omitempty"`

	UniqueItems  bool `json:"uniqueItems,omitempty"`
	ExclusiveMin bool `json:"exclusiveMinimum,omitempty"`
	ExclusiveMax bool `json:"exclusiveMaximum,omitempty"`

	Nullable   bool `json:"nullable,omitempty"`
	Deprecated bool `json:"deprecated,omitempty"`

	// Numeric constraints
	Min        *float64 `json:"minimum,omitempty"`
	Max        *float64 `json:"maximum,omitempty"`
	MultipleOf *float64 `json:"multipleOf,omitempty"`

	// String constraints
	MinLength uint64  `json:"minLength,omitempty"`
	MaxLength *uint64 `json:"maxLength,omitempty"`
	Pattern   string  `json:"pattern,omitempty"`

	// Array constraints
	MinItems uint64  `json:"minItems,omitempty"`
	MaxItems *uint64 `json:"maxItems,omitempty"`
	Items    *Schema `json:"items,omitempty"`

	// Object constraints
	Required []string `json:"required,omitempty"`

	// Additional fields
	Properties           map[string]*Schema `json:"properties,omitempty"`
	AdditionalProperties *Schema            `json:"additionalProperties,omitempty"`

	// OpenAPI specific fields
	Ref string `json:"$ref,omitempty"`
}

Schema represents a JSON Schema definition for WebSocket messages

type SecuritySchema

type SecuritySchema struct {
	Type string `json:"type,omitempty"`
	In   string `json:"in,omitempty"`
	Name string `json:"name,omitempty"`
}

SecuritySchema represents a security requirement for a channel

Jump to

Keyboard shortcuts

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