openapi

package
v0.0.0-...-1d58815 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithServerURL

func WithServerURL(ctx context.Context, u *url.URL) context.Context

WithServerURL sets context key to override server URL.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements OAS client.

func NewClient

func NewClient(serverURL string, opts ...ClientOption) (*Client, error)

NewClient initializes new Client defined by OAS.

func (*Client) Test

func (c *Client) Test(ctx context.Context) (*SchemaA, error)

Test invokes test operation.

GET /test

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

ClientOption is client config option.

func WithClient

func WithClient(client ht.Client) ClientOption

WithClient specifies http client to use.

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type Handler

type Handler interface {
	// Test implements test operation.
	//
	// GET /test
	Test(ctx context.Context) (*SchemaA, error)
}

Handler handles operations described by OpenAPI v3 specification.

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type NilString

type NilString struct {
	Value string
	Null  bool
}

NilString is nullable string.

func NewNilString

func NewNilString(v string) NilString

NewNilString returns new NilString with value set to v.

func (*NilString) Decode

func (o *NilString) Decode(d *jx.Decoder) error

Decode decodes string from json.

func (NilString) Encode

func (o NilString) Encode(e *jx.Encoder)

Encode encodes string as json.

func (NilString) Get

func (o NilString) Get() (v string, ok bool)

Get returns value and boolean that denotes whether value was set.

func (NilString) IsNull

func (o NilString) IsNull() bool

IsSet returns true if value is Null.

func (NilString) MarshalJSON

func (s NilString) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (NilString) Or

func (o NilString) Or(d string) string

Or returns value if set, or given parameter if does not.

func (*NilString) SetTo

func (o *NilString) SetTo(v string)

SetTo sets value to v.

func (*NilString) SetToNull

func (o *NilString) SetToNull()

SetNull sets value to null.

func (*NilString) UnmarshalJSON

func (s *NilString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptNilBool

type OptNilBool struct {
	Value bool
	Set   bool
	Null  bool
}

OptNilBool is optional nullable bool.

func NewOptNilBool

func NewOptNilBool(v bool) OptNilBool

NewOptNilBool returns new OptNilBool with value set to v.

func (*OptNilBool) Decode

func (o *OptNilBool) Decode(d *jx.Decoder) error

Decode decodes bool from json.

func (OptNilBool) Encode

func (o OptNilBool) Encode(e *jx.Encoder)

Encode encodes bool as json.

func (OptNilBool) Get

func (o OptNilBool) Get() (v bool, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptNilBool) IsNull

func (o OptNilBool) IsNull() bool

IsSet returns true if value is Null.

func (OptNilBool) IsSet

func (o OptNilBool) IsSet() bool

IsSet returns true if OptNilBool was set.

func (OptNilBool) MarshalJSON

func (s OptNilBool) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptNilBool) Or

func (o OptNilBool) Or(d bool) bool

Or returns value if set, or given parameter if does not.

func (*OptNilBool) Reset

func (o *OptNilBool) Reset()

Reset unsets value.

func (*OptNilBool) SetTo

func (o *OptNilBool) SetTo(v bool)

SetTo sets value to v.

func (*OptNilBool) SetToNull

func (o *OptNilBool) SetToNull()

SetNull sets value to null.

func (*OptNilBool) UnmarshalJSON

func (s *OptNilBool) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptNilSchemaAOptionalNullableEnum

type OptNilSchemaAOptionalNullableEnum struct {
	Value SchemaAOptionalNullableEnum
	Set   bool
	Null  bool
}

OptNilSchemaAOptionalNullableEnum is optional nullable SchemaAOptionalNullableEnum.

func NewOptNilSchemaAOptionalNullableEnum

func NewOptNilSchemaAOptionalNullableEnum(v SchemaAOptionalNullableEnum) OptNilSchemaAOptionalNullableEnum

NewOptNilSchemaAOptionalNullableEnum returns new OptNilSchemaAOptionalNullableEnum with value set to v.

func (*OptNilSchemaAOptionalNullableEnum) Decode

Decode decodes SchemaAOptionalNullableEnum from json.

func (OptNilSchemaAOptionalNullableEnum) Encode

Encode encodes SchemaAOptionalNullableEnum as json.

func (OptNilSchemaAOptionalNullableEnum) Get

Get returns value and boolean that denotes whether value was set.

func (OptNilSchemaAOptionalNullableEnum) IsNull

IsSet returns true if value is Null.

func (OptNilSchemaAOptionalNullableEnum) IsSet

IsSet returns true if OptNilSchemaAOptionalNullableEnum was set.

func (OptNilSchemaAOptionalNullableEnum) MarshalJSON

func (s OptNilSchemaAOptionalNullableEnum) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptNilSchemaAOptionalNullableEnum) Or

Or returns value if set, or given parameter if does not.

func (*OptNilSchemaAOptionalNullableEnum) Reset

Reset unsets value.

func (*OptNilSchemaAOptionalNullableEnum) SetTo

SetTo sets value to v.

func (*OptNilSchemaAOptionalNullableEnum) SetToNull

func (o *OptNilSchemaAOptionalNullableEnum) SetToNull()

SetNull sets value to null.

func (*OptNilSchemaAOptionalNullableEnum) UnmarshalJSON

func (s *OptNilSchemaAOptionalNullableEnum) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptSchemaB

type OptSchemaB struct {
	Value SchemaB
	Set   bool
}

OptSchemaB is optional SchemaB.

func NewOptSchemaB

func NewOptSchemaB(v SchemaB) OptSchemaB

NewOptSchemaB returns new OptSchemaB with value set to v.

func (*OptSchemaB) Decode

func (o *OptSchemaB) Decode(d *jx.Decoder) error

Decode decodes SchemaB from json.

func (OptSchemaB) Encode

func (o OptSchemaB) Encode(e *jx.Encoder)

Encode encodes SchemaB as json.

func (OptSchemaB) Get

func (o OptSchemaB) Get() (v SchemaB, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptSchemaB) IsSet

func (o OptSchemaB) IsSet() bool

IsSet returns true if OptSchemaB was set.

func (OptSchemaB) MarshalJSON

func (s OptSchemaB) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptSchemaB) Or

func (o OptSchemaB) Or(d SchemaB) SchemaB

Or returns value if set, or given parameter if does not.

func (*OptSchemaB) Reset

func (o *OptSchemaB) Reset()

Reset unsets value.

func (*OptSchemaB) SetTo

func (o *OptSchemaB) SetTo(v SchemaB)

SetTo sets value to v.

func (*OptSchemaB) UnmarshalJSON

func (s *OptSchemaB) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Option

type Option interface {
	ServerOption
	ClientOption
}

Option is config option.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider specifies a meter provider to use for creating a meter.

If none is specified, the otel.GetMeterProvider() is used.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer.

If none is specified, the global provider is used.

type Route

type Route struct {
	// contains filtered or unexported fields
}

Route is route object.

func (Route) Args

func (r Route) Args() []string

Args returns parsed arguments.

func (Route) Name

func (r Route) Name() string

Name returns ogen operation name.

It is guaranteed to be unique and not empty.

func (Route) OperationID

func (r Route) OperationID() string

OperationID returns OpenAPI operationId.

func (Route) PathPattern

func (r Route) PathPattern() string

PathPattern returns OpenAPI path.

type SchemaA

type SchemaA struct {
	Int64                           int64                             `json:"int64"`
	StringFoobarBind                string                            `json:"string_foobar_bind"`
	StringOptionalNullable          NilString                         `json:"string_optional_nullable"`
	OptionalNullableBool            OptNilBool                        `json:"optional_nullable_bool"`
	JsontypeStrings                 []string                          `json:"jsontype_strings"`
	JsontypeStringsOptional         []string                          `json:"jsontype_strings_optional"`
	JsontypeInts                    []int                             `json:"jsontype_ints"`
	JsontypeIntsOptional            []int                             `json:"jsontype_ints_optional"`
	RequiredEnum                    SchemaARequiredEnum               `json:"required_enum"`
	OptionalNullableEnum            OptNilSchemaAOptionalNullableEnum `json:"optional_nullable_enum"`
	Bytes                           []byte                            `json:"bytes"`
	EdgeSchemabUniqueRequired       SchemaB                           `json:"edge_schemab_unique_required"`
	EdgeSchemabUniqueRequiredBsBind SchemaB                           `json:"edge_schemab_unique_required_bs_bind"`
	EdgeSchemabUniqueOptional       OptSchemaB                        `json:"edge_schemab_unique_optional"`
	EdgeSchemab                     []SchemaB                         `json:"edge_schemab"`
	EdgeSchemaaRecursive            []SchemaA                         `json:"edge_schemaa_recursive"`
}

Ref: #/components/schemas/SchemaA

func (*SchemaA) Decode

func (s *SchemaA) Decode(d *jx.Decoder) error

Decode decodes SchemaA from json.

func (*SchemaA) Encode

func (s *SchemaA) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*SchemaA) GetBytes

func (s *SchemaA) GetBytes() []byte

GetBytes returns the value of Bytes.

func (*SchemaA) GetEdgeSchemaaRecursive

func (s *SchemaA) GetEdgeSchemaaRecursive() []SchemaA

GetEdgeSchemaaRecursive returns the value of EdgeSchemaaRecursive.

func (*SchemaA) GetEdgeSchemab

func (s *SchemaA) GetEdgeSchemab() []SchemaB

GetEdgeSchemab returns the value of EdgeSchemab.

func (*SchemaA) GetEdgeSchemabUniqueOptional

func (s *SchemaA) GetEdgeSchemabUniqueOptional() OptSchemaB

GetEdgeSchemabUniqueOptional returns the value of EdgeSchemabUniqueOptional.

func (*SchemaA) GetEdgeSchemabUniqueRequired

func (s *SchemaA) GetEdgeSchemabUniqueRequired() SchemaB

GetEdgeSchemabUniqueRequired returns the value of EdgeSchemabUniqueRequired.

func (*SchemaA) GetEdgeSchemabUniqueRequiredBsBind

func (s *SchemaA) GetEdgeSchemabUniqueRequiredBsBind() SchemaB

GetEdgeSchemabUniqueRequiredBsBind returns the value of EdgeSchemabUniqueRequiredBsBind.

func (*SchemaA) GetInt64

func (s *SchemaA) GetInt64() int64

GetInt64 returns the value of Int64.

func (*SchemaA) GetJsontypeInts

func (s *SchemaA) GetJsontypeInts() []int

GetJsontypeInts returns the value of JsontypeInts.

func (*SchemaA) GetJsontypeIntsOptional

func (s *SchemaA) GetJsontypeIntsOptional() []int

GetJsontypeIntsOptional returns the value of JsontypeIntsOptional.

func (*SchemaA) GetJsontypeStrings

func (s *SchemaA) GetJsontypeStrings() []string

GetJsontypeStrings returns the value of JsontypeStrings.

func (*SchemaA) GetJsontypeStringsOptional

func (s *SchemaA) GetJsontypeStringsOptional() []string

GetJsontypeStringsOptional returns the value of JsontypeStringsOptional.

func (*SchemaA) GetOptionalNullableBool

func (s *SchemaA) GetOptionalNullableBool() OptNilBool

GetOptionalNullableBool returns the value of OptionalNullableBool.

func (*SchemaA) GetOptionalNullableEnum

func (s *SchemaA) GetOptionalNullableEnum() OptNilSchemaAOptionalNullableEnum

GetOptionalNullableEnum returns the value of OptionalNullableEnum.

func (*SchemaA) GetRequiredEnum

func (s *SchemaA) GetRequiredEnum() SchemaARequiredEnum

GetRequiredEnum returns the value of RequiredEnum.

func (*SchemaA) GetStringFoobarBind

func (s *SchemaA) GetStringFoobarBind() string

GetStringFoobarBind returns the value of StringFoobarBind.

func (*SchemaA) GetStringOptionalNullable

func (s *SchemaA) GetStringOptionalNullable() NilString

GetStringOptionalNullable returns the value of StringOptionalNullable.

func (*SchemaA) MarshalJSON

func (s *SchemaA) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*SchemaA) SetBytes

func (s *SchemaA) SetBytes(val []byte)

SetBytes sets the value of Bytes.

func (*SchemaA) SetEdgeSchemaaRecursive

func (s *SchemaA) SetEdgeSchemaaRecursive(val []SchemaA)

SetEdgeSchemaaRecursive sets the value of EdgeSchemaaRecursive.

func (*SchemaA) SetEdgeSchemab

func (s *SchemaA) SetEdgeSchemab(val []SchemaB)

SetEdgeSchemab sets the value of EdgeSchemab.

func (*SchemaA) SetEdgeSchemabUniqueOptional

func (s *SchemaA) SetEdgeSchemabUniqueOptional(val OptSchemaB)

SetEdgeSchemabUniqueOptional sets the value of EdgeSchemabUniqueOptional.

func (*SchemaA) SetEdgeSchemabUniqueRequired

func (s *SchemaA) SetEdgeSchemabUniqueRequired(val SchemaB)

SetEdgeSchemabUniqueRequired sets the value of EdgeSchemabUniqueRequired.

func (*SchemaA) SetEdgeSchemabUniqueRequiredBsBind

func (s *SchemaA) SetEdgeSchemabUniqueRequiredBsBind(val SchemaB)

SetEdgeSchemabUniqueRequiredBsBind sets the value of EdgeSchemabUniqueRequiredBsBind.

func (*SchemaA) SetInt64

func (s *SchemaA) SetInt64(val int64)

SetInt64 sets the value of Int64.

func (*SchemaA) SetJsontypeInts

func (s *SchemaA) SetJsontypeInts(val []int)

SetJsontypeInts sets the value of JsontypeInts.

func (*SchemaA) SetJsontypeIntsOptional

func (s *SchemaA) SetJsontypeIntsOptional(val []int)

SetJsontypeIntsOptional sets the value of JsontypeIntsOptional.

func (*SchemaA) SetJsontypeStrings

func (s *SchemaA) SetJsontypeStrings(val []string)

SetJsontypeStrings sets the value of JsontypeStrings.

func (*SchemaA) SetJsontypeStringsOptional

func (s *SchemaA) SetJsontypeStringsOptional(val []string)

SetJsontypeStringsOptional sets the value of JsontypeStringsOptional.

func (*SchemaA) SetOptionalNullableBool

func (s *SchemaA) SetOptionalNullableBool(val OptNilBool)

SetOptionalNullableBool sets the value of OptionalNullableBool.

func (*SchemaA) SetOptionalNullableEnum

func (s *SchemaA) SetOptionalNullableEnum(val OptNilSchemaAOptionalNullableEnum)

SetOptionalNullableEnum sets the value of OptionalNullableEnum.

func (*SchemaA) SetRequiredEnum

func (s *SchemaA) SetRequiredEnum(val SchemaARequiredEnum)

SetRequiredEnum sets the value of RequiredEnum.

func (*SchemaA) SetStringFoobarBind

func (s *SchemaA) SetStringFoobarBind(val string)

SetStringFoobarBind sets the value of StringFoobarBind.

func (*SchemaA) SetStringOptionalNullable

func (s *SchemaA) SetStringOptionalNullable(val NilString)

SetStringOptionalNullable sets the value of StringOptionalNullable.

func (*SchemaA) UnmarshalJSON

func (s *SchemaA) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*SchemaA) Validate

func (s *SchemaA) Validate() error

type SchemaAOptionalNullableEnum

type SchemaAOptionalNullableEnum string
const (
	SchemaAOptionalNullableEnumC SchemaAOptionalNullableEnum = "c"
	SchemaAOptionalNullableEnumD SchemaAOptionalNullableEnum = "d"
)

func (*SchemaAOptionalNullableEnum) Decode

Decode decodes SchemaAOptionalNullableEnum from json.

func (SchemaAOptionalNullableEnum) Encode

func (s SchemaAOptionalNullableEnum) Encode(e *jx.Encoder)

Encode encodes SchemaAOptionalNullableEnum as json.

func (SchemaAOptionalNullableEnum) MarshalJSON

func (s SchemaAOptionalNullableEnum) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (SchemaAOptionalNullableEnum) MarshalText

func (s SchemaAOptionalNullableEnum) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*SchemaAOptionalNullableEnum) UnmarshalJSON

func (s *SchemaAOptionalNullableEnum) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*SchemaAOptionalNullableEnum) UnmarshalText

func (s *SchemaAOptionalNullableEnum) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (SchemaAOptionalNullableEnum) Validate

func (s SchemaAOptionalNullableEnum) Validate() error

type SchemaARequiredEnum

type SchemaARequiredEnum string
const (
	SchemaARequiredEnumA SchemaARequiredEnum = "a"
	SchemaARequiredEnumB SchemaARequiredEnum = "b"
)

func (*SchemaARequiredEnum) Decode

func (s *SchemaARequiredEnum) Decode(d *jx.Decoder) error

Decode decodes SchemaARequiredEnum from json.

func (SchemaARequiredEnum) Encode

func (s SchemaARequiredEnum) Encode(e *jx.Encoder)

Encode encodes SchemaARequiredEnum as json.

func (SchemaARequiredEnum) MarshalJSON

func (s SchemaARequiredEnum) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (SchemaARequiredEnum) MarshalText

func (s SchemaARequiredEnum) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*SchemaARequiredEnum) UnmarshalJSON

func (s *SchemaARequiredEnum) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*SchemaARequiredEnum) UnmarshalText

func (s *SchemaARequiredEnum) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (SchemaARequiredEnum) Validate

func (s SchemaARequiredEnum) Validate() error

type SchemaB

type SchemaB struct {
	ID int64 `json:"id"`
}

Ref: #/components/schemas/SchemaB

func (*SchemaB) Decode

func (s *SchemaB) Decode(d *jx.Decoder) error

Decode decodes SchemaB from json.

func (*SchemaB) Encode

func (s *SchemaB) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*SchemaB) GetID

func (s *SchemaB) GetID() int64

GetID returns the value of ID.

func (*SchemaB) MarshalJSON

func (s *SchemaB) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*SchemaB) SetID

func (s *SchemaB) SetID(val int64)

SetID sets the value of ID.

func (*SchemaB) UnmarshalJSON

func (s *SchemaB) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements http server based on OpenAPI v3 specification and calls Handler to handle requests.

func NewServer

func NewServer(h Handler, opts ...ServerOption) (*Server, error)

NewServer creates new Server.

func (*Server) FindPath

func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool)

FindPath finds Route for given method and URL.

func (*Server) FindRoute

func (s *Server) FindRoute(method, path string) (Route, bool)

FindRoute finds Route for given method and path.

Note: this method does not unescape path or handle reserved characters in path properly. Use FindPath instead.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves http request as defined by OpenAPI v3 specification, calling handler that matches the path or returning not found error.

type ServerOption

type ServerOption interface {
	// contains filtered or unexported methods
}

ServerOption is server config option.

func WithErrorHandler

func WithErrorHandler(h ErrorHandler) ServerOption

WithErrorHandler specifies error handler to use.

func WithMaxMultipartMemory

func WithMaxMultipartMemory(max int64) ServerOption

WithMaxMultipartMemory specifies limit of memory for storing file parts. File parts which can't be stored in memory will be stored on disk in temporary files.

func WithMethodNotAllowed

func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption

WithMethodNotAllowed specifies Method Not Allowed handler to use.

func WithMiddleware

func WithMiddleware(m ...Middleware) ServerOption

WithMiddleware specifies middlewares to use.

func WithNotFound

func WithNotFound(notFound http.HandlerFunc) ServerOption

WithNotFound specifies Not Found handler to use.

func WithPathPrefix

func WithPathPrefix(prefix string) ServerOption

WithPathPrefix specifies server path prefix.

type UnimplementedHandler

type UnimplementedHandler struct{}

UnimplementedHandler is no-op Handler which returns http.ErrNotImplemented.

func (UnimplementedHandler) Test

func (UnimplementedHandler) Test(ctx context.Context) (r *SchemaA, _ error)

Test implements test operation.

GET /test

Jump to

Keyboard shortcuts

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