Skip to content

Commit

Permalink
fix: Fixed some issues because OpenAPI 3.1 spec
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Sep 7, 2024
1 parent eeec7d2 commit 70de6b6
Show file tree
Hide file tree
Showing 62 changed files with 261 additions and 1,241 deletions.
20 changes: 15 additions & 5 deletions src/helpers/FixOpenApiSpec/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,28 @@

text = text
.Replace("openapi: 3.1.0", "openapi: 3.0.1")
.Replace(" type: [boolean, \"null\"]", @" type: boolean
nullable: true")
.Replace(" type: [number, \"null\"]", @" type: number
nullable: true")
.Replace(" type: [string, \"null\"]", @" type: string
nullable: true")
.Replace(" type: [integer, \"null\"]", @" type: integer
nullable: true")
.Replace(" type: [array, \"null\"]", @" type: array
nullable: true")
;

var openApiDocument = new OpenApiStringReader().Read(text, out var diagnostics);

openApiDocument.Components.Schemas["TranscriptOptionalParams"]!.Properties["language_confidence_threshold"]!.Nullable = true;
openApiDocument.Components.Schemas["Transcript"]!.Properties["language_confidence_threshold"]!.Nullable = true;
openApiDocument.Components.Schemas["Transcript"]!.Properties["language_confidence"]!.Nullable = true;
openApiDocument.Components.Schemas["Transcript"]!.Properties["confidence"]!.Nullable = true;

text = openApiDocument.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
_ = new OpenApiStringReader().Read(text, out diagnostics);

if (text.Contains(", \"null\""))
{
throw new Exception("Failed to remove nullable from OpenAPI 3.1 spec.");
}

if (diagnostics.Errors.Count > 0)
{
foreach (var error in diagnostics.Errors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public sealed partial class PageDetails
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("prev_url")]
[global::System.Text.Json.Serialization.JsonRequired]
public required string PrevUrl { get; set; }
public required string? PrevUrl { get; set; }

/// <summary>
/// The URL to the next page of transcripts. The next URL always points to a page with newer transcripts.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("next_url")]
[global::System.Text.Json.Serialization.JsonRequired]
public required string NextUrl { get; set; }
public required string? NextUrl { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public sealed partial class SentimentAnalysisResult
/// The speaker of the sentence if [Speaker Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is enabled, else null
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("speaker")]
public global::AssemblyAI.SentimentAnalysisResultSpeaker? Speaker { get; set; }
public string? Speaker { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down

This file was deleted.

Loading

0 comments on commit 70de6b6

Please sign in to comment.