openapi

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 19 Imported by: 0

README

Fox OpenAPI

English | 简体中文

OpenAPI 3.0.3 generator and CLI for Fox.

The recommended workflow is fox-openapi: expose a function that builds a *fox.Engine, then generate a committed openapi.yaml during development or CI. Business code does not need to mount OpenAPI handlers or import this module unless it uses optional OpenAPI metadata hooks or the library API directly.

Install

go install github.com/fox-gonic/openapi/cmd/fox-openapi@latest

For reproducible CI, pin the version used to generate committed specs. Replace vX.Y.Z with the release you want the downstream repository to use:

go install github.com/fox-gonic/openapi/cmd/fox-openapi@vX.Y.Z

For local development in this repository:

go run ./cmd/fox-openapi version

Quickstart

Expose one engine factory function that registers routes and returns a *fox.Engine. It should not call Run, open listeners, or start infrastructure that is not needed for route registration.

package server

import "github.com/fox-gonic/fox"

func NewEngine() *fox.Engine {
	engine := fox.New()
	engine.GET("/users/:id", getUser)
	return engine
}

Then generate, verify, and preview the committed spec:

fox-openapi                                # auto-discovers entry from ./...
fox-openapi ./internal/server              # narrow entry discovery to a directory
fox-openapi check
fox-openapi serve --addr 127.0.0.1:8765

When entry is omitted from the config and --entry is not passed, the CLI scans sources (default ./...) for an exported function whose signature matches one of the supported entry shapes. If exactly one is found, it is used. If multiple are found, prefer annotating the canonical entry with a doc comment marker:

// NewEngine builds the production HTTP engine.
//
// fox-openapi:entry
func NewEngine() *fox.Engine { ... }

When at least one function carries the fox-openapi:entry marker, only marked candidates are considered, so adding the marker disambiguates without deleting other entry-shaped helpers.

--entry is still available for scripts, CI, and unusual layouts that need to pin the function explicitly:

fox-openapi generate \
  --entry github.com/acme/myapp/internal/server.NewEngine

Supported entry signatures are:

func NewEngine() *fox.Engine
func NewEngine() (*fox.Engine, error)
func NewEngine(context.Context) *fox.Engine
func NewEngine(context.Context) (*fox.Engine, error)
func NewEngine(context.Context, *Config) *fox.Engine
func NewEngine(context.Context, *Config) (*fox.Engine, error)

*Config represents your application's own configuration struct type, not a fox-openapi-provided type.

serve exposes /openapi.yaml, /openapi.json, /docs, /scalar, and /redoc with embedded offline UI assets. It watches Go files by default and regenerates the preview when source changes.

For small projects, no config file is required. Pass flags only when you want to override output or metadata defaults:

fox-openapi \
  --out api/openapi.yaml \
  --title "Acme API"

Use fox-openapi init only when you want to commit a config file for shared metadata such as title, servers, tags, security schemes, or entry config.

The CLI builds an isolated temporary driver for entry-based generation. For basic generation, the application module does not need a tools.go file or a committed direct github.com/fox-gonic/openapi requirement; the driver build resolves that temporary dependency and restores go.mod/go.sum afterward. Add a direct requirement only when application code imports OpenAPI metadata hooks or library APIs.

Route Manifest Mode

Since v0.3.0, fox-openapi can generate from a route manifest exported by the application instead of calling the application entry through a generated driver. Use this when NewEngine needs real runtime dependencies, configuration objects, or environment setup that should not be recreated just for OpenAPI generation.

The application owns when to write the manifest. A common pattern is to add a non-production CLI flag next to normal startup code:

routeManifestPath := flag.String("openapi-route-manifest", "", "write Fox route manifest and exit")
flag.Parse()

engine, err := NewEngine(ctx, cfg)
if err != nil {
	log.Fatal(err)
}

if *routeManifestPath != "" {
	if err := fox.WriteRouteManifest(engine, *routeManifestPath); err != nil {
		log.Fatal(err)
	}
	return
}

if err := engine.Run(":8080"); err != nil {
	log.Fatal(err)
}

Do not enable this flag in normal production startup. The tool reads the file; it does not require the application to import github.com/fox-gonic/openapi.

Configure fox-openapi to consume the generated manifest:

routeManifest: api/routes.manifest.json
out: api/openapi.yaml
info:
  title: Acme API
# First ask the application to write or refresh the manifest.
myapp --openapi-route-manifest api/routes.manifest.json

# Then ask fox-openapi to read the manifest and write the OpenAPI document.
fox-openapi generate --route-manifest api/routes.manifest.json --out api/openapi.yaml

Manifest mode does not run the application entry and does not update the manifest file. It uses the existing manifest for methods, paths, handler identities, path parameters, operation IDs, request/response schemas, and source comment enrichment. If the manifest only contains handler symbols, fox-openapi loads the application packages from workdir to enrich request and response types, including aliases, generic wrappers, and handlers in _test.go when includeTestFiles is enabled.

Path resolution

Paths follow standard go-tooling conventions:

  • CLI flags (--out, --config, --workdir, --entry-config-path): relative to the current working directory (where you invoked the command).
  • YAML fields (out, entryConfig.path, workdir): relative to the directory containing the config file, so fox-openapi.yaml and the artifacts it points to keep a stable layout regardless of where you run.
  • Positional path (fox-openapi generate ./internal/aone): narrows where the CLI looks for the entry function. It does not narrow source scanning — sources (default ./...) still drives comment extraction so field/handler docs in sub-packages outside the entry directory are preserved. To override scanning explicitly, set sources in YAML or pass --source.
cd ~/myapp
fox-openapi generate internal/aone --out api/openapi.yaml
# wrote ~/myapp/api/openapi.yaml   ← relative to CWD, not the scanned dir

Filtered Specs

fox-openapi can derive narrower OpenAPI documents from the full generated contract. The first supported CLI shape is intentionally simple: remove operations whose extension has a specific scalar value, then optionally prune components that are no longer referenced.

For example, handlers can mark internal operations in source comments:

// List API keys.
//
// openapi:
//
//	x-public: false
func listAPIKeys(ctx *fox.Context) (ListAPIKeysResponse, error) {
	return ListAPIKeysResponse{}, nil
}

Then generate a public-only spec:

fox-openapi generate \
  --out api/public.openapi.yaml \
  --filter "x-public != false" \
  --filter "x-product = sandbox || x-product = account" \
  --prune-unused-components

The same settings can live in fox-openapi.yaml:

out: api/public.openapi.yaml
filters:
  - x-public != false
  - x-product = sandbox || x-product = account
pruneUnusedComponents: true

The library API exposes the generic pipeline directly:

spec := openapi.New(engine,
	openapi.WithFilters(
		openapi.FilterOperations(func(op openapi.OperationContext) bool {
			return op.ExtensionBoolDefault("x-public", true)
		}),
		openapi.PruneUnusedComponents(),
	),
)

Filtering is a post-generation step. Explicit metadata, inferred responses, and source comment enrichment still happen first, so derived specs keep the same contract semantics as the full document.

Config

fox-openapi init writes a config like:

entry: github.com/acme/myapp/internal/server.NewEngine
out: api/openapi.yaml
sources:
  - ./...
info:
  title: Acme API
  version: 1.0.0
servers:
  - url: https://api.acme.com

Supported config keys:

  • entry: entry function. Optional — when omitted, the CLI auto-discovers an exported function with a supported signature from sources. Set explicitly to override discovery, or use // fox-openapi:entry in source.
  • out: output file, default api/openapi.yaml.
  • format: yaml or json; inferred from out when omitted.
  • sources: source directories for Go doc comments; default ./....
  • includeTestFiles: include _test.go while scanning source comments.
  • routeManifest: read a Fox route manifest file instead of running an entry.
  • info: title, version, description.
  • servers: list of url and optional description.
  • tags: top-level OpenAPI tag registry.
  • securitySchemes: serializable HTTP, API key, OAuth2, or OpenID Connect schemes.
  • filters: operation filter expressions. Supported operators are =, ==, and !=. Use || inside one expression for OR; repeat filters to combine expressions with AND.
  • pruneUnusedComponents: remove components no longer referenced after filters.
  • metadataHook: optional advanced Go hook.
  • entryConfig: optional path and loader for config-taking entries. When path is set, fox-openapi first looks for a package-level Load(string) (*Config, error) function in the config type's package; set loader only when loading needs a non-standard function. When omitted, config-taking entries receive nil for compatibility.

CLI flags override config values. Config values override defaults.

Commands

fox-openapi init --entry internal/server.NewEngine --title "Acme API"
fox-openapi --out api/openapi.yaml --title "Acme API"
fox-openapi generate --entry github.com/acme/myapp/internal/server.NewEngine
fox-openapi generate --route-manifest api/routes.manifest.json --out api/openapi.yaml --title "Acme API"
fox-openapi check
fox-openapi serve --addr 127.0.0.1:8765
fox-openapi version

fox-openapi, generate, check, and serve share the common config flags:

  • --config: config file path, default fox-openapi.yaml.
  • --entry: explicitly pin the entry function when auto-discovery is not enough.
  • --out: output path, default api/openapi.yaml.
  • --title and --version: OpenAPI info metadata.
  • --server: repeatable OpenAPI server URL.
  • --workdir: user project root.
  • --filter: repeatable operation filter expression, for example --filter "x-public != false".
  • --prune-unused-components: remove components no longer referenced after filters.

Advanced flags remain available for scripts and unusual projects but are hidden from normal help: --format, --source, --include-test-files, --metadata-hook, --entry-config-loader, --entry-config-path, --route-manifest, --keep-driver, and --verbose.

serve also supports --addr, repeatable --ui, --watch, and --open.

Metadata

The generator reads regular Go comments from source files to fill operation summaries, operation descriptions, and schema field descriptions. It does not require doc tags. Handler comments can also include an openapi: block for operation-level metadata; when summary or description are omitted from the block, the regular handler comment still provides them.

type CreateUserRequest struct {
	// Display name for the new user.
	Name string `json:"name" binding:"required"`
}

// Create user.
//
// Creates a user and returns the persisted representation.
//
// openapi:
//   x-public: true
//   x-audience: external
func createUser(ctx *fox.Context, req CreateUserRequest) (UserResponse, error) {
	return UserResponse{}, nil
}

The openapi: block is removed from the generated description. It supports OpenAPI extension fields such as x-public and x-audience, plus simple operation fields such as summary, description, operationId, tags, and deprecated.

For metadata that needs Go values, add a small optional hook:

func ConfigureOpenAPI() []openapi.Option {
	return []openapi.Option{
		openapi.Group("/users", openapi.Tags("users")),
		openapi.Operation("GET", "/users/:id", openapi.Security("BearerAuth")),
	}
}

Then configure it:

metadataHook: github.com/acme/myapp/internal/openapimeta.ConfigureOpenAPI

Explicit success responses override the default success response inferred from the handler return type. For simple status wrapper helpers such as return statusResponse(http.StatusCreated, UserResponse{}), nil, Source can infer the response status from the return statement and use the wrapper's payload type as the response schema, so most handlers do not need a metadata hook just to document 201 or 202 responses.

Library Usage

The library mount API is useful for dev-time experiments, but the CLI is recommended for production artifacts.

package main

import (
	"github.com/fox-gonic/fox"
	"github.com/fox-gonic/openapi"
)

func main() {
	router := fox.Default()
	router.GET("/users/:id", getUser)

	spec := openapi.New(router,
		openapi.Info("My API", "1.0.0"),
		openapi.Server("https://api.example.com"),
		openapi.Source([]string{"."}),
		openapi.Operation("GET", "/users/:id", openapi.Tags("users")),
		openapi.WithFilters(openapi.PruneUnusedComponents()),
	)

	openapi.Mount(router, spec)
	router.Run(":8080")
}

By default, openapi.Mount registers /openapi.yaml and /openapi.json. You can also write artifacts directly:

if err := spec.WriteYAML(file); err != nil {
	panic(err)
}

yamlData, err := spec.YAML()
jsonData, err := spec.JSON()

Generation is best-effort. Non-fatal issues are collected as warnings:

for _, warning := range spec.Warnings() {
	log.Println(warning)
}

Generated Output

The generator covers:

  • OpenAPI version 3.0.3
  • info, servers, top-level tags, and security schemes
  • paths and methods from registered Fox routes
  • route manifest input when running the application is not desirable
  • Gin-style path parameters such as /users/:id as /users/{id}
  • uri, query, header, json, and form request fields
  • operation and schema descriptions from source comments
  • explicit operation and group metadata, including security and extensions
  • inferred success responses, explicit responses, status wrappers, no-body success statuses, and default error responses
  • reusable component schemas with recursive $ref support
  • post-generation operation filters and unused component pruning
  • custom type schema overrides through openapi.RegisterFormatter

Supported validation tags include required, email, url, uri, uuid, uuid4, min, max, gte, lte, gt, lt, len, oneof, and alphanum.

CI

- name: Generate OpenAPI spec
  run: fox-openapi generate
- name: Verify spec is up to date
  run: git diff --exit-code api/openapi.yaml

For manifest mode, refresh the application-owned manifest before generating:

- name: Refresh route manifest
  run: go run ./cmd/myapp --openapi-route-manifest api/routes.manifest.json
- name: Generate OpenAPI spec
  run: fox-openapi generate --route-manifest api/routes.manifest.json --out api/openapi.yaml
- name: Verify spec is up to date
  run: git diff --exit-code api/routes.manifest.json api/openapi.yaml

Troubleshooting

  • entry is required: no entry provided and auto-discovery found 0 or multiple candidates. Set entry in fox-openapi.yaml, pass --entry, or add // fox-openapi:entry to the canonical function.
  • Exit code 2: generated driver failed to build. Check imports, replaces, and entry/hook signatures.
  • Exit code 3: the driver built but failed at runtime. Check entry side effects or returned errors.
  • Exit code 4: check found drift; run fox-openapi generate and commit the updated spec.
  • unsupported route manifest version: regenerate the manifest with a compatible github.com/fox-gonic/fox version and rerun fox-openapi.

Current Limitations

The current implementation intentionally does not generate DomainEngine-specific multi-host specs or custom schema naming overrides. CLI filtering currently supports scalar extension equality plus component pruning; use the Go filter API for richer predicates such as path, method, operation ID, tags, or deprecation. Use handler comment openapi: blocks for simple operation metadata and metadataHook when metadata needs Go values.

Documentation

Overview

Package openapi generates OpenAPI specs from Fox routes and handler signatures.

Index

Constants

View Source
const RouteManifestVersion = "fox.route-manifest/v1"

RouteManifestVersion is the supported Fox route manifest format version.

Variables

This section is empty.

Functions

func ApplyFilters added in v0.4.0

func ApplyFilters(spec *openapi3.T, filters ...Filter) error

ApplyFilters applies filters in order.

func ApplySpecMetadata

func ApplySpecMetadata(spec *openapi3.T, metadata SpecMetadata)

ApplySpecMetadata applies top-level metadata to a generated OpenAPI model.

func CleanHandlerName added in v0.4.0

func CleanHandlerName(name string) string

CleanHandlerName strips runtime decorations from a Go handler symbol.

func HTTPBearerSecurity

func HTTPBearerSecurity(description string) *openapi3.SecurityScheme

HTTPBearerSecurity creates an HTTP bearer security scheme.

func JSONHandler

func JSONHandler(g *Generator) fox.HandlerFunc

JSONHandler returns a Fox handler that serves the generated JSON spec.

func MarshalSpecJSON

func MarshalSpecJSON(spec *openapi3.T) ([]byte, error)

MarshalSpecJSON serializes an OpenAPI model as formatted JSON.

func MarshalSpecYAML

func MarshalSpecYAML(spec *openapi3.T) ([]byte, error)

MarshalSpecYAML serializes an OpenAPI model as YAML.

func Mount

func Mount(router Router, g *Generator, opts ...MountOption)

Mount registers YAML and JSON spec endpoints on the router.

router accepts *fox.Engine or *fox.RouterGroup. Mount forces spec generation immediately so the spec endpoints themselves are not included in the generated paths. Routes registered after Mount are not picked up unless the caller invokes Generator.Regenerate().

func YAMLHandler

func YAMLHandler(g *Generator) fox.HandlerFunc

YAMLHandler returns a Fox handler that serves the generated YAML spec.

Types

type Filter added in v0.4.0

type Filter func(*openapi3.T) error

Filter mutates a generated OpenAPI document.

func ExcludeOperationsWithExtensionValue added in v0.4.0

func ExcludeOperationsWithExtensionValue(extension string, value any) Filter

ExcludeOperationsWithExtensionValue removes operations whose extension equals the provided scalar value.

func FilterOperationExpression added in v0.4.0

func FilterOperationExpression(expression string) (Filter, error)

FilterOperationExpression builds an operation filter from a small expression language: "field = value", "field == value", or "field != value". Field names currently address operation extensions such as x-public or x-product.

func FilterOperations added in v0.4.0

func FilterOperations(keep func(OperationContext) bool) Filter

FilterOperations removes operations for which keep returns false. Paths with no remaining operations are removed.

func PruneUnusedComponents added in v0.4.0

func PruneUnusedComponents() Filter

PruneUnusedComponents removes components that are no longer reachable from paths, operations, top-level security requirements, or other reachable components.

func StripOperationExtension added in v0.4.0

func StripOperationExtension(extension string) Filter

StripOperationExtension removes an extension from all retained operations.

type Generator

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

Generator builds and serializes an OpenAPI specification for a Fox engine.

Generation is lazy: routes registered after New() are still picked up on the next Spec()/JSON()/YAML() call. Schemas are cached across regenerations so repeated calls only re-walk the route table.

func New

func New(engine *fox.Engine, opts ...Option) *Generator

New creates a Generator and immediately scans the engine's current routes.

func NewFromRouteManifest added in v0.4.0

func NewFromRouteManifest(manifest RouteManifest, opts ...Option) *Generator

NewFromRouteManifest creates a Generator from a Fox route manifest instead of a live Engine.

func (*Generator) Err added in v0.4.0

func (g *Generator) Err() error

Err returns the generation error, if any.

func (*Generator) JSON

func (g *Generator) JSON() ([]byte, error)

JSON serializes the generated spec as formatted JSON.

func (*Generator) Regenerate

func (g *Generator) Regenerate()

Regenerate forces a full re-scan of the engine's routes on the next access. Useful when routes are added dynamically and the caller wants the next JSON()/YAML() call to reflect them without retaining stale state.

func (*Generator) Spec

func (g *Generator) Spec() *openapi3.T

Spec returns the generated OpenAPI model. Generation errors are ignored; call SpecErr or Err when the generator was configured with filters that can fail.

func (*Generator) SpecErr added in v0.4.0

func (g *Generator) SpecErr() (*openapi3.T, error)

SpecErr returns the generated OpenAPI model and any generation error.

func (*Generator) Warnings

func (g *Generator) Warnings() []string

Warnings returns non-fatal generation warnings, triggering generation if it has not yet happened. Call WarningsErr or Err to inspect fatal generation errors.

func (*Generator) WarningsErr added in v0.4.0

func (g *Generator) WarningsErr() ([]string, error)

WarningsErr returns non-fatal generation warnings and any generation error.

func (*Generator) WriteYAML

func (g *Generator) WriteYAML(w io.Writer) error

WriteYAML writes the generated YAML spec to w.

func (*Generator) YAML

func (g *Generator) YAML() ([]byte, error)

YAML serializes the generated spec as YAML.

type MountOption

type MountOption func(*mountConfig)

MountOption configures OpenAPI spec endpoint mounting.

func MountJSON

func MountJSON(path string) MountOption

MountJSON sets the JSON spec endpoint path. Empty string disables.

func MountYAML

func MountYAML(path string) MountOption

MountYAML sets the YAML spec endpoint path. Empty string disables.

type OAuthFlowConfig

type OAuthFlowConfig struct {
	AuthorizationURL string
	TokenURL         string
	RefreshURL       string
	Scopes           map[string]string
}

OAuthFlowConfig describes a serializable OAuth2 flow.

type OAuthFlowsConfig

type OAuthFlowsConfig struct {
	Implicit          *OAuthFlowConfig
	Password          *OAuthFlowConfig
	ClientCredentials *OAuthFlowConfig
	AuthorizationCode *OAuthFlowConfig
}

OAuthFlowsConfig describes serializable OAuth2 flows.

type OperationContext added in v0.4.0

type OperationContext struct {
	OperationID string
	Path        string
	Method      string
	PathItem    *openapi3.PathItem
	Operation   *openapi3.Operation
}

OperationContext describes an operation while filtering.

func (OperationContext) Extension added in v0.4.0

func (o OperationContext) Extension(name string) (any, bool)

Extension returns an operation extension value.

func (OperationContext) ExtensionBoolDefault added in v0.4.0

func (o OperationContext) ExtensionBoolDefault(name string, fallback bool) bool

ExtensionBoolDefault returns a boolean extension value or fallback when the extension is absent or not a boolean.

type OperationOption

type OperationOption func(*operationDoc)

OperationOption configures explicit metadata for one operation.

func Deprecated

func Deprecated(value bool) OperationOption

Deprecated marks the operation as deprecated.

func Description

func Description(value string) OperationOption

Description sets the operation description.

func OperationID

func OperationID(value string) OperationOption

OperationID sets the operationId.

func Response

func Response(status int, body any, description string) OperationOption

Response adds or replaces a response for the operation.

func Security

func Security(name string, scopes ...string) OperationOption

Security adds a security requirement to the operation.

func Summary

func Summary(value string) OperationOption

Summary sets the operation summary.

func Tags

func Tags(values ...string) OperationOption

Tags sets the operation tags.

type Option

type Option func(*Generator)

Option configures a Generator.

func Group

func Group(prefix string, opts ...OperationOption) Option

Group adds metadata to operations whose Fox route path starts with prefix.

func Info

func Info(title, version string) Option

Info sets the OpenAPI info title and version.

func Operation

func Operation(method, path string, opts ...OperationOption) Option

Operation adds explicit metadata for a registered route.

func RegisterFormatter

func RegisterFormatter(typ reflect.Type, schema *openapi3.Schema) Option

RegisterFormatter overrides schema generation for a Go type.

func SecurityScheme

func SecurityScheme(name string, scheme *openapi3.SecurityScheme) Option

SecurityScheme registers an OpenAPI security scheme.

func SecuritySchemeFromConfig

func SecuritySchemeFromConfig(name string, scheme SecuritySchemeConfig) Option

SecuritySchemeFromConfig registers a serializable OpenAPI security scheme.

func Server

func Server(url string) Option

Server appends a server URL to the generated OpenAPI spec.

func SetErrorSchema

func SetErrorSchema(body any) Option

SetErrorSchema overrides the default error response schema.

func Source

func Source(paths []string, opts ...SourceOption) Option

Source enables Go comment extraction from the provided paths. A path ending in "/..." recursively walks the tree skipping vendor and dot-prefixed directories. Test files (_test.go) are skipped unless IncludeTestFiles is passed.

func WithFilters added in v0.4.0

func WithFilters(filters ...Filter) Option

WithFilters applies post-generation filters before the spec is serialized.

type RouteManifest added in v0.4.0

type RouteManifest struct {
	Version string               `json:"version"`
	Routes  []RouteManifestRoute `json:"routes"`
}

RouteManifest is the route registry exchange format written by Fox.

type RouteManifestField added in v0.4.0

type RouteManifestField struct {
	Name      string            `json:"name"`
	PkgPath   string            `json:"pkgPath,omitempty"`
	Tag       string            `json:"tag,omitempty"`
	Anonymous bool              `json:"anonymous,omitempty"`
	Type      RouteManifestType `json:"type"`
}

RouteManifestField is a serializable subset of Go reflect.StructField.

type RouteManifestRoute added in v0.4.0

type RouteManifestRoute struct {
	Method      string              `json:"method"`
	Path        string              `json:"path"`
	Handler     string              `json:"handler,omitempty"`
	HandlerName string              `json:"handlerName,omitempty"`
	HandlerType string              `json:"handlerType,omitempty"`
	Inputs      []string            `json:"inputs,omitempty"`
	Results     []string            `json:"results,omitempty"`
	InputTypes  []RouteManifestType `json:"inputTypes,omitempty"`
	ResultTypes []RouteManifestType `json:"resultTypes,omitempty"`
}

RouteManifestRoute describes one registered Fox route.

func (RouteManifestRoute) HandlerSymbol added in v0.4.0

func (route RouteManifestRoute) HandlerSymbol() string

type RouteManifestType added in v0.4.0

type RouteManifestType struct {
	Kind     string               `json:"kind"`
	String   string               `json:"string,omitempty"`
	Name     string               `json:"name,omitempty"`
	PkgPath  string               `json:"pkgPath,omitempty"`
	TypeArgs []RouteManifestType  `json:"typeArgs,omitempty"`
	Key      *RouteManifestType   `json:"key,omitempty"`
	Elem     *RouteManifestType   `json:"elem,omitempty"`
	Fields   []RouteManifestField `json:"fields,omitempty"`
}

RouteManifestType is a serializable subset of Go reflect.Type.

type Router

type Router interface {
	GET(relativePath string, handlers ...fox.HandlerFunc) gin.IRoutes
}

Router is the minimal surface Mount needs — both *fox.Engine and *fox.RouterGroup satisfy it.

type SecuritySchemeConfig

type SecuritySchemeConfig struct {
	Type             string
	Description      string
	Name             string
	In               string
	Scheme           string
	BearerFormat     string
	OpenIDConnectURL string
	Flows            *OAuthFlowsConfig
}

SecuritySchemeConfig describes a serializable OpenAPI security scheme.

type SourceOption

type SourceOption func(*sourceConfig)

SourceOption configures Source.

func IncludeTestFiles

func IncludeTestFiles() SourceOption

IncludeTestFiles makes Source also scan _test.go files. By default test files are skipped so comments authored in tests do not bleed into production specs; this option exists for the rare case where handler documentation lives in test fixtures.

type SpecExternalDocs

type SpecExternalDocs struct {
	Description string
	URL         string
}

SpecExternalDocs describes top-level tag external documentation.

type SpecMetadata

type SpecMetadata struct {
	InfoDescription    string
	ServerDescriptions []string
	Tags               []SpecTag
}

SpecMetadata contains top-level OpenAPI metadata used by generated drivers.

type SpecTag

type SpecTag struct {
	Name         string
	Description  string
	ExternalDocs *SpecExternalDocs
}

SpecTag describes a top-level OpenAPI tag.

Directories

Path Synopsis
cmd
fox-openapi command
internal
cli
collisionfixture/v1/users
Package users in v1 path collides on short name with v2/users.
Package users in v1 path collides on short name with v2/users.
collisionfixture/v2/users
Package users in v2 path collides on short name with v1/users.
Package users in v2 path collides on short name with v1/users.

Jump to

Keyboard shortcuts

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