Skip to content

Commit c616f99

Browse files
authored
Use openapi generator (#8008)
1 parent 45e439b commit c616f99

File tree

46 files changed

+681
-459
lines changed

Some content is hidden

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

46 files changed

+681
-459
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<PackageVersion Include="Azure.Storage.Blobs" Version="$(AzureStorageBlobsVersion)" />
88
<PackageVersion Include="Azure.Storage.Queues" Version="$(AzureStorageQueuesVersion)" />
99
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(MicrosoftAspNetCoreAuthenticationJwtBearerVersion)" />
10+
<PackageVersion Include="Microsoft.AspnetCore.OpenApi" Version="$(MicrosoftAspNetCoreOpenApiVersion)" />
1011
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="$(MicrosoftAspNetCoreAuthenticationNegotiateVersion)" />
1112
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" />
1213
<PackageVersion Include="Microsoft.Diagnostics.Monitoring" Version="$(MicrosoftDiagnosticsMonitoringLibraryVersion)" />
@@ -25,7 +26,6 @@
2526
<PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
2627
<PackageVersion Include="NJsonSchema" Version="$(NJsonSchemaVersion)" />
2728
<PackageVersion Include="NJsonSchema.NewtonsoftJson" Version="$(NJsonSchemaVersion)" />
28-
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerGen" Version="$(SwashbuckleAspNetCoreVersion)" />
2929
<PackageVersion Include="System.CommandLine" Version="$(SystemCommandLineVersion)" />
3030
<PackageVersion Include="System.Private.Uri" Version="$(SystemPrivateUriVersion)" />
3131
<PackageVersion Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsVersion)" />

documentation/openapi.json

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,14 @@
187187
"in": "query",
188188
"description": "The type of dump to capture.",
189189
"schema": {
190-
"$ref": "#/components/schemas/DumpType"
190+
"enum": [
191+
"Full",
192+
"Mini",
193+
"WithHeap",
194+
"Triage"
195+
],
196+
"type": "string",
197+
"default": "WithHeap"
191198
}
192199
},
193200
{
@@ -351,7 +358,15 @@
351358
"in": "query",
352359
"description": "The profiles enabled for the trace session.",
353360
"schema": {
354-
"$ref": "#/components/schemas/TraceProfile"
361+
"enum": [
362+
"Cpu",
363+
"Http",
364+
"Logs",
365+
"Metrics",
366+
"GcCollect"
367+
],
368+
"type": "string",
369+
"default": "Cpu, Http, Metrics, GcCollect"
355370
}
356371
},
357372
{
@@ -705,7 +720,8 @@
705720
"$ref": "#/components/schemas/LogsConfiguration"
706721
}
707722
}
708-
}
723+
},
724+
"required": true
709725
},
710726
"responses": {
711727
"400": {
@@ -1430,7 +1446,8 @@
14301446
"$ref": "#/components/schemas/ExceptionsConfiguration"
14311447
}
14321448
}
1433-
}
1449+
},
1450+
"required": true
14341451
},
14351452
"responses": {
14361453
"400": {
@@ -1672,14 +1689,6 @@
16721689
"CollectionRuleDetailedDescription": {
16731690
"type": "object",
16741691
"properties": {
1675-
"state": {
1676-
"$ref": "#/components/schemas/CollectionRuleState"
1677-
},
1678-
"stateReason": {
1679-
"type": "string",
1680-
"description": "Human-readable explanation for the current state of the collection rule.",
1681-
"nullable": true
1682-
},
16831692
"lifetimeOccurrences": {
16841693
"type": "integer",
16851694
"description": "The number of times the trigger has executed for a process in its lifetime.",
@@ -1715,6 +1724,14 @@
17151724
"format": "time-span",
17161725
"nullable": true,
17171726
"example": "00:00:30"
1727+
},
1728+
"state": {
1729+
"$ref": "#/components/schemas/CollectionRuleState"
1730+
},
1731+
"stateReason": {
1732+
"type": "string",
1733+
"description": "Human-readable explanation for the current state of the collection rule.",
1734+
"nullable": true
17181735
}
17191736
},
17201737
"additionalProperties": false
@@ -1770,15 +1787,6 @@
17701787
},
17711788
"additionalProperties": false
17721789
},
1773-
"DumpType": {
1774-
"enum": [
1775-
"Full",
1776-
"Mini",
1777-
"WithHeap",
1778-
"Triage"
1779-
],
1780-
"type": "string"
1781-
},
17821790
"EventLevel": {
17831791
"enum": [
17841792
"LogAlways",
@@ -1985,9 +1993,9 @@
19851993
},
19861994
"MethodDescription": {
19871995
"required": [
1988-
"methodName",
19891996
"moduleName",
1990-
"typeName"
1997+
"typeName",
1998+
"methodName"
19911999
],
19922000
"type": "object",
19932001
"properties": {
@@ -2008,7 +2016,8 @@
20082016
},
20092017
"MonitorCapability": {
20102018
"required": [
2011-
"name"
2019+
"name",
2020+
"enabled"
20122021
],
20132022
"type": "object",
20142023
"properties": {
@@ -2034,7 +2043,8 @@
20342043
"nullable": true
20352044
}
20362045
},
2037-
"additionalProperties": false
2046+
"additionalProperties": false,
2047+
"nullable": true
20382048
},
20392049
"OperationProcessInfo": {
20402050
"type": "object",
@@ -2053,7 +2063,8 @@
20532063
}
20542064
},
20552065
"additionalProperties": false,
2056-
"description": "Represents the details of a given process used in an operation."
2066+
"description": "Represents the details of a given process used in an operation.",
2067+
"nullable": true
20572068
},
20582069
"OperationState": {
20592070
"enum": [
@@ -2069,6 +2080,13 @@
20692080
"OperationStatus": {
20702081
"type": "object",
20712082
"properties": {
2083+
"resourceLocation": {
2084+
"type": "string",
2085+
"nullable": true
2086+
},
2087+
"error": {
2088+
"$ref": "#/components/schemas/OperationError"
2089+
},
20722090
"operationId": {
20732091
"type": "string",
20742092
"format": "uuid"
@@ -2097,13 +2115,6 @@
20972115
"type": "string"
20982116
},
20992117
"nullable": true
2100-
},
2101-
"resourceLocation": {
2102-
"type": "string",
2103-
"nullable": true
2104-
},
2105-
"error": {
2106-
"$ref": "#/components/schemas/OperationError"
21072118
}
21082119
},
21092120
"additionalProperties": false,
@@ -2227,16 +2238,6 @@
22272238
},
22282239
"additionalProperties": false
22292240
},
2230-
"TraceProfile": {
2231-
"enum": [
2232-
"Cpu",
2233-
"Http",
2234-
"Logs",
2235-
"Metrics",
2236-
"GcCollect"
2237-
],
2238-
"type": "string"
2239-
},
22402241
"ValidationProblemDetails": {
22412242
"type": "object",
22422243
"properties": {
@@ -2307,5 +2308,19 @@
23072308
}
23082309
}
23092310
}
2310-
}
2311+
},
2312+
"tags": [
2313+
{
2314+
"name": "Diag"
2315+
},
2316+
{
2317+
"name": "Exceptions"
2318+
},
2319+
{
2320+
"name": "Metrics"
2321+
},
2322+
{
2323+
"name": "Operations"
2324+
}
2325+
]
23112326
}

eng/Signing.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
<FileSignInfo Include="AWSSDK.SecurityToken.dll" CertificateName="3PartySHA2" />
66
<FileSignInfo Include="Newtonsoft.Json.dll" CertificateName="3PartySHA2" />
77
<FileSignInfo Include="Newtonsoft.Json.Bson.dll" CertificateName="3PartySHA2" />
8-
<FileSignInfo Include="Swashbuckle.AspNetCore.Swagger.dll" CertificateName="3PartySHA2" />
9-
<FileSignInfo Include="Swashbuckle.AspNetCore.SwaggerGen.dll" CertificateName="3PartySHA2" />
108
</ItemGroup>
119
<ItemGroup Condition="'$(SignAllBinaries)' != 'true'">
1210
<!--

eng/Versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
<MicrosoftExtensionsLoggingAbstractionsVersion>$(MicrosoftExtensionsLoggingAbstractions90Version)</MicrosoftExtensionsLoggingAbstractionsVersion>
123123
<MicrosoftExtensionsLoggingConsoleVersion>$(MicrosoftExtensionsLoggingConsole90Version)</MicrosoftExtensionsLoggingConsoleVersion>
124124
<SystemTextJsonVersion>$(SystemTextJson90Version)</SystemTextJsonVersion>
125+
<MicrosoftAspNetCoreOpenApiVersion>$(MicrosoftAspNetCoreApp90Version)</MicrosoftAspNetCoreOpenApiVersion>
125126
</PropertyGroup>
126127
<PropertyGroup Condition="'$(UseMicrosoftDiagnosticsMonitoringShippedVersion)' == 'true'">
127128
<MicrosoftDiagnosticsMonitoringLibraryVersion>$(MicrosoftDiagnosticsMonitoringShippedVersion)</MicrosoftDiagnosticsMonitoringLibraryVersion>

src/Microsoft.Diagnostics.Monitoring.Options/CollectionRuleState.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
#if NET8_0_OR_GREATER
5+
using System.Text.Json.Serialization;
6+
#endif
7+
48
namespace Microsoft.Diagnostics.Monitoring.WebApi
59
{
10+
#if NET8_0_OR_GREATER
11+
[JsonConverter(typeof(JsonStringEnumConverter<CollectionRuleState>))]
12+
#endif
613
public enum CollectionRuleState
714
{
815
Running,

src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortConnectionMode.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
#if NET8_0_OR_GREATER
5+
using System.Text.Json.Serialization;
6+
#endif
7+
48
namespace Microsoft.Diagnostics.Monitoring.WebApi
59
{
10+
#if NET8_0_OR_GREATER
11+
[JsonConverter(typeof(JsonStringEnumConverter<DiagnosticPortConnectionMode>))]
12+
#endif
613
public enum DiagnosticPortConnectionMode
714
{
815
Connect,

src/Microsoft.Diagnostics.Monitoring.Options/MonitorCapability.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public class MonitorCapability : IMonitorCapability
1010
{
1111
[JsonPropertyName("name")]
1212
[Required]
13-
public string Name { get; }
13+
[MinLength(1)]
14+
public string Name { get; set; }
1415

1516
[JsonPropertyName("enabled")]
1617
public bool Enabled { get; }

src/Microsoft.Diagnostics.Monitoring.WebApi/Controllers/DiagController.Metrics.cs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,39 @@
55
using Microsoft.AspNetCore.Mvc;
66
using Microsoft.Diagnostics.Monitoring.EventPipe;
77
using System;
8+
using System.ComponentModel;
89
using System.ComponentModel.DataAnnotations;
910
using System.Threading.Tasks;
1011

1112
namespace Microsoft.Diagnostics.Monitoring.WebApi.Controllers
1213
{
1314
partial class DiagController
1415
{
15-
/// <summary>
16-
/// Capture metrics for a process.
17-
/// </summary>
18-
/// <param name="pid">Process ID used to identify the target process.</param>
19-
/// <param name="uid">The Runtime instance cookie used to identify the target process.</param>
20-
/// <param name="name">Process name used to identify the target process.</param>
21-
/// <param name="durationSeconds">The duration of the metrics session (in seconds).</param>
22-
/// <param name="egressProvider">The egress provider to which the metrics are saved.</param>
23-
/// <param name="tags">An optional set of comma-separated identifiers users can include to make an operation easier to identify.</param>
16+
[EndpointSummary("Capture metrics for a process.")]
2417
[HttpGet("livemetrics", Name = nameof(CaptureMetrics))]
25-
[ProducesWithProblemDetails(ContentTypes.ApplicationJsonSequence)]
18+
[ProducesWithProblemDetails]
2619
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status429TooManyRequests)]
27-
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
20+
[ProducesResponseType(typeof(string), StatusCodes.Status200OK, ContentTypes.ApplicationJsonSequence)]
2821
[ProducesResponseType(typeof(void), StatusCodes.Status202Accepted)]
2922
[EgressValidation]
3023
public Task<ActionResult> CaptureMetrics(
3124
[FromQuery]
25+
[Description("Process ID used to identify the target process.")]
3226
int? pid = null,
3327
[FromQuery]
28+
[Description("The Runtime instance cookie used to identify the target process.")]
3429
Guid? uid = null,
3530
[FromQuery]
31+
[Description("Process name used to identify the target process.")]
3632
string? name = null,
3733
[FromQuery][Range(-1, int.MaxValue)]
34+
[Description("The duration of the metrics session (in seconds).")]
3835
int durationSeconds = 30,
3936
[FromQuery]
37+
[Description("The egress provider to which the metrics are saved.")]
4038
string? egressProvider = null,
4139
[FromQuery]
40+
[Description("An optional set of comma-separated identifiers users can include to make an operation easier to identify.")]
4241
string? tags = null)
4342
{
4443
ProcessKey? processKey = Utilities.GetProcessKey(pid, uid, name);
@@ -59,36 +58,34 @@ public Task<ActionResult> CaptureMetrics(
5958
Utilities.ArtifactType_Metrics);
6059
}
6160

62-
/// <summary>
63-
/// Capture metrics for a process.
64-
/// </summary>
65-
/// <param name="configuration">The metrics configuration describing which metrics to capture.</param>
66-
/// <param name="pid">Process ID used to identify the target process.</param>
67-
/// <param name="uid">The Runtime instance cookie used to identify the target process.</param>
68-
/// <param name="name">Process name used to identify the target process.</param>
69-
/// <param name="durationSeconds">The duration of the metrics session (in seconds).</param>
70-
/// <param name="egressProvider">The egress provider to which the metrics are saved.</param>
71-
/// <param name="tags">An optional set of comma-separated identifiers users can include to make an operation easier to identify.</param>
61+
[EndpointSummary("Capture metrics for a process.")]
7262
[HttpPost("livemetrics", Name = nameof(CaptureMetricsCustom))]
73-
[ProducesWithProblemDetails(ContentTypes.ApplicationJsonSequence)]
63+
[ProducesWithProblemDetails]
7464
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status429TooManyRequests)]
75-
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
65+
[ProducesResponseType(typeof(string), StatusCodes.Status200OK, ContentTypes.ApplicationJsonSequence)]
7666
[ProducesResponseType(typeof(void), StatusCodes.Status202Accepted)]
7767
[EgressValidation]
7868
public Task<ActionResult> CaptureMetricsCustom(
7969
[FromBody][Required]
70+
[Description("The metrics configuration describing which metrics to capture.")]
8071
Models.EventMetricsConfiguration configuration,
8172
[FromQuery]
73+
[Description("Process ID used to identify the target process.")]
8274
int? pid = null,
8375
[FromQuery]
76+
[Description("The Runtime instance cookie used to identify the target process.")]
8477
Guid? uid = null,
8578
[FromQuery]
79+
[Description("Process name used to identify the target process.")]
8680
string? name = null,
8781
[FromQuery][Range(-1, int.MaxValue)]
82+
[Description("The duration of the metrics session (in seconds).")]
8883
int durationSeconds = 30,
8984
[FromQuery]
85+
[Description("The egress provider to which the metrics are saved.")]
9086
string? egressProvider = null,
9187
[FromQuery]
88+
[Description("An optional set of comma-separated identifiers users can include to make an operation easier to identify.")]
9289
string? tags = null)
9390
{
9491
ProcessKey? processKey = Utilities.GetProcessKey(pid, uid, name);

0 commit comments

Comments
 (0)