internal/application/config/Configuration.go   A
last analyzed

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
cc 1
eloc 45
dl 0
loc 61
rs 10
c 0
b 0
f 0
ccs 0
cts 1
cp 0
crap 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A config.*Configuration.Dump 0 16 1
1
package config
2
3
import (
4
	"math"
5
	"time"
6
7
	"github.com/muonsoft/openapi-mock/internal/openapi/generator/data"
8
	"github.com/sirupsen/logrus"
9
)
10
11
type Configuration struct {
12
	// OpenAPI options
13
	SpecificationURL string
14
15
	// HTTP server options
16
	CORSEnabled     bool
17
	Port            uint16
18
	ResponseTimeout time.Duration
19
20
	// Application options
21
	DryRun    bool
22
	Debug     bool
23
	LogFormat string
24
	LogLevel  logrus.Level
25
26
	// Generation options
27
	UseExamples     data.UseExamplesEnum
28
	NullProbability float64
29
	DefaultMinInt   int64
30
	DefaultMaxInt   int64
31
	DefaultMinFloat float64
32
	DefaultMaxFloat float64
33
	SuppressErrors  bool
34
}
35
36
const (
37
	DefaultPort            = uint16(8080)
38
	DefaultResponseTimeout = time.Second
39
	DefaultLogLevel        = logrus.InfoLevel
40
	DefaultNullProbability = 0.5
41
	DefaultMaxInt          = int64(math.MaxInt32)
42
	DefaultMinFloat        = -float64(math.MaxInt32 / 2)
43
	DefaultMaxFloat        = float64(math.MaxInt32 / 2)
44
)
45
46
func (config *Configuration) Dump() map[string]interface{} {
47
	return map[string]interface{}{
48
		"SpecificationURL": config.SpecificationURL,
49
		"CORSEnabled":      config.CORSEnabled,
50
		"Port":             config.Port,
51
		"ResponseTimeout":  config.ResponseTimeout,
52
		"Debug":            config.Debug,
53
		"LogFormat":        config.LogFormat,
54
		"LogLevel":         config.LogLevel,
55
		"UseExamples":      config.UseExamples,
56
		"NullProbability":  config.NullProbability,
57
		"DefaultMinInt":    config.DefaultMinInt,
58
		"DefaultMaxInt":    config.DefaultMaxInt,
59
		"DefaultMinFloat":  config.DefaultMinFloat,
60
		"DefaultMaxFloat":  config.DefaultMaxFloat,
61
		"SuppressErrors":   config.SuppressErrors,
62
	}
63
}
64