Skip to content

Commit 47f3518

Browse files
committed
fix: remove redundant AuthenticationScheme type param
1 parent 95693a9 commit 47f3518

6 files changed

Lines changed: 3 additions & 25 deletions

File tree

examples/complete-example/auth/session-auth.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const storedAuthCodes = new Map<
3030
*/
3131
class OAuth2Scheme extends SessionAuthenticationScheme {
3232
public readonly schemeName = 'OAuth2';
33-
public readonly type = 'oauth2' as const;
3433

3534
constructor() {
3635
super({ sessionDriver: new InMemorySessionDriver() });

src/authentication/authentication-scheme.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ export abstract class AuthenticationScheme {
3232
*/
3333
public abstract readonly schemeName: string;
3434

35-
/**
36-
* The type of security scheme as defined by OpenAPI
37-
*/
38-
public abstract readonly type:
39-
| 'http'
40-
| 'apiKey'
41-
| 'oauth2'
42-
| 'openIdConnect';
43-
4435
/**
4536
* Generate the OpenAPI security scheme object
4637
* This will be added to components.securitySchemes in the OpenAPI spec

src/authentication/schemes/bearer-authentication-scheme.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export interface BearerAuthenticationSchemeOptions extends AuthenticationSchemeO
4949
* Automatically generates OpenAPI security scheme documentation
5050
*/
5151
export class BearerAuthenticationScheme extends InlineAuthenticationScheme {
52-
public readonly type = 'http' as const;
5352
public readonly schemeName: string;
5453

5554
protected readonly bearerFormat: string;

test/spec/authentication/authentication-scheme.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ type AnyResponse = any;
2121
*/
2222
class TestInlineScheme extends InlineAuthenticationScheme {
2323
readonly schemeName = 'TestInline';
24-
readonly type = 'http' as const;
2524
private throwError = false;
2625

2726
public setThrowError(shouldThrow: boolean): void {
@@ -55,7 +54,6 @@ describe('AuthenticationScheme (Base Class)', () => {
5554
it('should have required abstract properties', () => {
5655
class TestScheme extends AuthenticationScheme {
5756
readonly schemeName = 'TestScheme';
58-
readonly type = 'http' as const;
5957

6058
getSecurityScheme() {
6159
return { type: 'http' as const, scheme: 'test' };
@@ -77,7 +75,6 @@ describe('AuthenticationScheme (Base Class)', () => {
7775

7876
const scheme = new TestScheme();
7977
expect(scheme.schemeName).toBe('TestScheme');
80-
expect(scheme.type).toBe('http');
8178
});
8279

8380
it('should have getSecurityRequirement method', () => {
@@ -96,7 +93,7 @@ describe('AuthenticationScheme (Base Class)', () => {
9693
checkToken: async () => true,
9794
});
9895

99-
expect(scheme.type).toBe('http');
96+
expect(scheme.getSecurityScheme().type).toBe('http');
10097
});
10198
});
10299

test/spec/authentication/bearer-scheme.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('BearerAuthenticationScheme', () => {
1515
});
1616

1717
expect(scheme.schemeName).toBe('BearerAuth');
18-
expect(scheme.type).toBe('http');
18+
expect(scheme.getSecurityScheme().type).toBe('http');
1919
});
2020

2121
it('should use custom scheme name if provided', () => {

test/spec/authentication/session-scheme.spec.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ abstract class TestAuthFlowImport extends BaseApiEndpoint {}
2626
*/
2727
class TestSessionScheme extends SessionAuthenticationScheme {
2828
public readonly schemeName = 'TestSession';
29-
public readonly type = 'apiKey' as const;
3029

3130
public constructor(options: { sessionDriver?: SessionDriver } = {}) {
3231
super({
@@ -95,7 +94,7 @@ describe('SessionAuthenticationScheme', () => {
9594
const scheme = new TestSessionScheme();
9695

9796
expect(scheme.schemeName).toBe('TestSession');
98-
expect(scheme.type).toBe('apiKey');
97+
expect(scheme.getSecurityScheme().type).toBe('apiKey');
9998
});
10099

101100
it('should initialize with session driver', () => {
@@ -250,7 +249,6 @@ describe('SessionAuthenticationScheme', () => {
250249
it('should use scheme name in requirement', () => {
251250
class CustomSessionScheme extends SessionAuthenticationScheme {
252251
public readonly schemeName = 'CustomSession';
253-
public readonly type = 'apiKey' as const;
254252

255253
public constructor(
256254
options: { sessionDriver?: SessionDriver } = {}
@@ -528,7 +526,6 @@ describe('SessionAuthenticationScheme', () => {
528526

529527
class TestSchemeWithSteps extends SessionAuthenticationScheme {
530528
public readonly schemeName = 'TestScheme';
531-
public readonly type = 'oauth2' as const;
532529

533530
public constructor(
534531
options: { sessionDriver?: SessionDriver } = {}
@@ -603,7 +600,6 @@ describe('SessionAuthenticationScheme', () => {
603600

604601
class TestSchemeWithRoutes extends SessionAuthenticationScheme {
605602
public readonly schemeName = 'TestScheme';
606-
public readonly type = 'oauth2' as const;
607603

608604
public constructor(
609605
options: { sessionDriver?: SessionDriver } = {}
@@ -653,7 +649,6 @@ describe('SessionAuthenticationScheme', () => {
653649
it('should return auth endpoints from the auth flow', () => {
654650
class SimpleSessionScheme extends SessionAuthenticationScheme {
655651
public readonly schemeName = 'SimpleSession';
656-
public readonly type = 'apiKey' as const;
657652

658653
public constructor(
659654
options: { sessionDriver?: SessionDriver } = {}
@@ -704,7 +699,6 @@ describe('SessionAuthenticationScheme', () => {
704699
it('should return auth step classes', () => {
705700
class MultiStepScheme extends SessionAuthenticationScheme {
706701
public readonly schemeName = 'MultiStep';
707-
public readonly type = 'oauth2' as const;
708702

709703
public constructor(
710704
options: { sessionDriver?: SessionDriver } = {}
@@ -773,7 +767,6 @@ describe('SessionAuthenticationScheme', () => {
773767
it('should return empty array for empty auth flow', () => {
774768
class EmptySessionScheme extends SessionAuthenticationScheme {
775769
public readonly schemeName = 'EmptySession';
776-
public readonly type = 'apiKey' as const;
777770

778771
public constructor(
779772
options: { sessionDriver?: SessionDriver } = {}
@@ -808,7 +801,6 @@ describe('SessionAuthenticationScheme', () => {
808801
it('should return endpoints from auth flow', async () => {
809802
class MatchingScheme extends SessionAuthenticationScheme {
810803
public readonly schemeName = 'Matching';
811-
public readonly type = 'apiKey' as const;
812804

813805
public constructor(
814806
options: { sessionDriver?: SessionDriver } = {}

0 commit comments

Comments
 (0)