MCPcopy Create free account
hub / github.com/goadesign/goa / extractQueryParams

Method extractQueryParams

http/codegen/service_data.go:2498–2576  ·  view source on GitHub ↗
(a *expr.MappedAttributeExpr, service *expr.AttributeExpr, scope *codegen.NameScope)

Source from the content-addressed store, hash-verified

2496}
2497
2498func (sds *ServicesData) extractQueryParams(a *expr.MappedAttributeExpr, service *expr.AttributeExpr, scope *codegen.NameScope) []*ParamData {
2499 var params []*ParamData
2500 codegen.WalkMappedAttr(a, func(name, elem string, required bool, c *expr.AttributeExpr) error { // nolint: errcheck
2501 // The StringSlice field of ParamData must be false for aliased primitive types
2502 var stringSlice bool
2503 if arr := expr.AsArray(c.Type); arr != nil {
2504 stringSlice = arr.ElemType.Type.Kind() == expr.StringKind
2505 }
2506
2507 c = makeHTTPType(c)
2508 var (
2509 varn = scope.Name(codegen.Goify(name, false))
2510 arr = expr.AsArray(c.Type)
2511 mp = expr.AsMap(c.Type)
2512 typeRef = scope.GoTypeRef(c)
2513 ctx = serviceContext("", scope)
2514 ft = service.Type
2515
2516 pointer bool
2517 fptr bool
2518 )
2519 pointer = a.IsPrimitivePointer(name, true)
2520 if pointer {
2521 typeRef = "*" + typeRef
2522 }
2523 fieldName := codegen.GoifyAtt(c, name, true)
2524 if !expr.IsObject(service.Type) {
2525 fieldName = ""
2526 } else {
2527 fptr = service.IsPrimitivePointer(name, true)
2528 ft = service.Find(name).Type
2529 }
2530 validate := codegen.AttributeValidationCode(c, nil, ctx, required, expr.IsAlias(c.Type), varn, name)
2531 if isStringMetaType(c) {
2532 // Build a copy of the attribute with Format cleared so the shared
2533 // validation code does not emit a format check (UnmarshalText covers it).
2534 cNoFmt := *c
2535 if c.Validation != nil {
2536 v := *c.Validation
2537 v.Format = ""
2538 cNoFmt.Validation = &v
2539 }
2540 validate = codegen.AttributeValidationCode(&cNoFmt, nil, ctx, required, expr.IsAlias(c.Type), varn+"Raw", name)
2541 }
2542 params = append(params, &ParamData{
2543 Map: mp != nil,
2544 MapStringSlice: mp != nil &&
2545 mp.KeyType.Type.Kind() == expr.StringKind &&
2546 mp.ElemType.Type.Kind() == expr.ArrayKind &&
2547 expr.AsArray(mp.ElemType.Type).ElemType.Type.Kind() == expr.StringKind,
2548 Element: &Element{
2549 Slice: arr != nil,
2550 StringSlice: stringSlice,
2551 HTTPName: elem,
2552 AttributeName: name,
2553 AttributeData: &AttributeData{
2554 Name: name,
2555 Description: c.Description,

Callers 1

buildPayloadDataMethod · 0.95

Calls 15

WalkMappedAttrFunction · 0.92
AsArrayFunction · 0.92
GoifyFunction · 0.92
AsMapFunction · 0.92
GoifyAttFunction · 0.92
IsObjectFunction · 0.92
AttributeValidationCodeFunction · 0.92
IsAliasFunction · 0.92
makeHTTPTypeFunction · 0.85
serviceContextFunction · 0.85
isStringMetaTypeFunction · 0.85
GoTypeRefMethod · 0.80

Tested by

no test coverage detected