diff --git a/src/NSwag.Core/OpenApiOperation.cs b/src/NSwag.Core/OpenApiOperation.cs index beb123a6f..739f2d876 100644 --- a/src/NSwag.Core/OpenApiOperation.cs +++ b/src/NSwag.Core/OpenApiOperation.cs @@ -292,12 +292,12 @@ private OpenApiParameter CreateBodyParameter() private void UpdateBodyParameter(OpenApiParameter parameter) { parameter.Kind = OpenApiParameterKind.Body; - parameter.Name = RequestBody.ActualName; - parameter.Position = RequestBody.Position; - parameter.Description = RequestBody.Description; - parameter.IsRequired = RequestBody.IsRequired; - parameter.Example = RequestBody.Content.FirstOrDefault().Value?.Example; - parameter.Schema = RequestBody.Content.FirstOrDefault().Value?.Schema; + parameter.Name = RequestBody.ActualRequestBody.ActualName; + parameter.Position = RequestBody.ActualRequestBody.Position; + parameter.Description = RequestBody.ActualRequestBody.Description; + parameter.IsRequired = RequestBody.ActualRequestBody.IsRequired; + parameter.Example = RequestBody.ActualRequestBody.Content.FirstOrDefault().Value?.Example; + parameter.Schema = RequestBody.ActualRequestBody.Content.FirstOrDefault().Value?.Schema; } private void UpdateRequestBody(NotifyCollectionChangedEventArgs args) diff --git a/src/NSwag.Core/OpenApiRequestBody.cs b/src/NSwag.Core/OpenApiRequestBody.cs index 7fe5036df..955b733be 100644 --- a/src/NSwag.Core/OpenApiRequestBody.cs +++ b/src/NSwag.Core/OpenApiRequestBody.cs @@ -111,5 +111,16 @@ public int? Position object IJsonReference.PossibleRoot => ParentOperation?.Parent?.Parent; #endregion + + /// Gets or sets the referenced object. + public override OpenApiRequestBody Reference + { + get => base.Reference; + set + { + base.Reference = value; + (Parent as OpenApiOperation)?.UpdateBodyParameter(); + } + } } } \ No newline at end of file