mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
Added Login Parameters to Swagger Documentation
This commit is contained in:
parent
aa93aecbaf
commit
8b48250eba
@ -92,6 +92,9 @@ type
|
||||
constructor Create(AAuthenticationHandler: IMVCAuthenticationHandler; ASecret: string = 'D3lph1MVCFram3w0rk';
|
||||
ALoginURLSegment: string = '/login'; AConfigClaims: TJWTClaimsSetup = nil;
|
||||
AClaimsToCheck: TJWTCheckableClaims = []; ALeewaySeconds: Cardinal = 300); overload; virtual;
|
||||
property AuthorizationHeaderName: string read FAuthorizationHeaderName;
|
||||
property UserNameHeaderName: string read FUserNameHeaderName;
|
||||
property PasswordHeaderName: string read FPasswordHeaderName;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
@ -248,7 +248,8 @@ begin
|
||||
LJwtUrlSegment.Insert(0, '/');
|
||||
|
||||
// Path operation Middleware JWT
|
||||
ASwagDoc.Paths.Add(TMVCSwagger.GetJWTAuthenticationPath(LJwtUrlSegment));
|
||||
ASwagDoc.Paths.Add(TMVCSwagger.GetJWTAuthenticationPath(LJwtUrlSegment,
|
||||
LJWTMiddleware.UserNameHeaderName, LJWTMiddleware.PasswordHeaderName));
|
||||
|
||||
// Methods that have the MVCRequiresAuthentication attribute use bearer authentication.
|
||||
LSecurityDefsBearer := TSwagSecurityDefinitionApiKey.Create;
|
||||
|
@ -558,6 +558,7 @@ class function TMVCSwagger.GetJWTAuthenticationPath(const AJWTUrlSegment: string
|
||||
var
|
||||
lSwagPathOp: TSwagPathOperation;
|
||||
lSwagResponse: TSwagResponse;
|
||||
lSwagParam: TSwagRequestParameter;
|
||||
begin
|
||||
lSwagPathOp := TSwagPathOperation.Create;
|
||||
lSwagPathOp.Tags.Add('JWT Authentication');
|
||||
@ -565,6 +566,19 @@ begin
|
||||
lSwagPathOp.Security.Add(SECURITY_BASIC_NAME);
|
||||
lSwagPathOp.Description := 'Create JSON Web Token';
|
||||
lSwagPathOp.Produces.Add(TMVCMediaType.APPLICATION_JSON);
|
||||
lSwagParam := TSwagRequestParameter.Create;
|
||||
lSwagParam.Name := AUserNameHeaderName;
|
||||
lSwagParam.TypeParameter := stpString;
|
||||
lSwagParam.Required := true;
|
||||
lSwagParam.InLocation := rpiHeader;
|
||||
lSwagPathOp.Parameters.Add(lSwagParam);
|
||||
|
||||
lSwagParam := TSwagRequestParameter.Create;
|
||||
lSwagParam.Name := APasswordHeaderName;
|
||||
lSwagParam.TypeParameter := stpString;
|
||||
lSwagParam.Required := true;
|
||||
lSwagParam.InLocation := rpiHeader;
|
||||
lSwagPathOp.Parameters.Add(lSwagParam);
|
||||
|
||||
lSwagResponse := TSwagResponse.Create;
|
||||
lSwagResponse.StatusCode := HTTP_STATUS.Unauthorized.ToString;
|
||||
|
Loading…
Reference in New Issue
Block a user