diagnostics

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package diagnostics carries fixtures that exercise the schema builder's diagnostic emission path. Each type is annotated with at least one deliberately invalid construct that the grammar parser rejects with a non-fatal diagnostic; the offending value is dropped from the output spec while the diagnostic flows through Builder.Diagnostics() / Options.OnDiagnostic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmbiguousEmbed

type AmbiguousEmbed struct {
	SharedFoo
	SharedBar
}

AmbiguousEmbed embeds two unrelated types that both promote the `shared` JSON property under different Go names. The schema builder emits a CodeAmbiguousEmbed diagnostic; the resulting spec is last-write-wins (Bar overrides Foo because struct fields iterate in source order — SharedBar is the later embed).

swagger:model AmbiguousEmbed

type BadMaximum

type BadMaximum struct {
	// Count holds an arbitrary count.
	//
	// maximum: notanumber
	Count int `json:"count"`
}

BadMaximum has an invalid maximum: value. The parser emits a CodeInvalidNumber diagnostic and the maximum keyword is dropped from the output schema.

swagger:model BadMaximum

type DepthInner

type DepthInner struct {
	Foo string `json:"shared"`
}

DepthInner carries `shared` under Go name Foo at the deeper layer.

swagger:model DepthInner

type DepthMiddle

type DepthMiddle struct {
	DepthInner
	Bar string `json:"shared"`
}

DepthMiddle re-declares `shared` under Go name Bar at its own (shallower) depth, on top of an embed of DepthInner.

swagger:model DepthMiddle

type DepthShadowingEmbed

type DepthShadowingEmbed struct {
	DepthMiddle
}

DepthShadowingEmbed exercises legitimate Go-depth-rule shadowing across an embed chain: DepthMiddle.Bar (depth 1 from the parent after embedding) shadows DepthInner.Foo (depth 2). The diagnostic must remain silent.

swagger:model DepthShadowingEmbed

type ExplicitOverride

type ExplicitOverride struct {
	SharedFoo
	Bar string `json:"shared"`
}

ExplicitOverride exercises the explicit-override case: a top-level struct embeds a type carrying `shared`, then re-declares `shared` as its own field. The explicit field wins at embedDepth = 0; the diagnostic must remain silent.

swagger:model ExplicitOverride

type SharedBar

type SharedBar struct {
	Bar string `json:"shared"`
}

SharedBar carries a `shared` JSON property under Go name Bar.

swagger:model SharedBar

type SharedFoo

type SharedFoo struct {
	Foo string `json:"shared"`
}

SharedFoo carries a `shared` JSON property under Go name Foo.

swagger:model SharedFoo

Jump to

Keyboard shortcuts

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