apischema

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package apischema derives the JSON schema of an API method's input and output from its Go type, and checks a JSON value against it, so every method is typed once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(s *Schema, raw json.RawMessage) error

Check validates a JSON document against s. Errors name the path from "params", for example `params.name: must be a string`.

Types

type Schema

type Schema struct {
	Type                 string             `json:"type"`
	Description          string             `json:"description,omitempty"`
	Properties           map[string]*Schema `json:"properties,omitempty"`
	Required             []string           `json:"required,omitempty"`
	AdditionalProperties *bool              `json:"additionalProperties,omitempty"`
	Items                *Schema            `json:"items,omitempty"`
}

Schema is the subset of JSON Schema the API uses.

func For

func For(v any) *Schema

For derives the schema of v's type. It panics on a type it cannot describe, which is a programming error that tests catch.

Jump to

Keyboard shortcuts

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