extension

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package extension reads the x-* extensions mockzilla-codegen knows into typed values.

Index

Constants

View Source
const (
	GoType           = "x-go-type"
	GoTypeImport     = "x-go-type-import"
	GoTypeName       = "x-go-type-name"
	GoName           = "x-go-name"
	GoNameExact      = "x-go-name-exact"
	SkipPointer      = "x-go-type-skip-optional-pointer"
	Nullable         = "x-go-nullable"
	JSONIgnore       = "x-go-json-ignore"
	OmitEmpty        = "x-omitempty"
	ExtraTags        = "x-go-extra-tags"
	EnumNames        = "x-enum-names"
	DeprecatedReason = "x-deprecated-reason"
	SensitiveData    = "x-sensitive-data"
	MCPName          = "x-mcp"
)

Names of the extensions Parse reads.

Variables

This section is empty.

Functions

This section is empty.

Types

type MCP

type MCP struct {
	Skip        *bool
	Name        string
	Description string
}

MCP is x-mcp on an operation.

func (*MCP) IsSkipped

func (m *MCP) IsSkipped(defaultSkip bool) bool

IsSkipped applies x-mcp.skip over the default of the config; a nil MCP is an operation without x-mcp.

type Mask

type Mask struct {
	Kind       MaskKind
	Pattern    string
	KeepPrefix int
	KeepSuffix int
}

Mask is x-sensitive-data. Pattern is the regular expression of MaskRegex; KeepPrefix and KeepSuffix are the characters MaskPartial leaves visible.

type MaskKind

type MaskKind int

MaskKind is how a sensitive value is masked.

const (
	MaskFull MaskKind = iota
	MaskRegex
	MaskHash
	MaskPartial
)

type Set

type Set struct {
	GoType           *Type
	TypeName         string
	Name             string
	IsExactName      bool
	IsPointerSkipped bool
	Nullable         *bool
	IsJSONIgnored    bool
	OmitEmpty        *bool
	Tags             []Tag
	EnumNames        []string
	DeprecatedReason string
	Sensitive        *Mask
	MCP              *MCP
}

Set holds the extensions of one schema, parameter or operation. Fields of extensions that are absent keep their zero value.

func Parse

func Parse(exts []spec.Extension, at spec.Origin) (Set, []diag.Diagnostic)

Parse reads exts, found at the given place. A value of the wrong type is left out with a warning, and so is an unknown name that looks like one of ours.

type Tag

type Tag struct {
	Key   string
	Value string
}

Tag is one struct tag of x-go-extra-tags.

type Type

type Type struct {
	Name  string
	Path  string
	Alias string
}

Type is x-go-type: Name as written, such as uuid.UUID or string, and the package x-go-type-import names, with the name to import it under.

Jump to

Keyboard shortcuts

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