codegen

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package codegen defines the intermediate representation used by generate parsers before template rendering.

Index

Constants

View Source
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

func DeriveNameWord(value string) string

DeriveNameWord normalizes a name into a compact lower-case token for paths.

func LowerCamel added in v0.8.0

func LowerCamel(value string) string

LowerCamel converts human-readable identifiers into lowerCamelCase.

func SplitWords added in v0.8.0

func SplitWords(value string) []string

SplitWords breaks identifiers like "PetAdmin", "pet-admin", or "pet_admin" into words.

func ValidateIfExistsStrategy added in v0.8.0

func ValidateIfExistsStrategy(strategy string) error

ValidateIfExistsStrategy validates supported conflict strategies.

Types

type AuthScheme

type AuthScheme struct {
	Key      string
	Type     string
	Name     string
	Location string
}

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 Group

type Group struct {
	Name     string
	Requests []Request
}

Group collects related requests, usually by tag or a stable path segment.

type Header struct {
	Name     string
	Value    string
	Required bool
}

Header describes one request header requirement.

type Param

type Param struct {
	Name     string
	In       string
	Type     string
	Format   string
	Required bool
}

Param describes one non-header request parameter.

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.

type Response

type Response struct {
	StatusCode  string
	Description string
}

Response captures one response status and description from the source spec.

type Spec

type Spec struct {
	Title       string
	Version     string
	BasePath    string
	Groups      []Group
	AuthSchemes []AuthScheme
}

Spec is the top-level intermediate representation of an API specification.

Directories

Path Synopsis
Package parser turns API specifications into the internal code generation intermediate representation.
Package parser turns API specifications into the internal code generation intermediate representation.

Jump to

Keyboard shortcuts

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