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.
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.
Index ¶
- func New(method, path, summary string, options ...Option) *swagger.Endpoint
- type Builder
- type Option
- func Body(prototype interface{}, description string, required bool) Option
- func BodyType(t reflect.Type, description string, required bool) Option
- func Consumes(v ...string) Option
- func Description(v string) Option
- func Handler(handler interface{}) Option
- func NoSecurity() Option
- func OperationID(v string) Option
- func Path(name, typ, description string, required bool) Option
- func Produces(v ...string) Option
- func Query(name, typ, description string, required bool) Option
- func Response(code int, prototype interface{}, description string, opts ...ResponseOption) Option
- func ResponseType(code int, t reflect.Type, description string, opts ...ResponseOption) Option
- func Security(scheme string, scopes ...string) Option
- func Tags(tags ...string) Option
- type ResponseOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(builder *Builder)
Option represents a functional option to customize the swagger endpoint
func Body ¶
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 ¶
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 ¶
Consumes sets the endpoint's produces; by default this will be set to application/json
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 Path ¶
Path defines a path parameter for the endpoint; name, typ, description, and required correspond to the matching swagger fields
func Produces ¶
Produces sets the endpoint's produces; by default this will be set to application/json
func Query ¶
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 ¶
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
type ResponseOption ¶
ResponseOption allows for additional configurations on responses like header information
func Header ¶
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