specification

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ExtTagGoType = "x-goag-go-type"

Variables

This section is empty.

Functions

func GetSecurity added in v0.0.12

func GetSecurity(secSchemes openapi3.SecuritySchemes, secRequirements openapi3.SecurityRequirements) ([][]Security, error)

Types

type Components added in v0.0.11

type Components struct {
	Schemas ComponentsSchemas

	Headers       Map[Ref[Header]]
	RequestBodies Map[Ref[RequestBody]]
	Responses     Map[Ref[Response]]

	// ---------------- Parameters ----------------
	QueryParameters  Map[Ref[QueryParameter]]
	HeaderParameters Map[Ref[HeaderParameter]]
	PathParameters   Map[Ref[PathParameter]]
	CookieParameters Map[Ref[CookieParameter]]

	SecuritySchemes SecuritySchemes
	Links           Map[Ref[Link]]
	PathItems       Map[Ref[PathItem]]
}

func NewComponents added in v0.0.11

func NewComponents(spec openapi3.Components, opts SchemaOptions) (zero Components, _ error)

type ComponentsSchemas added in v0.0.14

type ComponentsSchemas = Map[Ref[Schema]]

type Contact added in v0.0.14

type Contact struct {
	Name  string
	URL   string
	Email string
}

func NewContact added in v0.0.14

func NewContact(c *openapi3.Contact) Contact

type CookieParameter added in v0.0.14

type CookieParameter struct {
	NoRef[CookieParameter]

	Name        string
	Description string
	Required    bool
	Deprecated  bool

	Style   string
	Explode Maybe[bool]

	Schema Ref[Schema]
}

func NewCookieParameter added in v0.0.14

func NewCookieParameter(p *openapi3.Parameter, schemas ComponentsSchemas, opts SchemaOptions) (*CookieParameter, error)

func (*CookieParameter) Value added in v0.0.14

func (c *CookieParameter) Value() *CookieParameter

type HTTPMethod added in v0.0.14

type HTTPMethod string

HTTPMethod - http.MethodGet, http.MethodPost, ...

type HTTPMethodTitle added in v0.0.14

type HTTPMethodTitle string

HTTPMethodTitle - Get, Post, ...

type Header struct {
	NoRef[Header]

	Description string
	Required    bool
	Deprecated  bool

	Schema Ref[Schema]
}

func NewHeader

func NewHeader(s *openapi3.Header, schemas ComponentsSchemas, opts SchemaOptions) (*Header, error)

func (*Header) Value added in v0.0.14

func (h *Header) Value() *Header

type HeaderParameter

type HeaderParameter struct {
	NoRef[HeaderParameter]

	Name        string
	Description string
	Required    bool
	Deprecated  bool

	Style   string
	Explode Maybe[bool]

	Schema Ref[Schema]
}

func NewHeaderParameter added in v0.0.14

func NewHeaderParameter(p *openapi3.Parameter, schemas ComponentsSchemas, opts SchemaOptions) (*HeaderParameter, error)

func (*HeaderParameter) Value added in v0.0.14

func (h *HeaderParameter) Value() *HeaderParameter

type Info added in v0.0.10

type Info struct {
	Title          string
	Summary        string
	Description    string
	TermsOfService string
	Contact        Contact
	License        License
	Version        string
}

func NewInfo added in v0.0.10

func NewInfo(s *openapi3.Info) Info

type License added in v0.0.14

type License struct {
	Name       string
	Identifier string
	URL        string
}

func NewLicense added in v0.0.14

func NewLicense(l *openapi3.License) License
type Link struct {
	NoRef[Link]
}
func NewLink(s *openapi3.Link) *Link

func (*Link) Value added in v0.0.14

func (l *Link) Value() *Link

type Map added in v0.0.14

type Map[T any] struct {
	List []*Object[string, T]
	// contains filtered or unexported fields
}

func NewMap added in v0.0.14

func NewMap[T any, U any](m map[string]U, fn func(U) (T, error)) (Map[T], error)

func NewMapEmpty added in v0.0.14

func NewMapEmpty[T any](size int) Map[T]

func NewMapPrefix added in v0.0.14

func NewMapPrefix[T any, U any](m map[string]U, fn func(U) (T, error), prefix string) (zero Map[T], _ error)

func NewMapRefSelf added in v0.0.14

func NewMapRefSelf[T any, U any](m map[string]U, fn func(U) (ref string, _ Ref[T], _ error), prefix string) (Map[Ref[T]], error)

func NewMapRefSelfSource added in v0.0.14

func NewMapRefSelfSource[T any, U any](m map[string]U, fn func(U, Sourcer[T]) (ref string, _ Ref[T], _ error), source Sourcer[T], prefix string) (zero Map[Ref[T]], _ error)

func (*Map[T]) Add added in v0.0.14

func (m *Map[T]) Add(name string, v T)

func (Map[T]) Get added in v0.0.14

func (m Map[T]) Get(k string) (*Object[string, T], bool)

func (*Map[T]) Has added in v0.0.14

func (m *Map[T]) Has(k string) bool

type Maybe added in v0.1.5

type Maybe[T any] struct {
	Set bool
	// contains filtered or unexported fields
}

func Just added in v0.1.5

func Just[T any](v T) Maybe[T]

func JustPointer added in v0.1.21

func JustPointer[T any](v *T) Maybe[T]

func Nothing added in v0.1.5

func Nothing[T any]() Maybe[T]

func (Maybe[T]) Get added in v0.1.19

func (m Maybe[T]) Get() (zero T, _ bool)

type MediaType added in v0.0.14

type MediaType struct {
	Schema Ref[Schema]
}

func NewMediaType added in v0.0.14

func NewMediaType(s *openapi3.MediaType, components ComponentsSchemas, opts SchemaOptions) (*MediaType, error)

type NoRef added in v0.0.14

type NoRef[T any] struct{}

func (NoRef[T]) Ref added in v0.0.14

func (NoRef[T]) Ref() *Object[string, Ref[T]]

type OAuthFlow added in v0.0.14

type OAuthFlow struct {
	AuthorizationURL string
	TokenURL         string
	RefreshURL       string
	Scopes           Map[string]
}

func NewOAuthFlow added in v0.0.14

func NewOAuthFlow(s *openapi3.OAuthFlow) (zero OAuthFlow, _ error)

type OAuthFlows added in v0.0.14

type OAuthFlows struct {
	Implicit          Maybe[OAuthFlow]
	Password          Maybe[OAuthFlow]
	ClientCredentials Maybe[OAuthFlow]
	AuthorizationCode Maybe[OAuthFlow]
}

func NewOAuthFlows added in v0.0.14

func NewOAuthFlows(s *openapi3.OAuthFlows) (zero OAuthFlows, _ error)

type Object added in v0.0.14

type Object[K, T any] struct {
	Name K
	V    T
}

type Operation

type Operation struct {
	PathItem *PathItem

	PathRaw string

	Tags        []string
	Summary     string
	Description string
	OperationID string

	Parameters OperationParameters

	RequestBody Maybe[Ref[RequestBody]]

	HTTPMethod HTTPMethod
	Method     HTTPMethodTitle

	Security SecurityRequirements

	Responses Map[Ref[Response]]
}

func NewOperation

func NewOperation(pi *PathItem, rawPath string, method httpMethod, operation *openapi3.Operation, specSecurityReqs SecurityRequirements, legacyComponents openapi3.Components, securitySchemes SecuritySchemes, components Components, pathItemParameters openapi3.Parameters, opts SchemaOptions) (*Operation, error)

type OperationParameters added in v0.0.14

type OperationParameters struct {
	Query   Map[Ref[QueryParameter]]
	Headers Map[Ref[HeaderParameter]]
	Path    Map[Ref[PathParameter]]
	Cookie  Map[Ref[CookieParameter]]
}

func NewOperationParameters added in v0.0.14

func NewOperationParameters(pathParams, operationParams openapi3.Parameters, components Components, opts SchemaOptions) (zero OperationParameters, _ error)

type PathItem

type PathItem struct {
	NoRef[PathItem]

	RawPath    string
	Operations []*Operation
}

func NewPathItem added in v0.0.14

func NewPathItem(path string) *PathItem

func (*PathItem) GetOperation added in v0.1.14

func (p *PathItem) GetOperation(m HTTPMethod) (*Operation, bool)

func (*PathItem) HasOperation added in v0.1.14

func (p *PathItem) HasOperation(m HTTPMethod) bool

type PathParameter

type PathParameter struct {
	NoRef[PathParameter]

	Name        string
	Description string
	Deprecated  bool

	Style   string
	Explode Maybe[bool]

	Schema Ref[Schema]
}

func NewPathParameter added in v0.0.14

func NewPathParameter(p *openapi3.Parameter, schemas ComponentsSchemas, opts SchemaOptions) (*PathParameter, error)

func (*PathParameter) Value added in v0.0.14

func (p *PathParameter) Value() *PathParameter

type QueryParameter

type QueryParameter struct {
	NoRef[QueryParameter]

	Name            string
	Description     string
	Required        bool
	Deprecated      bool
	AllowEmptyValue bool

	Style         string
	Explode       Maybe[bool]
	AllowReserved bool

	Schema Ref[Schema]
}

func NewQueryParameter added in v0.0.14

func NewQueryParameter(p *openapi3.Parameter, schemas ComponentsSchemas, opts SchemaOptions) (*QueryParameter, error)

func (*QueryParameter) Value added in v0.0.14

func (q *QueryParameter) Value() *QueryParameter

type Ref added in v0.0.14

type Ref[T any] interface {
	Ref() *Object[string, Ref[T]]
	Value() *T
}

func NewRef added in v0.1.19

func NewRef[T any](v *Object[string, Ref[T]]) Ref[T]

func NewRefCookieParam added in v0.0.14

func NewRefCookieParam(p *openapi3.ParameterRef, components Components, opts SchemaOptions) (Ref[CookieParameter], error)

func NewRefHeaderParam added in v0.0.14

func NewRefHeaderParam(p *openapi3.ParameterRef, components Components, opts SchemaOptions) (Ref[HeaderParameter], error)

func NewRefPathParam added in v0.0.14

func NewRefPathParam(p *openapi3.ParameterRef, components Components, opts SchemaOptions) (Ref[PathParameter], error)

func NewRefQueryParam added in v0.0.14

func NewRefQueryParam(p *openapi3.ParameterRef, components Components, opts SchemaOptions) (Ref[QueryParameter], error)

func NewSchemaRef added in v0.0.14

func NewSchemaRef(schema *openapi3.SchemaRef, components Sourcer[Schema], opts SchemaOptions) (Ref[Schema], error)

type RequestBody added in v0.0.14

type RequestBody struct {
	NoRef[RequestBody]

	Description string
	Content     Map[*MediaType]
	Required    bool
}

func NewRequestBody added in v0.0.14

func NewRequestBody(r *openapi3.RequestBody, components ComponentsSchemas, opts SchemaOptions) (*RequestBody, error)

func (*RequestBody) Value added in v0.0.14

func (r *RequestBody) Value() *RequestBody

type Response

type Response struct {
	NoRef[Response]

	Description string
	Headers     Map[Ref[Header]]
	Content     Map[*MediaType]
	Links       Map[Ref[Link]]

	UsedIn []ResponseUsedIn
}

func NewResponse

func NewResponse(s *openapi3.Response, components Components, opts SchemaOptions) (*Response, error)

func (*Response) Value added in v0.0.14

func (r *Response) Value() *Response

type ResponseUsedIn added in v0.1.8

type ResponseUsedIn struct {
	Operation *Operation
	Status    string
}

type Schema

type Schema struct {
	NoRef[Schema]

	Type        string
	Format      string
	Items       Ref[Schema]
	Properties  []SchemaProperty
	AllOf       []Ref[Schema]
	Description string

	AdditionalProperties Maybe[Ref[Schema]]

	Custom Maybe[string]
}

func NewSchema

func NewSchema(schema *openapi3.Schema, components Sourcer[Schema], opts SchemaOptions) (*Schema, error)

func (*Schema) Value added in v0.0.14

func (s *Schema) Value() *Schema

type SchemaOptions added in v0.1.18

type SchemaOptions struct {
	IgnoreCustomType bool
}

type SchemaProperty added in v0.0.11

type SchemaProperty struct {
	Name     string
	Schema   Ref[Schema]
	Required bool
}

type Security added in v0.0.12

type Security struct {
	Requirement []string
}

type SecurityRequirement added in v0.0.14

type SecurityRequirement struct {
	Scheme       *SecurityScheme
	Requirements []string
}

func NewSecurityRequirement added in v0.0.14

func NewSecurityRequirement(k string, v []string, schemes SecuritySchemes) (zero SecurityRequirement, _ error)

func NewSecurityRequirements added in v0.0.14

func NewSecurityRequirements(s openapi3.SecurityRequirements, schemes SecuritySchemes) ([]SecurityRequirement, error)

type SecurityRequirements added in v0.0.14

type SecurityRequirements []SecurityRequirement

type SecurityScheme added in v0.0.14

type SecurityScheme struct {
	NoRef[SecurityScheme]

	// Any
	Type        SecuritySchemeType
	Description string

	// apiKey
	Name string
	In   SecuritySchemeIn

	// http
	Scheme       string
	BearerFormat string

	// oauth2
	Flows OAuthFlows

	// openIdConnect
	OpenIDConnectURL string
}

func NewSecurityScheme added in v0.0.14

func NewSecurityScheme(s *openapi3.SecurityScheme) (*SecurityScheme, error)

func (*SecurityScheme) Value added in v0.0.14

func (s *SecurityScheme) Value() *SecurityScheme

type SecuritySchemeIn added in v0.0.14

type SecuritySchemeIn string
const (
	SecuritySchemeInQuery  SecuritySchemeIn = "query"
	SecuritySchemeInHeader SecuritySchemeIn = "header"
	SecuritySchemeInCookie SecuritySchemeIn = "cookie"
)

type SecuritySchemeType added in v0.0.14

type SecuritySchemeType string
const (
	SecuritySchemeTypeApiKey        SecuritySchemeType = "apiKey"
	SecuritySchemeTypeHTTP          SecuritySchemeType = "http"
	SecuritySchemeTypeMutualTLS     SecuritySchemeType = "mutualTLS"
	SecuritySchemeTypeOAuth2        SecuritySchemeType = "oauth2"
	SecuritySchemeTypeOpenIDConnect SecuritySchemeType = "openIdConnect"
)

type SecuritySchemes added in v0.0.14

type SecuritySchemes = Map[Ref[SecurityScheme]]

type Server added in v0.0.14

type Server struct {
	URL         string
	Description string
	Variables   Map[ServerVariable]
}

func NewServer added in v0.0.14

func NewServer(s *openapi3.Server) (zero Server, _ error)

func NewServers added in v0.0.14

func NewServers(ss openapi3.Servers) ([]Server, error)

type ServerVariable added in v0.0.14

type ServerVariable struct {
	Enum        []string
	Default     string
	Description string
}

func NewServerVariable added in v0.0.14

func NewServerVariable(sv *openapi3.ServerVariable) ServerVariable

type Sourcer added in v0.1.8

type Sourcer[T any] interface {
	Get(string) (*Object[string, Ref[T]], bool)
}

type SourcerFunc added in v0.1.8

type SourcerFunc[T any] func(string) (*Object[string, Ref[T]], bool)

func (SourcerFunc[T]) Get added in v0.1.8

func (s SourcerFunc[T]) Get(str string) (*Object[string, Ref[T]], bool)

type Spec

type Spec struct {
	OpenAPI string
	Info    Info
	Servers []Server

	PathItems  []*PathItem
	Operations []*Operation

	Components Components

	Security []SecurityRequirement
}

func ParseSwagger

func ParseSwagger(spec *openapi3.Swagger, opts SchemaOptions) (*Spec, error)

Jump to

Keyboard shortcuts

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