| | | 1 | | namespace Kestrun.Hosting.Options; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Customization options for the OpenAPI metadata generated for the SSE broadcast endpoint. |
| | | 5 | | /// </summary> |
| | | 6 | | public sealed record SseBroadcastOptions |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// The default path for the SSE broadcast endpoint. |
| | | 10 | | /// </summary> |
| | | 11 | | public const string DefaultPath = "/sse/broadcast"; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// The default description for the SSE broadcast endpoint. |
| | | 15 | | /// </summary> |
| | | 16 | | public const string DefaultDescription = "Opens a Server-Sent Events (text/event-stream) connection that receives se |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// The default tag for the SSE broadcast endpoint. |
| | | 20 | | /// </summary> |
| | | 21 | | public const string DefaultTag = "SSE"; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// The default operationId for the SSE broadcast endpoint. |
| | | 25 | | /// </summary> |
| | | 26 | | public const string DefaultOperationId = "GetSseBroadcast"; |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// The default response description for the SSE broadcast endpoint. |
| | | 30 | | /// </summary> |
| | | 31 | | public const string DefaultResponseDescription = "SSE stream (text/event-stream)"; |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// The default summary for the SSE broadcast endpoint. |
| | | 35 | | /// </summary> |
| | | 36 | | public const string DefaultSummary = "Broadcast SSE stream"; |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// The default keep-alive interval in seconds for the SSE connection. |
| | | 40 | | /// </summary> |
| | | 41 | | public const int DefaultKeepAliveSeconds = 15; |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Gets a default configuration for the SSE broadcast OpenAPI metadata. |
| | | 45 | | /// </summary> |
| | 0 | 46 | | public static SseBroadcastOptions Default { get; } = new(); |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// The path for the SSE broadcast endpoint. |
| | | 50 | | /// </summary> |
| | 12 | 51 | | public string Path { get; init; } = DefaultPath; |
| | | 52 | | |
| | | 53 | | /// <summary> |
| | | 54 | | /// The path for the SSE broadcast endpoint. |
| | | 55 | | /// </summary> |
| | 4 | 56 | | public int KeepAliveSeconds { get; init; } = DefaultKeepAliveSeconds; |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Customization options for the OpenAPI metadata generated for the SSE broadcast endpoint. |
| | | 60 | | /// </summary> |
| | 4 | 61 | | public string[] DocId { get; set; } = OpenApi.OpenApiDocDescriptor.DefaultDocumentationIds; |
| | | 62 | | |
| | | 63 | | /// <summary> |
| | | 64 | | /// OpenAPI operationId for the endpoint. |
| | | 65 | | /// </summary> |
| | 7 | 66 | | public string? OperationId { get; init; } = DefaultOperationId; |
| | | 67 | | |
| | | 68 | | /// <summary> |
| | | 69 | | /// OpenAPI summary for the endpoint. |
| | | 70 | | /// </summary> |
| | 7 | 71 | | public string? Summary { get; init; } = DefaultSummary; |
| | | 72 | | |
| | | 73 | | /// <summary> |
| | | 74 | | /// OpenAPI description for the endpoint. |
| | | 75 | | /// </summary> |
| | 7 | 76 | | public string? Description { get; init; } = DefaultDescription; |
| | | 77 | | |
| | | 78 | | /// <summary> |
| | | 79 | | /// OpenAPI tags for the endpoint. |
| | | 80 | | /// </summary> |
| | 7 | 81 | | public IEnumerable<string> Tags { get; init; } = [DefaultTag]; |
| | | 82 | | |
| | | 83 | | /// <summary> |
| | | 84 | | /// Status code used for the SSE response (default: 200). |
| | | 85 | | /// </summary> |
| | 4 | 86 | | public string StatusCode { get; init; } = "200"; |
| | | 87 | | |
| | | 88 | | /// <summary> |
| | | 89 | | /// Response description shown in OpenAPI. |
| | | 90 | | /// </summary> |
| | 6 | 91 | | public string? ResponseDescription { get; init; } = DefaultResponseDescription; |
| | | 92 | | |
| | | 93 | | /// <summary> |
| | | 94 | | /// Response content type for the SSE stream (default: text/event-stream). |
| | | 95 | | /// </summary> |
| | 4 | 96 | | public string ContentType { get; init; } = "text/event-stream"; |
| | | 97 | | |
| | | 98 | | /// <summary> |
| | | 99 | | /// OpenAPI schema type for the stream payload items (default: string). |
| | | 100 | | /// </summary> |
| | 5 | 101 | | public Type ItemSchemaType { get; init; } = typeof(string); |
| | | 102 | | |
| | | 103 | | /// <summary> |
| | | 104 | | /// Optional OpenAPI schema format for the stream payload (e.g. "uuid", "date-time"). |
| | | 105 | | /// </summary> |
| | 0 | 106 | | public string? ItemSchemaFormat { get; init; } |
| | | 107 | | |
| | | 108 | | /// <summary> |
| | | 109 | | /// If true, the OpenAPI documentation for this endpoint will be skipped. |
| | | 110 | | /// </summary> |
| | 2 | 111 | | public bool SkipOpenApi { get; set; } |
| | | 112 | | } |