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 Register ¶
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 (*Spec) InstanceName ¶
InstanceName returns the registered instance name, defaulting to "swagger".