-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathconfig.go
More file actions
45 lines (39 loc) · 1.4 KB
/
config.go
File metadata and controls
45 lines (39 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package python
import (
"bytes"
json "encoding/json"
"fmt"
"strings"
)
type OverrideColumn struct {
Column string `json:"column"`
DbType string `json:"db_type"`
PyType string `json:"py_type"`
PyImport string `json:"py_import"`
}
type Config struct {
EmitExactTableNames bool `json:"emit_exact_table_names"`
EmitSyncQuerier bool `json:"emit_sync_querier"`
EmitAsyncQuerier bool `json:"emit_async_querier"`
Package string `json:"package"`
Out string `json:"out"`
EmitPydanticModels bool `json:"emit_pydantic_models"`
EmitStrEnum bool `json:"emit_str_enum"`
EmitSchemaNamePrefix bool `json:"emit_schema_name_prefix"`
QueryParameterLimit *int32 `json:"query_parameter_limit"`
InflectionExcludeTableNames []string `json:"inflection_exclude_table_names"`
Overrides []OverrideColumn `json:"overrides"`
}
func parseConfig(raw []byte) (Config, error) {
var conf Config
if len(raw) == 0 {
return conf, nil
}
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&conf); err != nil {
msg := strings.TrimPrefix(err.Error(), "json: ")
return Config{}, fmt.Errorf("invalid plugin options: %s", msg)
}
return conf, nil
}