stubgen

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package stubgen writes a type that implements a generated strict server interface by answering 501 for every operation. oapi-codegen emits an Unimplemented type for the plain ServerInterface but not for the strict one, and the strict one is what internal/server implements; without a stub every scaffolded operation would have to be hand-stubbed before the tree compiles.

Index

Constants

View Source
const InterfaceName = "StrictServerInterface"

InterfaceName is the strict interface oapi-codegen generates.

View Source
const TypeName = "UnimplementedStrict"

TypeName is the stub type written into the generated package.

Variables

This section is empty.

Functions

func Generate

func Generate(pkg string, methods []Method) ([]byte, error)

Generate renders the stub file for the parsed package. Every method returns apierror.ErrNotImplemented, which internal/server's response error handler renders as 501 with the selected error response profile.

func Run

func Run(genPath, outPath string) (int, error)

Run reads a generated server file and writes the stub next to it.

Types

type Method

type Method struct {
	Name     string
	Request  string
	Response string
}

Method is one interface method: name, request type and response type.

func Parse

func Parse(src []byte) (string, []Method, error)

Parse extracts the strict interface methods from generated source.

Jump to

Keyboard shortcuts

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