endpoint

package
v0.0.0-...-8255161 Latest Latest
Warning

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

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

Documentation

Overview

Copyright 2017 Matt Ho

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

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

Types

type Builder

type Builder struct {
	Endpoint *swagger.Endpoint
}

Builder uses the builder pattern to generate swagger endpoint definitions

type Option

type Option func(builder *Builder)

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 BodyType

func BodyType(t reflect.Type, 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 t represents the Type of the body

func Consumes

func Consumes(v ...string) Option

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

func Description

func Description(v string) Option

Description sets the endpoint's description

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, typ, 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 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, typ, 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 Response

func Response(code int, prototype interface{}, description string, opts ...ResponseOption) Option

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

func ResponseType

func ResponseType(code int, t reflect.Type, description string, opts ...ResponseOption) Option

ResponseType sets the endpoint response for the specified code; may be used multiple times with different status codes t represents the Type of the response

func Security

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

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

func Tags

func Tags(tags ...string) Option

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

func (Option) Apply

func (o Option) Apply(builder *Builder)

Apply improves the readability of applied options

type ResponseOption

type ResponseOption func(response *swagger.Response)

ResponseOption allows for additional configurations on responses like header information

func Header(name, typ, format, description string) ResponseOption

Header adds header definitions to swagger responses

func (ResponseOption) Apply

func (o ResponseOption) Apply(response *swagger.Response)

Apply improves the readability of applied options

Jump to

Keyboard shortcuts

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