enum_overrides

package
v0.36.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package enum_overrides isolates the v1 behavior of `enum:` when it coexists with (or replaces) `swagger:enum TypeName` const-value inference. The golden output of TestCoverage_EnumOverrides is the factual reference for what the v2 parser migration must preserve — or consciously diverge from — under W2's override semantics (`.claude/plans/workshops/w2-enum.md` §2.6).

Five cases, one per model in this file:

A. swagger:enum + matching consts, no inline enum on field → consts
B. inline comma-list on field, no swagger:enum, no consts       → inline
C. inline JSON array on field, no swagger:enum, no consts       → inline
D. swagger:enum but NO matching consts in package               → ?
E. swagger:enum + matching consts + inline enum on field        → ?

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NotificationA

type NotificationA struct {
	// required: true
	ID int64 `json:"id"`

	// The priority level. Enum values come from PriorityA's consts.
	Priority PriorityA `json:"priority"`
}

NotificationA exercises case A: field uses PriorityA, no inline enum override.

swagger:model NotificationA

type NotificationB

type NotificationB struct {
	// The priority level.
	//
	// enum: low, medium, high
	Priority string `json:"priority"`
}

NotificationB exercises case B: plain string field with inline comma-list enum. No swagger:enum on the type, no consts in code.

swagger:model NotificationB

type NotificationC

type NotificationC struct {
	// The priority level.
	//
	// enum: ["low","medium","high"]
	Priority string `json:"priority"`
}

NotificationC exercises case C: inline JSON-array enum.

swagger:model NotificationC

type NotificationD

type NotificationD struct {
	// The priority level.
	Priority PriorityD `json:"priority"`
}

NotificationD exercises case D.

swagger:model NotificationD

type NotificationE

type NotificationE struct {
	// Inline enum provides a narrower set than the const block.
	//
	// enum: urgent, normal
	Priority PriorityE `json:"priority"`
}

NotificationE exercises case E: the inline enum on the field competes with the const-derived enum from PriorityE. The golden output captures which one wins in v1.

swagger:model NotificationE

type PriorityA

type PriorityA string

PriorityA is a classic linked-const enum.

swagger:enum PriorityA

const (
	PriorityALow  PriorityA = "low"
	PriorityAMed  PriorityA = "medium"
	PriorityAHigh PriorityA = "high"
)

type PriorityD

type PriorityD string

PriorityD has a swagger:enum annotation but no corresponding const declarations in this package. The builder's FindEnumValues call returns an empty slice; the test captures how the spec renders in that case.

swagger:enum PriorityD

type PriorityE

type PriorityE string

PriorityE has both a linked-const set AND fields will provide an inline override.

swagger:enum PriorityE

const (
	PriorityELow  PriorityE = "low"
	PriorityEMed  PriorityE = "medium"
	PriorityEHigh PriorityE = "high"
)

Jump to

Keyboard shortcuts

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