How oaswrap/spec works
oaswrap/spec is a code-first Go library for registering HTTP routes and generating validated OpenAPI documents, with framework adapters and optional documentation UI wiring. The principal workflow is route and typed-option registration, schema reflection from Go types, document construction, validation, then JSON/YAML output. The README documents additional version-specific operations, webhooks, security and customization hooks. Adapter source excerpts are partial, so framework adapters are represented collectively; uncertain internal call wiring is omitted.
Main entry points: router.go Core router · openapi OpenAPI model · adapter Framework adapters · builder Document builder
Components 17
Route entry points
- Framework adapters
adapter - Core router
router.go - Typed options
option - Path parser
pkg/parser/colon_param_parser.go - Adapter docs wiring
adapter
Generation core
- Document builder
internal/builder - Webhook operations
router.go
Schema and models
- Type reflector
internal/reflect - OpenAPI model
openapi - Schemas and parameters
internal/reflect - Security configuration
option/security.go
Validation and output
- Spec validator
internal/validate - JSON YAML codec
openapi/codec.go - UI option mapper
internal/mapper/specui.go
Other components
- API developer
- Docs UI handler
- Document consumer
Connections 23
- API developer → Framework adapters: registers routes
- API developer → Core router: registers routes
- API developer → Typed options: supplies options
- Framework adapters → Core router: registers operations
- Framework adapters → Path parser: parses paths
- Core router → Document builder: adds operations
- Core router → Typed options: applies configuration
- Core router → Webhook operations: adds webhooks
- Document builder → Type reflector: reflects types
- Document builder → OpenAPI model: builds document
- Type reflector → OpenAPI model: creates schemas
- Typed options → Security configuration: configures schemes
- Security configuration → OpenAPI model: sets security
- Webhook operations → Document builder: adds webhook operation
- Core router → Spec validator: validates document
- Core router → JSON YAML codec: serializes document
- Spec validator → OpenAPI model: checks invariants
- JSON YAML codec → Document consumer: returns JSON YAML
- Core router → UI option mapper: maps UI options
- Framework adapters → Adapter docs wiring: wires docs routes
- Adapter docs wiring → Docs UI handler: serves docs UI
- UI option mapper → Docs UI handler: configures handler
- Document consumer → OpenAPI model: uses typed models