reflectschema

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package reflectschema enriches a Source's operations with request-body JSON Schemas reflected from Go structs. It exists for embedded mode: a router exposes method+path but not the request type behind each handler, so without help a POST tool would have an empty body schema. Register the request struct per operation and this fills the gap from the struct's json tags.

src := reflectschema.New(ginadapter.New(r)).
    Body("post_users", CreateUserRequest{})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Enricher

type Enricher struct {
	// contains filtered or unexported fields
}

Enricher wraps a base Source and augments operations whose request struct has been registered by operation id.

func New

func New(base source.Source) *Enricher

New returns an Enricher around base.

func (*Enricher) Body

func (e *Enricher) Body(operationID string, requestStruct any) *Enricher

Body registers the request struct for the operation with the given id. The struct's json tags drive the generated schema. Returns the Enricher for chaining.

func (*Enricher) Operations

func (e *Enricher) Operations(ctx context.Context) ([]ir.Operation, error)

Operations implements source.Source: it resolves the base operations and sets RequestBody on each one with a registered struct.

Jump to

Keyboard shortcuts

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