spec

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LowerFirst

func LowerFirst(s string) string

LowerFirst handles lower first.

func RefName

func RefName(ref string) string

RefName handles ref name.

func SafeArgName

func SafeArgName(s string) string

SafeArgName converts a generated argument name into a valid, non-keyword Go identifier.

func SortedKeys

func SortedKeys[T any](m map[string]T) []string

SortedKeys handles sorted keys.

func StatusSuffix

func StatusSuffix(status int) string

StatusSuffix handles status suffix.

func ToGoName

func ToGoName(s string) string

ToGoName converts value to target representation.

Types

type Document

type Document struct {
	Schemas    []Schema
	Operations []Operation
}

func Load

func Load(path string) (*Document, error)

Load loads data and resolves configuration.

type ErrorResponse

type ErrorResponse struct {
	Status int
	Schema string
}

type Field

type Field struct {
	Name     string
	JSONName string
	Type     string
	Kind     FieldKind
	RefName  string
	Optional bool
}

type FieldKind

type FieldKind string
const (
	FieldPrimitive      FieldKind = "primitive"
	FieldRef            FieldKind = "ref"
	FieldArrayPrimitive FieldKind = "array_primitive"
	FieldArrayRef       FieldKind = "array_ref"
)

type Operation

type Operation struct {
	ID             string
	Summary        string
	Method         string
	Path           string
	RequestSchema  string
	Params         []Param
	SuccessSchema  string
	ErrorResponses []ErrorResponse
}

type Param

type Param struct {
	Name            string
	GoName          string
	ArgName         string
	Type            string
	Location        string
	Required        bool
	ClientFieldName string
}

type Schema

type Schema struct {
	Name                  string
	Kind                  SchemaKind
	Type                  string
	RefName               string
	Fields                []Field
	EnumValues            []string
	DiscriminatorProperty string
	DiscriminatorField    string
	Variants              []Variant
}

type SchemaKind

type SchemaKind string
const (
	SchemaObject         SchemaKind = "object"
	SchemaPrimitiveAlias SchemaKind = "primitive_alias"
	SchemaEnumAlias      SchemaKind = "enum_alias"
	SchemaArrayPrimitive SchemaKind = "array_primitive"
	SchemaArrayRef       SchemaKind = "array_ref"
	SchemaOneOf          SchemaKind = "one_of"
)

type Variant

type Variant struct {
	FieldName string
	RefName   string
	JSONName  string
	TagValue  string
}

Jump to

Keyboard shortcuts

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