API defines a network service API. It provides the API name, description and other global properties. There may only be one API declaration in a given design package. API is a top level DSL. API takes two arguments: the name of the API and the defining DSL. The API properties are leveraged by the
(name string, fn func())
| 42 | // }) |
| 43 | // } |
| 44 | func API(name string, fn func()) *expr.APIExpr { |
| 45 | if name == "" { |
| 46 | eval.ReportError("API first argument cannot be empty") |
| 47 | return nil |
| 48 | } |
| 49 | if _, ok := eval.Current().(eval.TopExpr); !ok { |
| 50 | eval.IncompatibleDSL() |
| 51 | return nil |
| 52 | } |
| 53 | expr.Root.API = expr.NewAPIExpr(name, fn) |
| 54 | return expr.Root.API |
| 55 | } |
| 56 | |
| 57 | // Title sets the API title. It is used by the generated OpenAPI specification. |
| 58 | // |