| | | 1 | | using Microsoft.OpenApi; |
| | | 2 | | |
| | | 3 | | namespace Kestrun.OpenApi; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Extension methods for OaSchemaType enum. |
| | | 7 | | /// </summary> |
| | | 8 | | public static class OaSchemaTypeExtensions |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Converts OaSchemaType to JsonSchemaType. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <param name="schemaType">The OaSchemaType value.</param> |
| | | 14 | | /// <returns>The corresponding JsonSchemaType value, or null if OaSchemaType.None.</returns> |
| | | 15 | | public static JsonSchemaType? ToJsonSchemaType(this OaSchemaType schemaType) |
| | | 16 | | { |
| | 0 | 17 | | return schemaType switch |
| | 0 | 18 | | { |
| | 0 | 19 | | OaSchemaType.String => JsonSchemaType.String, |
| | 0 | 20 | | OaSchemaType.Number => JsonSchemaType.Number, |
| | 0 | 21 | | OaSchemaType.Integer => JsonSchemaType.Integer, |
| | 0 | 22 | | OaSchemaType.Boolean => JsonSchemaType.Boolean, |
| | 0 | 23 | | OaSchemaType.Array => JsonSchemaType.Array, |
| | 0 | 24 | | OaSchemaType.Object => JsonSchemaType.Object, |
| | 0 | 25 | | OaSchemaType.Null => JsonSchemaType.Null, |
| | 0 | 26 | | _ => null, |
| | 0 | 27 | | }; |
| | | 28 | | } |
| | | 29 | | } |