Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider service and API level requirements #3359

Merged
merged 1 commit into from Sep 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions expr/http_body_types.go
Expand Up @@ -17,11 +17,21 @@ import (
// single "Authorization" header is used to compute both the username and
// password attributes).
func defaultRequestHeaderAttributes(e *HTTPEndpointExpr) map[string]bool {
if len(e.MethodExpr.Requirements) == 0 {
var requirements []*SecurityExpr
if e.MethodExpr.Requirements != nil {
requirements = e.MethodExpr.Requirements
}
if e.Service.ServiceExpr.Requirements != nil {
requirements = append(requirements, e.Service.ServiceExpr.Requirements...)
}
if Root.API.Requirements != nil {
requirements = append(requirements, Root.API.Requirements...)
}
if len(requirements) == 0 {
return nil
}
headers := make(map[string]bool)
for _, req := range e.MethodExpr.Requirements {
for _, req := range requirements {
for _, sch := range req.Schemes {
var field string
switch sch.Kind {
Expand Down Expand Up @@ -343,7 +353,6 @@ func unionToObject(att *AttributeExpr, name, suffix, svcName string) *AttributeE
// 3) If the first string is a single word or camelcased, the rest of the
// strings are concatenated to form a valid upper camelcase.
// e.g. concat("myEndpoint", "streaming", "Body") => "MyEndpointStreamingBody"
//
func concat(strs ...string) string {
if len(strs) == 1 {
return strs[0]
Expand Down