definitions/apiconfig/apiconfig.go

66 lines
1.7 KiB
Go

package apiconfig
import "encoding/json"
type RequestType string
const (
JSON RequestType = "json"
FormData RequestType = "form-data"
)
type APIConfig struct {
ID string `json:"id"`
ListenPath string `json:"listenPath"`
Method string `json:"method"`
Request RequestConfig `json:"request"`
Actions map[string]Action `json:"actions"`
Conditionals map[string]Conditional `json:"conditionals"`
Responses map[string]ResponseConfig `json:"responses"`
}
type RequestConfig struct {
Type RequestType `json:"type"`
Schema string `json:"schema"`
FormValues []string `json:"formValues"`
Next string `json:"next"`
CORSAllowedOrigins []string `json:"corsAllowedOrigins"`
}
type Action struct {
Type string `json:"type"`
Config json.RawMessage `json:"config"`
Next string `json:"next"`
Fail string `json:"fail"`
}
type ConditionalExpressions struct {
Value string `json:"value"`
Type string `json:"type"`
Compare string `json:"compare,omitempty"`
}
type Conditional struct {
ValidPath string `json:"validPath"`
InvalidPath string `json:"invalidPath"`
Expression string `json:"expression"`
}
type ActionConfig struct {
ID string
Type string
Configuration string
}
type ResponseConfig struct {
Code int `json:"code"`
Template string `json:"template"`
Type string `json:"type"`
}
type DatasourceConfig struct {
ID string `json:"id"`
Config json.RawMessage `json:"config"`
Type string `json:"type"`
}