schematest

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package schematest provides assertions for the JSON schemas a plugin publishes, so that the fields a user configures in the Dev UI stay documented.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDescribed

func AssertDescribed(t *testing.T, name string, schema map[string]any)

AssertDescribed reports every property in schema, at any depth, that lacks a description or whose description does not end in a period.

Schema inference does not read Go doc comments: github.com/invopop/jsonschema runs without a comment map, so a field is described only by a struct tag. The Dev UI renders that description as the tooltip on the help icon beside the field, so a field without one offers the user no explanation at all.

name identifies the schema in failure messages, e.g. the middleware name.

func AssertNoInlineDescriptions

func AssertNoInlineDescriptions(t *testing.T, dir string)

AssertNoInlineDescriptions reports every `jsonschema:"description=..."` tag in the .go files directly under dir, which must instead be written as a `jsonschema_description` tag.

github.com/invopop/jsonschema splits the `jsonschema` tag on commas to separate its keywords, so an inline description silently loses everything from its first comma onward: `description=If true, descend into subdirectories.` reaches the schema as "If true". The dedicated tag is read whole, so punctuation needs no thought.

`json:"recursive,omitempty" jsonschema_description:"If true, descend into subdirectories."`

Both forms produce the same schema, and a field may carry the dedicated tag alongside a `jsonschema` tag holding other keywords such as an enum.

Unlike AssertDescribed, this reads the source rather than a published schema, so it also covers schemas a plugin never exposes as a descriptor, such as tool input types.

Types

This section is empty.

Jump to

Keyboard shortcuts

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