Documentation
¶
Overview ¶
Package codegen defines the intermediate representation used by generate parsers before template rendering.
Index ¶
- Constants
- func DeriveNameWord(value string) string
- func LowerCamel(value string) string
- func SplitWords(value string) []string
- func ValidateIfExistsStrategy(strategy string) error
- type AuthScheme
- type BodySchema
- type ConflictResult
- type ConflictStatus
- type Group
- type Header
- type Param
- type Request
- type Response
- type Spec
Constants ¶
const ( // IfExistsSuffix writes a sibling *.generated file when the target already exists. IfExistsSuffix = "suffix" // IfExistsMerge writes conflict markers into the existing target file. IfExistsMerge = "merge" // IfExistsSkip leaves the existing target untouched. IfExistsSkip = "skip" // IfExistsOverwrite replaces the existing target file completely. IfExistsOverwrite = "overwrite" )
Variables ¶
This section is empty.
Functions ¶
func DeriveNameWord ¶ added in v0.8.0
DeriveNameWord normalizes a name into a compact lower-case token for paths.
func LowerCamel ¶ added in v0.8.0
LowerCamel converts human-readable identifiers into lowerCamelCase.
func SplitWords ¶ added in v0.8.0
SplitWords breaks identifiers like "PetAdmin", "pet-admin", or "pet_admin" into words.
func ValidateIfExistsStrategy ¶ added in v0.8.0
ValidateIfExistsStrategy validates supported conflict strategies.
Types ¶
type AuthScheme ¶
AuthScheme describes one supported authentication scheme.
type BodySchema ¶
type BodySchema struct {
Name string
Type string
Format string
Required bool
Raw string
Fields []BodySchema
Items *BodySchema
}
BodySchema captures a recursive request body schema tree.
type ConflictResult ¶ added in v0.8.0
type ConflictResult struct {
Path string
WrittenPath string
Status ConflictStatus
}
ConflictResult reports how one file write was resolved.
func WriteFileWithStrategy ¶ added in v0.8.0
func WriteFileWithStrategy(targetPath string, content []byte, strategy string) (ConflictResult, error)
WriteFileWithStrategy writes content to targetPath honoring the selected conflict strategy.
type ConflictStatus ¶ added in v0.8.0
type ConflictStatus string
const ( ConflictStatusWritten ConflictStatus = "written" ConflictStatusSkipped ConflictStatus = "skipped" ConflictStatusConflict ConflictStatus = "conflict" ConflictStatusOverwritten ConflictStatus = "overwritten" )
type Request ¶
type Request struct {
Method string
Path string
Name string
Summary string
Comments []string
Headers []Header
Params []Param
Body *BodySchema
Responses []Response
}
Request describes one generated API request shape.