tagparser

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tagparser provides shared tag parsing functionality for schemagen. This module analyzes Go struct tags and extracts jsonschema validation rules, supporting the complete JSON Schema 2020-12 specification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldInfo

type FieldInfo struct {
	Name           string       // Go field name
	Type           reflect.Type // Go field type
	TypeName       string       // AST-based type name string for reference detection
	JSONName       string       // JSON field name (from json tag or field name)
	Tag            string       // Raw jsonschema tag value
	Rules          []TagRule    // Parsed validation rules
	Required       bool         // Whether field is required (has "required" rule)
	Optional       bool         // Whether field should be optional
	EmbeddingDepth int          // Embedding depth (0 = direct field)
	IsPromoted     bool         // Whether field is promoted from embedding
}

FieldInfo represents parsed information about a struct field

type TagParser

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

TagParser handles jsonschema tag parsing with configurable tag name

func New

func New() *TagParser

New creates a new TagParser with default "jsonschema" tag name

func NewWithTagName

func NewWithTagName(tagName string) *TagParser

NewWithTagName creates a new TagParser with custom tag name

func (*TagParser) ParseStructTags

func (p *TagParser) ParseStructTags(structType reflect.Type) ([]FieldInfo, error)

ParseStructTags parses all jsonschema tags in a struct type and returns field information

func (*TagParser) ParseTagString

func (p *TagParser) ParseTagString(tag string) ([]TagRule, error)

ParseTagString parses a single tag string into validation rules

type TagRule

type TagRule struct {
	Name   string   // Rule name (e.g., "required", "minLength", "format")
	Params []string // Rule parameters (e.g., ["2"] for "minLength=2")
}

TagRule represents a single validation rule parsed from a tag

Jump to

Keyboard shortcuts

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