Documentation
¶
Index ¶
- type Field
- type GeneratorParams
- type PropertySchema
- type Registry
- func (r *Registry) GenerateData(resourceName string, count int) ([]map[string]interface{}, error)
- func (r *Registry) GetAllResourceNames() []string
- func (r *Registry) GetRouteAliases(resourceName string) []string
- func (r *Registry) GetRouteMethods(resourceName string) []string
- func (r *Registry) GetRoutePath(resourceName string) string
- func (r *Registry) GetSchema(resourceName string) (*Schema, bool)
- func (r *Registry) LoadEmbeddedSchemas() error
- func (r *Registry) LoadSchema(path string) error
- func (r *Registry) LoadSchemas(schemasDir string) error
- func (r *Registry) SchemaToFields(schema *Schema) []Field
- func (r *Registry) SupportsMethod(resourceName string, method string) bool
- type ResourceMetadata
- type RouteConfig
- type Schema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GeneratorParams ¶
type GeneratorParams map[string]interface{}
GeneratorParams contains parameters for field generation
type PropertySchema ¶
type PropertySchema struct {
Type string `json:"type"`
Format string `json:"format,omitempty"`
Description string `json:"description,omitempty"`
Generator string `json:"x-generator,omitempty"`
GeneratorParams GeneratorParams `json:"x-generator-params,omitempty"`
Properties map[string]PropertySchema `json:"properties,omitempty"`
Items *PropertySchema `json:"items,omitempty"`
GeneratorCount int `json:"x-generator-count,omitempty"`
}
PropertySchema defines a single property in the schema
type Registry ¶
Registry holds all loaded schemas
func (*Registry) GenerateData ¶
GenerateData generates fake data for a resource
func (*Registry) GetAllResourceNames ¶
GetAllResourceNames returns all registered resource names
func (*Registry) GetRouteAliases ¶
GetRouteAliases returns additional paths for a resource
func (*Registry) GetRouteMethods ¶
GetRouteMethods returns allowed methods for a resource (defaults to ["GET"])
func (*Registry) GetRoutePath ¶
GetRoutePath returns the custom path or default path for a resource
func (*Registry) LoadEmbeddedSchemas ¶
LoadEmbeddedSchemas loads all schemas from embedded files
func (*Registry) LoadSchema ¶
LoadSchema loads a single schema file
func (*Registry) LoadSchemas ¶
LoadSchemas loads all schemas from the shared/schemas directory
func (*Registry) SchemaToFields ¶
SchemaToFields converts a schema into generator field definitions
type ResourceMetadata ¶
type ResourceMetadata struct {
Name string `json:"name"`
Singular string `json:"singular"`
Description string `json:"description"`
Routes *RouteConfig `json:"routes,omitempty"` // Custom route configuration
}
ResourceMetadata contains information about the resource
type RouteConfig ¶
type RouteConfig struct {
Path string `json:"path,omitempty"` // Custom path (e.g., "/v1/users")
Methods []string `json:"methods,omitempty"` // Allowed methods ["GET", "POST", etc.]
Aliases []string `json:"aliases,omitempty"` // Additional paths for this resource
}
RouteConfig defines custom route configuration
type Schema ¶
type Schema struct {
SchemaURI string `json:"$schema"`
Type string `json:"type"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Resource ResourceMetadata `json:"x-resource"`
Properties map[string]PropertySchema `json:"properties"`
Required []string `json:"required,omitempty"`
}
Schema represents a JSON Schema with our custom extensions