Skip to content

Commit ba87fcf

Browse files
authored
When processing the body of a request with an unsupported media type, and there is no OperationId defined, print the path in the error instead (#277)
1 parent 656ac33 commit ba87fcf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/SwaggerProvider.DesignTime/v3/OperationCompiler.fs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,14 @@ type OperationCompiler(schema: OpenApiDocument, defCompiler: DefinitionCompiler,
120120
formatAndParam NoData defSchema
121121
| _ ->
122122
let keys = operation.RequestBody.Content.Keys |> String.concat ";"
123-
failwithf $"Operation '%s{operation.OperationId}' does not contain supported media types [%A{keys}]"
123+
124+
let operationId =
125+
if String.IsNullOrWhiteSpace(operation.OperationId) then
126+
$"%s{path}/%A{opTy}"
127+
else
128+
operation.OperationId
129+
130+
failwithf $"Operation '%s{operationId}' does not contain supported media types [%A{keys}]"
124131

125132
let payloadTy = bodyFormatAndParam |> Option.map fst |> Option.defaultValue NoData
126133

0 commit comments

Comments
 (0)