Skip to content

Commit a551442

Browse files
committed
fix: Fixed rare issue with oneOf usage to define required property.
1 parent 462afa7 commit a551442

15 files changed

+33
-5
lines changed

src/libs/OpenApiGenerator.Core/Models/TypeData.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,15 @@ Default with
155155
IsDateTime: context.Schema.IsDateTime(),
156156
IsBinary: context.Schema.IsBinary(),
157157
IsUnixTimestamp: context.Schema.IsUnixTimestamp(),
158-
AnyOfCount: context.Schema.AnyOf?.Count ?? 0,
159-
OneOfCount: context.Schema.OneOf?.Count ?? 0,
160-
AllOfCount: context.Schema.AllOf?.Count ?? 0,
158+
AnyOfCount: context.Schema.IsAnyOf() // Sometimes here AnyOf with only required properties
159+
? context.Schema.AnyOf?.Count ?? 0
160+
: 0,
161+
OneOfCount: context.Schema.IsOneOf() // Sometimes here OneOf with only required properties
162+
? context.Schema.OneOf?.Count ?? 0
163+
: 0,
164+
AllOfCount: context.Schema.IsAllOf() // Sometimes here AllOf with only required properties
165+
? context.Schema.AllOf?.Count ?? 0
166+
: 0,
161167
IsComponent: context.IsComponent,
162168
Properties: properties,
163169
EnumValues: enumValues,

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/GitHub/NewtonsoftJson/_#G.ChecksClient.ChecksCreate.g.verified.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ partial void ProcessChecksCreateResponseContent(
4444
global::G.ChecksCreateRequest request,
4545
global::System.Threading.CancellationToken cancellationToken = default)
4646
{
47+
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
48+
4749
PrepareArguments(
4850
client: _httpClient);
4951
PrepareChecksCreateArguments(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/GitHub/NewtonsoftJson/_#G.ChecksClient.ChecksUpdate.g.verified.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ partial void ProcessChecksUpdateResponseContent(
4747
global::G.ChecksUpdateRequest request,
4848
global::System.Threading.CancellationToken cancellationToken = default)
4949
{
50+
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
51+
5052
PrepareArguments(
5153
client: _httpClient);
5254
PrepareChecksUpdateArguments(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/GitHub/NewtonsoftJson/_#G.CodeScanningClient.CodeScanningCreateVariantAnalysis.g.verified.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ partial void ProcessCodeScanningCreateVariantAnalysisResponseContent(
4545
global::G.CodeScanningCreateVariantAnalysisRequest request,
4646
global::System.Threading.CancellationToken cancellationToken = default)
4747
{
48+
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
49+
4850
PrepareArguments(
4951
client: _httpClient);
5052
PrepareCodeScanningCreateVariantAnalysisArguments(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/GitHub/NewtonsoftJson/_#G.PullsClient.PullsRequestReviewers.g.verified.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ partial void ProcessPullsRequestReviewersResponseContent(
4646
global::G.PullsRequestReviewersRequest request,
4747
global::System.Threading.CancellationToken cancellationToken = default)
4848
{
49+
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
50+
4951
PrepareArguments(
5052
client: _httpClient);
5153
PreparePullsRequestReviewersArguments(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/GitHub/NewtonsoftJson/_#G.ReposClient.ReposCreatePagesSite.g.verified.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ partial void ProcessReposCreatePagesSiteResponseContent(
4343
global::G.ReposCreatePagesSiteRequest request,
4444
global::System.Threading.CancellationToken cancellationToken = default)
4545
{
46+
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
47+
4648
PrepareArguments(
4749
client: _httpClient);
4850
PrepareReposCreatePagesSiteArguments(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/GitHub/NewtonsoftJson/_#G.ReposClient.ReposUpdateInformationAboutPagesSite.g.verified.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ partial void ProcessReposUpdateInformationAboutPagesSiteResponseContent(
4343
global::G.ReposUpdateInformationAboutPagesSiteRequest request,
4444
global::System.Threading.CancellationToken cancellationToken = default)
4545
{
46+
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
47+
4648
PrepareArguments(
4749
client: _httpClient);
4850
PrepareReposUpdateInformationAboutPagesSiteArguments(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/GitHub/SystemTextJson/_#G.ChecksClient.ChecksCreate.g.verified.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ partial void ProcessChecksCreateResponseContent(
4444
global::G.ChecksCreateRequest request,
4545
global::System.Threading.CancellationToken cancellationToken = default)
4646
{
47+
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
48+
4749
PrepareArguments(
4850
client: _httpClient);
4951
PrepareChecksCreateArguments(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/GitHub/SystemTextJson/_#G.ChecksClient.ChecksUpdate.g.verified.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ partial void ProcessChecksUpdateResponseContent(
4747
global::G.ChecksUpdateRequest request,
4848
global::System.Threading.CancellationToken cancellationToken = default)
4949
{
50+
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
51+
5052
PrepareArguments(
5153
client: _httpClient);
5254
PrepareChecksUpdateArguments(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/GitHub/SystemTextJson/_#G.CodeScanningClient.CodeScanningCreateVariantAnalysis.g.verified.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ partial void ProcessCodeScanningCreateVariantAnalysisResponseContent(
4545
global::G.CodeScanningCreateVariantAnalysisRequest request,
4646
global::System.Threading.CancellationToken cancellationToken = default)
4747
{
48+
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
49+
4850
PrepareArguments(
4951
client: _httpClient);
5052
PrepareCodeScanningCreateVariantAnalysisArguments(

0 commit comments

Comments
 (0)