| | | 1 | | using Microsoft.OpenApi; |
| | | 2 | | |
| | | 3 | | namespace Kestrun.Hosting.Options; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Metadata for OpenAPI documentation related to the route. |
| | | 7 | | /// </summary> |
| | | 8 | | public record OpenAPICommonMetadata |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// The route mapping options associated with this metadata. |
| | | 12 | | /// </summary> |
| | 21 | 13 | | public MapRouteOptions MapOptions { get; init; } |
| | | 14 | | /// <summary> |
| | | 15 | | /// Initializes a new instance of the <see cref="OpenAPICommonMetadata"/> class with the specified pattern. |
| | | 16 | | /// </summary> |
| | | 17 | | /// <param name="pattern">The route pattern.</param> |
| | | 18 | | /// <param name="mapOptions">The route mapping options.</param> |
| | 16 | 19 | | public OpenAPICommonMetadata(string pattern, MapRouteOptions mapOptions) |
| | | 20 | | { |
| | 16 | 21 | | Pattern = pattern; |
| | 16 | 22 | | MapOptions = mapOptions; |
| | 16 | 23 | | Enabled = true; |
| | 16 | 24 | | } |
| | | 25 | | /// <summary> |
| | | 26 | | /// Initializes a new instance of the <see cref="OpenAPICommonMetadata"/> class. |
| | | 27 | | /// </summary> |
| | | 28 | | /// <param name="mapOptions">The route mapping options.</param> |
| | 5 | 29 | | public OpenAPICommonMetadata(MapRouteOptions mapOptions) |
| | | 30 | | { |
| | 5 | 31 | | Pattern = "/"; |
| | 5 | 32 | | MapOptions = mapOptions; |
| | 5 | 33 | | Enabled = true; |
| | 5 | 34 | | } |
| | | 35 | | /// <summary> |
| | | 36 | | /// Indicates whether OpenAPI documentation is enabled for this route. |
| | | 37 | | /// </summary> |
| | 23 | 38 | | public bool Enabled { get; set; } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// The relative path for the route in OpenAPI documentation. |
| | | 42 | | /// </summary> |
| | 23 | 43 | | public string Pattern { get; set; } |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// A brief summary of the route for OpenAPI documentation. |
| | | 47 | | /// </summary> |
| | 18 | 48 | | public string? Summary { get; set; } |
| | | 49 | | /// <summary> |
| | | 50 | | /// A detailed description of the route for OpenAPI documentation. |
| | | 51 | | /// </summary> |
| | 14 | 52 | | public string? Description { get; set; } |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// The name of the CORS policy to apply to this route. |
| | | 56 | | /// </summary> |
| | 0 | 57 | | public string? CorsPolicy { get; set; } |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// An alternative server array to service this operation. |
| | | 61 | | /// If an alternative server object is specified at the Path Item Object or Root level, |
| | | 62 | | /// it will be overridden by this value. |
| | | 63 | | /// </summary> |
| | 25 | 64 | | public IList<OpenApiServer>? Servers { get; set; } = []; |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// A list of parameters that are applicable for this operation. |
| | | 68 | | /// If a parameter is already defined at the Path Item, the new definition will override it but can never remove it. |
| | | 69 | | /// The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and lo |
| | | 70 | | /// The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object's components/ |
| | | 71 | | /// </summary> |
| | 25 | 72 | | public IList<IOpenApiParameter>? Parameters { get; set; } = []; |
| | | 73 | | } |