Documentation
¶
Index ¶
- func LoadDefaultContexts() []map[string]map[string]any
- func LoadServiceContext(serviceCtx []byte, defaultContexts []map[string]map[string]any) []map[string]any
- type Generate
- type ResponseGenerator
- func (g *ResponseGenerator) Error(errSchema *schema.Schema, errPath, error string) []byte
- func (g *ResponseGenerator) Request(req *api.GenerateRequest, op *schema.Operation, ctxData map[string]any) json.RawMessage
- func (g *ResponseGenerator) Response(respSchema *schema.ResponseSchema, ctxData map[string]any) schema.ResponseData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadDefaultContexts ¶
LoadDefaultContexts loads the built-in replacement contexts (common, fake, words). This allows standalone usage without an api.Router.
func LoadServiceContext ¶
func LoadServiceContext(serviceCtx []byte, defaultContexts []map[string]map[string]any) []map[string]any
LoadServiceContext loads the service context and combines it with the default contexts. It returns a flattened array of context maps in a specific order:
- [0]: service - The service-specific context loaded from serviceCtx YAML
- [1]: common - Common context with patterns like _id$, _email$, etc. (from resources/contexts/common.yml)
- [2]: fake - Fake data generators for testing (from resources/contexts/fake.yml)
- [3]: words - Common words for realistic-looking data (from resources/contexts/words.yml)
The map keys ("service", "common", "fake", "words") correspond to context namespaces that are loaded from embedded YAML files in the resources/contexts directory. These namespaces are used during the Load() call to organize and resolve context data, but are discarded in the returned array since only the values are needed for replacement.
Types ¶
type Generate ¶
type Generate interface {
Request(req *api.GenerateRequest, op *schema.Operation, ctxData map[string]any) json.RawMessage
Response(respSchema *schema.ResponseSchema, ctxData map[string]any) schema.ResponseData
Error(errSchema *schema.Schema, errPath, error string) []byte
}
type ResponseGenerator ¶
type ResponseGenerator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
func (*ResponseGenerator) Error ¶
func (g *ResponseGenerator) Error(errSchema *schema.Schema, errPath, error string) []byte
func (*ResponseGenerator) Request ¶
func (g *ResponseGenerator) Request(req *api.GenerateRequest, op *schema.Operation, ctxData map[string]any) json.RawMessage
func (*ResponseGenerator) Response ¶
func (g *ResponseGenerator) Response(respSchema *schema.ResponseSchema, ctxData map[string]any) schema.ResponseData
Click to show internal directories.
Click to hide internal directories.