Visitar URL original
fix: refactor ToIdentifier() to normalize flaggable enums by MaggieKimani1 · Pull Request #2156 · microsoft/OpenAPI.NET · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: clean up
  • Loading branch information
MaggieKimani1 committed Feb 20, 2025
commit ee430271f0ad45971449a38f468099a599876aeb
11 changes: 7 additions & 4 deletions src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@ public static string[] ToIdentifiers(this JsonSchemaType schemaType)
{
return schemaType.ToIdentifiersInternal().ToArray();
}
private static readonly Dictionary<JsonSchemaType, string> allSchemaTypes = [
{ JsonSchemaType.Boolean, "boolean"},

private static readonly Dictionary<JsonSchemaType, string> allSchemaTypes = new()
{
{ JsonSchemaType.Boolean, "boolean" },
{ JsonSchemaType.Integer, "integer" },
{ JsonSchemaType.Number, "number" },
{ JsonSchemaType.String, "string" },
{ JsonSchemaType.Object, "object" },
{ JsonSchemaType.Array, "array" },
{ JsonSchemaType.Null, "null" },
];
{ JsonSchemaType.Null, "null" }
};

private static IEnumerable<string> ToIdentifiersInternal(this JsonSchemaType schemaType)
{
return allSchemaTypes.Where(kvp => schemaType.HasFlag(kvp.Key)).Select(static kvp => kvp.Value);
Expand Down