File tree Expand file tree Collapse file tree 7 files changed +64
-0
lines changed Expand file tree Collapse file tree 7 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -16,4 +16,9 @@ public function __construct(string $name)
16
16
}
17
17
});
18
18
}
19
+
20
+ public function getSchema (): array
21
+ {
22
+ return parent ::getSchema () + ['type ' => 'boolean ' ];
23
+ }
19
24
}
Original file line number Diff line number Diff line change @@ -34,4 +34,9 @@ public function __construct(string $name)
34
34
}
35
35
});
36
36
}
37
+
38
+ public function getSchema (): array
39
+ {
40
+ return parent ::getSchema () + ['type ' => 'string ' , 'format ' => 'date ' ];
41
+ }
37
42
}
Original file line number Diff line number Diff line change @@ -32,4 +32,9 @@ public function __construct(string $name)
32
32
}
33
33
});
34
34
}
35
+
36
+ public function getSchema (): array
37
+ {
38
+ return parent ::getSchema () + ['type ' => 'string ' , 'format ' => 'date-time ' ];
39
+ }
35
40
}
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ abstract class Field
14
14
15
15
public ?string $ property = null ;
16
16
public bool $ nullable = false ;
17
+ public ?string $ description = null ;
18
+ public array $ schema = [];
17
19
18
20
public function __construct (public readonly string $ name )
19
21
{
@@ -37,4 +39,23 @@ public function nullable(bool $nullable = true): static
37
39
38
40
return $ this ;
39
41
}
42
+
43
+ public function description (?string $ description ): static
44
+ {
45
+ $ this ->description = $ description ;
46
+
47
+ return $ this ;
48
+ }
49
+
50
+ public function schema (array $ schema ): static
51
+ {
52
+ $ this ->schema = $ schema ;
53
+
54
+ return $ this ;
55
+ }
56
+
57
+ public function getSchema (): array
58
+ {
59
+ return $ this ->schema + ['description ' => $ this ->description , 'nullable ' => $ this ->nullable ];
60
+ }
40
61
}
Original file line number Diff line number Diff line change @@ -18,4 +18,9 @@ public function __construct(string $name)
18
18
}
19
19
});
20
20
}
21
+
22
+ public function getSchema (): array
23
+ {
24
+ return ['type ' => 'integer ' ] + parent ::getSchema ();
25
+ }
21
26
}
Original file line number Diff line number Diff line change @@ -73,4 +73,16 @@ public function multipleOf(?float $number): static
73
73
74
74
return $ this ;
75
75
}
76
+
77
+ public function getSchema (): array
78
+ {
79
+ return parent ::getSchema () + [
80
+ 'type ' => 'number ' ,
81
+ 'minimum ' => $ this ->minimum ,
82
+ 'exclusiveMinimum ' => $ this ->exclusiveMinimum ,
83
+ 'maximum ' => $ this ->maximum ,
84
+ 'exclusiveMaximum ' => $ this ->exclusiveMaximum ,
85
+ 'multipleOf ' => $ this ->multipleOf ,
86
+ ];
87
+ }
76
88
}
Original file line number Diff line number Diff line change @@ -65,4 +65,15 @@ public function format(?string $format): static
65
65
66
66
return $ this ;
67
67
}
68
+
69
+ public function getSchema (): array
70
+ {
71
+ return parent ::getSchema () + [
72
+ 'type ' => 'string ' ,
73
+ 'minLength ' => $ this ->minLength ,
74
+ 'maxLength ' => $ this ->maxLength ,
75
+ 'pattern ' => $ this ->pattern ,
76
+ 'format ' => $ this ->format ,
77
+ ];
78
+ }
68
79
}
You can’t perform that action at this time.
0 commit comments