| | | 1 | | using Kestrun.OpenApi; |
| | | 2 | | using Microsoft.OpenApi; |
| | | 3 | | |
| | | 4 | | namespace Kestrun.Hosting.Options; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Metadata for OpenAPI documentation related to the route. |
| | | 8 | | /// </summary> |
| | | 9 | | public record OpenAPIPathMetadata : OpenAPICommonMetadata |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Initializes a new instance of the <see cref="OpenAPIPathMetadata"/> class with the specified pattern. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="pattern">The route pattern.</param> |
| | | 15 | | /// <param name="mapOptions">The route mapping options.</param> |
| | | 16 | | public OpenAPIPathMetadata(string pattern, MapRouteOptions mapOptions) |
| | 16 | 17 | | : base(pattern, mapOptions) |
| | | 18 | | { |
| | 16 | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Initializes a new instance of the <see cref="OpenAPIPathMetadata"/> class. |
| | | 23 | | /// </summary> |
| | | 24 | | /// <param name="mapOptions">The route mapping options.</param> |
| | | 25 | | public OpenAPIPathMetadata(MapRouteOptions mapOptions) |
| | 5 | 26 | | : base(mapOptions) |
| | | 27 | | { |
| | 5 | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// The IDs of the OpenAPI documents this metadata belongs to. |
| | | 32 | | /// If empty, it belongs to all documents. |
| | | 33 | | /// </summary> |
| | 23 | 34 | | public List<string> DocumentIds { get; set; } = []; |
| | | 35 | | /// <summary> |
| | | 36 | | /// The unique operation ID for the route in OpenAPI documentation. |
| | | 37 | | /// </summary> |
| | 16 | 38 | | public string? OperationId { get; set; } |
| | | 39 | | /// <summary> |
| | | 40 | | /// Comma-separated tags for OpenAPI documentation. |
| | | 41 | | /// </summary> |
| | 40 | 42 | | public List<string> Tags { get; set; } = []; // Comma-separated tags |
| | | 43 | | /// <summary> |
| | | 44 | | /// External documentation reference for the route. |
| | | 45 | | /// </summary> |
| | 2 | 46 | | public OpenApiExternalDocs? ExternalDocs { get; set; } |
| | | 47 | | /// <summary> |
| | | 48 | | /// Indicates whether the operation is deprecated in OpenAPI documentation. |
| | | 49 | | /// </summary> |
| | 2 | 50 | | public bool Deprecated { get; set; } |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// The request body applicable for this operation. |
| | | 54 | | /// The requestBody is only supported in HTTP methods where the HTTP 1.1 specification RFC7231 |
| | | 55 | | /// has explicitly defined semantics for request bodies. |
| | | 56 | | /// In other cases where the HTTP spec is vague, requestBody SHALL be ignored by consumers. |
| | | 57 | | /// </summary> |
| | 4 | 58 | | public IOpenApiRequestBody? RequestBody { get; set; } |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// REQUIRED. The list of possible responses as they are returned from executing this operation. |
| | | 62 | | /// </summary> |
| | 27 | 63 | | public OpenApiResponses? Responses { get; set; } = []; |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// A map of possible out-of band callbacks related to the parent operation. |
| | | 67 | | /// The key is a unique identifier for the Callback Object. |
| | | 68 | | /// Each value in the map is a Callback Object that describes a request |
| | | 69 | | /// that may be initiated by the API provider and the expected responses. |
| | | 70 | | /// The key value used to identify the callback object is an expression, evaluated at runtime, |
| | | 71 | | /// that identifies a URL to use for the callback operation. |
| | | 72 | | /// </summary> |
| | 4 | 73 | | public IDictionary<string, IOpenApiCallback>? Callbacks { get; set; } |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// A declaration of which security mechanisms can be used for this operation. |
| | | 77 | | /// The list of values includes alternative security requirement objects that can be used. |
| | | 78 | | /// </summary> |
| | 6 | 79 | | public List<Dictionary<string, List<string>>>? SecuritySchemes { get; set; } |
| | | 80 | | |
| | | 81 | | /// <summary> |
| | | 82 | | /// The kind of OpenAPI path-like object represented by this metadata. |
| | | 83 | | /// </summary> |
| | 0 | 84 | | public OpenApiPathLikeKind? PathLikeKind { get; set; } |
| | | 85 | | |
| | | 86 | | /// <summary> |
| | | 87 | | /// Indicates whether this metadata represents an OpenAPI webhook. |
| | | 88 | | /// </summary> |
| | 0 | 89 | | public bool IsOpenApiWebhook => PathLikeKind == OpenApiPathLikeKind.Webhook; |
| | | 90 | | |
| | | 91 | | /// <summary> |
| | | 92 | | /// Indicates whether this metadata represents an OpenAPI path. |
| | | 93 | | /// </summary> |
| | 0 | 94 | | public bool IsOpenApiPath => PathLikeKind == OpenApiPathLikeKind.Path; |
| | | 95 | | |
| | | 96 | | /// <summary> |
| | | 97 | | /// Indicates whether this metadata represents an OpenAPI callback. |
| | | 98 | | /// </summary> |
| | 0 | 99 | | public bool IsOpenApiCallback => PathLikeKind == OpenApiPathLikeKind.Callback; |
| | | 100 | | |
| | | 101 | | /// <summary> |
| | | 102 | | /// The IDs of the OpenAPI document this metadata belongs to. |
| | | 103 | | /// If null, it belongs to all documents. |
| | | 104 | | /// </summary> |
| | 2 | 105 | | public string[]? DocumentId { get; set; } |
| | | 106 | | |
| | | 107 | | /// <summary> |
| | | 108 | | /// The callback expression for the OpenAPI callback object. |
| | | 109 | | /// </summary> |
| | 0 | 110 | | public RuntimeExpression? Expression { get; set; } |
| | | 111 | | |
| | | 112 | | /// <summary> |
| | | 113 | | /// Indicates whether the callback should be inlined within the parent OpenAPI document. |
| | | 114 | | /// </summary> |
| | 0 | 115 | | public bool Inline { get; set; } |
| | | 116 | | |
| | | 117 | | /// <summary> |
| | | 118 | | /// A map of custom extensions for the OpenAPI object. |
| | | 119 | | /// </summary> |
| | 18 | 120 | | public Dictionary<string, IOpenApiExtension>? Extensions { get; set; } |
| | | 121 | | } |