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 ¶
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 ¶
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 ¶
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.