Skip to content

Commit

Permalink
fix: Fixed rare issue with oneOf usage to define required property.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Aug 31, 2024
1 parent 462afa7 commit a551442
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/libs/OpenApiGenerator.Core/Models/TypeData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,15 @@ Default with
IsDateTime: context.Schema.IsDateTime(),
IsBinary: context.Schema.IsBinary(),
IsUnixTimestamp: context.Schema.IsUnixTimestamp(),
AnyOfCount: context.Schema.AnyOf?.Count ?? 0,
OneOfCount: context.Schema.OneOf?.Count ?? 0,
AllOfCount: context.Schema.AllOf?.Count ?? 0,
AnyOfCount: context.Schema.IsAnyOf() // Sometimes here AnyOf with only required properties
? context.Schema.AnyOf?.Count ?? 0
: 0,
OneOfCount: context.Schema.IsOneOf() // Sometimes here OneOf with only required properties
? context.Schema.OneOf?.Count ?? 0
: 0,
AllOfCount: context.Schema.IsAllOf() // Sometimes here AllOf with only required properties
? context.Schema.AllOf?.Count ?? 0
: 0,
IsComponent: context.IsComponent,
Properties: properties,
EnumValues: enumValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ partial void ProcessChecksCreateResponseContent(
global::G.ChecksCreateRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareChecksCreateArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ partial void ProcessChecksUpdateResponseContent(
global::G.ChecksUpdateRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareChecksUpdateArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ partial void ProcessCodeScanningCreateVariantAnalysisResponseContent(
global::G.CodeScanningCreateVariantAnalysisRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareCodeScanningCreateVariantAnalysisArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ partial void ProcessPullsRequestReviewersResponseContent(
global::G.PullsRequestReviewersRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PreparePullsRequestReviewersArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ partial void ProcessReposCreatePagesSiteResponseContent(
global::G.ReposCreatePagesSiteRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareReposCreatePagesSiteArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ partial void ProcessReposUpdateInformationAboutPagesSiteResponseContent(
global::G.ReposUpdateInformationAboutPagesSiteRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareReposUpdateInformationAboutPagesSiteArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ partial void ProcessChecksCreateResponseContent(
global::G.ChecksCreateRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareChecksCreateArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ partial void ProcessChecksUpdateResponseContent(
global::G.ChecksUpdateRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareChecksUpdateArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ partial void ProcessCodeScanningCreateVariantAnalysisResponseContent(
global::G.CodeScanningCreateVariantAnalysisRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareCodeScanningCreateVariantAnalysisArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ partial void ProcessPullsRequestReviewersResponseContent(
global::G.PullsRequestReviewersRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PreparePullsRequestReviewersArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ partial void ProcessReposCreatePagesSiteResponseContent(
global::G.ReposCreatePagesSiteRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareReposCreatePagesSiteArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ partial void ProcessReposUpdateInformationAboutPagesSiteResponseContent(
global::G.ReposUpdateInformationAboutPagesSiteRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareReposUpdateInformationAboutPagesSiteArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public sealed partial class CreateAssistantRequestToolResources
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("file_search")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.OneOfJsonConverterFactory2))]
public global::G.CreateAssistantRequestToolResourcesFileSearch? FileSearch { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public sealed partial class CreateThreadRequestToolResources
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("file_search")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.OneOfJsonConverterFactory2))]
public global::G.CreateThreadRequestToolResourcesFileSearch? FileSearch { get; set; }

/// <summary>
Expand Down

0 comments on commit a551442

Please sign in to comment.