example

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package example modified from https://github.com/danielgtaylor/apisprout

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoExample is sent when no example was found for an operation.
	ErrNoExample = errors.New("no example found")

	// ErrRecursive is when a schema is impossible to represent because it infinitely recurses.
	ErrRecursive = errors.New("recursive schema")

	// ErrCannotMarshal is set when an example cannot be marshalled.
	ErrCannotMarshal = errors.New("cannot marshal example")

	// ErrMissingAuth is set when no authorization header or key is present but
	// one is required by the API description.
	ErrMissingAuth = errors.New("missing auth")

	// ErrInvalidAuth is set when the authorization scheme doesn't correspond
	// to the one required by the API description.
	ErrInvalidAuth = errors.New("invalid auth")
)

Functions

func GetBodyExample

func GetBodyExample(mode Mode, mt *openapi3.MediaType) (interface{}, error)

GetBodyExample ###

func GetParameterExample

func GetParameterExample(mode Mode, p *openapi3.Parameter) (interface{}, error)

GetParameterExample ###

func GetResponseExample

func GetResponseExample(mode Mode, p *openapi3.MediaType) (interface{}, error)

GetResponseExample ###

func OpenAPIExample

func OpenAPIExample(mode Mode, schema *openapi3.Schema) (interface{}, error)

OpenAPIExample creates an example structure from an OpenAPI 3 schema object, which is an extended subset of JSON Schema. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#schemaObject

Types

type Mode

type Mode int

Mode defines a mode of operation for example generation.

const (
	// ModeRequest is for the request body (writes to the server)
	ModeRequest Mode = iota
	// ModeResponse is for the response body (reads from the server)
	ModeResponse
)

Jump to

Keyboard shortcuts

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