-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathOpenApiComponentsGenerator.cs
More file actions
42 lines (39 loc) · 1.78 KB
/
OpenApiComponentsGenerator.cs
File metadata and controls
42 lines (39 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using Microsoft.OpenApi.OData.Common;
using Microsoft.OpenApi.OData.Edm;
namespace Microsoft.OpenApi.OData.Generator
{
/// <summary>
/// Extension methods to create <see cref="OpenApiComponents"/> by Edm model.
/// </summary>
internal static class OpenApiComponentsGenerator
{
/// <summary>
/// Create a <see cref="OpenApiComponents"/>.
/// The value of components is a Components Object.
/// It holds maps of reusable schemas describing message bodies, operation parameters, and responses.
/// </summary>
/// <param name="context">The OData to Open API context.</param>
/// <param name="document">The Open API document.</param>
public static void AddComponentsToDocument(this ODataContext context, OpenApiDocument document)
{
Utils.CheckArgumentNull(context, nameof(context));
Utils.CheckArgumentNull(document, nameof(document));
context.AddSchemasToDocument(document);
context.AddParametersToDocument(document);
context.AddResponsesToDocument(document);
context.AddRequestBodiesToDocument(document);
context.AddExamplesToDocument(document);
context.AddSecuritySchemesToDocument(document);
if (document.Components is not null)
{
document.Components.Links = null;
document.Components.Callbacks = null;
document.Components.Extensions = null;
}
}
}
}