repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequence | docstring
stringlengths 6
2.61k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 85
252
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
go-swagger/go-swagger | examples/generated/restapi/operations/pet/update_pet_with_form.go | NewUpdatePetWithForm | func NewUpdatePetWithForm(ctx *middleware.Context, handler UpdatePetWithFormHandler) *UpdatePetWithForm {
return &UpdatePetWithForm{Context: ctx, Handler: handler}
} | go | func NewUpdatePetWithForm(ctx *middleware.Context, handler UpdatePetWithFormHandler) *UpdatePetWithForm {
return &UpdatePetWithForm{Context: ctx, Handler: handler}
} | [
"func",
"NewUpdatePetWithForm",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"UpdatePetWithFormHandler",
")",
"*",
"UpdatePetWithForm",
"{",
"return",
"&",
"UpdatePetWithForm",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewUpdatePetWithForm creates a new http.Handler for the update pet with form operation | [
"NewUpdatePetWithForm",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"update",
"pet",
"with",
"form",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/generated/restapi/operations/pet/update_pet_with_form.go#L28-L30 | train |
go-swagger/go-swagger | examples/oauth2/restapi/operations/get_auth_callback_responses.go | WithPayload | func (o *GetAuthCallbackOK) WithPayload(payload *GetAuthCallbackOKBody) *GetAuthCallbackOK {
o.Payload = payload
return o
} | go | func (o *GetAuthCallbackOK) WithPayload(payload *GetAuthCallbackOKBody) *GetAuthCallbackOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetAuthCallbackOK",
")",
"WithPayload",
"(",
"payload",
"*",
"GetAuthCallbackOKBody",
")",
"*",
"GetAuthCallbackOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get auth callback o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"auth",
"callback",
"o",
"k",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/oauth2/restapi/operations/get_auth_callback_responses.go#L38-L41 | train |
go-swagger/go-swagger | examples/oauth2/restapi/operations/get_auth_callback_responses.go | WithStatusCode | func (o *GetAuthCallbackDefault) WithStatusCode(code int) *GetAuthCallbackDefault {
o._statusCode = code
return o
} | go | func (o *GetAuthCallbackDefault) WithStatusCode(code int) *GetAuthCallbackDefault {
o._statusCode = code
return o
} | [
"func",
"(",
"o",
"*",
"GetAuthCallbackDefault",
")",
"WithStatusCode",
"(",
"code",
"int",
")",
"*",
"GetAuthCallbackDefault",
"{",
"o",
".",
"_statusCode",
"=",
"code",
"\n",
"return",
"o",
"\n",
"}"
] | // WithStatusCode adds the status to the get auth callback default response | [
"WithStatusCode",
"adds",
"the",
"status",
"to",
"the",
"get",
"auth",
"callback",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/oauth2/restapi/operations/get_auth_callback_responses.go#L85-L88 | train |
go-swagger/go-swagger | examples/oauth2/restapi/operations/get_auth_callback_responses.go | WithPayload | func (o *GetAuthCallbackDefault) WithPayload(payload *models.Error) *GetAuthCallbackDefault {
o.Payload = payload
return o
} | go | func (o *GetAuthCallbackDefault) WithPayload(payload *models.Error) *GetAuthCallbackDefault {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetAuthCallbackDefault",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Error",
")",
"*",
"GetAuthCallbackDefault",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get auth callback default response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"auth",
"callback",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/oauth2/restapi/operations/get_auth_callback_responses.go#L96-L99 | train |
go-swagger/go-swagger | examples/generated/restapi/operations/pet/find_pets_by_tags.go | NewFindPetsByTags | func NewFindPetsByTags(ctx *middleware.Context, handler FindPetsByTagsHandler) *FindPetsByTags {
return &FindPetsByTags{Context: ctx, Handler: handler}
} | go | func NewFindPetsByTags(ctx *middleware.Context, handler FindPetsByTagsHandler) *FindPetsByTags {
return &FindPetsByTags{Context: ctx, Handler: handler}
} | [
"func",
"NewFindPetsByTags",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"FindPetsByTagsHandler",
")",
"*",
"FindPetsByTags",
"{",
"return",
"&",
"FindPetsByTags",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewFindPetsByTags creates a new http.Handler for the find pets by tags operation | [
"NewFindPetsByTags",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"find",
"pets",
"by",
"tags",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/generated/restapi/operations/pet/find_pets_by_tags.go#L28-L30 | train |
go-swagger/go-swagger | examples/todo-list/client/todos/destroy_one_parameters.go | WithTimeout | func (o *DestroyOneParams) WithTimeout(timeout time.Duration) *DestroyOneParams {
o.SetTimeout(timeout)
return o
} | go | func (o *DestroyOneParams) WithTimeout(timeout time.Duration) *DestroyOneParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"DestroyOneParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"DestroyOneParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the destroy one params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"destroy",
"one",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/todo-list/client/todos/destroy_one_parameters.go#L73-L76 | train |
go-swagger/go-swagger | examples/todo-list/client/todos/destroy_one_parameters.go | WithContext | func (o *DestroyOneParams) WithContext(ctx context.Context) *DestroyOneParams {
o.SetContext(ctx)
return o
} | go | func (o *DestroyOneParams) WithContext(ctx context.Context) *DestroyOneParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"DestroyOneParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"DestroyOneParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the destroy one params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"destroy",
"one",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/todo-list/client/todos/destroy_one_parameters.go#L84-L87 | train |
go-swagger/go-swagger | examples/todo-list/client/todos/destroy_one_parameters.go | WithHTTPClient | func (o *DestroyOneParams) WithHTTPClient(client *http.Client) *DestroyOneParams {
o.SetHTTPClient(client)
return o
} | go | func (o *DestroyOneParams) WithHTTPClient(client *http.Client) *DestroyOneParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"DestroyOneParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"DestroyOneParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the destroy one params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"destroy",
"one",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/todo-list/client/todos/destroy_one_parameters.go#L95-L98 | train |
go-swagger/go-swagger | examples/todo-list/client/todos/destroy_one_parameters.go | WithID | func (o *DestroyOneParams) WithID(id string) *DestroyOneParams {
o.SetID(id)
return o
} | go | func (o *DestroyOneParams) WithID(id string) *DestroyOneParams {
o.SetID(id)
return o
} | [
"func",
"(",
"o",
"*",
"DestroyOneParams",
")",
"WithID",
"(",
"id",
"string",
")",
"*",
"DestroyOneParams",
"{",
"o",
".",
"SetID",
"(",
"id",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithID adds the id to the destroy one params | [
"WithID",
"adds",
"the",
"id",
"to",
"the",
"destroy",
"one",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/todo-list/client/todos/destroy_one_parameters.go#L106-L109 | train |
go-swagger/go-swagger | examples/authentication/restapi/operations/customers/get_id.go | NewGetID | func NewGetID(ctx *middleware.Context, handler GetIDHandler) *GetID {
return &GetID{Context: ctx, Handler: handler}
} | go | func NewGetID(ctx *middleware.Context, handler GetIDHandler) *GetID {
return &GetID{Context: ctx, Handler: handler}
} | [
"func",
"NewGetID",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"GetIDHandler",
")",
"*",
"GetID",
"{",
"return",
"&",
"GetID",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewGetID creates a new http.Handler for the get Id operation | [
"NewGetID",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"get",
"Id",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/authentication/restapi/operations/customers/get_id.go#L30-L32 | train |
go-swagger/go-swagger | examples/composed-auth/restapi/operations/get_items_responses.go | WithPayload | func (o *GetItemsOK) WithPayload(payload []models.Item) *GetItemsOK {
o.Payload = payload
return o
} | go | func (o *GetItemsOK) WithPayload(payload []models.Item) *GetItemsOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetItemsOK",
")",
"WithPayload",
"(",
"payload",
"[",
"]",
"models",
".",
"Item",
")",
"*",
"GetItemsOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get items o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"items",
"o",
"k",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/composed-auth/restapi/operations/get_items_responses.go#L38-L41 | train |
go-swagger/go-swagger | examples/composed-auth/restapi/operations/get_items_responses.go | WithStatusCode | func (o *GetItemsDefault) WithStatusCode(code int) *GetItemsDefault {
o._statusCode = code
return o
} | go | func (o *GetItemsDefault) WithStatusCode(code int) *GetItemsDefault {
o._statusCode = code
return o
} | [
"func",
"(",
"o",
"*",
"GetItemsDefault",
")",
"WithStatusCode",
"(",
"code",
"int",
")",
"*",
"GetItemsDefault",
"{",
"o",
".",
"_statusCode",
"=",
"code",
"\n",
"return",
"o",
"\n",
"}"
] | // WithStatusCode adds the status to the get items default response | [
"WithStatusCode",
"adds",
"the",
"status",
"to",
"the",
"get",
"items",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/composed-auth/restapi/operations/get_items_responses.go#L88-L91 | train |
go-swagger/go-swagger | examples/composed-auth/restapi/operations/get_items_responses.go | WithPayload | func (o *GetItemsDefault) WithPayload(payload *models.Error) *GetItemsDefault {
o.Payload = payload
return o
} | go | func (o *GetItemsDefault) WithPayload(payload *models.Error) *GetItemsDefault {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetItemsDefault",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Error",
")",
"*",
"GetItemsDefault",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get items default response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"items",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/composed-auth/restapi/operations/get_items_responses.go#L99-L102 | train |
go-swagger/go-swagger | generator/model.go | handleFormatConflicts | func handleFormatConflicts(model *spec.Schema) {
switch model.Format {
case "date", "datetime", "uuid", "bsonobjectid", "base64", "duration":
model.MinLength = nil
model.MaxLength = nil
model.Pattern = ""
// more cases should be inserted here if they arise
}
} | go | func handleFormatConflicts(model *spec.Schema) {
switch model.Format {
case "date", "datetime", "uuid", "bsonobjectid", "base64", "duration":
model.MinLength = nil
model.MaxLength = nil
model.Pattern = ""
// more cases should be inserted here if they arise
}
} | [
"func",
"handleFormatConflicts",
"(",
"model",
"*",
"spec",
".",
"Schema",
")",
"{",
"switch",
"model",
".",
"Format",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
":",
"model",
".",
"MinLength",
"=",
"nil",
"\n",
"model",
".",
"MaxLength",
"=",
"nil",
"\n",
"model",
".",
"Pattern",
"=",
"\"",
"\"",
"\n",
"// more cases should be inserted here if they arise",
"}",
"\n",
"}"
] | // handleFormatConflicts handles all conflicting model properties when a format is set | [
"handleFormatConflicts",
"handles",
"all",
"conflicting",
"model",
"properties",
"when",
"a",
"format",
"is",
"set"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/model.go#L620-L628 | train |
go-swagger/go-swagger | generator/model.go | liftSpecialAllOf | func (sg *schemaGenContext) liftSpecialAllOf() error {
// if there is only a $ref or a primitive and an x-isnullable schema then this is a nullable pointer
// so this should not compose several objects, just 1
// if there is a ref with a discriminator then we look for x-class on the current definition to know
// the value of the discriminator to instantiate the class
if len(sg.Schema.AllOf) < 2 {
return nil
}
var seenSchema int
var seenNullable bool
var schemaToLift spec.Schema
for _, sch := range sg.Schema.AllOf {
tpe, err := sg.TypeResolver.ResolveSchema(&sch, true, true)
if err != nil {
return err
}
if sg.TypeResolver.IsNullable(&sch) {
seenNullable = true
}
if len(sch.Type) > 0 || len(sch.Properties) > 0 || sch.Ref.GetURL() != nil || len(sch.AllOf) > 0 {
seenSchema++
if seenSchema > 1 {
// won't do anything if several candidates for a lift
break
}
if (!tpe.IsAnonymous && tpe.IsComplexObject) || tpe.IsPrimitive {
// lifting complex objects here results in inlined structs in the model
schemaToLift = sch
}
}
}
if seenSchema == 1 {
// when there only a single schema to lift in allOf, replace the schema by its allOf definition
debugLog("lifted schema in allOf for %s", sg.Name)
sg.Schema = schemaToLift
sg.GenSchema.IsNullable = seenNullable
}
return nil
} | go | func (sg *schemaGenContext) liftSpecialAllOf() error {
// if there is only a $ref or a primitive and an x-isnullable schema then this is a nullable pointer
// so this should not compose several objects, just 1
// if there is a ref with a discriminator then we look for x-class on the current definition to know
// the value of the discriminator to instantiate the class
if len(sg.Schema.AllOf) < 2 {
return nil
}
var seenSchema int
var seenNullable bool
var schemaToLift spec.Schema
for _, sch := range sg.Schema.AllOf {
tpe, err := sg.TypeResolver.ResolveSchema(&sch, true, true)
if err != nil {
return err
}
if sg.TypeResolver.IsNullable(&sch) {
seenNullable = true
}
if len(sch.Type) > 0 || len(sch.Properties) > 0 || sch.Ref.GetURL() != nil || len(sch.AllOf) > 0 {
seenSchema++
if seenSchema > 1 {
// won't do anything if several candidates for a lift
break
}
if (!tpe.IsAnonymous && tpe.IsComplexObject) || tpe.IsPrimitive {
// lifting complex objects here results in inlined structs in the model
schemaToLift = sch
}
}
}
if seenSchema == 1 {
// when there only a single schema to lift in allOf, replace the schema by its allOf definition
debugLog("lifted schema in allOf for %s", sg.Name)
sg.Schema = schemaToLift
sg.GenSchema.IsNullable = seenNullable
}
return nil
} | [
"func",
"(",
"sg",
"*",
"schemaGenContext",
")",
"liftSpecialAllOf",
"(",
")",
"error",
"{",
"// if there is only a $ref or a primitive and an x-isnullable schema then this is a nullable pointer",
"// so this should not compose several objects, just 1",
"// if there is a ref with a discriminator then we look for x-class on the current definition to know",
"// the value of the discriminator to instantiate the class",
"if",
"len",
"(",
"sg",
".",
"Schema",
".",
"AllOf",
")",
"<",
"2",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"var",
"seenSchema",
"int",
"\n",
"var",
"seenNullable",
"bool",
"\n",
"var",
"schemaToLift",
"spec",
".",
"Schema",
"\n\n",
"for",
"_",
",",
"sch",
":=",
"range",
"sg",
".",
"Schema",
".",
"AllOf",
"{",
"tpe",
",",
"err",
":=",
"sg",
".",
"TypeResolver",
".",
"ResolveSchema",
"(",
"&",
"sch",
",",
"true",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"sg",
".",
"TypeResolver",
".",
"IsNullable",
"(",
"&",
"sch",
")",
"{",
"seenNullable",
"=",
"true",
"\n",
"}",
"\n",
"if",
"len",
"(",
"sch",
".",
"Type",
")",
">",
"0",
"||",
"len",
"(",
"sch",
".",
"Properties",
")",
">",
"0",
"||",
"sch",
".",
"Ref",
".",
"GetURL",
"(",
")",
"!=",
"nil",
"||",
"len",
"(",
"sch",
".",
"AllOf",
")",
">",
"0",
"{",
"seenSchema",
"++",
"\n",
"if",
"seenSchema",
">",
"1",
"{",
"// won't do anything if several candidates for a lift",
"break",
"\n",
"}",
"\n",
"if",
"(",
"!",
"tpe",
".",
"IsAnonymous",
"&&",
"tpe",
".",
"IsComplexObject",
")",
"||",
"tpe",
".",
"IsPrimitive",
"{",
"// lifting complex objects here results in inlined structs in the model",
"schemaToLift",
"=",
"sch",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"seenSchema",
"==",
"1",
"{",
"// when there only a single schema to lift in allOf, replace the schema by its allOf definition",
"debugLog",
"(",
"\"",
"\"",
",",
"sg",
".",
"Name",
")",
"\n",
"sg",
".",
"Schema",
"=",
"schemaToLift",
"\n",
"sg",
".",
"GenSchema",
".",
"IsNullable",
"=",
"seenNullable",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // liftSpecialAllOf attempts to simplify the rendering of allOf constructs by lifting simple things into the current schema. | [
"liftSpecialAllOf",
"attempts",
"to",
"simplify",
"the",
"rendering",
"of",
"allOf",
"constructs",
"by",
"lifting",
"simple",
"things",
"into",
"the",
"current",
"schema",
"."
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/model.go#L1690-L1731 | train |
go-swagger/go-swagger | examples/generated/restapi/operations/pet/find_pets_by_status.go | NewFindPetsByStatus | func NewFindPetsByStatus(ctx *middleware.Context, handler FindPetsByStatusHandler) *FindPetsByStatus {
return &FindPetsByStatus{Context: ctx, Handler: handler}
} | go | func NewFindPetsByStatus(ctx *middleware.Context, handler FindPetsByStatusHandler) *FindPetsByStatus {
return &FindPetsByStatus{Context: ctx, Handler: handler}
} | [
"func",
"NewFindPetsByStatus",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"FindPetsByStatusHandler",
")",
"*",
"FindPetsByStatus",
"{",
"return",
"&",
"FindPetsByStatus",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewFindPetsByStatus creates a new http.Handler for the find pets by status operation | [
"NewFindPetsByStatus",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"find",
"pets",
"by",
"status",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/generated/restapi/operations/pet/find_pets_by_status.go#L28-L30 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/store/order_create_parameters.go | WithTimeout | func (o *OrderCreateParams) WithTimeout(timeout time.Duration) *OrderCreateParams {
o.SetTimeout(timeout)
return o
} | go | func (o *OrderCreateParams) WithTimeout(timeout time.Duration) *OrderCreateParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"OrderCreateParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"OrderCreateParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the order create params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"order",
"create",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/store/order_create_parameters.go#L78-L81 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/store/order_create_parameters.go | WithContext | func (o *OrderCreateParams) WithContext(ctx context.Context) *OrderCreateParams {
o.SetContext(ctx)
return o
} | go | func (o *OrderCreateParams) WithContext(ctx context.Context) *OrderCreateParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"OrderCreateParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"OrderCreateParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the order create params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"order",
"create",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/store/order_create_parameters.go#L89-L92 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/store/order_create_parameters.go | WithHTTPClient | func (o *OrderCreateParams) WithHTTPClient(client *http.Client) *OrderCreateParams {
o.SetHTTPClient(client)
return o
} | go | func (o *OrderCreateParams) WithHTTPClient(client *http.Client) *OrderCreateParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"OrderCreateParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"OrderCreateParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the order create params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"order",
"create",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/store/order_create_parameters.go#L100-L103 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/store/order_create_parameters.go | WithBody | func (o *OrderCreateParams) WithBody(body *models.Order) *OrderCreateParams {
o.SetBody(body)
return o
} | go | func (o *OrderCreateParams) WithBody(body *models.Order) *OrderCreateParams {
o.SetBody(body)
return o
} | [
"func",
"(",
"o",
"*",
"OrderCreateParams",
")",
"WithBody",
"(",
"body",
"*",
"models",
".",
"Order",
")",
"*",
"OrderCreateParams",
"{",
"o",
".",
"SetBody",
"(",
"body",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithBody adds the body to the order create params | [
"WithBody",
"adds",
"the",
"body",
"to",
"the",
"order",
"create",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/store/order_create_parameters.go#L111-L114 | train |
go-swagger/go-swagger | examples/task-tracker/models/task.go | Validate | func (m *TaskAttachmentsAnon) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDescription(formats); err != nil {
res = append(res, err)
}
if err := m.validateURL(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *TaskAttachmentsAnon) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDescription(formats); err != nil {
res = append(res, err)
}
if err := m.validateURL(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"TaskAttachmentsAnon",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateDescription",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateURL",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this task attachments anon | [
"Validate",
"validates",
"this",
"task",
"attachments",
"anon"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/models/task.go#L324-L339 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/delete_task_responses.go | WithStatusCode | func (o *DeleteTaskDefault) WithStatusCode(code int) *DeleteTaskDefault {
o._statusCode = code
return o
} | go | func (o *DeleteTaskDefault) WithStatusCode(code int) *DeleteTaskDefault {
o._statusCode = code
return o
} | [
"func",
"(",
"o",
"*",
"DeleteTaskDefault",
")",
"WithStatusCode",
"(",
"code",
"int",
")",
"*",
"DeleteTaskDefault",
"{",
"o",
".",
"_statusCode",
"=",
"code",
"\n",
"return",
"o",
"\n",
"}"
] | // WithStatusCode adds the status to the delete task default response | [
"WithStatusCode",
"adds",
"the",
"status",
"to",
"the",
"delete",
"task",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/delete_task_responses.go#L69-L72 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/delete_task_responses.go | WithXErrorCode | func (o *DeleteTaskDefault) WithXErrorCode(xErrorCode string) *DeleteTaskDefault {
o.XErrorCode = xErrorCode
return o
} | go | func (o *DeleteTaskDefault) WithXErrorCode(xErrorCode string) *DeleteTaskDefault {
o.XErrorCode = xErrorCode
return o
} | [
"func",
"(",
"o",
"*",
"DeleteTaskDefault",
")",
"WithXErrorCode",
"(",
"xErrorCode",
"string",
")",
"*",
"DeleteTaskDefault",
"{",
"o",
".",
"XErrorCode",
"=",
"xErrorCode",
"\n",
"return",
"o",
"\n",
"}"
] | // WithXErrorCode adds the xErrorCode to the delete task default response | [
"WithXErrorCode",
"adds",
"the",
"xErrorCode",
"to",
"the",
"delete",
"task",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/delete_task_responses.go#L80-L83 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/delete_task_responses.go | WithPayload | func (o *DeleteTaskDefault) WithPayload(payload *models.Error) *DeleteTaskDefault {
o.Payload = payload
return o
} | go | func (o *DeleteTaskDefault) WithPayload(payload *models.Error) *DeleteTaskDefault {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"DeleteTaskDefault",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Error",
")",
"*",
"DeleteTaskDefault",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the delete task default response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"delete",
"task",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/delete_task_responses.go#L91-L94 | train |
go-swagger/go-swagger | examples/composed-auth/auth/authorizers.go | IsReseller | func IsReseller(token string) (*models.Principal, error) {
claims, err := parseAndCheckToken(token)
if err == nil {
if claims.Issuer == issuerName && claims.Id != "" {
isReseller := false
for _, role := range claims.Roles {
if role == "reseller" {
isReseller = true
break
}
}
if isReseller {
return &models.Principal{
Name: claims.Id,
}, nil
}
return nil, errors.New(403, "Forbidden: insufficient API key privileges")
}
}
return nil, errors.New(401, "Unauthorized: invalid API key token: %v", err)
} | go | func IsReseller(token string) (*models.Principal, error) {
claims, err := parseAndCheckToken(token)
if err == nil {
if claims.Issuer == issuerName && claims.Id != "" {
isReseller := false
for _, role := range claims.Roles {
if role == "reseller" {
isReseller = true
break
}
}
if isReseller {
return &models.Principal{
Name: claims.Id,
}, nil
}
return nil, errors.New(403, "Forbidden: insufficient API key privileges")
}
}
return nil, errors.New(401, "Unauthorized: invalid API key token: %v", err)
} | [
"func",
"IsReseller",
"(",
"token",
"string",
")",
"(",
"*",
"models",
".",
"Principal",
",",
"error",
")",
"{",
"claims",
",",
"err",
":=",
"parseAndCheckToken",
"(",
"token",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"if",
"claims",
".",
"Issuer",
"==",
"issuerName",
"&&",
"claims",
".",
"Id",
"!=",
"\"",
"\"",
"{",
"isReseller",
":=",
"false",
"\n",
"for",
"_",
",",
"role",
":=",
"range",
"claims",
".",
"Roles",
"{",
"if",
"role",
"==",
"\"",
"\"",
"{",
"isReseller",
"=",
"true",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"isReseller",
"{",
"return",
"&",
"models",
".",
"Principal",
"{",
"Name",
":",
"claims",
".",
"Id",
",",
"}",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"403",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"401",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}"
] | // IsReseller tells if the API key is a JWT signed by us with a claim to be a reseller | [
"IsReseller",
"tells",
"if",
"the",
"API",
"key",
"is",
"a",
"JWT",
"signed",
"by",
"us",
"with",
"a",
"claim",
"to",
"be",
"a",
"reseller"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/composed-auth/auth/authorizers.go#L66-L86 | train |
go-swagger/go-swagger | examples/composed-auth/auth/authorizers.go | HasRole | func HasRole(token string, scopes []string) (*models.Principal, error) {
claims, err := parseAndCheckToken(token)
if err == nil {
if claims.Issuer == issuerName {
isInScopes := false
claimedRoles := []string{}
for _, scope := range scopes {
for _, role := range claims.Roles {
if role == scope {
isInScopes = true
// we enrich the principal with all claimed roles within scope (hence: not breaking here)
claimedRoles = append(claimedRoles, role)
}
}
}
if isInScopes {
return &models.Principal{
Name: claims.Id,
Roles: claimedRoles,
}, nil
}
return nil, errors.New(403, "Forbidden: insufficient privileges")
}
}
return nil, errors.New(401, "Unauthorized: invalid Bearer token: %v", err)
} | go | func HasRole(token string, scopes []string) (*models.Principal, error) {
claims, err := parseAndCheckToken(token)
if err == nil {
if claims.Issuer == issuerName {
isInScopes := false
claimedRoles := []string{}
for _, scope := range scopes {
for _, role := range claims.Roles {
if role == scope {
isInScopes = true
// we enrich the principal with all claimed roles within scope (hence: not breaking here)
claimedRoles = append(claimedRoles, role)
}
}
}
if isInScopes {
return &models.Principal{
Name: claims.Id,
Roles: claimedRoles,
}, nil
}
return nil, errors.New(403, "Forbidden: insufficient privileges")
}
}
return nil, errors.New(401, "Unauthorized: invalid Bearer token: %v", err)
} | [
"func",
"HasRole",
"(",
"token",
"string",
",",
"scopes",
"[",
"]",
"string",
")",
"(",
"*",
"models",
".",
"Principal",
",",
"error",
")",
"{",
"claims",
",",
"err",
":=",
"parseAndCheckToken",
"(",
"token",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"if",
"claims",
".",
"Issuer",
"==",
"issuerName",
"{",
"isInScopes",
":=",
"false",
"\n",
"claimedRoles",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"scope",
":=",
"range",
"scopes",
"{",
"for",
"_",
",",
"role",
":=",
"range",
"claims",
".",
"Roles",
"{",
"if",
"role",
"==",
"scope",
"{",
"isInScopes",
"=",
"true",
"\n",
"// we enrich the principal with all claimed roles within scope (hence: not breaking here)",
"claimedRoles",
"=",
"append",
"(",
"claimedRoles",
",",
"role",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"isInScopes",
"{",
"return",
"&",
"models",
".",
"Principal",
"{",
"Name",
":",
"claims",
".",
"Id",
",",
"Roles",
":",
"claimedRoles",
",",
"}",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"403",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"401",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}"
] | // HasRole tells if the Bearer token is a JWT signed by us with a claim to be
// member of an authorization scope.
// We verify that the claimed role is one of the passed scopes | [
"HasRole",
"tells",
"if",
"the",
"Bearer",
"token",
"is",
"a",
"JWT",
"signed",
"by",
"us",
"with",
"a",
"claim",
"to",
"be",
"member",
"of",
"an",
"authorization",
"scope",
".",
"We",
"verify",
"that",
"the",
"claimed",
"role",
"is",
"one",
"of",
"the",
"passed",
"scopes"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/composed-auth/auth/authorizers.go#L91-L116 | train |
go-swagger/go-swagger | examples/task-tracker/models/error.go | Validate | func (m *Error) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCode(formats); err != nil {
res = append(res, err)
}
if err := m.validateHelpURL(formats); err != nil {
res = append(res, err)
}
if err := m.validateMessage(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *Error) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCode(formats); err != nil {
res = append(res, err)
}
if err := m.validateHelpURL(formats); err != nil {
res = append(res, err)
}
if err := m.validateMessage(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"Error",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateCode",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateHelpURL",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateMessage",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this error | [
"Validate",
"validates",
"this",
"error"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/models/error.go#L38-L57 | train |
go-swagger/go-swagger | examples/task-tracker/models/task_card.go | Validate | func (m *TaskCard) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAssignedTo(formats); err != nil {
res = append(res, err)
}
if err := m.validateEffort(formats); err != nil {
res = append(res, err)
}
if err := m.validateKarma(formats); err != nil {
res = append(res, err)
}
if err := m.validateMilestone(formats); err != nil {
res = append(res, err)
}
if err := m.validateReportedAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateSeverity(formats); err != nil {
res = append(res, err)
}
if err := m.validateStatus(formats); err != nil {
res = append(res, err)
}
if err := m.validateTags(formats); err != nil {
res = append(res, err)
}
if err := m.validateTitle(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *TaskCard) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAssignedTo(formats); err != nil {
res = append(res, err)
}
if err := m.validateEffort(formats); err != nil {
res = append(res, err)
}
if err := m.validateKarma(formats); err != nil {
res = append(res, err)
}
if err := m.validateMilestone(formats); err != nil {
res = append(res, err)
}
if err := m.validateReportedAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateSeverity(formats); err != nil {
res = append(res, err)
}
if err := m.validateStatus(formats); err != nil {
res = append(res, err)
}
if err := m.validateTags(formats); err != nil {
res = append(res, err)
}
if err := m.validateTitle(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"TaskCard",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateAssignedTo",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateEffort",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateKarma",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateMilestone",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateReportedAt",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateSeverity",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateStatus",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateTags",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateTitle",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this task card | [
"Validate",
"validates",
"this",
"task",
"card"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/models/task_card.go#L100-L143 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/restapi/operations/store/order_create_responses.go | WithPayload | func (o *OrderCreateOK) WithPayload(payload *models.Order) *OrderCreateOK {
o.Payload = payload
return o
} | go | func (o *OrderCreateOK) WithPayload(payload *models.Order) *OrderCreateOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"OrderCreateOK",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Order",
")",
"*",
"OrderCreateOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the order create o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"order",
"create",
"o",
"k",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/restapi/operations/store/order_create_responses.go#L38-L41 | train |
go-swagger/go-swagger | cmd/swagger/commands/expand.go | Execute | func (c *ExpandSpec) Execute(args []string) error {
if len(args) != 1 {
return errors.New("The expand command requires the single swagger document url to be specified")
}
swaggerDoc := args[0]
specDoc, err := loads.Spec(swaggerDoc)
if err != nil {
return err
}
exp, err := specDoc.Expanded()
if err != nil {
return err
}
return writeToFile(exp.Spec(), !c.Compact, c.Format, string(c.Output))
} | go | func (c *ExpandSpec) Execute(args []string) error {
if len(args) != 1 {
return errors.New("The expand command requires the single swagger document url to be specified")
}
swaggerDoc := args[0]
specDoc, err := loads.Spec(swaggerDoc)
if err != nil {
return err
}
exp, err := specDoc.Expanded()
if err != nil {
return err
}
return writeToFile(exp.Spec(), !c.Compact, c.Format, string(c.Output))
} | [
"func",
"(",
"c",
"*",
"ExpandSpec",
")",
"Execute",
"(",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"swaggerDoc",
":=",
"args",
"[",
"0",
"]",
"\n",
"specDoc",
",",
"err",
":=",
"loads",
".",
"Spec",
"(",
"swaggerDoc",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"exp",
",",
"err",
":=",
"specDoc",
".",
"Expanded",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"writeToFile",
"(",
"exp",
".",
"Spec",
"(",
")",
",",
"!",
"c",
".",
"Compact",
",",
"c",
".",
"Format",
",",
"string",
"(",
"c",
".",
"Output",
")",
")",
"\n",
"}"
] | // Execute expands the spec | [
"Execute",
"expands",
"the",
"spec"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/cmd/swagger/commands/expand.go#L26-L43 | train |
go-swagger/go-swagger | cmd/swagger/commands/generate/spec.go | Execute | func (s *SpecFile) Execute(args []string) error {
input, err := loadSpec(string(s.Input))
if err != nil {
return err
}
var opts scan.Opts
opts.BasePath = s.BasePath
opts.Input = input
opts.ScanModels = s.ScanModels
opts.BuildTags = s.BuildTags
opts.Include = s.Include
opts.Exclude = s.Exclude
opts.IncludeTags = s.IncludeTags
opts.ExcludeTags = s.ExcludeTags
swspec, err := scan.Application(opts)
if err != nil {
return err
}
return writeToFile(swspec, !s.Compact, string(s.Output))
} | go | func (s *SpecFile) Execute(args []string) error {
input, err := loadSpec(string(s.Input))
if err != nil {
return err
}
var opts scan.Opts
opts.BasePath = s.BasePath
opts.Input = input
opts.ScanModels = s.ScanModels
opts.BuildTags = s.BuildTags
opts.Include = s.Include
opts.Exclude = s.Exclude
opts.IncludeTags = s.IncludeTags
opts.ExcludeTags = s.ExcludeTags
swspec, err := scan.Application(opts)
if err != nil {
return err
}
return writeToFile(swspec, !s.Compact, string(s.Output))
} | [
"func",
"(",
"s",
"*",
"SpecFile",
")",
"Execute",
"(",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"input",
",",
"err",
":=",
"loadSpec",
"(",
"string",
"(",
"s",
".",
"Input",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"opts",
"scan",
".",
"Opts",
"\n",
"opts",
".",
"BasePath",
"=",
"s",
".",
"BasePath",
"\n",
"opts",
".",
"Input",
"=",
"input",
"\n",
"opts",
".",
"ScanModels",
"=",
"s",
".",
"ScanModels",
"\n",
"opts",
".",
"BuildTags",
"=",
"s",
".",
"BuildTags",
"\n",
"opts",
".",
"Include",
"=",
"s",
".",
"Include",
"\n",
"opts",
".",
"Exclude",
"=",
"s",
".",
"Exclude",
"\n",
"opts",
".",
"IncludeTags",
"=",
"s",
".",
"IncludeTags",
"\n",
"opts",
".",
"ExcludeTags",
"=",
"s",
".",
"ExcludeTags",
"\n",
"swspec",
",",
"err",
":=",
"scan",
".",
"Application",
"(",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"writeToFile",
"(",
"swspec",
",",
"!",
"s",
".",
"Compact",
",",
"string",
"(",
"s",
".",
"Output",
")",
")",
"\n",
"}"
] | // Execute runs this command | [
"Execute",
"runs",
"this",
"command"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/cmd/swagger/commands/generate/spec.go#L46-L67 | train |
go-swagger/go-swagger | examples/authentication/client/customers/create_parameters.go | WithTimeout | func (o *CreateParams) WithTimeout(timeout time.Duration) *CreateParams {
o.SetTimeout(timeout)
return o
} | go | func (o *CreateParams) WithTimeout(timeout time.Duration) *CreateParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"CreateParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"CreateParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the create params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"create",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/authentication/client/customers/create_parameters.go#L75-L78 | train |
go-swagger/go-swagger | examples/authentication/client/customers/create_parameters.go | WithContext | func (o *CreateParams) WithContext(ctx context.Context) *CreateParams {
o.SetContext(ctx)
return o
} | go | func (o *CreateParams) WithContext(ctx context.Context) *CreateParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"CreateParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"CreateParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the create params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"create",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/authentication/client/customers/create_parameters.go#L86-L89 | train |
go-swagger/go-swagger | examples/authentication/client/customers/create_parameters.go | WithHTTPClient | func (o *CreateParams) WithHTTPClient(client *http.Client) *CreateParams {
o.SetHTTPClient(client)
return o
} | go | func (o *CreateParams) WithHTTPClient(client *http.Client) *CreateParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"CreateParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"CreateParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the create params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"create",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/authentication/client/customers/create_parameters.go#L97-L100 | train |
go-swagger/go-swagger | examples/authentication/client/customers/create_parameters.go | WithInfo | func (o *CreateParams) WithInfo(info *models.Customer) *CreateParams {
o.SetInfo(info)
return o
} | go | func (o *CreateParams) WithInfo(info *models.Customer) *CreateParams {
o.SetInfo(info)
return o
} | [
"func",
"(",
"o",
"*",
"CreateParams",
")",
"WithInfo",
"(",
"info",
"*",
"models",
".",
"Customer",
")",
"*",
"CreateParams",
"{",
"o",
".",
"SetInfo",
"(",
"info",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithInfo adds the info to the create params | [
"WithInfo",
"adds",
"the",
"info",
"to",
"the",
"create",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/authentication/client/customers/create_parameters.go#L108-L111 | train |
go-swagger/go-swagger | examples/task-tracker/models/milestone.go | Validate | func (m *Milestone) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDueDate(formats); err != nil {
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
res = append(res, err)
}
if err := m.validateStats(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *Milestone) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDueDate(formats); err != nil {
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
res = append(res, err)
}
if err := m.validateStats(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"Milestone",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateDueDate",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateName",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateStats",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this milestone | [
"Validate",
"validates",
"this",
"milestone"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/models/milestone.go#L52-L71 | train |
go-swagger/go-swagger | examples/2.0/petstore/server/api/petstore.go | NewPetstore | func NewPetstore() (http.Handler, error) {
spec, err := loads.Analyzed(json.RawMessage([]byte(swaggerJSON)), "")
if err != nil {
return nil, err
}
api := untyped.NewAPI(spec)
api.RegisterOperation("get", "/pets", getAllPets)
api.RegisterOperation("post", "/pets", createPet)
api.RegisterOperation("delete", "/pets/{id}", deletePet)
api.RegisterOperation("get", "/pets/{id}", getPetByID)
return middleware.Serve(spec, api), nil
} | go | func NewPetstore() (http.Handler, error) {
spec, err := loads.Analyzed(json.RawMessage([]byte(swaggerJSON)), "")
if err != nil {
return nil, err
}
api := untyped.NewAPI(spec)
api.RegisterOperation("get", "/pets", getAllPets)
api.RegisterOperation("post", "/pets", createPet)
api.RegisterOperation("delete", "/pets/{id}", deletePet)
api.RegisterOperation("get", "/pets/{id}", getPetByID)
return middleware.Serve(spec, api), nil
} | [
"func",
"NewPetstore",
"(",
")",
"(",
"http",
".",
"Handler",
",",
"error",
")",
"{",
"spec",
",",
"err",
":=",
"loads",
".",
"Analyzed",
"(",
"json",
".",
"RawMessage",
"(",
"[",
"]",
"byte",
"(",
"swaggerJSON",
")",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"api",
":=",
"untyped",
".",
"NewAPI",
"(",
"spec",
")",
"\n\n",
"api",
".",
"RegisterOperation",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"getAllPets",
")",
"\n",
"api",
".",
"RegisterOperation",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"createPet",
")",
"\n",
"api",
".",
"RegisterOperation",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"deletePet",
")",
"\n",
"api",
".",
"RegisterOperation",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"getPetByID",
")",
"\n\n",
"return",
"middleware",
".",
"Serve",
"(",
"spec",
",",
"api",
")",
",",
"nil",
"\n",
"}"
] | // NewPetstore creates a new petstore api handler | [
"NewPetstore",
"creates",
"a",
"new",
"petstore",
"api",
"handler"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/2.0/petstore/server/api/petstore.go#L33-L46 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/restapi/operations/store/inventory_get.go | NewInventoryGet | func NewInventoryGet(ctx *middleware.Context, handler InventoryGetHandler) *InventoryGet {
return &InventoryGet{Context: ctx, Handler: handler}
} | go | func NewInventoryGet(ctx *middleware.Context, handler InventoryGetHandler) *InventoryGet {
return &InventoryGet{Context: ctx, Handler: handler}
} | [
"func",
"NewInventoryGet",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"InventoryGetHandler",
")",
"*",
"InventoryGet",
"{",
"return",
"&",
"InventoryGet",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewInventoryGet creates a new http.Handler for the inventory get operation | [
"NewInventoryGet",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"inventory",
"get",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/restapi/operations/store/inventory_get.go#L28-L30 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/models/pet.go | Validate | func (m *Pet) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCategory(formats); err != nil {
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
res = append(res, err)
}
if err := m.validatePhotoUrls(formats); err != nil {
res = append(res, err)
}
if err := m.validateStatus(formats); err != nil {
res = append(res, err)
}
if err := m.validateTags(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *Pet) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCategory(formats); err != nil {
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
res = append(res, err)
}
if err := m.validatePhotoUrls(formats); err != nil {
res = append(res, err)
}
if err := m.validateStatus(formats); err != nil {
res = append(res, err)
}
if err := m.validateTags(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"Pet",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateCategory",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateName",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validatePhotoUrls",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateStatus",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateTags",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this pet | [
"Validate",
"validates",
"this",
"pet"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/models/pet.go#L46-L73 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/pet/pet_list_parameters.go | WithTimeout | func (o *PetListParams) WithTimeout(timeout time.Duration) *PetListParams {
o.SetTimeout(timeout)
return o
} | go | func (o *PetListParams) WithTimeout(timeout time.Duration) *PetListParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"PetListParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"PetListParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the pet list params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"pet",
"list",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/pet/pet_list_parameters.go#L77-L80 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/pet/pet_list_parameters.go | WithContext | func (o *PetListParams) WithContext(ctx context.Context) *PetListParams {
o.SetContext(ctx)
return o
} | go | func (o *PetListParams) WithContext(ctx context.Context) *PetListParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"PetListParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"PetListParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the pet list params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"pet",
"list",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/pet/pet_list_parameters.go#L88-L91 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/pet/pet_list_parameters.go | WithHTTPClient | func (o *PetListParams) WithHTTPClient(client *http.Client) *PetListParams {
o.SetHTTPClient(client)
return o
} | go | func (o *PetListParams) WithHTTPClient(client *http.Client) *PetListParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"PetListParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"PetListParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the pet list params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"pet",
"list",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/pet/pet_list_parameters.go#L99-L102 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/pet/pet_list_parameters.go | WithStatus | func (o *PetListParams) WithStatus(status []string) *PetListParams {
o.SetStatus(status)
return o
} | go | func (o *PetListParams) WithStatus(status []string) *PetListParams {
o.SetStatus(status)
return o
} | [
"func",
"(",
"o",
"*",
"PetListParams",
")",
"WithStatus",
"(",
"status",
"[",
"]",
"string",
")",
"*",
"PetListParams",
"{",
"o",
".",
"SetStatus",
"(",
"status",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithStatus adds the status to the pet list params | [
"WithStatus",
"adds",
"the",
"status",
"to",
"the",
"pet",
"list",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/pet/pet_list_parameters.go#L110-L113 | train |
go-swagger/go-swagger | generator/structs.go | HasSomeDefaults | func (g GenHeaders) HasSomeDefaults() bool {
// NOTE: this is currently used by templates to avoid empty constructs
for _, header := range g {
if header.HasDefault {
return true
}
}
return false
} | go | func (g GenHeaders) HasSomeDefaults() bool {
// NOTE: this is currently used by templates to avoid empty constructs
for _, header := range g {
if header.HasDefault {
return true
}
}
return false
} | [
"func",
"(",
"g",
"GenHeaders",
")",
"HasSomeDefaults",
"(",
")",
"bool",
"{",
"// NOTE: this is currently used by templates to avoid empty constructs",
"for",
"_",
",",
"header",
":=",
"range",
"g",
"{",
"if",
"header",
".",
"HasDefault",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // HasSomeDefaults returns true is at least one header has a default value set | [
"HasSomeDefaults",
"returns",
"true",
"is",
"at",
"least",
"one",
"header",
"has",
"a",
"default",
"value",
"set"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/structs.go#L219-L227 | train |
go-swagger/go-swagger | generator/structs.go | HasSomeDefaults | func (g GenParameters) HasSomeDefaults() bool {
// NOTE: this is currently used by templates to avoid empty constructs
for _, param := range g {
if param.HasDefault {
return true
}
}
return false
} | go | func (g GenParameters) HasSomeDefaults() bool {
// NOTE: this is currently used by templates to avoid empty constructs
for _, param := range g {
if param.HasDefault {
return true
}
}
return false
} | [
"func",
"(",
"g",
"GenParameters",
")",
"HasSomeDefaults",
"(",
")",
"bool",
"{",
"// NOTE: this is currently used by templates to avoid empty constructs",
"for",
"_",
",",
"param",
":=",
"range",
"g",
"{",
"if",
"param",
".",
"HasDefault",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // HasSomeDefaults returns true is at least one parameter has a default value set | [
"HasSomeDefaults",
"returns",
"true",
"is",
"at",
"least",
"one",
"parameter",
"has",
"a",
"default",
"value",
"set"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/structs.go#L327-L335 | train |
go-swagger/go-swagger | generator/structs.go | ItemsDepth | func (g *GenItems) ItemsDepth() string {
// NOTE: this is currently used by templates to generate explicit comments in nested structures
current := g
i := 1
for current.Parent != nil {
i++
current = current.Parent
}
return strings.Repeat("items.", i)
} | go | func (g *GenItems) ItemsDepth() string {
// NOTE: this is currently used by templates to generate explicit comments in nested structures
current := g
i := 1
for current.Parent != nil {
i++
current = current.Parent
}
return strings.Repeat("items.", i)
} | [
"func",
"(",
"g",
"*",
"GenItems",
")",
"ItemsDepth",
"(",
")",
"string",
"{",
"// NOTE: this is currently used by templates to generate explicit comments in nested structures",
"current",
":=",
"g",
"\n",
"i",
":=",
"1",
"\n",
"for",
"current",
".",
"Parent",
"!=",
"nil",
"{",
"i",
"++",
"\n",
"current",
"=",
"current",
".",
"Parent",
"\n",
"}",
"\n",
"return",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"i",
")",
"\n",
"}"
] | // ItemsDepth returns a string "items.items..." with as many items as the level of nesting of the array. | [
"ItemsDepth",
"returns",
"a",
"string",
"items",
".",
"items",
"...",
"with",
"as",
"many",
"items",
"as",
"the",
"level",
"of",
"nesting",
"of",
"the",
"array",
"."
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/structs.go#L360-L369 | train |
go-swagger/go-swagger | generator/structs.go | MarshalJSON | func (g GenStatusCodeResponses) MarshalJSON() ([]byte, error) {
if g == nil {
return nil, nil
}
var buf bytes.Buffer
buf.WriteRune('{')
for i, v := range g {
rb, err := json.Marshal(v)
if err != nil {
return nil, err
}
if i > 0 {
buf.WriteRune(',')
}
buf.WriteString(fmt.Sprintf("%q:", strconv.Itoa(v.Code)))
buf.Write(rb)
}
buf.WriteRune('}')
return buf.Bytes(), nil
} | go | func (g GenStatusCodeResponses) MarshalJSON() ([]byte, error) {
if g == nil {
return nil, nil
}
var buf bytes.Buffer
buf.WriteRune('{')
for i, v := range g {
rb, err := json.Marshal(v)
if err != nil {
return nil, err
}
if i > 0 {
buf.WriteRune(',')
}
buf.WriteString(fmt.Sprintf("%q:", strconv.Itoa(v.Code)))
buf.Write(rb)
}
buf.WriteRune('}')
return buf.Bytes(), nil
} | [
"func",
"(",
"g",
"GenStatusCodeResponses",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"g",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"buf",
".",
"WriteRune",
"(",
"'{'",
")",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"g",
"{",
"rb",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"i",
">",
"0",
"{",
"buf",
".",
"WriteRune",
"(",
"','",
")",
"\n",
"}",
"\n",
"buf",
".",
"WriteString",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"v",
".",
"Code",
")",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"rb",
")",
"\n",
"}",
"\n",
"buf",
".",
"WriteRune",
"(",
"'}'",
")",
"\n",
"return",
"buf",
".",
"Bytes",
"(",
")",
",",
"nil",
"\n",
"}"
] | // MarshalJSON marshals these responses to json | [
"MarshalJSON",
"marshals",
"these",
"responses",
"to",
"json"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/structs.go#L400-L419 | train |
go-swagger/go-swagger | generator/structs.go | UnmarshalJSON | func (g *GenStatusCodeResponses) UnmarshalJSON(data []byte) error {
var dd map[string]GenResponse
if err := json.Unmarshal(data, &dd); err != nil {
return err
}
var gg GenStatusCodeResponses
for _, v := range dd {
gg = append(gg, v)
}
sort.Sort(gg)
*g = gg
return nil
} | go | func (g *GenStatusCodeResponses) UnmarshalJSON(data []byte) error {
var dd map[string]GenResponse
if err := json.Unmarshal(data, &dd); err != nil {
return err
}
var gg GenStatusCodeResponses
for _, v := range dd {
gg = append(gg, v)
}
sort.Sort(gg)
*g = gg
return nil
} | [
"func",
"(",
"g",
"*",
"GenStatusCodeResponses",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"dd",
"map",
"[",
"string",
"]",
"GenResponse",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"dd",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"var",
"gg",
"GenStatusCodeResponses",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"dd",
"{",
"gg",
"=",
"append",
"(",
"gg",
",",
"v",
")",
"\n",
"}",
"\n",
"sort",
".",
"Sort",
"(",
"gg",
")",
"\n",
"*",
"g",
"=",
"gg",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON unmarshals this GenStatusCodeResponses from json | [
"UnmarshalJSON",
"unmarshals",
"this",
"GenStatusCodeResponses",
"from",
"json"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/structs.go#L422-L434 | train |
go-swagger/go-swagger | generator/structs.go | UseGoStructFlags | func (g *GenApp) UseGoStructFlags() bool {
if g.GenOpts == nil {
return true
}
return g.GenOpts.FlagStrategy == "" || g.GenOpts.FlagStrategy == "go-flags"
} | go | func (g *GenApp) UseGoStructFlags() bool {
if g.GenOpts == nil {
return true
}
return g.GenOpts.FlagStrategy == "" || g.GenOpts.FlagStrategy == "go-flags"
} | [
"func",
"(",
"g",
"*",
"GenApp",
")",
"UseGoStructFlags",
"(",
")",
"bool",
"{",
"if",
"g",
".",
"GenOpts",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"g",
".",
"GenOpts",
".",
"FlagStrategy",
"==",
"\"",
"\"",
"||",
"g",
".",
"GenOpts",
".",
"FlagStrategy",
"==",
"\"",
"\"",
"\n",
"}"
] | // UseGoStructFlags returns true when no strategy is specified or it is set to "go-flags" | [
"UseGoStructFlags",
"returns",
"true",
"when",
"no",
"strategy",
"is",
"specified",
"or",
"it",
"is",
"set",
"to",
"go",
"-",
"flags"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/structs.go#L533-L538 | train |
go-swagger/go-swagger | generator/structs.go | UsePFlags | func (g *GenApp) UsePFlags() bool {
return g.GenOpts != nil && strings.HasPrefix(g.GenOpts.FlagStrategy, "pflag")
} | go | func (g *GenApp) UsePFlags() bool {
return g.GenOpts != nil && strings.HasPrefix(g.GenOpts.FlagStrategy, "pflag")
} | [
"func",
"(",
"g",
"*",
"GenApp",
")",
"UsePFlags",
"(",
")",
"bool",
"{",
"return",
"g",
".",
"GenOpts",
"!=",
"nil",
"&&",
"strings",
".",
"HasPrefix",
"(",
"g",
".",
"GenOpts",
".",
"FlagStrategy",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // UsePFlags returns true when the flag strategy is set to pflag | [
"UsePFlags",
"returns",
"true",
"when",
"the",
"flag",
"strategy",
"is",
"set",
"to",
"pflag"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/structs.go#L541-L543 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/list_tasks_parameters.go | bindPageSize | func (o *ListTasksParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
// Default values have been previously initialized by NewListTasksParams()
return nil
}
value, err := swag.ConvertInt32(raw)
if err != nil {
return errors.InvalidType("pageSize", "query", "int32", raw)
}
o.PageSize = &value
return nil
} | go | func (o *ListTasksParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
// Default values have been previously initialized by NewListTasksParams()
return nil
}
value, err := swag.ConvertInt32(raw)
if err != nil {
return errors.InvalidType("pageSize", "query", "int32", raw)
}
o.PageSize = &value
return nil
} | [
"func",
"(",
"o",
"*",
"ListTasksParams",
")",
"bindPageSize",
"(",
"rawData",
"[",
"]",
"string",
",",
"hasKey",
"bool",
",",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"raw",
"string",
"\n",
"if",
"len",
"(",
"rawData",
")",
">",
"0",
"{",
"raw",
"=",
"rawData",
"[",
"len",
"(",
"rawData",
")",
"-",
"1",
"]",
"\n",
"}",
"\n\n",
"// Required: false",
"// AllowEmptyValue: false",
"if",
"raw",
"==",
"\"",
"\"",
"{",
"// empty values pass all other validations",
"// Default values have been previously initialized by NewListTasksParams()",
"return",
"nil",
"\n",
"}",
"\n\n",
"value",
",",
"err",
":=",
"swag",
".",
"ConvertInt32",
"(",
"raw",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"InvalidType",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"raw",
")",
"\n",
"}",
"\n",
"o",
".",
"PageSize",
"=",
"&",
"value",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // bindPageSize binds and validates parameter PageSize from query. | [
"bindPageSize",
"binds",
"and",
"validates",
"parameter",
"PageSize",
"from",
"query",
"."
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/list_tasks_parameters.go#L105-L125 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/list_tasks_parameters.go | bindSinceID | func (o *ListTasksParams) bindSinceID(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("sinceId", "query", "int64", raw)
}
o.SinceID = &value
return nil
} | go | func (o *ListTasksParams) bindSinceID(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("sinceId", "query", "int64", raw)
}
o.SinceID = &value
return nil
} | [
"func",
"(",
"o",
"*",
"ListTasksParams",
")",
"bindSinceID",
"(",
"rawData",
"[",
"]",
"string",
",",
"hasKey",
"bool",
",",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"raw",
"string",
"\n",
"if",
"len",
"(",
"rawData",
")",
">",
"0",
"{",
"raw",
"=",
"rawData",
"[",
"len",
"(",
"rawData",
")",
"-",
"1",
"]",
"\n",
"}",
"\n\n",
"// Required: false",
"// AllowEmptyValue: false",
"if",
"raw",
"==",
"\"",
"\"",
"{",
"// empty values pass all other validations",
"return",
"nil",
"\n",
"}",
"\n\n",
"value",
",",
"err",
":=",
"swag",
".",
"ConvertInt64",
"(",
"raw",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"InvalidType",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"raw",
")",
"\n",
"}",
"\n",
"o",
".",
"SinceID",
"=",
"&",
"value",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // bindSinceID binds and validates parameter SinceID from query. | [
"bindSinceID",
"binds",
"and",
"validates",
"parameter",
"SinceID",
"from",
"query",
"."
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/list_tasks_parameters.go#L128-L147 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/list_tasks_parameters.go | validateStatus | func (o *ListTasksParams) validateStatus(formats strfmt.Registry) error {
// uniqueItems: true
if err := validate.UniqueItems("status", "query", o.Status); err != nil {
return err
}
return nil
} | go | func (o *ListTasksParams) validateStatus(formats strfmt.Registry) error {
// uniqueItems: true
if err := validate.UniqueItems("status", "query", o.Status); err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"*",
"ListTasksParams",
")",
"validateStatus",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"// uniqueItems: true",
"if",
"err",
":=",
"validate",
".",
"UniqueItems",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"o",
".",
"Status",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // validateStatus carries on validations for parameter Status | [
"validateStatus",
"carries",
"on",
"validations",
"for",
"parameter",
"Status"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/list_tasks_parameters.go#L185-L193 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/list_tasks_parameters.go | validateTags | func (o *ListTasksParams) validateTags(formats strfmt.Registry) error {
// uniqueItems: true
if err := validate.UniqueItems("tags", "query", o.Tags); err != nil {
return err
}
return nil
} | go | func (o *ListTasksParams) validateTags(formats strfmt.Registry) error {
// uniqueItems: true
if err := validate.UniqueItems("tags", "query", o.Tags); err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"*",
"ListTasksParams",
")",
"validateTags",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"// uniqueItems: true",
"if",
"err",
":=",
"validate",
".",
"UniqueItems",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"o",
".",
"Tags",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // validateTags carries on validations for parameter Tags | [
"validateTags",
"carries",
"on",
"validations",
"for",
"parameter",
"Tags"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/list_tasks_parameters.go#L227-L235 | train |
go-swagger/go-swagger | examples/todo-list/restapi/operations/todos/find_responses.go | WithPayload | func (o *FindOK) WithPayload(payload []*models.Item) *FindOK {
o.Payload = payload
return o
} | go | func (o *FindOK) WithPayload(payload []*models.Item) *FindOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"FindOK",
")",
"WithPayload",
"(",
"payload",
"[",
"]",
"*",
"models",
".",
"Item",
")",
"*",
"FindOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the find o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"find",
"o",
"k",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/todo-list/restapi/operations/todos/find_responses.go#L38-L41 | train |
go-swagger/go-swagger | examples/todo-list/restapi/operations/todos/find_responses.go | WithStatusCode | func (o *FindDefault) WithStatusCode(code int) *FindDefault {
o._statusCode = code
return o
} | go | func (o *FindDefault) WithStatusCode(code int) *FindDefault {
o._statusCode = code
return o
} | [
"func",
"(",
"o",
"*",
"FindDefault",
")",
"WithStatusCode",
"(",
"code",
"int",
")",
"*",
"FindDefault",
"{",
"o",
".",
"_statusCode",
"=",
"code",
"\n",
"return",
"o",
"\n",
"}"
] | // WithStatusCode adds the status to the find default response | [
"WithStatusCode",
"adds",
"the",
"status",
"to",
"the",
"find",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/todo-list/restapi/operations/todos/find_responses.go#L88-L91 | train |
go-swagger/go-swagger | examples/todo-list/restapi/operations/todos/find_responses.go | WithPayload | func (o *FindDefault) WithPayload(payload *models.Error) *FindDefault {
o.Payload = payload
return o
} | go | func (o *FindDefault) WithPayload(payload *models.Error) *FindDefault {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"FindDefault",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Error",
")",
"*",
"FindDefault",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the find default response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"find",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/todo-list/restapi/operations/todos/find_responses.go#L99-L102 | train |
go-swagger/go-swagger | cmd/swagger/commands/generate/contrib.go | contribOptionsOverride | func contribOptionsOverride(opts *generator.GenOpts) {
switch opts.Template {
case "stratoscale":
// Stratoscale template needs to regenerate the configureapi on every run.
opts.RegenerateConfigureAPI = true
// It also does not use the main.go
opts.IncludeMain = false
}
} | go | func contribOptionsOverride(opts *generator.GenOpts) {
switch opts.Template {
case "stratoscale":
// Stratoscale template needs to regenerate the configureapi on every run.
opts.RegenerateConfigureAPI = true
// It also does not use the main.go
opts.IncludeMain = false
}
} | [
"func",
"contribOptionsOverride",
"(",
"opts",
"*",
"generator",
".",
"GenOpts",
")",
"{",
"switch",
"opts",
".",
"Template",
"{",
"case",
"\"",
"\"",
":",
"// Stratoscale template needs to regenerate the configureapi on every run.",
"opts",
".",
"RegenerateConfigureAPI",
"=",
"true",
"\n",
"// It also does not use the main.go",
"opts",
".",
"IncludeMain",
"=",
"false",
"\n",
"}",
"\n",
"}"
] | // contribOptionsOverride gives contributed templates the ability to override the options if they need | [
"contribOptionsOverride",
"gives",
"contributed",
"templates",
"the",
"ability",
"to",
"override",
"the",
"options",
"if",
"they",
"need"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/cmd/swagger/commands/generate/contrib.go#L8-L16 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/restapi/operations/pet/pet_update.go | NewPetUpdate | func NewPetUpdate(ctx *middleware.Context, handler PetUpdateHandler) *PetUpdate {
return &PetUpdate{Context: ctx, Handler: handler}
} | go | func NewPetUpdate(ctx *middleware.Context, handler PetUpdateHandler) *PetUpdate {
return &PetUpdate{Context: ctx, Handler: handler}
} | [
"func",
"NewPetUpdate",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"PetUpdateHandler",
")",
"*",
"PetUpdate",
"{",
"return",
"&",
"PetUpdate",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewPetUpdate creates a new http.Handler for the pet update operation | [
"NewPetUpdate",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"pet",
"update",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/restapi/operations/pet/pet_update.go#L28-L30 | train |
go-swagger/go-swagger | examples/task-tracker/client/tasks/add_comment_to_task_parameters.go | WithTimeout | func (o *AddCommentToTaskParams) WithTimeout(timeout time.Duration) *AddCommentToTaskParams {
o.SetTimeout(timeout)
return o
} | go | func (o *AddCommentToTaskParams) WithTimeout(timeout time.Duration) *AddCommentToTaskParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"AddCommentToTaskParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"AddCommentToTaskParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the add comment to task params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"add",
"comment",
"to",
"task",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/client/tasks/add_comment_to_task_parameters.go#L82-L85 | train |
go-swagger/go-swagger | examples/task-tracker/client/tasks/add_comment_to_task_parameters.go | WithContext | func (o *AddCommentToTaskParams) WithContext(ctx context.Context) *AddCommentToTaskParams {
o.SetContext(ctx)
return o
} | go | func (o *AddCommentToTaskParams) WithContext(ctx context.Context) *AddCommentToTaskParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"AddCommentToTaskParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"AddCommentToTaskParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the add comment to task params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"add",
"comment",
"to",
"task",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/client/tasks/add_comment_to_task_parameters.go#L93-L96 | train |
go-swagger/go-swagger | examples/task-tracker/client/tasks/add_comment_to_task_parameters.go | WithHTTPClient | func (o *AddCommentToTaskParams) WithHTTPClient(client *http.Client) *AddCommentToTaskParams {
o.SetHTTPClient(client)
return o
} | go | func (o *AddCommentToTaskParams) WithHTTPClient(client *http.Client) *AddCommentToTaskParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"AddCommentToTaskParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"AddCommentToTaskParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the add comment to task params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"add",
"comment",
"to",
"task",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/client/tasks/add_comment_to_task_parameters.go#L104-L107 | train |
go-swagger/go-swagger | examples/task-tracker/client/tasks/add_comment_to_task_parameters.go | WithBody | func (o *AddCommentToTaskParams) WithBody(body AddCommentToTaskBody) *AddCommentToTaskParams {
o.SetBody(body)
return o
} | go | func (o *AddCommentToTaskParams) WithBody(body AddCommentToTaskBody) *AddCommentToTaskParams {
o.SetBody(body)
return o
} | [
"func",
"(",
"o",
"*",
"AddCommentToTaskParams",
")",
"WithBody",
"(",
"body",
"AddCommentToTaskBody",
")",
"*",
"AddCommentToTaskParams",
"{",
"o",
".",
"SetBody",
"(",
"body",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithBody adds the body to the add comment to task params | [
"WithBody",
"adds",
"the",
"body",
"to",
"the",
"add",
"comment",
"to",
"task",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/client/tasks/add_comment_to_task_parameters.go#L115-L118 | train |
go-swagger/go-swagger | examples/task-tracker/client/tasks/add_comment_to_task_parameters.go | WithID | func (o *AddCommentToTaskParams) WithID(id int64) *AddCommentToTaskParams {
o.SetID(id)
return o
} | go | func (o *AddCommentToTaskParams) WithID(id int64) *AddCommentToTaskParams {
o.SetID(id)
return o
} | [
"func",
"(",
"o",
"*",
"AddCommentToTaskParams",
")",
"WithID",
"(",
"id",
"int64",
")",
"*",
"AddCommentToTaskParams",
"{",
"o",
".",
"SetID",
"(",
"id",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithID adds the id to the add comment to task params | [
"WithID",
"adds",
"the",
"id",
"to",
"the",
"add",
"comment",
"to",
"task",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/client/tasks/add_comment_to_task_parameters.go#L126-L129 | train |
go-swagger/go-swagger | examples/tutorials/custom-server/gen/restapi/operations/get_greeting.go | NewGetGreeting | func NewGetGreeting(ctx *middleware.Context, handler GetGreetingHandler) *GetGreeting {
return &GetGreeting{Context: ctx, Handler: handler}
} | go | func NewGetGreeting(ctx *middleware.Context, handler GetGreetingHandler) *GetGreeting {
return &GetGreeting{Context: ctx, Handler: handler}
} | [
"func",
"NewGetGreeting",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"GetGreetingHandler",
")",
"*",
"GetGreeting",
"{",
"return",
"&",
"GetGreeting",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewGetGreeting creates a new http.Handler for the get greeting operation | [
"NewGetGreeting",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"get",
"greeting",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/tutorials/custom-server/gen/restapi/operations/get_greeting.go#L28-L30 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_urlbuilder.go | Must | func (o *PetDeleteURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
} | go | func (o *PetDeleteURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
} | [
"func",
"(",
"o",
"*",
"PetDeleteURL",
")",
"Must",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"err",
"error",
")",
"*",
"url",
".",
"URL",
"{",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"u",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"u",
"\n",
"}"
] | // Must is a helper function to panic when the url builder returns an error | [
"Must",
"is",
"a",
"helper",
"function",
"to",
"panic",
"when",
"the",
"url",
"builder",
"returns",
"an",
"error"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_urlbuilder.go#L64-L72 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_urlbuilder.go | BuildFull | func (o *PetDeleteURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on PetDeleteURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on PetDeleteURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
} | go | func (o *PetDeleteURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on PetDeleteURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on PetDeleteURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
} | [
"func",
"(",
"o",
"*",
"PetDeleteURL",
")",
"BuildFull",
"(",
"scheme",
",",
"host",
"string",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
"{",
"if",
"scheme",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"host",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"base",
",",
"err",
":=",
"o",
".",
"Build",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"base",
".",
"Scheme",
"=",
"scheme",
"\n",
"base",
".",
"Host",
"=",
"host",
"\n",
"return",
"base",
",",
"nil",
"\n",
"}"
] | // BuildFull builds a full url with scheme, host, path and query string | [
"BuildFull",
"builds",
"a",
"full",
"url",
"with",
"scheme",
"host",
"path",
"and",
"query",
"string"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_urlbuilder.go#L80-L96 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_urlbuilder.go | StringFull | func (o *PetDeleteURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
} | go | func (o *PetDeleteURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
} | [
"func",
"(",
"o",
"*",
"PetDeleteURL",
")",
"StringFull",
"(",
"scheme",
",",
"host",
"string",
")",
"string",
"{",
"return",
"o",
".",
"Must",
"(",
"o",
".",
"BuildFull",
"(",
"scheme",
",",
"host",
")",
")",
".",
"String",
"(",
")",
"\n",
"}"
] | // StringFull returns the string representation of a complete url | [
"StringFull",
"returns",
"the",
"string",
"representation",
"of",
"a",
"complete",
"url"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_urlbuilder.go#L99-L101 | train |
go-swagger/go-swagger | examples/task-tracker/client/tasks/add_comment_to_task_responses.go | Validate | func (o *AddCommentToTaskBody) Validate(formats strfmt.Registry) error {
var res []error
if err := o.validateContent(formats); err != nil {
res = append(res, err)
}
if err := o.validateUserID(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (o *AddCommentToTaskBody) Validate(formats strfmt.Registry) error {
var res []error
if err := o.validateContent(formats); err != nil {
res = append(res, err)
}
if err := o.validateUserID(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"o",
"*",
"AddCommentToTaskBody",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"o",
".",
"validateContent",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"o",
".",
"validateUserID",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this add comment to task body | [
"Validate",
"validates",
"this",
"add",
"comment",
"to",
"task",
"body"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/client/tasks/add_comment_to_task_responses.go#L132-L147 | train |
go-swagger/go-swagger | cmd/swagger/commands/flatten.go | Execute | func (c *FlattenSpec) Execute(args []string) error {
if len(args) != 1 {
return errors.New("The flatten command requires the single swagger document url to be specified")
}
swaggerDoc := args[0]
specDoc, err := loads.Spec(swaggerDoc)
if err != nil {
return err
}
flattenOpts := c.FlattenCmdOptions.SetFlattenOptions(&analysis.FlattenOpts{
// defaults
Minimal: true,
Verbose: true,
Expand: false,
RemoveUnused: false,
})
flattenOpts.BasePath = specDoc.SpecFilePath()
flattenOpts.Spec = analysis.New(specDoc.Spec())
if err := analysis.Flatten(*flattenOpts); err != nil {
return err
}
return writeToFile(specDoc.Spec(), !c.Compact, c.Format, string(c.Output))
} | go | func (c *FlattenSpec) Execute(args []string) error {
if len(args) != 1 {
return errors.New("The flatten command requires the single swagger document url to be specified")
}
swaggerDoc := args[0]
specDoc, err := loads.Spec(swaggerDoc)
if err != nil {
return err
}
flattenOpts := c.FlattenCmdOptions.SetFlattenOptions(&analysis.FlattenOpts{
// defaults
Minimal: true,
Verbose: true,
Expand: false,
RemoveUnused: false,
})
flattenOpts.BasePath = specDoc.SpecFilePath()
flattenOpts.Spec = analysis.New(specDoc.Spec())
if err := analysis.Flatten(*flattenOpts); err != nil {
return err
}
return writeToFile(specDoc.Spec(), !c.Compact, c.Format, string(c.Output))
} | [
"func",
"(",
"c",
"*",
"FlattenSpec",
")",
"Execute",
"(",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"swaggerDoc",
":=",
"args",
"[",
"0",
"]",
"\n",
"specDoc",
",",
"err",
":=",
"loads",
".",
"Spec",
"(",
"swaggerDoc",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"flattenOpts",
":=",
"c",
".",
"FlattenCmdOptions",
".",
"SetFlattenOptions",
"(",
"&",
"analysis",
".",
"FlattenOpts",
"{",
"// defaults",
"Minimal",
":",
"true",
",",
"Verbose",
":",
"true",
",",
"Expand",
":",
"false",
",",
"RemoveUnused",
":",
"false",
",",
"}",
")",
"\n",
"flattenOpts",
".",
"BasePath",
"=",
"specDoc",
".",
"SpecFilePath",
"(",
")",
"\n",
"flattenOpts",
".",
"Spec",
"=",
"analysis",
".",
"New",
"(",
"specDoc",
".",
"Spec",
"(",
")",
")",
"\n",
"if",
"err",
":=",
"analysis",
".",
"Flatten",
"(",
"*",
"flattenOpts",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"writeToFile",
"(",
"specDoc",
".",
"Spec",
"(",
")",
",",
"!",
"c",
".",
"Compact",
",",
"c",
".",
"Format",
",",
"string",
"(",
"c",
".",
"Output",
")",
")",
"\n",
"}"
] | // Execute flattens the spec | [
"Execute",
"flattens",
"the",
"spec"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/cmd/swagger/commands/flatten.go#L23-L48 | train |
go-swagger/go-swagger | examples/stream-server/restapi/operations/elapse.go | NewElapse | func NewElapse(ctx *middleware.Context, handler ElapseHandler) *Elapse {
return &Elapse{Context: ctx, Handler: handler}
} | go | func NewElapse(ctx *middleware.Context, handler ElapseHandler) *Elapse {
return &Elapse{Context: ctx, Handler: handler}
} | [
"func",
"NewElapse",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"ElapseHandler",
")",
"*",
"Elapse",
"{",
"return",
"&",
"Elapse",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewElapse creates a new http.Handler for the elapse operation | [
"NewElapse",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"elapse",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/stream-server/restapi/operations/elapse.go#L28-L30 | train |
go-swagger/go-swagger | examples/composed-auth/restapi/operations/get_order_responses.go | WithPayload | func (o *GetOrderOK) WithPayload(payload *models.Order) *GetOrderOK {
o.Payload = payload
return o
} | go | func (o *GetOrderOK) WithPayload(payload *models.Order) *GetOrderOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetOrderOK",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Order",
")",
"*",
"GetOrderOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get order o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"order",
"o",
"k",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/composed-auth/restapi/operations/get_order_responses.go#L38-L41 | train |
go-swagger/go-swagger | examples/composed-auth/restapi/operations/get_order_responses.go | WithStatusCode | func (o *GetOrderDefault) WithStatusCode(code int) *GetOrderDefault {
o._statusCode = code
return o
} | go | func (o *GetOrderDefault) WithStatusCode(code int) *GetOrderDefault {
o._statusCode = code
return o
} | [
"func",
"(",
"o",
"*",
"GetOrderDefault",
")",
"WithStatusCode",
"(",
"code",
"int",
")",
"*",
"GetOrderDefault",
"{",
"o",
".",
"_statusCode",
"=",
"code",
"\n",
"return",
"o",
"\n",
"}"
] | // WithStatusCode adds the status to the get order default response | [
"WithStatusCode",
"adds",
"the",
"status",
"to",
"the",
"get",
"order",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/composed-auth/restapi/operations/get_order_responses.go#L133-L136 | train |
go-swagger/go-swagger | examples/composed-auth/restapi/operations/get_order_responses.go | WithPayload | func (o *GetOrderDefault) WithPayload(payload *models.Error) *GetOrderDefault {
o.Payload = payload
return o
} | go | func (o *GetOrderDefault) WithPayload(payload *models.Error) *GetOrderDefault {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetOrderDefault",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Error",
")",
"*",
"GetOrderDefault",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get order default response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"order",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/composed-auth/restapi/operations/get_order_responses.go#L144-L147 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/get_task_comments_responses.go | WithPayload | func (o *GetTaskCommentsOK) WithPayload(payload []*models.Comment) *GetTaskCommentsOK {
o.Payload = payload
return o
} | go | func (o *GetTaskCommentsOK) WithPayload(payload []*models.Comment) *GetTaskCommentsOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetTaskCommentsOK",
")",
"WithPayload",
"(",
"payload",
"[",
"]",
"*",
"models",
".",
"Comment",
")",
"*",
"GetTaskCommentsOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get task comments o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"task",
"comments",
"o",
"k",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/get_task_comments_responses.go#L38-L41 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/get_task_comments_responses.go | WithStatusCode | func (o *GetTaskCommentsDefault) WithStatusCode(code int) *GetTaskCommentsDefault {
o._statusCode = code
return o
} | go | func (o *GetTaskCommentsDefault) WithStatusCode(code int) *GetTaskCommentsDefault {
o._statusCode = code
return o
} | [
"func",
"(",
"o",
"*",
"GetTaskCommentsDefault",
")",
"WithStatusCode",
"(",
"code",
"int",
")",
"*",
"GetTaskCommentsDefault",
"{",
"o",
".",
"_statusCode",
"=",
"code",
"\n",
"return",
"o",
"\n",
"}"
] | // WithStatusCode adds the status to the get task comments default response | [
"WithStatusCode",
"adds",
"the",
"status",
"to",
"the",
"get",
"task",
"comments",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/get_task_comments_responses.go#L92-L95 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/get_task_comments_responses.go | WithXErrorCode | func (o *GetTaskCommentsDefault) WithXErrorCode(xErrorCode string) *GetTaskCommentsDefault {
o.XErrorCode = xErrorCode
return o
} | go | func (o *GetTaskCommentsDefault) WithXErrorCode(xErrorCode string) *GetTaskCommentsDefault {
o.XErrorCode = xErrorCode
return o
} | [
"func",
"(",
"o",
"*",
"GetTaskCommentsDefault",
")",
"WithXErrorCode",
"(",
"xErrorCode",
"string",
")",
"*",
"GetTaskCommentsDefault",
"{",
"o",
".",
"XErrorCode",
"=",
"xErrorCode",
"\n",
"return",
"o",
"\n",
"}"
] | // WithXErrorCode adds the xErrorCode to the get task comments default response | [
"WithXErrorCode",
"adds",
"the",
"xErrorCode",
"to",
"the",
"get",
"task",
"comments",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/get_task_comments_responses.go#L103-L106 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/get_task_comments_responses.go | WithPayload | func (o *GetTaskCommentsDefault) WithPayload(payload *models.Error) *GetTaskCommentsDefault {
o.Payload = payload
return o
} | go | func (o *GetTaskCommentsDefault) WithPayload(payload *models.Error) *GetTaskCommentsDefault {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetTaskCommentsDefault",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Error",
")",
"*",
"GetTaskCommentsDefault",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get task comments default response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"task",
"comments",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/get_task_comments_responses.go#L114-L117 | train |
go-swagger/go-swagger | examples/authentication/client/customers/get_id_parameters.go | WithTimeout | func (o *GetIDParams) WithTimeout(timeout time.Duration) *GetIDParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetIDParams) WithTimeout(timeout time.Duration) *GetIDParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetIDParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetIDParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get Id params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"Id",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/authentication/client/customers/get_id_parameters.go#L75-L78 | train |
go-swagger/go-swagger | examples/authentication/client/customers/get_id_parameters.go | WithContext | func (o *GetIDParams) WithContext(ctx context.Context) *GetIDParams {
o.SetContext(ctx)
return o
} | go | func (o *GetIDParams) WithContext(ctx context.Context) *GetIDParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetIDParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetIDParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get Id params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"Id",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/authentication/client/customers/get_id_parameters.go#L86-L89 | train |
go-swagger/go-swagger | examples/authentication/client/customers/get_id_parameters.go | WithHTTPClient | func (o *GetIDParams) WithHTTPClient(client *http.Client) *GetIDParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetIDParams) WithHTTPClient(client *http.Client) *GetIDParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetIDParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetIDParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get Id params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"Id",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/authentication/client/customers/get_id_parameters.go#L97-L100 | train |
go-swagger/go-swagger | examples/authentication/client/customers/get_id_parameters.go | WithInfo | func (o *GetIDParams) WithInfo(info *models.SocialID) *GetIDParams {
o.SetInfo(info)
return o
} | go | func (o *GetIDParams) WithInfo(info *models.SocialID) *GetIDParams {
o.SetInfo(info)
return o
} | [
"func",
"(",
"o",
"*",
"GetIDParams",
")",
"WithInfo",
"(",
"info",
"*",
"models",
".",
"SocialID",
")",
"*",
"GetIDParams",
"{",
"o",
".",
"SetInfo",
"(",
"info",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithInfo adds the info to the get Id params | [
"WithInfo",
"adds",
"the",
"info",
"to",
"the",
"get",
"Id",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/authentication/client/customers/get_id_parameters.go#L108-L111 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/restapi/operations/pet/pet_delete.go | NewPetDelete | func NewPetDelete(ctx *middleware.Context, handler PetDeleteHandler) *PetDelete {
return &PetDelete{Context: ctx, Handler: handler}
} | go | func NewPetDelete(ctx *middleware.Context, handler PetDeleteHandler) *PetDelete {
return &PetDelete{Context: ctx, Handler: handler}
} | [
"func",
"NewPetDelete",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"PetDeleteHandler",
")",
"*",
"PetDelete",
"{",
"return",
"&",
"PetDelete",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewPetDelete creates a new http.Handler for the pet delete operation | [
"NewPetDelete",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"pet",
"delete",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/restapi/operations/pet/pet_delete.go#L28-L30 | train |
go-swagger/go-swagger | examples/oauth2/restapi/configure_oauth_sample.go | setupMiddlewares | func setupMiddlewares(handler http.Handler) http.Handler {
ourFunc := func(w http.ResponseWriter, r *http.Request) {
rctx := context.WithValue(r.Context(), ctxResponseWriter, w)
handler.ServeHTTP(w, r.WithContext(rctx))
}
return http.HandlerFunc(ourFunc)
} | go | func setupMiddlewares(handler http.Handler) http.Handler {
ourFunc := func(w http.ResponseWriter, r *http.Request) {
rctx := context.WithValue(r.Context(), ctxResponseWriter, w)
handler.ServeHTTP(w, r.WithContext(rctx))
}
return http.HandlerFunc(ourFunc)
} | [
"func",
"setupMiddlewares",
"(",
"handler",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"ourFunc",
":=",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"rctx",
":=",
"context",
".",
"WithValue",
"(",
"r",
".",
"Context",
"(",
")",
",",
"ctxResponseWriter",
",",
"w",
")",
"\n",
"handler",
".",
"ServeHTTP",
"(",
"w",
",",
"r",
".",
"WithContext",
"(",
"rctx",
")",
")",
"\n",
"}",
"\n",
"return",
"http",
".",
"HandlerFunc",
"(",
"ourFunc",
")",
"\n\n",
"}"
] | // The middleware configuration is for the handler executors. These do not apply to the swagger.json document.
// The middleware executes after routing but before authentication, binding and validation | [
"The",
"middleware",
"configuration",
"is",
"for",
"the",
"handler",
"executors",
".",
"These",
"do",
"not",
"apply",
"to",
"the",
"swagger",
".",
"json",
"document",
".",
"The",
"middleware",
"executes",
"after",
"routing",
"but",
"before",
"authentication",
"binding",
"and",
"validation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/oauth2/restapi/configure_oauth_sample.go#L107-L114 | train |
go-swagger/go-swagger | examples/generated/restapi/operations/pet/get_pet_by_id_responses.go | WithPayload | func (o *GetPetByIDOK) WithPayload(payload *models.Pet) *GetPetByIDOK {
o.Payload = payload
return o
} | go | func (o *GetPetByIDOK) WithPayload(payload *models.Pet) *GetPetByIDOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetPetByIDOK",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Pet",
")",
"*",
"GetPetByIDOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get pet by Id o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"pet",
"by",
"Id",
"o",
"k",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/generated/restapi/operations/pet/get_pet_by_id_responses.go#L38-L41 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/restapi/operations/pet/pet_get.go | NewPetGet | func NewPetGet(ctx *middleware.Context, handler PetGetHandler) *PetGet {
return &PetGet{Context: ctx, Handler: handler}
} | go | func NewPetGet(ctx *middleware.Context, handler PetGetHandler) *PetGet {
return &PetGet{Context: ctx, Handler: handler}
} | [
"func",
"NewPetGet",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"PetGetHandler",
")",
"*",
"PetGet",
"{",
"return",
"&",
"PetGet",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewPetGet creates a new http.Handler for the pet get operation | [
"NewPetGet",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"pet",
"get",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/restapi/operations/pet/pet_get.go#L28-L30 | train |
go-swagger/go-swagger | generator/template_repo.go | NewRepository | func NewRepository(funcs template.FuncMap) *Repository {
repo := Repository{
files: make(map[string]string),
templates: make(map[string]*template.Template),
funcs: funcs,
}
if repo.funcs == nil {
repo.funcs = make(template.FuncMap)
}
return &repo
} | go | func NewRepository(funcs template.FuncMap) *Repository {
repo := Repository{
files: make(map[string]string),
templates: make(map[string]*template.Template),
funcs: funcs,
}
if repo.funcs == nil {
repo.funcs = make(template.FuncMap)
}
return &repo
} | [
"func",
"NewRepository",
"(",
"funcs",
"template",
".",
"FuncMap",
")",
"*",
"Repository",
"{",
"repo",
":=",
"Repository",
"{",
"files",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
",",
"templates",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"template",
".",
"Template",
")",
",",
"funcs",
":",
"funcs",
",",
"}",
"\n\n",
"if",
"repo",
".",
"funcs",
"==",
"nil",
"{",
"repo",
".",
"funcs",
"=",
"make",
"(",
"template",
".",
"FuncMap",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"repo",
"\n",
"}"
] | // NewRepository creates a new template repository with the provided functions defined | [
"NewRepository",
"creates",
"a",
"new",
"template",
"repository",
"with",
"the",
"provided",
"functions",
"defined"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/template_repo.go#L238-L250 | train |
go-swagger/go-swagger | generator/template_repo.go | LoadDefaults | func (t *Repository) LoadDefaults() {
for name, asset := range assets {
if err := t.addFile(name, string(asset), true); err != nil {
log.Fatal(err)
}
}
} | go | func (t *Repository) LoadDefaults() {
for name, asset := range assets {
if err := t.addFile(name, string(asset), true); err != nil {
log.Fatal(err)
}
}
} | [
"func",
"(",
"t",
"*",
"Repository",
")",
"LoadDefaults",
"(",
")",
"{",
"for",
"name",
",",
"asset",
":=",
"range",
"assets",
"{",
"if",
"err",
":=",
"t",
".",
"addFile",
"(",
"name",
",",
"string",
"(",
"asset",
")",
",",
"true",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // LoadDefaults will load the embedded templates | [
"LoadDefaults",
"will",
"load",
"the",
"embedded",
"templates"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/template_repo.go#L260-L267 | train |
go-swagger/go-swagger | generator/template_repo.go | LoadDir | func (t *Repository) LoadDir(templatePath string) error {
err := filepath.Walk(templatePath, func(path string, info os.FileInfo, err error) error {
if strings.HasSuffix(path, ".gotmpl") {
if assetName, e := filepath.Rel(templatePath, path); e == nil {
if data, e := ioutil.ReadFile(path); e == nil {
if ee := t.AddFile(assetName, string(data)); ee != nil {
// Fatality is decided by caller
// log.Fatal(ee)
return fmt.Errorf("Could not add template: %v", ee)
}
}
// Non-readable files are skipped
}
}
if err != nil {
return err
}
// Non-template files are skipped
return nil
})
if err != nil {
return fmt.Errorf("Could not complete template processing in directory \"%s\": %v", templatePath, err)
}
return nil
} | go | func (t *Repository) LoadDir(templatePath string) error {
err := filepath.Walk(templatePath, func(path string, info os.FileInfo, err error) error {
if strings.HasSuffix(path, ".gotmpl") {
if assetName, e := filepath.Rel(templatePath, path); e == nil {
if data, e := ioutil.ReadFile(path); e == nil {
if ee := t.AddFile(assetName, string(data)); ee != nil {
// Fatality is decided by caller
// log.Fatal(ee)
return fmt.Errorf("Could not add template: %v", ee)
}
}
// Non-readable files are skipped
}
}
if err != nil {
return err
}
// Non-template files are skipped
return nil
})
if err != nil {
return fmt.Errorf("Could not complete template processing in directory \"%s\": %v", templatePath, err)
}
return nil
} | [
"func",
"(",
"t",
"*",
"Repository",
")",
"LoadDir",
"(",
"templatePath",
"string",
")",
"error",
"{",
"err",
":=",
"filepath",
".",
"Walk",
"(",
"templatePath",
",",
"func",
"(",
"path",
"string",
",",
"info",
"os",
".",
"FileInfo",
",",
"err",
"error",
")",
"error",
"{",
"if",
"strings",
".",
"HasSuffix",
"(",
"path",
",",
"\"",
"\"",
")",
"{",
"if",
"assetName",
",",
"e",
":=",
"filepath",
".",
"Rel",
"(",
"templatePath",
",",
"path",
")",
";",
"e",
"==",
"nil",
"{",
"if",
"data",
",",
"e",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
";",
"e",
"==",
"nil",
"{",
"if",
"ee",
":=",
"t",
".",
"AddFile",
"(",
"assetName",
",",
"string",
"(",
"data",
")",
")",
";",
"ee",
"!=",
"nil",
"{",
"// Fatality is decided by caller",
"// log.Fatal(ee)",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ee",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// Non-readable files are skipped",
"}",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"// Non-template files are skipped",
"return",
"nil",
"\n",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"templatePath",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // LoadDir will walk the specified path and add each .gotmpl file it finds to the repository | [
"LoadDir",
"will",
"walk",
"the",
"specified",
"path",
"and",
"add",
"each",
".",
"gotmpl",
"file",
"it",
"finds",
"to",
"the",
"repository"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/template_repo.go#L270-L295 | train |
go-swagger/go-swagger | generator/template_repo.go | LoadContrib | func (t *Repository) LoadContrib(name string) error {
log.Printf("loading contrib %s", name)
const pathPrefix = "templates/contrib/"
basePath := pathPrefix + name
filesAdded := 0
for _, aname := range AssetNames() {
if !strings.HasSuffix(aname, ".gotmpl") {
continue
}
if strings.HasPrefix(aname, basePath) {
target := aname[len(basePath)+1:]
err := t.addFile(target, string(MustAsset(aname)), true)
if err != nil {
return err
}
log.Printf("added contributed template %s from %s", target, aname)
filesAdded++
}
}
if filesAdded == 0 {
return fmt.Errorf("no files added from template: %s", name)
}
return nil
} | go | func (t *Repository) LoadContrib(name string) error {
log.Printf("loading contrib %s", name)
const pathPrefix = "templates/contrib/"
basePath := pathPrefix + name
filesAdded := 0
for _, aname := range AssetNames() {
if !strings.HasSuffix(aname, ".gotmpl") {
continue
}
if strings.HasPrefix(aname, basePath) {
target := aname[len(basePath)+1:]
err := t.addFile(target, string(MustAsset(aname)), true)
if err != nil {
return err
}
log.Printf("added contributed template %s from %s", target, aname)
filesAdded++
}
}
if filesAdded == 0 {
return fmt.Errorf("no files added from template: %s", name)
}
return nil
} | [
"func",
"(",
"t",
"*",
"Repository",
")",
"LoadContrib",
"(",
"name",
"string",
")",
"error",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"const",
"pathPrefix",
"=",
"\"",
"\"",
"\n",
"basePath",
":=",
"pathPrefix",
"+",
"name",
"\n",
"filesAdded",
":=",
"0",
"\n",
"for",
"_",
",",
"aname",
":=",
"range",
"AssetNames",
"(",
")",
"{",
"if",
"!",
"strings",
".",
"HasSuffix",
"(",
"aname",
",",
"\"",
"\"",
")",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"aname",
",",
"basePath",
")",
"{",
"target",
":=",
"aname",
"[",
"len",
"(",
"basePath",
")",
"+",
"1",
":",
"]",
"\n",
"err",
":=",
"t",
".",
"addFile",
"(",
"target",
",",
"string",
"(",
"MustAsset",
"(",
"aname",
")",
")",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"target",
",",
"aname",
")",
"\n",
"filesAdded",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"filesAdded",
"==",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // LoadContrib loads template from contrib directory | [
"LoadContrib",
"loads",
"template",
"from",
"contrib",
"directory"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/template_repo.go#L298-L321 | train |
go-swagger/go-swagger | generator/template_repo.go | MustGet | func (t *Repository) MustGet(name string) *template.Template {
tpl, err := t.Get(name)
if err != nil {
panic(err)
}
return tpl
} | go | func (t *Repository) MustGet(name string) *template.Template {
tpl, err := t.Get(name)
if err != nil {
panic(err)
}
return tpl
} | [
"func",
"(",
"t",
"*",
"Repository",
")",
"MustGet",
"(",
"name",
"string",
")",
"*",
"template",
".",
"Template",
"{",
"tpl",
",",
"err",
":=",
"t",
".",
"Get",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"tpl",
"\n",
"}"
] | // MustGet a template by name, panics when fails | [
"MustGet",
"a",
"template",
"by",
"name",
"panics",
"when",
"fails"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/template_repo.go#L353-L359 | train |
go-swagger/go-swagger | generator/template_repo.go | Get | func (t *Repository) Get(name string) (*template.Template, error) {
templ, found := t.templates[name]
if !found {
return templ, fmt.Errorf("Template doesn't exist %s", name)
}
return t.addDependencies(templ)
} | go | func (t *Repository) Get(name string) (*template.Template, error) {
templ, found := t.templates[name]
if !found {
return templ, fmt.Errorf("Template doesn't exist %s", name)
}
return t.addDependencies(templ)
} | [
"func",
"(",
"t",
"*",
"Repository",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"*",
"template",
".",
"Template",
",",
"error",
")",
"{",
"templ",
",",
"found",
":=",
"t",
".",
"templates",
"[",
"name",
"]",
"\n\n",
"if",
"!",
"found",
"{",
"return",
"templ",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"}",
"\n\n",
"return",
"t",
".",
"addDependencies",
"(",
"templ",
")",
"\n",
"}"
] | // Get will return the named template from the repository, ensuring that all dependent templates are loaded.
// It will return an error if a dependent template is not defined in the repository. | [
"Get",
"will",
"return",
"the",
"named",
"template",
"from",
"the",
"repository",
"ensuring",
"that",
"all",
"dependent",
"templates",
"are",
"loaded",
".",
"It",
"will",
"return",
"an",
"error",
"if",
"a",
"dependent",
"template",
"is",
"not",
"defined",
"in",
"the",
"repository",
"."
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/template_repo.go#L488-L496 | train |
go-swagger/go-swagger | generator/template_repo.go | DumpTemplates | func (t *Repository) DumpTemplates() {
buf := bytes.NewBuffer(nil)
fmt.Fprintln(buf, "\n# Templates")
for name, templ := range t.templates {
fmt.Fprintf(buf, "## %s\n", name)
fmt.Fprintf(buf, "Defined in `%s`\n", t.files[name])
if deps := findDependencies(templ.Tree.Root); len(deps) > 0 {
fmt.Fprintf(buf, "####requires \n - %v\n\n\n", strings.Join(deps, "\n - "))
}
fmt.Fprintln(buf, "\n---")
}
log.Println(buf.String())
} | go | func (t *Repository) DumpTemplates() {
buf := bytes.NewBuffer(nil)
fmt.Fprintln(buf, "\n# Templates")
for name, templ := range t.templates {
fmt.Fprintf(buf, "## %s\n", name)
fmt.Fprintf(buf, "Defined in `%s`\n", t.files[name])
if deps := findDependencies(templ.Tree.Root); len(deps) > 0 {
fmt.Fprintf(buf, "####requires \n - %v\n\n\n", strings.Join(deps, "\n - "))
}
fmt.Fprintln(buf, "\n---")
}
log.Println(buf.String())
} | [
"func",
"(",
"t",
"*",
"Repository",
")",
"DumpTemplates",
"(",
")",
"{",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"nil",
")",
"\n",
"fmt",
".",
"Fprintln",
"(",
"buf",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"for",
"name",
",",
"templ",
":=",
"range",
"t",
".",
"templates",
"{",
"fmt",
".",
"Fprintf",
"(",
"buf",
",",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"buf",
",",
"\"",
"\\n",
"\"",
",",
"t",
".",
"files",
"[",
"name",
"]",
")",
"\n\n",
"if",
"deps",
":=",
"findDependencies",
"(",
"templ",
".",
"Tree",
".",
"Root",
")",
";",
"len",
"(",
"deps",
")",
">",
"0",
"{",
"fmt",
".",
"Fprintf",
"(",
"buf",
",",
"\"",
"\\n",
"\\n",
"\\n",
"\\n",
"\"",
",",
"strings",
".",
"Join",
"(",
"deps",
",",
"\"",
"\\n",
"\"",
")",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintln",
"(",
"buf",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"}",
"\n",
"log",
".",
"Println",
"(",
"buf",
".",
"String",
"(",
")",
")",
"\n",
"}"
] | // DumpTemplates prints out a dump of all the defined templates, where they are defined and what their dependencies are. | [
"DumpTemplates",
"prints",
"out",
"a",
"dump",
"of",
"all",
"the",
"defined",
"templates",
"where",
"they",
"are",
"defined",
"and",
"what",
"their",
"dependencies",
"are",
"."
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/generator/template_repo.go#L499-L513 | train |
go-swagger/go-swagger | examples/generated/restapi/operations/user/logout_user_responses.go | WithStatusCode | func (o *LogoutUserDefault) WithStatusCode(code int) *LogoutUserDefault {
o._statusCode = code
return o
} | go | func (o *LogoutUserDefault) WithStatusCode(code int) *LogoutUserDefault {
o._statusCode = code
return o
} | [
"func",
"(",
"o",
"*",
"LogoutUserDefault",
")",
"WithStatusCode",
"(",
"code",
"int",
")",
"*",
"LogoutUserDefault",
"{",
"o",
".",
"_statusCode",
"=",
"code",
"\n",
"return",
"o",
"\n",
"}"
] | // WithStatusCode adds the status to the logout user default response | [
"WithStatusCode",
"adds",
"the",
"status",
"to",
"the",
"logout",
"user",
"default",
"response"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/generated/restapi/operations/user/logout_user_responses.go#L34-L37 | train |
go-swagger/go-swagger | examples/task-tracker/restapi/operations/tasks/create_task.go | NewCreateTask | func NewCreateTask(ctx *middleware.Context, handler CreateTaskHandler) *CreateTask {
return &CreateTask{Context: ctx, Handler: handler}
} | go | func NewCreateTask(ctx *middleware.Context, handler CreateTaskHandler) *CreateTask {
return &CreateTask{Context: ctx, Handler: handler}
} | [
"func",
"NewCreateTask",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"CreateTaskHandler",
")",
"*",
"CreateTask",
"{",
"return",
"&",
"CreateTask",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewCreateTask creates a new http.Handler for the create task operation | [
"NewCreateTask",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"create",
"task",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/task-tracker/restapi/operations/tasks/create_task.go#L28-L30 | train |
go-swagger/go-swagger | examples/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos.go | NewFindTodos | func NewFindTodos(ctx *middleware.Context, handler FindTodosHandler) *FindTodos {
return &FindTodos{Context: ctx, Handler: handler}
} | go | func NewFindTodos(ctx *middleware.Context, handler FindTodosHandler) *FindTodos {
return &FindTodos{Context: ctx, Handler: handler}
} | [
"func",
"NewFindTodos",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"FindTodosHandler",
")",
"*",
"FindTodos",
"{",
"return",
"&",
"FindTodos",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewFindTodos creates a new http.Handler for the find todos operation | [
"NewFindTodos",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"find",
"todos",
"operation"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos.go#L28-L30 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/store/order_get_parameters.go | WithTimeout | func (o *OrderGetParams) WithTimeout(timeout time.Duration) *OrderGetParams {
o.SetTimeout(timeout)
return o
} | go | func (o *OrderGetParams) WithTimeout(timeout time.Duration) *OrderGetParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"OrderGetParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"OrderGetParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the order get params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"order",
"get",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/store/order_get_parameters.go#L77-L80 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/store/order_get_parameters.go | WithContext | func (o *OrderGetParams) WithContext(ctx context.Context) *OrderGetParams {
o.SetContext(ctx)
return o
} | go | func (o *OrderGetParams) WithContext(ctx context.Context) *OrderGetParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"OrderGetParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"OrderGetParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the order get params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"order",
"get",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/store/order_get_parameters.go#L88-L91 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/store/order_get_parameters.go | WithHTTPClient | func (o *OrderGetParams) WithHTTPClient(client *http.Client) *OrderGetParams {
o.SetHTTPClient(client)
return o
} | go | func (o *OrderGetParams) WithHTTPClient(client *http.Client) *OrderGetParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"OrderGetParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"OrderGetParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the order get params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"order",
"get",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/store/order_get_parameters.go#L99-L102 | train |
go-swagger/go-swagger | examples/contributed-templates/stratoscale/client/store/order_get_parameters.go | WithOrderID | func (o *OrderGetParams) WithOrderID(orderID int64) *OrderGetParams {
o.SetOrderID(orderID)
return o
} | go | func (o *OrderGetParams) WithOrderID(orderID int64) *OrderGetParams {
o.SetOrderID(orderID)
return o
} | [
"func",
"(",
"o",
"*",
"OrderGetParams",
")",
"WithOrderID",
"(",
"orderID",
"int64",
")",
"*",
"OrderGetParams",
"{",
"o",
".",
"SetOrderID",
"(",
"orderID",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithOrderID adds the orderID to the order get params | [
"WithOrderID",
"adds",
"the",
"orderID",
"to",
"the",
"order",
"get",
"params"
] | ffefbd274717d6fa3bcca1c494487edf1f48104b | https://github.com/go-swagger/go-swagger/blob/ffefbd274717d6fa3bcca1c494487edf1f48104b/examples/contributed-templates/stratoscale/client/store/order_get_parameters.go#L110-L113 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.