model

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package model provides data structures for Unimock's HTTP mocking and scenarios.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scenario

type Scenario struct {
	// UUID is the unique identifier for the scenario
	// If not provided when creating, a UUID will be generated automatically
	UUID string `json:"uuid,omitempty"`

	// RequestPath defines which requests this scenario handles
	// Format: "METHOD /path" (e.g., "GET /api/users" or "POST /orders")
	// The path portion can contain wildcards (e.g., "GET /users/*")
	RequestPath string `json:"requestPath"`

	// StatusCode is the HTTP status code to return (e.g., 200, 201, 404, 500)
	StatusCode int `json:"statusCode"`

	// ContentType is the MIME type of the response (e.g., "application/json")
	ContentType string `json:"contentType"`

	// Location is the optional Location header value
	// Usually used with 201 Created responses
	Location string `json:"location,omitempty"`

	// Data is the response body to return
	// For JSON responses, this should be a valid JSON string
	Data string `json:"data"`

	// Headers is a map of HTTP headers to return with the scenario response
	Headers map[string]string `json:"headers,omitempty"`
}

Scenario represents a predefined mock scenario for specific API requests Scenarios allow bypassing the normal mocking behavior for certain paths, enabling precise control over specific API responses.

type UniData added in v0.0.5

type UniData struct {
	// Path of the resource (e.g., "/users/123")
	Path string `json:"path"`

	// IDs contains all identifiers associated with this resource
	// Multiple IDs allow a single resource to be accessible via different identifiers
	IDs []string `json:"ids,omitempty"`

	// Location header value for the resource
	// Usually used in POST responses to indicate where a new resource can be found
	Location string `json:"location,omitempty"`

	// ContentType specifies the MIME type of the data (e.g., "application/json")
	ContentType string `json:"content_type"`

	// Body contains the raw response data to be returned
	// For JSON responses, this is the serialized JSON body
	Body []byte `json:"body"`
}

UniData represents the data stored for a uni HTTP resource

Jump to

Keyboard shortcuts

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