openapi

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnumTypes bool = true

Functions

func Export

func Export(model *sadl.Model, conf *sadl.Data) error

func Import

func Import(paths []string, conf *sadl.Data) (*sadl.Model, error)

func ImportSwagger added in v1.7.1

func ImportSwagger(paths []string, conf *sadl.Data) (*sadl.Model, error)

func IsValidFile

func IsValidFile(path string) bool

func IsValidSwaggerFile added in v1.7.1

func IsValidSwaggerFile(path string) bool

func OasError

func OasError(format string, args ...interface{}) error

func ValidateInfo

func ValidateInfo(info *Info) error

func ValidatePaths

func ValidatePaths(paths map[string]*PathItem) error

Types

type Callback

type Callback map[string]*PathItem

type Components

type Components struct {
	Extensions      map[string]interface{}     `json:"-"`
	Schemas         map[string]*Schema         `json:"schemas,omitempty"`
	Parameters      map[string]*Parameter      `json:"parameters,omitempty"`
	Headers         map[string]*Header         `json:"headers,omitempty"`
	RequestBodies   map[string]*RequestBody    `json:"requestBodies,omitempty"`
	Responses       map[string]*Response       `json:"responses,omitempty"`
	SecuritySchemes map[string]*SecurityScheme `json:"securitySchemes,omitempty"`
	Examples        map[string]*Example        `json:"examples,omitempty"`
	Tags            []*Tag                     `json:"tags,omitempty"`
	Links           map[string]*Link           `json:"links,omitempty"`
	Callbacks       map[string]*Callback       `json:"callbacks,omitempty"`
}

type Contact

type Contact struct {
	Extensions map[string]interface{} `json:"-"`
	Name       string                 `json:"name,omitempty"`
	URL        string                 `json:"url,omitempty"`
	Email      string                 `json:"email,omitempty"`
}

type Content

type Content map[string]*MediaType

type Discriminator

type Discriminator struct {
	Extensions   map[string]interface{} `json:"-"`
	PropertyName string                 `json:"propertyName"`
	Mapping      map[string]string      `json:"mapping,omitempty"`
}

type Encoding

type Encoding struct {
	Extensions    map[string]interface{} `json:"-"`
	ContentType   string                 `json:"contentType,omitempty"`
	Headers       map[string]*Header     `json:"headers,omitempty"`
	Style         string                 `json:"style,omitempty"`
	Explode       bool                   `json:"explode,omitempty"`
	AllowReserved bool                   `json:"allowReserved,omitempty"`
}

type Example

type Example struct {
	Extensions    map[string]interface{} `json:"-"`
	Summary       string                 `json:"summary,omitempty"`
	Description   string                 `json:"description,omitempty"`
	Value         interface{}            `json:"value,omitempty"`
	ExternalValue string                 `json:"externalValue,omitempty"`
}

type ExternalDocumentation

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

type Generator

type Generator struct {
	sadl.Generator
	Model *sadl.Model
}

func NewGenerator

func NewGenerator(model *sadl.Model, conf *sadl.Data) *Generator

func (*Generator) ExportToOAS3

func (gen *Generator) ExportToOAS3() (*Model, error)

func (*Generator) FindOperation

func (gen *Generator) FindOperation(model *Model, opId string) *Operation
type Header struct {
	Extensions  map[string]interface{} `json:"-"`
	Description string                 `json:"description,omitempty"`
	Schema      *Schema                `json:"schema,omitempty"`
}

type Info

type Info struct {
	Extensions     map[string]interface{} `json:"-"`
	Title          string                 `json:"title,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 {
	Extensions map[string]interface{} `json:"-"`
	Name       string                 `json:"name,omitempty"`
	URL        string                 `json:"url,omitempty"`
}
type Link struct {
	Extensions  map[string]interface{} `json:"-"`
	Description string                 `json:"description,omitempty"`
	Href        string                 `json:"href,omitempty"`
	OperationId string                 `json:"operationId,omitempty"`
	Parameters  map[string]interface{} `json:"parameters,omitempty"`
	Headers     map[string]*Schema     `json:"headers,omitempty"`
}

type MediaType

type MediaType struct {
	Extensions map[string]interface{} `json:"-"`
	Schema     *Schema                `json:"schema,omitempty"`
	Example    interface{}            `json:"example,omitempty"`
	Examples   map[string]*Example    `json:"examples,omitempty"`
	Encoding   map[string]*Encoding   `json:"encoding,omitempty"`
}

type Model

type Model struct {
	Extensions   map[string]interface{} `json:"-"`
	OpenAPI      string                 `json:"openapi"`           // Required
	Info         *Info                  `json:"info"`              // Required
	Servers      []*Server              `json:"servers,omitempty"` //?change
	Paths        map[string]*PathItem   `json:"paths,omitempty"`   //?change
	Components   *Components            `json:"components,omitempty"`
	Security     []SecurityRequirement  `json:"security,omitempty"`
	ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
}

func Load

func Load(path string) (*Model, error)

func LoadSwagger added in v1.7.1

func LoadSwagger(path string) (*Model, error)

func Validate

func Validate(v3 *Model) (*Model, error)

func (Model) MarshalJSON

func (model Model) MarshalJSON() ([]byte, error)

func (*Model) ToSadl

func (model *Model) ToSadl(name string) (*sadl.Model, error)

type OAuthFlow

type OAuthFlow struct {
	Extensions       map[string]interface{} `json:"-"`
	AuthorizationURL string                 `json:"authorizationUrl,omitempty"`
	TokenURL         string                 `json:"tokenUrl,omitempty"`
	RefreshURL       string                 `json:"refreshUrl,omitempty"`
	Scopes           map[string]string      `json:"scopes"`
}

type OAuthFlows

type OAuthFlows struct {
	Extensions        map[string]interface{} `json:"-"`
	Implicit          *OAuthFlow             `json:"implicit,omitempty"`
	Password          *OAuthFlow             `json:"password,omitempty"`
	ClientCredentials *OAuthFlow             `json:"clientCredentials,omitempty"`
	AuthorizationCode *OAuthFlow             `json:"authorizationCode,omitempty"`
}

type Operation

type Operation struct {
	Extensions  map[string]interface{} `json:"-"`
	Tags        []string               `json:"tags,omitempty"`
	Summary     string                 `json:"summary,omitempty"`
	Description string                 `json:"description,omitempty"`
	OperationId string                 `json:"operationId,omitempty"`
	Parameters  []*Parameter           `json:"parameters,omitempty"`
	RequestBody *RequestBody           `json:"requestBody,omitempty"`
	Responses   map[string]*Response   `json:"responses,omitempty"`
	Callbacks   map[string]*Callback   `json:"callbacks,omitempty"`
	Deprecated  bool                   `json:"deprecated,omitempty"`
	Security    []SecurityRequirement  `json:"security,omitempty"`
	Servers     []*Server              `json:"servers,omitempty"`
}

type Parameter

type Parameter struct {
	Extensions      map[string]interface{} `json:"-"`
	Name            string                 `json:"name,omitempty"`
	In              string                 `json:"in,omitempty"`
	Description     string                 `json:"description,omitempty"`
	Style           string                 `json:"style,omitempty"`
	Explode         *bool                  `json:"explode,omitempty"`
	AllowEmptyValue bool                   `json:"allowEmptyValue,omitempty"`
	AllowReserved   bool                   `json:"allowReserved,omitempty"`
	Deprecated      bool                   `json:"deprecated,omitempty"`
	Required        bool                   `json:"required,omitempty"`
	Schema          *Schema                `json:"schema,omitempty"`
	Example         interface{}            `json:"example,omitempty"`
	Examples        map[string]*Example    `json:"examples,omitempty"`
	Content         Content                `json:"content,omitempty"`
}

type PathItem

type PathItem struct {
	Extensions  map[string]interface{} `json:"-"`
	Summary     string                 `json:"summary,omitempty"`
	Description string                 `json:"description,omitempty"`
	Connect     *Operation             `json:"connect,omitempty"`
	Delete      *Operation             `json:"delete,omitempty"`
	Get         *Operation             `json:"get,omitempty"`
	Head        *Operation             `json:"head,omitempty"`
	Options     *Operation             `json:"options,omitempty"`
	Patch       *Operation             `json:"patch,omitempty"`
	Post        *Operation             `json:"post,omitempty"`
	Put         *Operation             `json:"put,omitempty"`
	Trace       *Operation             `json:"trace,omitempty"`
	Servers     []*Server              `json:"servers,omitempty"`
	Parameters  []*Parameter           `json:"parameters,omitempty"`
}

type RequestBody

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

type Response

type Response struct {
	Extensions  map[string]interface{} `json:"-"`
	Description string                 `json:"description,omitempty"`
	Headers     map[string]*Header     `json:"headers,omitempty"`
	Content     Content                `json:"content,omitempty"`
	Links       map[string]*Link       `json:"links,omitempty"`
}

type Schema

type Schema struct {
	Ref          string        `json:"$ref,omitempty"`
	OneOf        []*Schema     `json:"oneOf,omitempty"`
	AnyOf        []*Schema     `json:"anyOf,omitempty"`
	AllOf        []*Schema     `json:"allOf,omitempty"`
	Not          *Schema       `json:"not,omitempty"`
	Type         string        `json:"type,omitempty"`
	Format       string        `json:"format,omitempty"`
	Description  string        `json:"description,omitempty"`
	Enum         []interface{} `json:"enum,omitempty"`
	Default      interface{}   `json:"default,omitempty"`
	Example      interface{}   `json:"example,omitempty"`
	ExternalDocs interface{}   `json:"externalDocs,omitempty"`

	// Array-related, here for struct compactness
	UniqueItems bool `json:"uniqueItems,omitempty"`
	// Number-related, here for struct compactness
	ExclusiveMin bool `json:"exclusiveMinimum,omitempty"`
	ExclusiveMax bool `json:"exclusiveMaximum,omitempty"`
	// Properties
	Nullable  bool        `json:"nullable,omitempty"`
	ReadOnly  bool        `json:"readOnly,omitempty"`
	WriteOnly bool        `json:"writeOnly,omitempty"`
	XML       interface{} `json:"xml,omitempty"`

	// Number
	Min        *float64 `json:"minimum,omitempty"`
	Max        *float64 `json:"maximum,omitempty"`
	MultipleOf *float64 `json:"multipleOf,omitempty"`

	// String
	MinLength uint64  `json:"minLength,omitempty"`
	MaxLength *uint64 `json:"maxLength,omitempty"`
	Pattern   string  `json:"pattern,omitempty"`

	// Array
	MinItems uint64  `json:"minItems,omitempty"`
	MaxItems *uint64 `json:"maxItems,omitempty"`
	Items    *Schema `json:"items,omitempty"`

	// Object
	Required             []string           `json:"required,omitempty"`
	Properties           map[string]*Schema `json:"properties,omitempty"`
	MinProps             uint64             `json:"minProperties,omitempty"`
	MaxProps             *uint64            `json:"maxProperties,omitempty"`
	AdditionalProperties interface{}        `json:"additionalProperties,omitempty"`
	Discriminator        *Discriminator     `json:"discriminator,omitempty"`

	PatternProperties string `json:"patternProperties,omitempty"`
}

type SecurityRequirement

type SecurityRequirement map[string][]string

type SecurityScheme

type SecurityScheme struct {
	Extensions   map[string]interface{} `json:"-"`
	Type         string                 `json:"type,omitempty"`
	Description  string                 `json:"description,omitempty"`
	Name         string                 `json:"name,omitempty"`
	In           string                 `json:"in,omitempty"`
	Scheme       string                 `json:"scheme,omitempty"`
	BearerFormat string                 `json:"bearerFormat,omitempty"`
	Flows        *OAuthFlows            `json:"flows,omitempty"`
}

type Server

type Server struct {
	Extensions  map[string]interface{}     `json:"-"`
	URL         string                     `json:"url,omitempty"`
	Description string                     `json:"description,omitempty"`
	Variables   map[string]*ServerVariable `json:"variables,omitempty"`
}

type ServerVariable

type ServerVariable struct {
	Extensions  map[string]interface{} `json:"-"`
	Enum        []interface{}          `json:"enum,omitempty"`
	Default     interface{}            `json:"default,omitempty"`
	Description string                 `json:"description,omitempty"`
}

type Tag

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

Jump to

Keyboard shortcuts

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