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
Update src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs
Co-authored-by: Vincent Biret <[email protected]>
  • Loading branch information
MaggieKimani1 and baywet authored Feb 20, 2025
commit fe50da3a35c39423d6772401aabaf8d41f060e31
25 changes: 14 additions & 11 deletions src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@
/// <returns></returns>
public static string[] ToIdentifiers(this JsonSchemaType schemaType)
{
var types = new List<string>();

if (schemaType.HasFlag(JsonSchemaType.Boolean)) types.Add("boolean");
if (schemaType.HasFlag(JsonSchemaType.Integer)) types.Add("integer");
if (schemaType.HasFlag(JsonSchemaType.Number)) types.Add("number");
if (schemaType.HasFlag(JsonSchemaType.String)) types.Add("string");
if (schemaType.HasFlag(JsonSchemaType.Object)) types.Add("object");
if (schemaType.HasFlag(JsonSchemaType.Array)) types.Add("array");
if (schemaType.HasFlag(JsonSchemaType.Null)) types.Add("null");

return types.ToArray();
return schemaType.ToIdentifiersInternal().ToArray();
}
private static readonly Dictionary<JsonSchemaType, string> allSchemaTypes = [

Check failure on line 41 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Identifier expected

Check failure on line 41 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Identifier expected

Check failure on line 41 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Identifier expected

Check failure on line 41 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

Identifier expected

Check failure on line 41 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Identifier expected

Check failure on line 41 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Identifier expected
{ JsonSchemaType.Boolean, "boolean"},

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Syntax error, ']' expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

; expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Type or namespace definition, or end-of-file expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Syntax error, ']' expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

; expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Type or namespace definition, or end-of-file expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Syntax error, ']' expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

; expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Type or namespace definition, or end-of-file expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

Syntax error, ']' expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

; expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

Type or namespace definition, or end-of-file expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Syntax error, ']' expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

; expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Type or namespace definition, or end-of-file expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Syntax error, ']' expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

; expected

Check failure on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Type or namespace definition, or end-of-file expected
{ JsonSchemaType.Integer, "integer" },

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

A namespace cannot directly contain members such as fields, methods or statements

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

A namespace cannot directly contain members such as fields, methods or statements

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

A namespace cannot directly contain members such as fields, methods or statements

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

A namespace cannot directly contain members such as fields, methods or statements

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

A namespace cannot directly contain members such as fields, methods or statements

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

A namespace cannot directly contain members such as fields, methods or statements

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Type or namespace definition, or end-of-file expected

Check failure on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Type or namespace definition, or end-of-file expected
{ JsonSchemaType.Number, "number" },

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Top-level statements must precede namespace and type declarations.

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

; expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

} expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

Top-level statements must precede namespace and type declarations.

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

; expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

} expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Top-level statements must precede namespace and type declarations.

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

; expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

} expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

Top-level statements must precede namespace and type declarations.

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

; expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

} expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

Top-level statements must precede namespace and type declarations.

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

; expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

} expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Top-level statements must precede namespace and type declarations.

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

; expected

Check failure on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

} expected
{ JsonSchemaType.String, "string" },
{ JsonSchemaType.Object, "object" },
{ JsonSchemaType.Array, "array" },
{ JsonSchemaType.Null, "null" },
];
private static IEnumerable<string> ToIdentifiersInternal(this JsonSchemaType schemaType)
{
return allSchemaTypes.Where(kvp => schemaType.HasFlag(kvp.Key)).Select(static kvp => kvp.Value);
}

/// <summary>
Expand Down