Skip to content

Commit 834e41f

Browse files
committed
feat: make response request body, header and parameter content referenceable
Signed-off-by: Vincent Biret <[email protected]>
1 parent 02cf2b8 commit 834e41f

File tree

48 files changed

+254
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+254
-253
lines changed

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ public interface IOpenApiHeader : IOpenApiDescribedElement, IOpenApiReadOnlyExte
5959
/// <summary>
6060
/// A map containing the representations for the header.
6161
/// </summary>
62-
public IDictionary<string, OpenApiMediaType>? Content { get; }
62+
public IDictionary<string, IOpenApiMediaType>? Content { get; }
6363

6464
}

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE
101101
/// When example or examples are provided in conjunction with the schema object,
102102
/// the example MUST follow the prescribed serialization strategy for the parameter.
103103
/// </summary>
104-
public IDictionary<string, OpenApiMediaType>? Content { get; }
104+
public IDictionary<string, IOpenApiMediaType>? Content { get; }
105105
}

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public interface IOpenApiRequestBody : IOpenApiDescribedElement, IOpenApiReadOnl
1717
/// REQUIRED. The content of the request body. The key is a media type or media type range and the value describes it.
1818
/// For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*
1919
/// </summary>
20-
public IDictionary<string, OpenApiMediaType>? Content { get; }
20+
public IDictionary<string, IOpenApiMediaType>? Content { get; }
2121
/// <summary>
2222
/// Converts the request body to a body parameter in preparation for a v2 serialization.
2323
/// </summary>

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public interface IOpenApiResponse : IOpenApiDescribedElement, IOpenApiReadOnlyEx
1717
/// A map containing descriptions of potential response payloads.
1818
/// The key is a media type or media type range and the value describes it.
1919
/// </summary>
20-
public IDictionary<string, OpenApiMediaType>? Content { get; }
20+
public IDictionary<string, IOpenApiMediaType>? Content { get; }
2121

2222
/// <summary>
2323
/// A map of operations links that can be followed from the response.

src/Microsoft.OpenApi/Models/OpenApiHeader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class OpenApiHeader : IOpenApiHeader, IOpenApiExtensible
4444
public IDictionary<string, IOpenApiExample>? Examples { get; set; }
4545

4646
/// <inheritdoc/>
47-
public IDictionary<string, OpenApiMediaType>? Content { get; set; }
47+
public IDictionary<string, IOpenApiMediaType>? Content { get; set; }
4848

4949
/// <inheritdoc/>
5050
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; }
@@ -70,7 +70,7 @@ internal OpenApiHeader(IOpenApiHeader header)
7070
Schema = header.Schema?.CreateShallowCopy();
7171
Example = header.Example != null ? JsonNodeCloneHelper.Clone(header.Example) : null;
7272
Examples = header.Examples != null ? new Dictionary<string, IOpenApiExample>(header.Examples) : null;
73-
Content = header.Content != null ? new Dictionary<string, OpenApiMediaType>(header.Content) : null;
73+
Content = header.Content != null ? new Dictionary<string, IOpenApiMediaType>(header.Content) : null;
7474
Extensions = header.Extensions != null ? new Dictionary<string, IOpenApiExtension>(header.Extensions) : null;
7575
}
7676

src/Microsoft.OpenApi/Models/OpenApiParameter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public bool Explode
6161
public JsonNode? Example { get; set; }
6262

6363
/// <inheritdoc/>
64-
public IDictionary<string, OpenApiMediaType>? Content { get; set; }
64+
public IDictionary<string, IOpenApiMediaType>? Content { get; set; }
6565

6666
/// <inheritdoc/>
6767
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; }
@@ -87,7 +87,7 @@ internal OpenApiParameter(IOpenApiParameter parameter)
8787
Schema = parameter.Schema?.CreateShallowCopy();
8888
Examples = parameter.Examples != null ? new Dictionary<string, IOpenApiExample>(parameter.Examples) : null;
8989
Example = parameter.Example != null ? JsonNodeCloneHelper.Clone(parameter.Example) : null;
90-
Content = parameter.Content != null ? new Dictionary<string, OpenApiMediaType>(parameter.Content) : null;
90+
Content = parameter.Content != null ? new Dictionary<string, IOpenApiMediaType>(parameter.Content) : null;
9191
Extensions = parameter.Extensions != null ? new Dictionary<string, IOpenApiExtension>(parameter.Extensions) : null;
9292
AllowEmptyValue = parameter.AllowEmptyValue;
9393
Deprecated = parameter.Deprecated;

src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class OpenApiRequestBody : IOpenApiExtensible, IOpenApiRequestBody
1919
public bool Required { get; set; }
2020

2121
/// <inheritdoc />
22-
public IDictionary<string, OpenApiMediaType>? Content { get; set; }
22+
public IDictionary<string, IOpenApiMediaType>? Content { get; set; }
2323

2424
/// <inheritdoc />
2525
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; }
@@ -37,7 +37,7 @@ internal OpenApiRequestBody(IOpenApiRequestBody requestBody)
3737
Utils.CheckArgumentNull(requestBody);
3838
Description = requestBody.Description ?? Description;
3939
Required = requestBody.Required;
40-
Content = requestBody.Content != null ? new Dictionary<string, OpenApiMediaType>(requestBody.Content) : null;
40+
Content = requestBody.Content != null ? new Dictionary<string, IOpenApiMediaType>(requestBody.Content) : null;
4141
Extensions = requestBody.Extensions != null ? new Dictionary<string, IOpenApiExtension>(requestBody.Extensions) : null;
4242
}
4343

src/Microsoft.OpenApi/Models/OpenApiResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class OpenApiResponse : IOpenApiExtensible, IOpenApiResponse
2222
public IDictionary<string, IOpenApiHeader>? Headers { get; set; }
2323

2424
/// <inheritdoc/>
25-
public IDictionary<string, OpenApiMediaType>? Content { get; set; }
25+
public IDictionary<string, IOpenApiMediaType>? Content { get; set; }
2626

2727
/// <inheritdoc/>
2828
public IDictionary<string, IOpenApiLink>? Links { get; set; }
@@ -44,7 +44,7 @@ internal OpenApiResponse(IOpenApiResponse response)
4444
Summary = response.Summary ?? Summary;
4545
Description = response.Description ?? Description;
4646
Headers = response.Headers != null ? new Dictionary<string, IOpenApiHeader>(response.Headers) : null;
47-
Content = response.Content != null ? new Dictionary<string, OpenApiMediaType>(response.Content) : null;
47+
Content = response.Content != null ? new Dictionary<string, IOpenApiMediaType>(response.Content) : null;
4848
Links = response.Links != null ? new Dictionary<string, IOpenApiLink>(response.Links) : null;
4949
Extensions = response.Extensions != null ? new Dictionary<string, IOpenApiExtension>(response.Extensions) : null;
5050
}

src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public string? Description
6868
public IDictionary<string, IOpenApiExample>? Examples { get => Target?.Examples; }
6969

7070
/// <inheritdoc/>
71-
public IDictionary<string, OpenApiMediaType>? Content { get => Target?.Content; }
71+
public IDictionary<string, IOpenApiMediaType>? Content { get => Target?.Content; }
7272

7373
/// <inheritdoc/>
7474
public IDictionary<string, IOpenApiExtension>? Extensions { get => Target?.Extensions; }

src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public string? Description
7474
public bool Explode { get => Target?.Explode ?? default; }
7575

7676
/// <inheritdoc/>
77-
public IDictionary<string, OpenApiMediaType>? Content { get => Target?.Content; }
77+
public IDictionary<string, IOpenApiMediaType>? Content { get => Target?.Content; }
7878

7979
/// <inheritdoc/>
8080
public IDictionary<string, IOpenApiExtension>? Extensions { get => Target?.Extensions; }

0 commit comments

Comments
 (0)