(a *expr.MappedAttributeExpr, service *expr.AttributeExpr, scope *codegen.NameScope)
| 2496 | } |
| 2497 | |
| 2498 | func (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, |
no test coverage detected