openapi

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Components

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

type Contact

type Contact struct {
	Name  string `json:"name,omitempty"`
	Url   string `json:"url,omitempty"`
	Email string `json:"email,omitempty"`
}

type ContentType

type ContentType string
const (
	ContentTypeJson ContentType = "application/json"
	ContentTypeXml  ContentType = "application/xml"
	ContentTypeForm ContentType = "application/x-www-form-urlencoded"
)

func (ContentType) GetStructTag

func (c ContentType) GetStructTag() string

type Info

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

type License

type License struct {
	Name       string `json:"name,omitempty"`
	Url        string `json:"url,omitempty"`
	Identifier string `json:"identifier,omitempty"`
}

type MediaType

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

type OAuthFlow

type OAuthFlow struct {
	AuthorizationUrl string            `json:"authorizationUrl,omitempty"`
	TokenUrl         string            `json:"tokenUrl,omitempty"`
	RefreshUrl       string            `json:"refreshUrl,omitempty"`
	Scopes           map[string]string `json:"scopes,omitempty"`
}

type OAuthFlows

type OAuthFlows struct {
	Implicit          *OAuthFlow `json:"implicit,omitempty"`
	Password          *OAuthFlow `json:"password,omitempty"`
	ClientCredentials *OAuthFlow `json:"clientCredentials,omitempty"`
	AuthorizationCode *OAuthFlow `json:"authorizationCode,omitempty"`
}

type Openapi

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

func (*Openapi) GetRefSchema

func (o *Openapi) GetRefSchema(ref string) *Schema

func (*Openapi) NewSchema

func (o *Openapi) NewSchema(service string, obj any, ct ContentType) *Schema

type Operation

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

type Parameter

type Parameter struct {
	Name            string  `json:"name,omitempty"`
	In              string  `json:"in,omitempty"` // query, path, header, cookie
	Schema          *Schema `json:"schema,omitempty"`
	Description     string  `json:"description,omitempty"`
	Required        bool    `json:"required,omitempty"`
	Deprecated      bool    `json:"deprecated,omitempty"`
	AllowEmptyValue bool    `json:"allowEmptyValue,omitempty"`
}

type PathItem

type PathItem map[string]*Operation

type RequestBody

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

type ResponseBody

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

type ResponseCode

type ResponseCode string

type Schema

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

func (*Schema) RequiredFields

func (s *Schema) RequiredFields(fields []string)

type SecurityScheme

type SecurityScheme struct {
	Type             SecuritySchemeType `json:"type,omitempty"`
	Description      string             `json:"description,omitempty"`
	Name             string             `json:"name,omitempty"`
	In               string             `json:"in,omitempty"` // header, query, cookie
	Scheme           string             `json:"scheme,omitempty"`
	BearerFormat     string             `json:"bearerFormat,omitempty"`
	OpenIdConnectUrl string             `json:"openIdConnectUrl,omitempty"`
	Flows            *OAuthFlows        `json:"flows,omitempty"`
}

type SecuritySchemeType

type SecuritySchemeType string
const (
	SecuritySchemeTypeApiKey    SecuritySchemeType = "apiKey"
	SecuritySchemeTypeHttp      SecuritySchemeType = "http"
	SecuritySchemeTypeOauth     SecuritySchemeType = "oauth2"
	SecuritySchemeTypeOpenId    SecuritySchemeType = "openIdConnect"
	SecuritySchemeTypeMutualTLS SecuritySchemeType = "mutualTLS"
)

type SecuritySchemes

type SecuritySchemes map[string]*SecurityScheme

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