oas

package
v1.2.85 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplicationJsonContent

func ApplicationJsonContent(v *Schema) (c map[string]*MediaType)

func ComponentsSchemaURI

func ComponentsSchemaURI(key string) (v string)

func ElementKey

func ElementKey(key string) string

Types

type API

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

func Openapi

func Openapi(title string, description string, term string, openapiVersion string, document spec.Document) (api API)

func (*API) Encode

func (api *API) Encode() (p []byte, err error)

func (*API) Merge

func (api *API) Merge(o *API)

type Components

type Components struct {
	Schemas   map[string]*Schema   `json:"schemas,omitempty"`
	Responses map[string]*Response `json:"responses,omitempty"`
}
type Header struct {
	Description string  `json:"description,omitempty"`
	Schema      *Schema `json:"schema,omitempty"`
}

type Info

type Info struct {
	Title          string      `json:"title,omitempty"`
	Description    string      `json:"description,omitempty"`
	TermsOfService string      `json:"termsOfService,omitempty"`
	Contact        interface{} `json:"contact,omitempty"`
	License        interface{} `json:"license,omitempty"`
	Version        string      `json:"version,omitempty"`
}

func (*Info) SetContact

func (v *Info) SetContact(name string, url string, email string)

func (*Info) SetLicense

func (v *Info) SetLicense(name string, url string)

type MediaType

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

type Operation

type Operation struct {
	OperationId string              `json:"operationId,omitempty"`
	Tags        []string            `json:"tags,omitempty"`
	Summary     string              `json:"summary,omitempty"`
	Description string              `json:"description,omitempty"`
	Deprecated  bool                `json:"deprecated,omitempty"`
	Parameters  []Parameter         `json:"parameters,omitempty"`
	RequestBody *RequestBody        `json:"requestBody,omitempty"`
	Responses   map[string]Response `json:"responses,omitempty"`
}

type Parameter

type Parameter struct {
	Name string `json:"name,omitempty"`
	// In header query path cookie
	In          string `json:"in,omitempty"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

type Path

type Path struct {
	Get  *Operation `json:"get,omitempty"`
	Post *Operation `json:"post,omitempty"`
}

type RequestBody

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

type Response

type Response struct {
	Description string                `json:"description,omitempty"`
	Header      map[string]*Header    `json:"header,omitempty"`
	Content     map[string]*MediaType `json:"content,omitempty"`
	Ref         string                `json:"$ref,omitempty"`
}

type Schema

type Schema struct {
	Key                  string             `json:"-"`
	Title                string             `json:"title,omitempty"`
	Description          string             `json:"description,omitempty"`
	Type                 string             `json:"type,omitempty"`
	Required             []string           `json:"required,omitempty"`
	Format               string             `json:"format,omitempty"`
	Enum                 []interface{}      `json:"enum,omitempty"`
	Properties           map[string]*Schema `json:"properties,omitempty"`
	Items                *Schema            `json:"items,omitempty"`
	AdditionalProperties *Schema            `json:"additionalProperties,omitempty"`
	Deprecated           bool               `json:"deprecated,omitempty"`
	Example              interface{}        `json:"example,omitempty"`
	Ref                  string             `json:"$ref,omitempty"`
}

func ElementSchema

func ElementSchema(element documents.Element) (v *Schema)

func RefSchema

func RefSchema(key string) (v *Schema)

type Server

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

type Tag

type Tag struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
}

Jump to

Keyboard shortcuts

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