schema

package module
v0.0.0-...-6deb74b Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	String  TypeName = "string"
	Number  TypeName = "number"
	Integer TypeName = "integer"
	Object  TypeName = "object"
	Array   TypeName = "array"
	Boolean TypeName = "boolean"
	Null    TypeName = "null"

	// TODO: Date     Format = "date"
	DateTime Format = "date-time"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Info    Info            `json:"info"`
	Servers []Server        `json:"servers"`
	Paths   map[string]Path `json:"paths"`
}

type Format

type Format string

type Info

type Info struct {
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
	Version     string `json:"version"`
}

type MediaType

type MediaType struct {
	Description string  `json:"description,omitempty"`
	Schema      *Schema `json:"schema,omitempty"`
}

type Operation

type Operation struct {
	Params   []Param             `json:"parameters,omitempty"`
	ReqBody  ReqBody             `json:"requestBody"`
	Response map[string]Response `json:"response"`
}

type Option

type Option func(*config)

func CustomType

func CustomType(packagePath, typeName string, fn func(reflect.Type) Type) Option

func Tags

func Tags(tag ...string) Option

type Param

type Param struct {
	Name        string        `json:"name"`
	In          ParamLocation `json:"in"`
	Description string        `json:"description,omitempty"`
	Required    bool          `json:"required,omitempty"`
}

type ParamLocation

type ParamLocation string
const (
	QueryParam  ParamLocation = "query"
	HeaderParam ParamLocation = "header"
	PathParam   ParamLocation = "path"
	CookieParam ParamLocation = "cookie"
)

type Path

type Path struct {
	Summary     string     `json:"summary,omitempty"`
	Description string     `json:"description,omitempty"`
	Get         *Operation `json:"get,omitempty"`
	Put         *Operation `json:"put,omitempty"`
	Post        *Operation `json:"post,omitempty"`
	Delete      *Operation `json:"delete,omitempty"`
	Options     *Operation `json:"options,omitempty"`
	Head        *Operation `json:"head,omitempty"`
	Patch       *Operation `json:"patch,omitempty"`
	Trace       *Operation `json:"trace,omitempty"`
}

type Properties

type Properties map[string]Type

type ReqBody

type ReqBody struct {
	Description string               `json:"description,omitempty"`
	Content     map[string]MediaType `json:"content"`
	Required    bool                 `json:"required,omitempty"`
}

type Response

type Response struct {
	Description string               `json:"description,omitempty"`
	Content     map[string]MediaType `json:"content"`
}

type Schema

type Schema struct {
	Definitions map[string]Type `json:"definitions,omitempty"`
}

type Server

type Server struct {
	URL         string `json:"url"`
	Description string `json:"description,omitempty"`
}

type Type

type Type struct {
	Type       TypeName   `json:"type,omitempty"`
	Format     Format     `json:"format,omitempty"`
	Properties Properties `json:"properties,omitempty"`
	Items      *Type      `json:"items,omitempty"`

	Tags map[string]string `json:"tags,omitempty"`
}

func ResolveType

func ResolveType[T any](opts ...Option) Type

func ResolveTypeOf

func ResolveTypeOf(v any, opts ...Option) Type

func (Type) ExampleJSON

func (t Type) ExampleJSON() string

func (Type) ExampleValue

func (t Type) ExampleValue() any

func (Type) JSONName

func (t Type) JSONName(key string) string

type TypeName

type TypeName string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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