openapi3gen

package
v1.28.0-dev Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package openapi3gen converts Gitea's Swagger 2.0 spec to an OpenAPI 3.0 spec. It discovers Go enum type names by scanning swagger:enum annotations in the source tree, then names extracted shared-enum schemas accordingly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(swaggerJSON []byte, astEnumMap map[string][]string) (*openapi3.T, error)

Convert parses a Swagger 2.0 spec and returns an OAS3 spec, applying Gitea-specific post-processing: file-schema fixups, URI formats, deprecated flags, and shared-enum extraction.

astEnumMap is a value-set-key → Go-type-name(s) map (built by ScanSwaggerEnumTypes). When a value set is shared by multiple Go types, per-property disambiguation uses the x-go-enum-desc extension. If a shared enum in the spec has no matching entry, Convert returns an error — no fallback naming.

func EnumKey

func EnumKey(values []any) string

EnumKey returns a canonical key for a set of enum values: values are stringified, sorted, and joined with "|". Used to match enum value sets across spec properties and scanned Go type declarations.

func ScanSwaggerEnumTypes

func ScanSwaggerEnumTypes(dirs []string) (map[string][]string, error)

ScanSwaggerEnumTypes walks .go files under each dir and returns a map from a canonical value-set key (see EnumKey) to the Go type names declared with // swagger:enum TypeName. Multiple type names per key are allowed (e.g. distinct enum types that happen to share a value set such as {public, limited, private}); callers must disambiguate per-usage (typically by parsing the property's x-go-enum-desc extension to recover the const type prefix).

Returns an error on parse failure or on an annotation for a type whose constants can't be extracted.

Types

This section is empty.

Jump to

Keyboard shortcuts

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