testserver

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package testserver provides a comprehensive Huma-based HTTP server that serves an auto-generated OpenAPI spec and implements operations for E2E contract testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartTestServer

func StartTestServer(t *testing.T) (baseURL, specURL string, cleanup func())

StartTestServer starts an HTTP server with a comprehensive Huma API for E2E tests. Returns baseURL, specURL (baseURL + /openapi.json), and a cleanup function.

Types

type AllOfOutput

type AllOfOutput struct {
	Body struct {
		AllOfPart1
		AllOfPart2
	} `json:"body"`
}

type AllOfPart1

type AllOfPart1 struct {
	A string `json:"a"`
}

type AllOfPart2

type AllOfPart2 struct {
	B int `json:"b"`
}

type AnyOfOutput

type AnyOfOutput struct {
	Body struct {
		Value string `json:"value"`
	} `json:"body"`
}

type CircleShape

type CircleShape struct {
	Kind   string  `json:"kind" enum:"circle"`
	Radius float64 `json:"radius"`
}

type ConfigOutput

type ConfigOutput struct {
	Body struct {
		Key   string `json:"key"`
		Value string `json:"value"`
	} `json:"body"`
}

type CreateUserInput

type CreateUserInput struct {
	Body struct {
		Email    string `json:"email" format:"email" required:"true"`
		Password string `json:"password" writeOnly:"true" required:"true"`
	} `json:"body"`
}

type CreateWidgetInput

type CreateWidgetInput struct {
	Body struct {
		Name   string  `json:"name" minLength:"1" maxLength:"100" required:"true"`
		Weight float64 `json:"weight" minimum:"0" maximum:"1000"`
		Active bool    `json:"active"`
	} `json:"body"`
}

type CreateWidgetOutput

type CreateWidgetOutput struct {
	Status int `json:"status"`
	Body   struct {
		ID     int     `json:"id"`
		Name   string  `json:"name"`
		Weight float64 `json:"weight"`
		Active bool    `json:"active"`
	} `json:"body"`
}

type DefaultsOutput

type DefaultsOutput struct {
	Body struct {
		Name string `json:"name" default:"unknown"`
		Size int    `json:"size" default:"0"`
	} `json:"body"`
}

type DeleteWidgetInput

type DeleteWidgetInput struct {
	WidgetID string `path:"widgetId"`
}

type EchoInput

type EchoInput struct {
	RequestID string `header:"X-Request-ID" doc:"Request ID"`
}

type EchoOutput

type EchoOutput struct {
	Body struct {
		RequestID string `json:"requestId"`
	} `json:"body"`
}

type GetUserInput

type GetUserInput struct {
	UserID string `path:"userId"`
}

type GetWidgetInput

type GetWidgetInput struct {
	WidgetID string `path:"widgetId" doc:"Widget ID"`
}

type GetWidgetOutput

type GetWidgetOutput struct {
	Status int `json:"status"`
	Body   Widget
}

type LegacyOutput

type LegacyOutput struct {
	Body struct {
		Message string `json:"message"`
	} `json:"body"`
}

type LoginInput

type LoginInput struct {
	Body struct {
		Username string `json:"username" required:"true"`
		Password string `json:"password" required:"true"`
	} `json:"body"`
}

type LoginOutput

type LoginOutput struct {
	Body struct {
		Token string `json:"token"`
	} `json:"body"`
}

type MetadataOutput

type MetadataOutput struct {
	Body map[string]string `json:"body"`
}

type NullableOutput

type NullableOutput struct {
	Body struct {
		Value *string `json:"value,omitempty" nullable:"true"`
		Num   *int    `json:"num,omitempty" nullable:"true"`
	} `json:"body"`
}

type OneOfOutput

type OneOfOutput struct {
	Body struct {
		Type string `json:"type"`
		ID   int    `json:"id"`
	} `json:"body"`
}

type RectangleShape

type RectangleShape struct {
	Kind   string  `json:"kind" enum:"rectangle"`
	Width  float64 `json:"width"`
	Height float64 `json:"height"`
}

type SearchInput

type SearchInput struct {
	Limit  int    `query:"limit" default:"10" minimum:"1" maximum:"100" doc:"Page size"`
	Offset int    `query:"offset" minimum:"0" doc:"Offset"`
	Status string `query:"status" enum:"active,inactive,pending" doc:"Filter by status"`
}

type SearchOutput

type SearchOutput struct {
	Body struct {
		Limit  int    `json:"limit"`
		Offset int    `json:"offset"`
		Status string `json:"status"`
	} `json:"body"`
}

type ShapeOutput

type ShapeOutput struct {
	Body json.RawMessage `json:"body"`
}

type TagsOutput

type TagsOutput struct {
	Body []string `json:"body" minItems:"1" maxItems:"10"`
}

type TreeNode

type TreeNode struct {
	Value    string     `json:"value"`
	Children []TreeNode `json:"children,omitempty"`
}

type TreeOutput

type TreeOutput struct {
	Body TreeNode `json:"body"`
}

type UserOutput

type UserOutput struct {
	Body struct {
		ID        string `json:"id" format:"uuid" readOnly:"true"`
		Email     string `json:"email" format:"email"`
		CreatedAt string `json:"createdAt" format:"date-time" readOnly:"true"`
	} `json:"body"`
}

type Widget

type Widget struct {
	ID     int     `json:"id"`
	Name   string  `json:"name"`
	Weight float64 `json:"weight"`
	Active bool    `json:"active"`
}

type WidgetListOutput

type WidgetListOutput struct {
	Body []Widget `json:"body"`
}

Jump to

Keyboard shortcuts

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