package models

// OpenRPCSpec represents an OpenRPC specification document
type OpenRPCSpec struct {
	OpenRPC string     `json:"openrpc"`
	Info    InfoObject `json:"info"`
	Servers []Server   `json:"servers"`
	Methods []Method   `json:"methods"`
}

// InfoObject contains metadata about the API
type InfoObject struct {
	Version     string         `json:"version"`
	Title       string         `json:"title"`
	Description string         `json:"description,omitempty"`
	License     *LicenseObject `json:"license,omitempty"`
}

// LicenseObject contains license information for the API
type LicenseObject struct {
	Name string `json:"name"`
}

// Server represents a server that provides the API
type Server struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

// Method represents a method in the API
type Method struct {
	Name        string        `json:"name"`
	Description string        `json:"description,omitempty"`
	Params      []Parameter   `json:"params"`
	Result      ResultObject  `json:"result"`
	Examples    []Example     `json:"examples,omitempty"`
	Errors      []ErrorObject `json:"errors,omitempty"`
}

// Parameter represents a parameter for a method
type Parameter struct {
	Name        string       `json:"name"`
	Description string       `json:"description,omitempty"`
	Required    bool         `json:"required"`
	Schema      SchemaObject `json:"schema"`
}

// ResultObject represents the result of a method
type ResultObject struct {
	Name        string       `json:"name"`
	Description string       `json:"description,omitempty"`
	Schema      SchemaObject `json:"schema"`
}

// SchemaObject represents a JSON Schema object
type SchemaObject struct {
	Type                 string                  `json:"type,omitempty"`
	Properties           map[string]SchemaObject `json:"properties,omitempty"`
	Items                *SchemaObject           `json:"items,omitempty"`
	AdditionalProperties *SchemaObject           `json:"additionalProperties,omitempty"`
	Description          string                  `json:"description,omitempty"`
	Enum                 []string                `json:"enum,omitempty"`
}

// Example represents an example for a method
type Example struct {
	Name   string                   `json:"name"`
	Params []map[string]interface{} `json:"params"`
	Result ExampleResultObject      `json:"result"`
}

// ExampleResultObject represents the result of an example
type ExampleResultObject struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
}

// ErrorObject represents an error that can be returned by a method
type ErrorObject struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data,omitempty"`
}

// Validate validates the OpenRPC specification
func (spec *OpenRPCSpec) Validate() error {
	// TODO: Implement validation logic
	return nil
}
