@@ -89,26 +89,47 @@ public function getResult(): ?GenerativeAiResult
89
89
public static function getJsonSchema (): array
90
90
{
91
91
return [
92
- 'type ' => 'object ' ,
93
- 'properties ' => [
94
- 'id ' => [
95
- 'type ' => 'string ' ,
96
- 'description ' => 'Unique identifier for this operation. ' ,
97
- ],
98
- 'state ' => [
99
- 'type ' => 'string ' ,
100
- 'enum ' => ['starting ' , 'processing ' , 'succeeded ' , 'failed ' , 'canceled ' ],
101
- 'description ' => 'The current state of the operation. ' ,
92
+ 'oneOf ' => [
93
+ // Succeeded state - has result
94
+ [
95
+ 'type ' => 'object ' ,
96
+ 'properties ' => [
97
+ 'id ' => [
98
+ 'type ' => 'string ' ,
99
+ 'description ' => 'Unique identifier for this operation. ' ,
100
+ ],
101
+ 'state ' => [
102
+ 'type ' => 'string ' ,
103
+ 'const ' => OperationStateEnum::succeeded ()->value ,
104
+ ],
105
+ 'result ' => GenerativeAiResult::getJsonSchema (),
106
+ ],
107
+ 'required ' => ['id ' , 'state ' , 'result ' ],
108
+ 'additionalProperties ' => false ,
102
109
],
103
- 'result ' => [
104
- 'oneOf ' => [
105
- ['type ' => 'null ' ],
106
- GenerativeAiResult::getJsonSchema (),
110
+ // All other states - no result
111
+ [
112
+ 'type ' => 'object ' ,
113
+ 'properties ' => [
114
+ 'id ' => [
115
+ 'type ' => 'string ' ,
116
+ 'description ' => 'Unique identifier for this operation. ' ,
117
+ ],
118
+ 'state ' => [
119
+ 'type ' => 'string ' ,
120
+ 'enum ' => [
121
+ OperationStateEnum::starting ()->value ,
122
+ OperationStateEnum::processing ()->value ,
123
+ OperationStateEnum::failed ()->value ,
124
+ OperationStateEnum::canceled ()->value ,
125
+ ],
126
+ 'description ' => 'The current state of the operation. ' ,
127
+ ],
107
128
],
108
- 'description ' => 'The result once the operation completes. ' ,
129
+ 'required ' => ['id ' , 'state ' ],
130
+ 'additionalProperties ' => false ,
109
131
],
110
132
],
111
- 'required ' => ['id ' , 'state ' ],
112
133
];
113
134
}
114
135
}
0 commit comments