oas

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package oas represents OpenAPI v3 Specification in Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discriminator

type Discriminator struct {
	PropertyName string
	Mapping      map[string]string
}

Discriminator discriminates types for OneOf, AllOf, AnyOf.

type Format

type Format string

Format of Schema.

const (
	FormatNone     Format = ""
	FormatUUID     Format = "uuid"
	FormatDate     Format = "date"
	FormatTime     Format = "time"
	FormatDateTime Format = "date-time"
	FormatDuration Format = "duration"
	FormatURI      Format = "uri"
	FormatIPv4     Format = "ipv4"
	FormatIPv6     Format = "ipv6"
	FormatByte     Format = "byte"
	FormatBinary   Format = "binary"
	FormatPassword Format = "password"
	FormatInt64    Format = "int64"
	FormatInt32    Format = "int32"
	FormatFloat    Format = "float"
	FormatDouble   Format = "double"
	FormatEmail    Format = "email"
	FormatHostname Format = "hostname"

	FormatIP Format = "ip" // custom, non-standard
)

Possible formats.

type Operation

type Operation struct {
	OperationID string // optional
	HTTPMethod  string
	Path        Path
	Parameters  []*Parameter
	RequestBody *RequestBody // optional

	// Operation responses.
	// Map is always non-nil.
	//
	// Key can be:
	//  * HTTP Status code
	//  * default
	//  * 1XX, 2XX, 3XX, 4XX, 5XX
	Responses map[string]*Response
}

Operation is an OpenAPI Operation.

type Parameter

type Parameter struct {
	Name     string
	Schema   *Schema
	In       ParameterLocation
	Style    string
	Explode  bool
	Required bool
}

Parameter is an OpenAPI Operation Parameter.

type ParameterLocation

type ParameterLocation string

ParameterLocation defines where OpenAPI parameter is located.

const (
	LocationQuery  ParameterLocation = "query"
	LocationHeader ParameterLocation = "header"
	LocationPath   ParameterLocation = "path"
	LocationCookie ParameterLocation = "cookie"
)

func (ParameterLocation) Cookie

func (l ParameterLocation) Cookie() bool

func (ParameterLocation) Header

func (l ParameterLocation) Header() bool

func (ParameterLocation) Path

func (l ParameterLocation) Path() bool

func (ParameterLocation) Query

func (l ParameterLocation) Query() bool

type Path added in v0.5.0

type Path []PathPart

func (Path) String added in v0.5.0

func (p Path) String() (path string)

type PathPart

type PathPart struct {
	Raw   string
	Param *Parameter
}

PathPart is a part of an OpenAPI Operation Path.

type Property

type Property struct {
	Name     string  // Property name.
	Schema   *Schema // Property schema.
	Required bool    // Whether the field is required or not.
}

Property is an OpenAPI JSON Schema Object property.

type RequestBody

type RequestBody struct {
	Contents map[string]*Schema
	Required bool
}

RequestBody of an OpenAPI Operation.

type Response

type Response struct {
	Ref      string
	Contents map[string]*Schema
}

Response is an OpenAPI Response definition.

type Schema

type Schema struct {
	Type        SchemaType
	Format      Format // Schema format, optional.
	Description string // Schema description, optional.
	Ref         string // Whether schema is referenced.

	Item       *Schema       // Only for Array.
	Enum       []interface{} // Only for Enum.
	Properties []Property    // Only for Object.

	Nullable bool // Whether schema is nullable or not. Any types.

	OneOf         []*Schema
	AnyOf         []*Schema
	AllOf         []*Schema
	Discriminator *Discriminator

	// Numeric validation (Integer, Number).
	Maximum          *int64
	ExclusiveMaximum bool
	Minimum          *int64
	ExclusiveMinimum bool
	MultipleOf       *int

	// String validation.
	MaxLength *uint64
	MinLength *int64
	Pattern   string

	// Array validation.
	MaxItems    *uint64
	MinItems    *uint64
	UniqueItems bool

	// Struct validation.
	MaxProperties *uint64
	MinProperties *uint64
}

Schema is an OpenAPI JSON Schema.

type SchemaType

type SchemaType string

SchemaType is an OpenAPI JSON Schema type.

const (
	Empty   SchemaType = "" // OneOf, AnyOf, AllOf.
	Object  SchemaType = "object"
	Array   SchemaType = "array"
	Integer SchemaType = "integer"
	Number  SchemaType = "number"
	String  SchemaType = "string"
	Boolean SchemaType = "boolean"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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