swagstub

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package swagstub provides stable stubs for swagger-based workflows.

The package exists so projects can keep optional Swagger tooling isolated from runtime HTTP wiring. Prefer the docs endpoint and specs packages for normal OpenAPI serving paths.

Purpose: See the package summary above. Import: `github.com/aatuh/api-toolkit/v4/swagstub`. Example: See docs/api-reference.md for package example links and docs/cookbook.md for task recipes. Errors: Constructors, parsers, and handlers return or write documented errors according to their signatures; packages with plain data types do not add hidden error channels. Concurrency: Treat configured middleware and helpers as immutable after construction; request and response values remain request-scoped unless a type documents stronger guarantees. Stability: Compatibility-only API under VERSIONING.md; stable for v3 migration compatibility but not a model for new generic designs. When not to use: Prefer net/http, application-owned types, or narrower helpers when this package contract is not needed.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List() []string

List returns all registered spec names.

func Register

func Register(name string, spec *Spec)

Register stores the spec under the provided name.

Example
package main

import (
	"fmt"

	"github.com/aatuh/api-toolkit/v4/swagstub"
)

func main() {
	swagstub.Register("example-widget", &swagstub.Spec{Title: "Widget API"})

	fmt.Println(swagstub.Get("example-widget").Title)

}
Output:
Widget API

Types

type Spec

type Spec struct {
	Version          string
	Host             string
	BasePath         string
	Schemes          []string
	Title            string
	Description      string
	InfoInstanceName string
	SwaggerTemplate  string
	LeftDelim        string
	RightDelim       string
}

Spec is a minimal stub of github.com/swaggo/swag.Spec used by generated docs. This allows generated swagger documentation to work without importing the full swag package.

func Get

func Get(name string) *Spec

Get retrieves a spec by name.

func (*Spec) InstanceName

func (s *Spec) InstanceName() string

InstanceName returns the registered instance name, defaulting to "swagger".

Jump to

Keyboard shortcuts

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