openapi

package
v1.30.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SchemaRef

func SchemaRef(name string) string

Types

type Components

type Components struct {
	Schemas map[string]Schema `json:"schemas,omitempty"`
}

type Content

type Content struct {
	Schema Schema `json:"schema"`
}

type Contents

type Contents struct {
	ApplicationJSON               *Content `json:"application/json,omitempty"`
	ApplicationXWWWFormUrlencoded *Content `json:"application/x-www-form-urlencoded,omitempty"`
}

func (Contents) Iter

func (c Contents) Iter() (res []Content)

type Format

type Format string
const (
	Uuid     Format = "uuid"
	Binary   Format = "binary"
	Email    Format = "email"
	Int32    Format = "int32"
	Int64    Format = "int64"
	Base64   Format = "base64"
	DateTime Format = "date-time"
)

type Info

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

type Operation

type Operation struct {
	Summary     string       `json:"summary"`
	Description string       `json:"description,omitempty"`
	Responses   Responses    `json:"responses"`
	RequestBody *RequestBody `json:"requestBody,omitempty"`
}

type Parameter

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

func PathParameter

func PathParameter(name, description string) Parameter

type Path

type Path struct {
	Parameters []Parameter `json:"parameters,omitempty"`
	Get        *Operation  `json:"get,omitempty"`
	Post       *Operation  `json:"post,omitempty"`
	Put        *Operation  `json:"put,omitempty"`
	Delete     *Operation  `json:"delete,omitempty"`
}

func (Path) Iter

func (p Path) Iter() (res []Operation)

type RequestBody

type RequestBody struct {
	Content Contents `json:"content,omitempty"`
}

type Response

type Response struct {
	Description string   `json:"description"`
	Content     Contents `json:"content"`
}

type Responses

type Responses struct {
	Status200 *Response `json:"200,omitempty"`
	Status404 *Response `json:"404,omitempty"`
	Status403 *Response `json:"403,omitempty"`
	Status422 *Response `json:"422,omitempty"`
}

func (Responses) Iter

func (r Responses) Iter() (res []Response)

type Root

type Root struct {
	Openapi    string          `json:"openapi"`
	Info       Info            `json:"info"`
	Servers    []Server        `json:"servers,omitempty"`
	Paths      map[string]Path `json:"paths"`
	Components Components      `json:"components"`
}

type Schema

type Schema struct {
	Type                 Type              `json:"type,omitempty"`
	Format               Format            `json:"format,omitempty"`
	Properties           map[string]Schema `json:"properties,omitempty"`
	Items                *Schema           `json:"items,omitempty"`
	Required             []string          `json:"required,omitempty"`
	Description          string            `json:"description,omitempty"`
	Example              interface{}       `json:"example,omitempty"`
	Ref                  string            `json:"$ref,omitempty"`
	AdditionalProperties *Schema           `json:"additionalProperties,omitempty"`
}

func SchemaArrayFromTdField

func SchemaArrayFromTdField(tdField codegen.TdStructField) Schema

func SchemaFromTdField

func SchemaFromTdField(tdField codegen.TdStructField) (res Schema)

func SchemaFromType

func SchemaFromType(v interface{}) Schema

func SchemaFromTypeName

func SchemaFromTypeName(name string) Schema

func (Schema) Refs

func (s Schema) Refs() []string

type Server

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

type Type

type Type string
const (
	String  Type = "string"
	Array   Type = "array"
	Object  Type = "object"
	Boolean Type = "boolean"
	Number  Type = "number"
)

Jump to

Keyboard shortcuts

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