Documentation ¶
Overview ¶
Package goagen_js provides a goa generator for a javascript client module. The module exposes functions for calling the API actions. It relies on the fetch API (or using fetch polyfill like https://github.com/github/fetch) to perform the actual HTTP requests.
Output js is es2015 format. So you may need to build using babel https://babeljs.io/.
The generator also produces an validator of API parameters. Since this validator is separeted on each fields, you can use as is, for example form validator.
The controller simply serves all the files under the "js" directory.
Index ¶
- Constants
- func Generate() (files []string, err error)
- type Constraint
- type Generator
- type Option
- type Param
- type Params
- type ParamsDefinition
- func (p ParamsDefinition) Comments(action *design.ActionDefinition) []string
- func (p ParamsDefinition) FuncArgs(target string) string
- func (p ParamsDefinition) FuncName() string
- func (p ParamsDefinition) FuncRet(target string) string
- func (p ParamsDefinition) PayloadDefinition(target string) []string
- func (p ParamsDefinition) Request() string
- func (p ParamsDefinition) ResponseDefinition(target string) []string
- func (p ParamsDefinition) UrlArgs() string
- func (p ParamsDefinition) ValidateRequired() bool
- type Response
- type Validator
Constants ¶
const ( TargetJS = "js" TargetFlow = "flow" TargetTS = "typescript" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Constraint ¶
type Constraint struct { Kind string `json:"kind,omitempty"` Enum []interface{} `json:"enum,omitempty"` Format string `json:"format,omitempty"` Pattern string `json:"pattern,omitempty"` Minimum *float64 `json:"minimum,omitempty"` Maximum *float64 `json:"maximum,omitempty"` MinLength *int `json:"min_length,omitempty"` MaxLength *int `json:"max_length,omitempty"` Required *bool `json:"required,omitempty"` }
type Generator ¶
type Generator struct { API *design.APIDefinition // The API definition OutDir string // Destination directory Scheme string // Scheme used by JavaScript client Host string // Host addressed by JavaScript client Target string // Target JS (es2015, flowtype, tc) // contains filtered or unexported fields }
Generator is the application code generator.
func NewGenerator ¶
NewGenerator returns an initialized instance of a JavaScript Client Generator
type ParamsDefinition ¶
type ParamsDefinition struct { Action *design.ActionDefinition Base string Name string Path Params // sorted by goa order Query Params // sorted by alphabetical Validator Validator Response *Response }
func (ParamsDefinition) Comments ¶
func (p ParamsDefinition) Comments(action *design.ActionDefinition) []string
func (ParamsDefinition) FuncArgs ¶
func (p ParamsDefinition) FuncArgs(target string) string
func (ParamsDefinition) FuncName ¶
func (p ParamsDefinition) FuncName() string
func (ParamsDefinition) FuncRet ¶
func (p ParamsDefinition) FuncRet(target string) string
func (ParamsDefinition) PayloadDefinition ¶
func (p ParamsDefinition) PayloadDefinition(target string) []string
func (ParamsDefinition) Request ¶
func (p ParamsDefinition) Request() string
func (ParamsDefinition) ResponseDefinition ¶
func (p ParamsDefinition) ResponseDefinition(target string) []string
func (ParamsDefinition) UrlArgs ¶
func (p ParamsDefinition) UrlArgs() string
func (ParamsDefinition) ValidateRequired ¶
func (p ParamsDefinition) ValidateRequired() bool