@@ -96,7 +96,7 @@ directive:
96
96
transform : $["$ref"] = "#/components/schemas/State"; delete $.allOf;
97
97
- from : openapi-document
98
98
where : $.components.schemas["ContentFilterResult"].properties.severity
99
- transform : $[" $ref"] = "#/components/schemas/ContentFilterSeverity" ; delete $.allOf;
99
+ transform : $. $ref = $.allOf[0].$ref ; delete $.allOf;
100
100
- from : openapi-document
101
101
where : $.components.schemas["ChatChoice"].properties.finish_reason
102
102
transform : $["$ref"] = "#/components/schemas/CompletionsFinishReason"; delete $.oneOf;
@@ -109,6 +109,102 @@ directive:
109
109
- from : openapi-document
110
110
where : $.components.schemas["AzureCognitiveSearchChatExtensionConfiguration"].properties.queryType
111
111
transform : $["$ref"] = "#/components/schemas/AzureCognitiveSearchQueryType"; delete $.allOf;
112
+ - from : openapi-document
113
+ where : $.components.schemas["ContentFilterResults"].properties.sexual
114
+ transform : $.$ref = $.allOf[0].$ref; delete $.allOf;
115
+ - from : openapi-document
116
+ where : $.components.schemas["ContentFilterResults"].properties.hate
117
+ transform : $.$ref = $.allOf[0].$ref; delete $.allOf;
118
+ - from : openapi-document
119
+ where : $.components.schemas["ContentFilterResults"].properties.self_harm
120
+ transform : $.$ref = $.allOf[0].$ref; delete $.allOf;
121
+ - from : openapi-document
122
+ where : $.components.schemas["ContentFilterResults"].properties.violence
123
+ transform : $.$ref = $.allOf[0].$ref; delete $.allOf;
124
+
125
+ #
126
+ # [BEGIN] Whisper
127
+ #
128
+
129
+ # the whisper operations are really long since they are a conglomeration of _all_ the
130
+ # possible return types.
131
+ - rename-operation :
132
+ from : getAudioTranscriptionAsPlainText_getAudioTranscriptionAsResponseObject
133
+ to : GetAudioTranscriptionInternal
134
+ - rename-operation :
135
+ from : getAudioTranslationAsPlainText_getAudioTranslationAsResponseObject
136
+ to : GetAudioTranslationInternal
137
+
138
+ # fixup the responses
139
+ - from : openapi-document
140
+ where : $.paths["/deployments/{deploymentId}/audio/transcriptions"]
141
+ transform : |
142
+ delete $.post.responses["200"].statusCode;
143
+ $.post.responses["200"].content["application/json"].schema["$ref"] = "#/components/schemas/AudioTranscription"; delete $.post.responses["200"].content["application/json"].schema.anyOf;
144
+ - from : openapi-document
145
+ where : $.paths["/deployments/{deploymentId}/audio/translations"]
146
+ transform : |
147
+ delete $.post.responses["200"].statusCode;
148
+ $.post.responses["200"].content["application/json"].schema["$ref"] = "#/components/schemas/AudioTranscription"; delete $.post.responses["200"].content["application/json"].schema.anyOf;
149
+
150
+ # hide the generated functions, in favor of our public wrappers.
151
+ - from :
152
+ - client.go
153
+ - models.go
154
+ - models_serde.go
155
+ - response_types.go
156
+ - options.go
157
+ where : $
158
+ transform : |
159
+ return $
160
+ .replace(/GetAudioTranscriptionInternal([^){ ]*)/g, "getAudioTranscriptionInternal$1")
161
+ .replace(/GetAudioTranslationInternal([^){ ]*)/g, "getAudioTranslationInternal$1");
162
+
163
+ # some multipart fixing
164
+ - from : client.go
165
+ where : $
166
+ transform : |
167
+ return $
168
+ .replace(/(func.*getAudio(?:Translation|Transcription)InternalCreateRequest\(.+?)options/g, "$1body")
169
+ .replace(/runtime\.SetMultipartFormData\(.+?\)/sg, "setMultipartFormData(req, file, *body)")
170
+
171
+ # response type parsing (can be text/plain _or_ JSON)
172
+ - from : client.go
173
+ where : $
174
+ transform : |
175
+ return $
176
+ .replace(/client\.getAudioTranscriptionInternalHandleResponse/g, "getAudioTranscriptionInternalHandleResponse")
177
+ .replace(/client\.getAudioTranslationInternalHandleResponse/g, "getAudioTranslationInternalHandleResponse")
178
+
179
+ # Whisper openapi3 generation: we have two oneOf that point to the same type.
180
+ # and we want to activate our multipart support in the generator.
181
+ - from : openapi-document
182
+ where : $.paths
183
+ transform : |
184
+ let makeMultipart = (item) => {
185
+ if (item["application/json"] == null) { return item; }
186
+ item["multipart/form-data"] = {
187
+ ...item["application/json"]
188
+ };
189
+ delete item["application/json"];
190
+ }
191
+ makeMultipart($["/deployments/{deploymentId}/audio/transcriptions"].post.requestBody.content);
192
+ makeMultipart($["/deployments/{deploymentId}/audio/translations"].post.requestBody.content);
193
+
194
+ - from : openapi-document
195
+ where : $.components.schemas
196
+ transform : |
197
+ let fix = (v) => { if (v.allOf != null) { v.$ref = v.allOf[0].$ref; delete v.allOf; } };
198
+
199
+ fix($.AudioTranscriptionOptions.properties.response_format);
200
+ fix($.AudioTranscription.properties.task);
201
+
202
+ fix($.AudioTranslationOptions.properties.response_format);
203
+ fix($.AudioTranslation.properties.task);
204
+ #
205
+ # [END] Whisper
206
+ #
207
+
112
208
# Fix "AutoGenerated" models
113
209
- from : openapi-document
114
210
where : $.components.schemas["ChatCompletions"].properties.usage
@@ -155,13 +251,26 @@ directive:
155
251
- models_serde.go
156
252
- models.go
157
253
where : $
158
- transform : return $.replace(/AzureCoreFoundations/g, "azureCoreFoundations");
159
- - from :
160
- - models_serde.go
161
- - models.go
162
- where : $
163
- transform : return $.replace(/(?:\/\/.*\s)?func \(\w \*?(?:ErrorResponse|ErrorResponseError|InnerError|InnerErrorInnererror)\).*\{\s(?:.+\s)+\}\s/g, "");
164
-
254
+ transform : |
255
+ return $
256
+ // InnerError is actually a recursive type, no need for this innererrorinnererror type
257
+ .replace(/\/\/ AzureCoreFoundationsInnerErrorInnererror.+?\n}/s, "")
258
+ // also, remove its marshalling functions
259
+ .replace(/\/\/ (Unmarshal|Marshal)JSON implements[^\n]+?AzureCoreFoundationsInnerErrorInnererror.+?\n}/sg, "")
260
+
261
+ // Remove any references to the type and replace them with InnerError.
262
+ .replace(/Innererror \*(AzureCoreFoundationsInnerErrorInnererror|AzureCoreFoundationsErrorInnererror)/g, "InnerError *InnerError")
263
+
264
+ // Fix the marshallers/unmarshallers to use the right case.
265
+ .replace(/(a|c).Innererror/g, '$1.InnerError')
266
+
267
+ // We have two "inner error" types that are identical (ErrorInnerError and InnerError). Let's eliminate the one that's not actually directly referenced.
268
+ .replace(/\/\/azureCoreFoundationsInnerError.+?\n}/s, "")
269
+
270
+ //
271
+ // Fix the AzureCoreFoundation naming to match our style.
272
+ //
273
+ .replace(/AzureCoreFoundations/g, "")
165
274
- from : constants.go
166
275
where : $
167
276
transform : >-
@@ -185,15 +294,6 @@ directive:
185
294
return $
186
295
.replace(/runtime\.JoinPaths\(client.endpoint, urlPath\)/g, "client.formatURL(urlPath, getDeployment(body))");
187
296
188
- # Some ImageGenerations hackery to represent the ImageLocation/ImagePayload polymorphism.
189
- # - Remove the auto-generated ImageGenerationsDataItem.
190
- # - Replace the ImageGenerations.Data type with []ImageGenerationDataItem
191
- # - from: models.go
192
- # where: $
193
- # transform: |
194
- # return $.replace(/type ImageGenerationsDataItem struct {[^}]+}/, "// ImageGenerationsDataItem represents an image URL or payload\ntype ImageGenerationsDataItem struct{\nImageLocation\nImagePayload\n}")
195
- # $.replace(/(type ImageGenerations struct.+?)Data any/g, "$1Data []ImageGenerationsDataItem")
196
-
197
297
- from : models.go
198
298
where : $
199
299
transform : |
@@ -261,16 +361,6 @@ directive:
261
361
where : $
262
362
transform : return $.replace(/Logprobs/g, "LogProbs")
263
363
264
- # delete ContentFilterResult in favor of our custom representation.
265
- - from :
266
- - models.go
267
- - models_serde.go
268
- where : $
269
- transform : |
270
- return $.replace(/\/\/ ContentFilterResult.+?\n}/s, "")
271
- .replace(/\/\/ MarshalJSON implements the json.Marshaller interface for type ContentFilterResult.+?\n}/s, "")
272
- .replace(/\/\/ UnmarshalJSON implements the json.Unmarshaller interface for type ContentFilterResult.+?\n}/s, "");
273
-
274
364
- from : constants.go
275
365
where : $
276
366
transform : return $.replace(/\/\/ PossibleazureOpenAIOperationStateValues returns.+?\n}/s, "");
@@ -295,14 +385,14 @@ directive:
295
385
where : $
296
386
transform : |
297
387
return $
298
- .replace(/\/\/ The model name .*?Model \*string/sg, "// REQUIRED: Deployment specifies the name of the deployment (for Azure OpenAI) or model (for OpenAI) to use for this request.\nDeployment string");
388
+ .replace(/\/\/ The model.*?Model \*string/sg, "// REQUIRED: Deployment specifies the name of the deployment (for Azure OpenAI) or model (for OpenAI) to use for this request.\nDeployment string");
299
389
300
390
- from : models_serde.go
301
391
where : $
302
392
transform : |
303
393
return $
304
- .replace(/populate\(objectMap, "model", (c|e).Model\)/g, 'populate(objectMap, "model", &$1.Deployment)')
305
- .replace(/err = unpopulate\(val, "Model", &(c|e).Model\)/g, 'err = unpopulate(val, "Model", &$1.Deployment)');
394
+ .replace(/populate\(objectMap, "model", (c|e|a ).Model\)/g, 'populate(objectMap, "model", &$1.Deployment)')
395
+ .replace(/err = unpopulate\(val, "Model", &(c|e|a ).Model\)/g, 'err = unpopulate(val, "Model", &$1.Deployment)');
306
396
307
397
# Make the Azure extensions internal - we expose these through the GetChatCompletions*() functions
308
398
# and just treat which endpoint we use as an implementation detail.
@@ -344,4 +434,9 @@ directive:
344
434
return $.replace(
345
435
/(AzureChatExtensionTypeAzureCognitiveSearch AzureChatExtensionType)/,
346
436
"// AzureChatExtensionTypeAzureCognitiveSearch enables the use of an Azure Cognitive Search index with chat completions.\n// [AzureChatExtensionConfiguration.Parameter] should be of type [AzureCognitiveSearchChatExtensionConfiguration].\n$1");
437
+
438
+ # HACK: prompt_filter_results <-> prompt_annotations change
439
+ - from : models_serde.go
440
+ where : $
441
+ transform : return $.replace(/case "prompt_filter_results":/g, 'case "prompt_annotations":\nfallthrough\ncase "prompt_filter_results":')
347
442
` ` `
0 commit comments