forked from topnguyen/Elect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElectSwaggerOptions.cs
118 lines (96 loc) · 4.03 KB
/
ElectSwaggerOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#region License
//--------------------------------------------------
// <License>
// <Copyright> 2018 © Top Nguyen </Copyright>
// <Url> http://topnguyen.com/ </Url>
// <Author> Top </Author>
// <Project> Elect </Project>
// <File>
// <Name> HideInApiDocDocumentFilter.cs </Name>
// <Created> 28/03/2018 11:49:15 PM </Created>
// <Key> 7a4dbe4d-600c-47b5-9f70-1e6443eb0048 </Key>
// </File>
// <Summary>
// HideInApiDocDocumentFilter.cs is a part of Elect
// </Summary>
// <License>
//--------------------------------------------------
#endregion License
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Collections.Generic;
using Microsoft.OpenApi.Models;
namespace Elect.Web.Swagger.Models
{
public class ElectSwaggerOptions
{
public bool IsEnable { get; set; } = true;
public bool SerializeAsV2 { get; set; } = true;
private string _swaggerRoutePrefix = "developers/api-docs";
/// <summary>
/// Swagger Endpoint, default is "/developers/api-docs".
/// </summary>
/// <remarks> Must start with "/" </remarks>
public string SwaggerRoutePrefix
{
get => _swaggerRoutePrefix.Trim('~').Trim('/');
set => _swaggerRoutePrefix = value;
}
/// <summary>
/// Swagger name, default is "all"
/// </summary>
public string SwaggerName { get; set; } = "all";
/// <summary>
/// Api Document Endpoint, default is "/developers".
/// </summary>
/// <remarks> Must start with "/" </remarks>
public string Url { get; set; } = "/developers";
/// <summary>
/// Json Viewer Endpoint, Default is "/developers/json-viewer".
/// </summary>
/// <remarks> Must start with "/" </remarks>
public string JsonViewerUrl { get; set; } = "/developers/json-viewer";
/// <summary>
/// Api Document Title. Default is "API Document"
/// </summary>
public string Title { get; set; } = "API Document";
/// <summary>
/// Api Document Version. Ex: latest, v1, v2 and so on. Default is "latest"
/// </summary>
public string Version { get; set; } = "latest";
/// <summary>
/// Access Key via uri param "key", default is "" - allow anonymous.
/// </summary>
public string AccessKey { get; set; } = string.Empty;
/// <summary>
/// Un-authorize message when user access api document with not correct key. Default is
/// "You don't have permission to view API Document, please contact your administrator."
/// </summary>
public string UnAuthorizeMessage { get; set; } = "You don't have permission to view API Document, please contact your administrator.";
/// <summary>
/// Authenticate Token Type, default is "Bearer".
/// </summary>
public string AuthTokenType { get; set; } = "Bearer";
/// <summary>
/// Show full schema for each type in Document
/// </summary>
public bool IsFullSchemaForType { get; set; } = true;
/// <summary>
/// Default is true.
/// </summary>
public bool IsDescribeAllEnumsAsString { get; set; } = true;
/// <summary>
/// Default is true.
/// </summary>
public bool IsDescribeAllParametersInCamelCase { get; set; } = true;
public string AuthorName { get; set; }
public string AuthorEmail { get; set; }
public string AuthorWebsite { get; set; }
public List<OpenApiParameter> GlobalParameters { get; set; } = new List<OpenApiParameter>();
/// <summary>
/// Additional Options if you want to add your customize (Operation Filter, Document
/// Filter and so on) after Elect add Swagger Options.
/// </summary>
public Action<SwaggerGenOptions, ElectSwaggerOptions> ExtendOptions { get; set; }
}
}