Skip to content

Commit

Permalink
Support $ref in request-bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
Eruzo committed Jul 29, 2024
1 parent 7d6df3a commit 9211c03
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/NSwag.Core/OpenApiOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,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)
Expand Down
13 changes: 13 additions & 0 deletions src/NSwag.Core/OpenApiRequestBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,18 @@ public int? Position
object IJsonReference.PossibleRoot => ParentOperation?.Parent?.Parent;

#endregion

public override OpenApiRequestBody Reference
{
get
{
return base.Reference;
}
set
{
base.Reference = value;
(Parent as OpenApiOperation)?.UpdateBodyParameter();
}
}
}
}

0 comments on commit 9211c03

Please sign in to comment.