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

Function hasAbsoluteRoutes

http/codegen/openapi/v2/builder.go:206–238  ·  view source on GitHub ↗

hasAbsoluteRoutes returns true if any endpoint exposed by the API uses an absolute route of if the API has file servers. This is needed as OpenAPI does not support exceptions to the base path so if the API has any absolute route the base path must be "/" and all routes must be absolutes.

(root *expr.RootExpr)

Source from the content-addressed store, hash-verified

204// not support exceptions to the base path so if the API has any absolute route
205// the base path must be "/" and all routes must be absolutes.
206func hasAbsoluteRoutes(root *expr.RootExpr) bool {
207 hasAbsoluteRoutes := false
208 for _, res := range root.API.HTTP.Services {
209 if !openapi.MustGenerate(res.Meta) || !openapi.MustGenerate(res.ServiceExpr.Meta) {
210 continue
211 }
212 for _, fs := range res.FileServers {
213 if !openapi.MustGenerate(fs.Meta) || !openapi.MustGenerate(fs.Service.Meta) {
214 continue
215 }
216 hasAbsoluteRoutes = true
217 break
218 }
219 for _, a := range res.HTTPEndpoints {
220 if !openapi.MustGenerate(a.Meta) || !openapi.MustGenerate(a.MethodExpr.Meta) {
221 continue
222 }
223 for _, ro := range a.Routes {
224 if ro.IsAbsolute() {
225 hasAbsoluteRoutes = true
226 break
227 }
228 }
229 if hasAbsoluteRoutes {
230 break
231 }
232 }
233 if hasAbsoluteRoutes {
234 break
235 }
236 }
237 return hasAbsoluteRoutes
238}
239
240func summaryFromExpr(name string, e *expr.HTTPEndpointExpr, meta expr.MetaExpr) string {
241 for n, mdata := range e.Meta {

Callers 1

NewV2Function · 0.85

Calls 2

MustGenerateFunction · 0.92
IsAbsoluteMethod · 0.80

Tested by

no test coverage detected