27
27
final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareInterface
28
28
{
29
29
private const BASE_PROP = [
30
- 'readOnly ' => true ,
31
30
'type ' => 'string ' ,
32
31
];
33
32
private const BASE_PROPS = [
@@ -36,7 +35,6 @@ final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareI
36
35
];
37
36
private const BASE_ROOT_PROPS = [
38
37
'@context ' => [
39
- 'readOnly ' => true ,
40
38
'oneOf ' => [
41
39
['type ' => 'string ' ],
42
40
[
@@ -87,28 +85,28 @@ public function buildSchema(string $className, string $format = 'jsonld', string
87
85
}
88
86
}
89
87
90
- if ('input ' === $ type ) {
91
- return $ schema ;
92
- }
93
-
94
88
$ definitions = $ schema ->getDefinitions ();
95
89
if ($ key = $ schema ->getRootDefinitionKey ()) {
96
90
$ definitions [$ key ]['properties ' ] = self ::BASE_ROOT_PROPS + ($ definitions [$ key ]['properties ' ] ?? []);
97
- foreach (array_keys (self ::BASE_ROOT_PROPS ) as $ property ) {
98
- $ definitions [$ key ]['required ' ] ??= [];
99
- if (!\in_array ($ property , $ definitions [$ key ]['required ' ], true )) {
100
- $ definitions [$ key ]['required ' ][] = $ property ;
91
+ if (Schema::TYPE_OUTPUT === $ type ) {
92
+ foreach (array_keys (self ::BASE_ROOT_PROPS ) as $ property ) {
93
+ $ definitions [$ key ]['required ' ] ??= [];
94
+ if (!\in_array ($ property , $ definitions [$ key ]['required ' ], true )) {
95
+ $ definitions [$ key ]['required ' ][] = $ property ;
96
+ }
101
97
}
102
98
}
103
99
104
100
return $ schema ;
105
101
}
106
102
if ($ key = $ schema ->getItemsDefinitionKey ()) {
107
103
$ definitions [$ key ]['properties ' ] = self ::BASE_PROPS + ($ definitions [$ key ]['properties ' ] ?? []);
108
- foreach (array_keys (self ::BASE_PROPS ) as $ property ) {
109
- $ definitions [$ key ]['required ' ] ??= [];
110
- if (!\in_array ($ property , $ definitions [$ key ]['required ' ], true )) {
111
- $ definitions [$ key ]['required ' ][] = $ property ;
104
+ if (Schema::TYPE_OUTPUT === $ type ) {
105
+ foreach (array_keys (self ::BASE_PROPS ) as $ property ) {
106
+ $ definitions [$ key ]['required ' ] ??= [];
107
+ if (!\in_array ($ property , $ definitions [$ key ]['required ' ], true )) {
108
+ $ definitions [$ key ]['required ' ][] = $ property ;
109
+ }
112
110
}
113
111
}
114
112
}
0 commit comments