endpoint

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Schema is the same as SchemaResponseOption. Deprecated.

Functions

func New

func New(method, path string, options ...Option) *swag.Endpoint

New constructs a new swagger endpoint using the fields and functional options provided

Types

type Option

type Option func(e *swag.Endpoint)

Option represents a functional option to customize the swagger endpoint

func Body

func Body(prototype interface{}, description string, required bool) Option

Body defines a body parameter for the swagger endpoint as would commonly be used for the POST, PUT, and PATCH methods prototype should be a struct or a pointer to struct that swag can use to reflect upon the return type

func BodyR

func BodyR(prototype interface{}) Option

BodyR defines a body parameter for the swagger endpoint as would commonly be used for the POST, PUT, and PATCH methods prototype should be a struct or a pointer to struct that swag can use to reflect upon the return type

func Consumes

func Consumes(v ...string) Option

Consumes sets the endpoint's produces; by default this will be set to application/json

func Deprecated

func Deprecated() Option

func Description

func Description(v string) Option

Description sets the endpoint's description

func FormData

func FormData(name string, typ types.ParameterType, description string, required bool) Option

FormData defines a form-data parameter for the endpoint; name, typ, description and required correspond to the matching swagger fields

func Handler

func Handler(handler interface{}) Option

Handler allows an instance of the web handler to be associated with the endpoint. This can be especially useful when using swag to bind the endpoints to the web router. See the examples package for how the Handler can be used in conjunction with Walk to simplify binding endpoints to a router

func NoSecurity

func NoSecurity() Option

NoSecurity explicitly sets the endpoint to have no security requirements.

func OperationID

func OperationID(v string) Option

OperationID sets the endpoint's operationId

func Path

func Path(name string, typ types.ParameterType, description string, required bool) Option

Path defines a path parameter for the endpoint; name, typ, description and required correspond to the matching swagger fields

func PathDefault

func PathDefault(name string, typ types.ParameterType, description, defVal string, required bool) Option

PathDefault defines a path parameter for the endpoint; name, typ, description, defVal and required correspond to the matching swagger fields

func PathS

func PathS(name, description string) Option

PathS defines a path parameter for the endpoint; name and description correspond to the matching swagger fields, type defaults to string, required defaults to true.

func PathString

func PathString(name, description string) Option

PathString is the same as PathS. Deprecated.

func Produces

func Produces(v ...string) Option

Produces sets the endpoint's produces; by default this will be set to application/json

func Query

func Query(name string, typ types.ParameterType, description string, required bool) Option

Query defines a query parameter for the endpoint; name, typ, description and required correspond to the matching swagger fields

func QueryDefault

func QueryDefault(name string, typ types.ParameterType, description, defVal string, required bool) Option

QueryDefault defines a query parameter for the endpoint; name, typ, description, defVal and required correspond to the matching swagger fields

func QueryS

func QueryS(name, description string) Option

QueryS defines a query parameter for the endpoint; name and description correspond to the matching swagger fields, type defaults to string, required defaults to false.

func QueryString

func QueryString(name, description string) Option

QueryString is the same as QueryS. Deprecated.

func Response

func Response(code int, description string, opts ...ResponseOption) Option

Response sets the endpoint response for the specified code; may be used multiple times with different status codes

func ResponseSuccess

func ResponseSuccess(opts ...ResponseOption) Option

func Security

func Security(scheme string, scopes ...string) Option

Security allows a security scheme to be associated with the endpoint.

func Summary

func Summary(v string) Option

Summary sets the endpoint's summary

func Tags

func Tags(tags ...string) Option

Tags allows one or more tags to be associated with the endpoint

type ResponseOption

type ResponseOption func(response *swag.Response)

ResponseOption allows for additional configurations on responses like header information

func HeaderResponseOption

func HeaderResponseOption(name string, typ types.ParameterType, format, description string) ResponseOption

HeaderResponseOption adds header definitions to swagger responses

func HeaderSResponseOption

func HeaderSResponseOption(name, description string) ResponseOption

HeaderSResponseOption adds the string type header definitions to swagger responses

func SchemaResponseOption

func SchemaResponseOption(schema interface{}) ResponseOption

SchemaResponseOption adds schema definitions to swagger responses

Jump to

Keyboard shortcuts

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