Documentation
¶
Index ¶
- func ValidateJSONSchema(schemaData json.RawMessage) error
- type CreateSchemaRequest
- type JSONSchema
- type JSONSchemaProperty
- type Schema
- type SchemaRepo
- func (r *SchemaRepo) Create(ctx context.Context, projectID uuid.UUID, req *CreateSchemaRequest) (*Schema, error)
- func (r *SchemaRepo) Delete(ctx context.Context, projectID uuid.UUID, id uuid.UUID) error
- func (r *SchemaRepo) GetByID(ctx context.Context, projectID uuid.UUID, id uuid.UUID) (*Schema, error)
- func (r *SchemaRepo) GetByName(ctx context.Context, projectID uuid.UUID, name string) (*Schema, error)
- func (r *SchemaRepo) List(ctx context.Context, projectID uuid.UUID) ([]*Schema, error)
- func (r *SchemaRepo) Update(ctx context.Context, projectID uuid.UUID, id uuid.UUID, ...) (*Schema, error)
- type SchemaService
- func (s *SchemaService) CreateSchema(ctx context.Context, projectID uuid.UUID, req *CreateSchemaRequest) (*Schema, error)
- func (s *SchemaService) DeleteSchema(ctx context.Context, projectID uuid.UUID, id uuid.UUID) error
- func (s *SchemaService) GetSchema(ctx context.Context, projectID uuid.UUID, id uuid.UUID) (*Schema, error)
- func (s *SchemaService) GetSchemaByName(ctx context.Context, projectID uuid.UUID, name string) (*Schema, error)
- func (s *SchemaService) ListSchemas(ctx context.Context, projectID uuid.UUID) ([]*Schema, error)
- func (s *SchemaService) UpdateSchema(ctx context.Context, projectID uuid.UUID, id uuid.UUID, ...) (*Schema, error)
- type SourceType
- type UpdateSchemaRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateJSONSchema ¶
func ValidateJSONSchema(schemaData json.RawMessage) error
ValidateJSONSchema performs basic validation on a JSON schema
Types ¶
type CreateSchemaRequest ¶
type CreateSchemaRequest struct {
Name string `json:"name" validate:"required,min=1,max=255"`
Description *string `json:"description,omitempty"`
Schema json.RawMessage `json:"schema" validate:"required"`
SourceType SourceType `json:"source_type,omitempty"`
SourceContent *string `json:"source_content,omitempty"`
}
CreateSchemaRequest represents the request to create a new schema
type JSONSchema ¶
type JSONSchema struct {
Schema string `json:"$schema,omitempty"`
Type string `json:"type"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Properties map[string]JSONSchemaProperty `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
Definitions map[string]JSONSchemaProperty `json:"definitions,omitempty"`
}
JSONSchema represents a full JSON schema document
type JSONSchemaProperty ¶
type JSONSchemaProperty struct {
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Properties map[string]JSONSchemaProperty `json:"properties,omitempty"`
Items *JSONSchemaProperty `json:"items,omitempty"`
Required []string `json:"required,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Default interface{} `json:"default,omitempty"`
Format string `json:"format,omitempty"`
Minimum *float64 `json:"minimum,omitempty"`
Maximum *float64 `json:"maximum,omitempty"`
MinLength *int `json:"minLength,omitempty"`
MaxLength *int `json:"maxLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
Ref string `json:"$ref,omitempty"`
}
JSONSchemaProperty represents a property in a JSON schema
type Schema ¶
type Schema struct {
ID uuid.UUID `json:"id" db:"id"`
ProjectID uuid.UUID `json:"project_id" db:"project_id"`
Name string `json:"name" db:"name"`
Description *string `json:"description,omitempty" db:"description"`
Schema json.RawMessage `json:"schema" db:"schema"`
SourceType SourceType `json:"source_type" db:"source_type"`
SourceContent *string `json:"source_content,omitempty" db:"source_content"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Schema represents a JSON schema with metadata
type SchemaRepo ¶
type SchemaRepo struct {
// contains filtered or unexported fields
}
SchemaRepo handles database operations for schemas
func NewSchemaRepo ¶
func NewSchemaRepo(db *sqlx.DB) *SchemaRepo
NewSchemaRepo creates a new schema repository
func (*SchemaRepo) Create ¶
func (r *SchemaRepo) Create(ctx context.Context, projectID uuid.UUID, req *CreateSchemaRequest) (*Schema, error)
Create creates a new schema
func (*SchemaRepo) GetByID ¶
func (r *SchemaRepo) GetByID(ctx context.Context, projectID uuid.UUID, id uuid.UUID) (*Schema, error)
GetByID retrieves a schema by ID
func (*SchemaRepo) GetByName ¶
func (r *SchemaRepo) GetByName(ctx context.Context, projectID uuid.UUID, name string) (*Schema, error)
GetByName retrieves a schema by name
type SchemaService ¶
type SchemaService struct {
// contains filtered or unexported fields
}
SchemaService handles business logic for schemas
func NewSchemaService ¶
func NewSchemaService(repo *SchemaRepo) *SchemaService
NewSchemaService creates a new schema service
func (*SchemaService) CreateSchema ¶
func (s *SchemaService) CreateSchema(ctx context.Context, projectID uuid.UUID, req *CreateSchemaRequest) (*Schema, error)
CreateSchema creates a new schema
func (*SchemaService) DeleteSchema ¶
DeleteSchema deletes a schema
func (*SchemaService) GetSchema ¶
func (s *SchemaService) GetSchema(ctx context.Context, projectID uuid.UUID, id uuid.UUID) (*Schema, error)
GetSchema retrieves a schema by ID
func (*SchemaService) GetSchemaByName ¶
func (s *SchemaService) GetSchemaByName(ctx context.Context, projectID uuid.UUID, name string) (*Schema, error)
GetSchemaByName retrieves a schema by name
func (*SchemaService) ListSchemas ¶
ListSchemas retrieves all schemas for a project
func (*SchemaService) UpdateSchema ¶
func (s *SchemaService) UpdateSchema(ctx context.Context, projectID uuid.UUID, id uuid.UUID, req *UpdateSchemaRequest) (*Schema, error)
UpdateSchema updates a schema
type SourceType ¶
type SourceType string
SourceType represents the source from which a schema was generated
const ( SourceTypeManual SourceType = "manual" // Manually created via UI SourceTypeGoStruct SourceType = "go_struct" // Generated from Go struct (future) SourceTypeTypeScript SourceType = "typescript" // Generated from TypeScript interface (future) )
type UpdateSchemaRequest ¶
type UpdateSchemaRequest struct {
Name *string `json:"name,omitempty" validate:"omitempty,min=1,max=255"`
Description *string `json:"description,omitempty"`
Schema json.RawMessage `json:"schema,omitempty"`
SourceType *SourceType `json:"source_type,omitempty"`
SourceContent *string `json:"source_content,omitempty"`
}
UpdateSchemaRequest represents the request to update a schema