| | | 1 | | using Microsoft.OpenApi; |
| | | 2 | | |
| | | 3 | | namespace Kestrun.Hosting.Options; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Options for OpenAPI map route. |
| | | 7 | | /// </summary> |
| | | 8 | | public record OpenApiMapRouteOptions |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Constructor for OpenApiMapRouteOptions. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <param name="mapOptions"></param> |
| | 0 | 14 | | public OpenApiMapRouteOptions(MapRouteOptions mapOptions) |
| | | 15 | | { |
| | 0 | 16 | | MapOptions = mapOptions; |
| | 0 | 17 | | if (MapOptions.Pattern == null) |
| | | 18 | | { |
| | | 19 | | //MapOptions.Pattern = "/openapi/{version:regex(^v(2\\.0|3\\.0(\\.\\d+)?|3\\.1(\\.\\d+)?)$)}/{file:regex(^([ |
| | 0 | 20 | | MapOptions.Pattern = "/openapi/{version}/openapi.{format}"; |
| | | 21 | | } |
| | 0 | 22 | | } |
| | | 23 | | /// <summary> |
| | | 24 | | /// The document ID to serve. |
| | | 25 | | /// </summary> |
| | 0 | 26 | | public string DocId { get; set; } = Authentication.IOpenApiAuthenticationOptions.DefaultSchemeName; |
| | | 27 | | /// <summary> |
| | | 28 | | /// The supported OpenAPI spec versions. |
| | | 29 | | /// </summary> |
| | 0 | 30 | | public OpenApiSpecVersion[] SpecVersion { get; set; } = |
| | 0 | 31 | | [OpenApiSpecVersion.OpenApi2_0, OpenApiSpecVersion.OpenApi3_0, OpenApiSpecVersion.OpenApi3_1]; |
| | | 32 | | /// <summary> |
| | | 33 | | /// The name of the route variable for version. |
| | | 34 | | /// </summary> |
| | 0 | 35 | | public string VersionVarName { get; set; } = "version"; |
| | | 36 | | /// <summary> |
| | | 37 | | /// The name of the route variable for format. |
| | | 38 | | /// </summary> |
| | 0 | 39 | | public string FormatVarName { get; set; } = "format"; |
| | | 40 | | /// <summary> |
| | | 41 | | /// The name of the query variable for refresh. |
| | | 42 | | /// </summary> |
| | 0 | 43 | | public string RefreshVarName { get; set; } = "refresh"; |
| | | 44 | | /// <summary> |
| | | 45 | | /// The default format to use if not specified in the route. |
| | | 46 | | /// </summary> |
| | 0 | 47 | | public string DefaultFormat { get; set; } = "json"; |
| | | 48 | | /// <summary> |
| | | 49 | | /// The default version to use if not specified in the route. |
| | | 50 | | /// </summary> |
| | 0 | 51 | | public string DefaultVersion { get; set; } = "v3.0"; |
| | | 52 | | /// <summary> |
| | | 53 | | /// The map route options. |
| | | 54 | | /// </summary> |
| | 0 | 55 | | public MapRouteOptions MapOptions { get; set; } |
| | | 56 | | } |