Skip to content

Commit

Permalink
fix: Fixed null in enums in OpenAPI 3.1 yaml.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Oct 12, 2024
1 parent a1f4e46 commit 43a3b2c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
8 changes: 8 additions & 0 deletions src/libs/AutoSDK/Helpers/OpenApi31Support.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ private static void ConvertYamlNode(Dictionary<object, object?> node)
node.Remove(keyString);
}

if (keyString == "enum" &&
entry.Value is List<object?> { Count: > 0 } enumItems &&
enumItems.Contains(null))
{
node[new string("enum".ToCharArray())] = enumItems.Where(v => v != null).ToList();
node[new string("nullable".ToCharArray())] = true;
}

// Remove "prefixItems"
if (keyString == "prefixItems" && entry.Value is List<object?> { Count: > 0 } prefixItemsList)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
[
{
RuleName: SchemaMismatchedDataType,
Message: Data and type mismatch found.,
Pointer: #/components/schemas/FineTuneEvent/properties/level/enum/0
},
{
RuleName: SchemaMismatchedDataType,
Message: Data and type mismatch found.,
Pointer: #/components/schemas/FinetuneEventLevels/enum/0
}
]
[]
Original file line number Diff line number Diff line change
Expand Up @@ -823,13 +823,13 @@
type: string
level:
enum:
- null
- info
- warning
- error
- legacy_info
- legacy_iwarning
- legacy_ierror
nullable: true
type: string
message:
type: string
Expand Down Expand Up @@ -904,8 +904,8 @@
type: string
object:
enum:
- null
- local
nullable: true
size:
type: integer
type: object
Expand Down Expand Up @@ -935,13 +935,13 @@
type: object
FinetuneEventLevels:
enum:
- null
- info
- warning
- error
- legacy_info
- legacy_iwarning
- legacy_ierror
nullable: true
type: string
FinetuneEventType:
enum:
Expand Down

0 comments on commit 43a3b2c

Please sign in to comment.