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

Function New

http/codegen/openapi/v3/builder.go:28–62  ·  view source on GitHub ↗

New returns the OpenAPI v3 specification for the given API. It returns nil if the design does not define HTTP endpoints.

(root *expr.RootExpr)

Source from the content-addressed store, hash-verified

26// New returns the OpenAPI v3 specification for the given API.
27// It returns nil if the design does not define HTTP endpoints.
28func New(root *expr.RootExpr) *OpenAPI {
29 if root == nil || root.API == nil || root.API.HTTP == nil || len(root.API.HTTP.Services) == 0 {
30 // No HTTP transport
31 return nil
32 }
33
34 m, ok := root.API.Meta.Last("openapi:example")
35 if !ok {
36 m, ok = root.API.Meta.Last("swagger:example")
37 }
38 if ok && m == "false" {
39 root.API.ExampleGenerator.Randomizer = nil
40 }
41
42 var (
43 bodies, types = buildBodyTypes(root.API, root.Types, root.ResultTypes)
44
45 info = buildInfo(root.API)
46 comps = buildComponents(root, types)
47 servers = buildServers(root.API.Servers)
48 paths = buildPaths(root.API.HTTP, bodies, root.API)
49 security = buildSecurityRequirements(root.API.Requirements)
50 tags = buildTags(root.API)
51 )
52
53 return &OpenAPI{
54 OpenAPI: OpenAPIVersion,
55 Info: info,
56 Components: comps,
57 Paths: paths,
58 Servers: servers,
59 Security: security,
60 Tags: tags,
61 }
62}
63
64// buildInfo builds the OpenAPI Info object.
65func buildInfo(api *expr.APIExpr) *Info {

Callers 3

FilesFunction · 0.70

Calls 8

buildBodyTypesFunction · 0.85
buildInfoFunction · 0.85
buildComponentsFunction · 0.85
buildServersFunction · 0.85
buildPathsFunction · 0.85
buildTagsFunction · 0.85
LastMethod · 0.80