Skip to content

Commit

Permalink
Use x-data-type extension
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed May 23, 2023
1 parent 9823a0f commit c192cdc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ApiGenerator/Generator/ApiEndpointFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,12 @@ private static string GetOpenSearchType(JsonSchema schema)
{
while (schema.HasReference) schema = schema.Reference;

if (schema.GetExtension("x-data-type") is string dataType)
return dataType;

return schema.Type switch
{
JsonObjectType.String when schema.Enumeration is { Count: > 0 } => "enum",
JsonObjectType.String when schema.Pattern is "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" => "time",
JsonObjectType.String when schema.GetExtension("x-comma-separated-list") is "true" => "list",
JsonObjectType.Integer => "number",
JsonObjectType.Array => "list",
var t => t.ToString().ToLowerInvariant()
Expand Down

0 comments on commit c192cdc

Please sign in to comment.