-
Notifications
You must be signed in to change notification settings - Fork 1
/
Options.php
136 lines (113 loc) · 3.14 KB
/
Options.php
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
namespace Swaggest\GoCodeBuilder\JsonSchema;
use Swaggest\JsonSchema\Constraint\Properties;
use Swaggest\JsonSchema\Schema;
use Swaggest\JsonSchema\Structure\ClassStructure;
class Options extends ClassStructure
{
/**
* Remove parent prefix from property name
* Example:
* type Property struct { PropertySimple *PropertySimple `json:"-"`}
* would become
* type Property struct { Simple *PropertySimple `json:"-"`}
* @var bool
*/
public $trimParentFromPropertyNames = true;
/**
* Hide properties with constant values
* @var bool
*/
public $hideConstProperties = true;
/**
* Use integer types based on minimum/maximum
* @var bool
*/
public $optimizeIntegers = true;
/**
* Skip Unmarshal generation
* @var bool
*/
public $skipUnmarshal = false;
/**
* Skip Marshal generation
* @var bool
*/
public $skipMarshal = false;
/**
* Generate structure for schema with `x-go-type` available.
* @var bool
*/
public $ignoreXGoType = false;
/**
* Add `null` to types if `x-nullable` or `nullable` is available.
* @var bool
*/
public $enableXNullable = false;
/**
* Use pointer types to avoid zero value ambiguity.
* @var bool
*/
public $withZeroValues = false;
/**
* Ignore if property is required when deciding on pointer type or omitempty.
* @var bool
*/
public $ignoreRequired = false;
/**
* Validate that required properties are present when unmarshaling.
* @var bool
*/
public $validateRequired = true;
/**
* Add omitempty to nullable values.
* @var bool
*/
public $ignoreNullable = false;
/**
* Separate `null` from non-existent key by using `*interface{}` type in property.
* @var bool
*/
public $distinctNull = true;
/**
* Enable `additionalProperties` if they are missing (null) in schema.
* @var bool
*/
public $defaultAdditionalProperties = true;
/**
* Inherit schema from schema examples where available.
* @var bool
*/
public $inheritSchemaFromExamples = false;
/**
* Generate fluent setters for struct fields.
* @var bool
*/
public $fluentSetters = false;
/**
* Map of default exported symbol names to new ones, e.g. PoorlyGenerated:NicelyReadable.
* @var array
*/
public $renames = [];
/**
* Only generate schemas that have `x-generate: true`.
* @var bool
*/
public $requireXGenerate = false;
/**
* Set additional field tags with property name.
* @var string[]
*/
public $nameTags = [];
/**
* @param Properties|static $properties
* @param Schema $ownerSchema
*/
public static function setUpProperties($properties, Schema $ownerSchema)
{
$properties->trimParentFromPropertyNames = Schema::boolean()->setDefault(true);
$properties->hideConstProperties = Schema::boolean()->setDefault(true);
$properties->skipMarshal = Schema::boolean();
$properties->skipUnmarshal = Schema::boolean();
}
}