{"record":{"id":"b8d314fefb31979a","repo":"RicoSuter/NSwag","slug":"the-operation-operationdescription-operation-operationid-has-b8d314","errorCode":null,"errorMessage":"The operation '{operationDescription.Operation.OperationId}' has more than one body parameter.","messagePattern":"The operation '(.+?)' has more than one body parameter\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs","lineNumber":272,"sourceCode":"        /// </summary>\n        /// <param name=\"operationDescription\">Operation to check.</param>\n        /// <param name=\"schemaType\">Schema type.</param>\n        private static void UpdateNullableRawOperationParameters(OpenApiOperationDescription operationDescription, SchemaType schemaType)\n        {\n            if (schemaType == SchemaType.OpenApi3)\n            {\n                foreach (OpenApiParameter openApiParameter in operationDescription.Operation.Parameters)\n                {\n                    openApiParameter.IsNullableRaw = null;\n                }\n            }\n        }\n\n        private static void EnsureSingleBodyParameter(OpenApiOperationDescription operationDescription)\n        {\n            if (operationDescription.Operation.ActualParameters.Count(p => p.Kind == OpenApiParameterKind.Body) > 1)\n            {\n                throw new InvalidOperationException($\"The operation '{operationDescription.Operation.OperationId}' has more than one body parameter.\");\n            }\n        }\n\n        private static void UpdateConsumedTypes(OpenApiOperationDescription operationDescription)\n        {\n            if (operationDescription.Operation.ActualParameters.Any(p => p.IsBinary || p.ActualSchema.IsBinary))\n            {\n                operationDescription.Operation.TryAddConsumes(\"multipart/form-data\");\n            }\n        }\n\n        private static void RemoveUnusedPathParameters(OpenApiOperationDescription operationDescription, string httpPath)\n        {\n            operationDescription.Path = Regex.Replace(httpPath, \"{(.*?)(:(([^/]*)?))?}\", match =>\n            {\n                var parameterName = match.Groups[1].Value.TrimEnd('?');\n                if (operationDescription.Operation.ActualParameters.Any(p => p.Kind == OpenApiParameterKind.Path && string.Equals(p.Name, parameterName, StringComparison.OrdinalIgnoreCase)))\n                {","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/RicoSuter/NSwag/blob/63daf8fcc3a25151b62eb4b326a1e8ea048a0d41/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs#L254-L290","documentation":"The WebApi (non-ASP.NET-Core) operation generator throws when an operation's actual parameters contain more than one parameter with OpenApiParameterKind.Body after processing. An OpenAPI operation permits only a single body parameter, so EnsureSingleBodyParameter (called from Process) enforces this and throws InvalidOperationException with the operation's OperationId.","triggerScenarios":"Generating a document for a Web API 2 / OWIN controller action with multiple parameters that resolve to body kind (e.g. two complex typed parameters without [FromBody]/[FromUri] markers, so both default to body), or two parameters explicitly marked [FromBody].","commonSituations":"Classic ASP.NET Web API actions taking two complex types where one was intended as [FromUri]; migrating actions between frameworks and keeping duplicate body bindings; custom parameter processors adding a second body parameter.","solutions":["Merge the multiple body inputs into one request DTO and use it as the single body parameter.","Decorate the non-body parameter with [FromUri] (Web API 2) so it is treated as route/query instead of body.","Mark exactly one parameter [FromBody] and give the others explicit non-body binding sources.","If a custom NSwag processor adds the extra body parameter, correct it to emit at most one."],"exampleFix":"// before\npublic void Post(OrderDto order, AuditContext audit) // both become body\n\n// after\npublic void Post([FromBody] OrderDto order, [FromUri] AuditContext audit)","handlingStrategy":"validation","validationCode":"// Web API 2: exactly one implicit/explicit body parameter per action\nvar bodyParams = actionDescriptor.GetParameters()\n    .Where(p => !p.GetCustomAttributes(typeof(FromUriAttribute), false).Any());\nbool tooManyBodies = bodyParams.Count() > 1;","typeGuard":null,"tryCatchPattern":"try { document = generator.Generate(settings); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"more than one body parameter\"))\n{\n    logger.LogError(ex, \"Web API operation has multiple body parameters\");\n}","preventionTips":["Mark every non-body parameter [FromUri] explicitly in Web API 2 actions.","Merge multiple payloads into a single request DTO.","Generate the Swagger document in tests to catch binding-source mistakes."],"tags":["webapi","swagger","body-parameter","openapi"],"backgroundTag":"multiple-body-parameters","analyzedSha":"63daf8fcc3a25151b62eb4b326a1e8ea048a0d41","analyzedAt":"2026-09-14T11:38:15.205Z","contentChangedAt":"2026-09-14T11:38:15.205Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}