TypeMappers

Services responsible for mapping internal data structures onto different formats data types.

TypeMappers of struct type TypeMappers

Those services are responsible for mapping internal data structures onto different formats data types.

// TypeMappers is container for different data format mappers
type TypeMappers struct {
	// JSON is entity that has ability to map underlying data type into JSON data type
	JSON types.Mapper

	// YAML is entity that has ability to map underlying data type into YAML data type
	YAML types.Mapper

	// GO is entity that has ability to map underlying data type into GO-like data type
	GO types.Mapper
}

Each mapper has to implement following interface:

// Mapper is entity that has ability to map data's type into corresponding DataType of given format.
type Mapper interface {
	// Map maps data type.
	Map(data any) DataType
}

To replace them with your own implementation use following setters:

// SetJSONTypeMapper sets new type mapper for JSON.
func (apiCtx *APIContext) SetJSONTypeMapper(c types.Mapper) {
	apiCtx.TypeMappers.JSON = c
}

// SetYAMLTypeMapper sets new type mapper for YAML.
func (apiCtx *APIContext) SetYAMLTypeMapper(c types.Mapper) {
	apiCtx.TypeMappers.YAML = c
}

// SetGoTypeMapper sets new type mapper for Go.
func (apiCtx *APIContext) SetGoTypeMapper(c types.Mapper) {
	apiCtx.TypeMappers.GO = c
}