openApi3Schema

package
v0.0.0-...-4f1e413 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpenAPIVersion = "3.0.3"

	ContentTypeText = "text/plain"
	ContentTypeJson = "application/json"
	ContentTypeFile = "application/octet-stream"
	ContentTypeForm = "multipart/form-data"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ComponentsObject

type ComponentsObject struct {
	Schemas         map[string]*SchemaObject         `json:"schemas,omitempty"`
	SecuritySchemes map[string]*SecuritySchemeObject `json:"securitySchemes,omitempty"`
	Parameters      map[string]*ParameterObject      `json:"parameters,omitempty"`
}

type ContactObject

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

type ExternalDocs

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

type HeaderObject

type HeaderObject struct {
	Description string `json:"description,omitempty"`
	Type        string `json:"type,omitempty"`

	// Ref is used when HeaderObject is as a ReferenceObject
	Ref string `json:"$ref,omitempty"`
}

type InfoObject

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

type LicenseObject

type LicenseObject struct {
	Name string `json:"name,omitempty"`
	URL  string `json:"url,omitempty"`
}

type MediaTypeObject

type MediaTypeObject struct {
	Schema SchemaObject `json:"schema,omitempty"`
}

type OpenAPIObject

type OpenAPIObject struct {
	Version    string                `json:"openapi"` // Required
	Info       InfoObject            `json:"info"`    // Required
	Servers    []ServerObject        `json:"servers,omitempty"`
	Paths      PathsObject           `json:"paths"`                // Required
	Components ComponentsObject      `json:"components,omitempty"` // Required for Authorization header
	Security   []map[string][]string `json:"security,omitempty"`
	Tags       []*Tags               `json:"tags,omitempty"`
}

type OperationObject

type OperationObject struct {
	Responses ResponsesObject `json:"responses"` // Required

	Tags        []string           `json:"tags,omitempty"`
	Summary     string             `json:"summary,omitempty"`
	Description string             `json:"description,omitempty"`
	Parameters  []ParameterObject  `json:"parameters,omitempty"`
	RequestBody *RequestBodyObject `json:"requestBody,omitempty"`
	OperationId string             `json:"operationId,omitempty"`
	Deprecated  bool               `json:"deprecated,omitempty"`
}

type ParameterObject

type ParameterObject struct {
	Name        string        `json:"name,omitempty"` // Required
	In          string        `json:"in,omitempty"`   // Required. Possible values are "query", "header", "path" or "cookie"
	Description string        `json:"description,omitempty"`
	Required    bool          `json:"required,omitempty"`
	Example     interface{}   `json:"example,omitempty"`
	Schema      *SchemaObject `json:"schema,omitempty"`

	// Ref is used when ParameterOjbect is as a ReferenceObject
	Ref string `json:"$ref,omitempty"`
}

type PathItemObject

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

type PathsObject

type PathsObject map[string]*PathItemObject

type RequestBodyObject

type RequestBodyObject struct {
	Content map[string]*MediaTypeObject `json:"content"` // Required

	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`

	// Ref is used when RequestBodyObject is as a ReferenceObject
	Ref string `json:"$ref,omitempty"`
}

type ResponseObject

type ResponseObject struct {
	Description string `json:"description"` // Required

	Headers map[string]*HeaderObject    `json:"headers,omitempty"`
	Content map[string]*MediaTypeObject `json:"content,omitempty"`

	// Ref is for ReferenceObject
	Ref string `json:"$ref,omitempty"`
}

type ResponsesObject

type ResponsesObject map[string]*ResponseObject // [status]ResponseObject

type SchemaObject

type SchemaObject struct {
	ID                 string                 `json:"-"` // For go-swagger3
	PkgName            string                 `json:"-"` // For go-swagger3
	FieldName          string                 `json:"-"` // For go-swagger3
	DisabledFieldNames map[string]struct{}    `json:"-"` // For go-swagger3
	Type               string                 `json:"type,omitempty"`
	Format             string                 `json:"format,omitempty"`
	Required           []string               `json:"required,omitempty"`
	Properties         *orderedmap.OrderedMap `json:"properties,omitempty"`
	Description        string                 `json:"description,omitempty"`
	Minimum            any                    `json:"minimum,omitempty"`
	Maximum            any                    `json:"maximum,omitempty"`
	ExclusiveMaximum   any                    `json:"exclusiveMaximum,omitempty"`
	ExclusiveMinimum   any                    `json:"exclusiveMinimum,omitempty"`
	Items              *SchemaObject          `json:"items,omitempty"` // use ptr to prevent recursive error
	Example            interface{}            `json:"example,omitempty"`
	Deprecated         bool                   `json:"deprecated,omitempty"`
	Ref                string                 `json:"$ref,omitempty"` // Ref is used when SchemaObject is as a ReferenceObject
	Enum               interface{}            `json:"enum,omitempty"`
	Title              string                 `json:"title,omitempty"`
	Default            any                    `json:"default,omitempty"`
	MultipleOf         any                    `json:"multipleOf,omitempty"`
	MaxLength          int32                  `json:"maxLength,omitempty"`
	MinLength          int32                  `json:"minLength,omitempty"`
	ReadOnly           bool                   `json:"read_only,omitempty"`
	WriteOnly          bool                   `json:"write_only,omitempty"`
	Pattern            string                 `json:"pattern,omitempty"`
}

type SecuritySchemeOauthFlowObject

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

type SecuritySchemeOauthObject

type SecuritySchemeOauthObject struct {
	Implicit              *SecuritySchemeOauthFlowObject `json:"implicit,omitempty"`
	AuthorizationCode     *SecuritySchemeOauthFlowObject `json:"authorizationCode,omitempty"`
	ResourceOwnerPassword *SecuritySchemeOauthFlowObject `json:"password,omitempty"`
	ClientCredentials     *SecuritySchemeOauthFlowObject `json:"clientCredentials,omitempty"`
}

func (*SecuritySchemeOauthObject) ApplyScopes

func (s *SecuritySchemeOauthObject) ApplyScopes(scopes map[string]string)

type SecuritySchemeObject

type SecuritySchemeObject struct {
	// Generic fields
	Type        string `json:"type"` // Required
	Description string `json:"description,omitempty"`

	// http
	Scheme string `json:"scheme,omitempty"`

	// apiKey
	In   string `json:"in,omitempty"`
	Name string `json:"name,omitempty"`

	// OpenID
	OpenIdConnectUrl string `json:"openIdConnectUrl,omitempty"`

	// OAuth2
	OAuthFlows *SecuritySchemeOauthObject `json:"flows,omitempty"`
}

type ServerObject

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

type Tags

type Tags struct {
	Name         string        `json:"name,omitempty"`
	Description  string        `json:"description,omitempty"`
	ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
}

Jump to

Keyboard shortcuts

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