-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1520 from chriswiggins/feat/add-http-bearer-security
- Loading branch information
Showing
12 changed files
with
191 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hey-api/openapi-ts': minor | ||
--- | ||
|
||
Add support for HTTP Bearer Authentication Scheme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/openapi-ts/test/__snapshots__/3.0.x/security-http-bearer/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
export * from './types.gen'; | ||
export * from './sdk.gen'; |
20 changes: 20 additions & 0 deletions
20
packages/openapi-ts/test/__snapshots__/3.0.x/security-http-bearer/sdk.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
import { createClient, createConfig, type Options } from '@hey-api/client-fetch'; | ||
import type { GetFooData } from './types.gen'; | ||
|
||
export const client = createClient(createConfig()); | ||
|
||
export const getFoo = <ThrowOnError extends boolean = false>(options?: Options<GetFooData, ThrowOnError>) => { | ||
return (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ | ||
...options, | ||
security: [ | ||
{ | ||
fn: 'accessToken', | ||
in: 'header', | ||
name: 'Authorization' | ||
} | ||
], | ||
url: '/foo' | ||
}); | ||
}; |
15 changes: 15 additions & 0 deletions
15
packages/openapi-ts/test/__snapshots__/3.0.x/security-http-bearer/types.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
export type GetFooData = { | ||
body?: never; | ||
path?: never; | ||
query?: never; | ||
url: '/foo'; | ||
}; | ||
|
||
export type GetFooResponses = { | ||
/** | ||
* OK | ||
*/ | ||
200: unknown; | ||
}; |
3 changes: 3 additions & 0 deletions
3
packages/openapi-ts/test/__snapshots__/3.1.x/security-http-bearer/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
export * from './types.gen'; | ||
export * from './sdk.gen'; |
20 changes: 20 additions & 0 deletions
20
packages/openapi-ts/test/__snapshots__/3.1.x/security-http-bearer/sdk.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
import { createClient, createConfig, type Options } from '@hey-api/client-fetch'; | ||
import type { GetFooData } from './types.gen'; | ||
|
||
export const client = createClient(createConfig()); | ||
|
||
export const getFoo = <ThrowOnError extends boolean = false>(options?: Options<GetFooData, ThrowOnError>) => { | ||
return (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ | ||
...options, | ||
security: [ | ||
{ | ||
fn: 'accessToken', | ||
in: 'header', | ||
name: 'Authorization' | ||
} | ||
], | ||
url: '/foo' | ||
}); | ||
}; |
15 changes: 15 additions & 0 deletions
15
packages/openapi-ts/test/__snapshots__/3.1.x/security-http-bearer/types.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
export type GetFooData = { | ||
body?: never; | ||
path?: never; | ||
query?: never; | ||
url: '/foo'; | ||
}; | ||
|
||
export type GetFooResponses = { | ||
/** | ||
* OK | ||
*/ | ||
200: unknown; | ||
}; |
32 changes: 32 additions & 0 deletions
32
packages/openapi-ts/test/spec/3.0.x/security-http-bearer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"openapi": "3.0.4", | ||
"info": { | ||
"title": "OpenAPI 3.0.4 security bearer example", | ||
"version": "1" | ||
}, | ||
"paths": { | ||
"/foo": { | ||
"get": { | ||
"responses": { | ||
"200": { | ||
"description": "OK" | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"foo": [] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"components": { | ||
"securitySchemes": { | ||
"foo": { | ||
"bearerFormat": "JWT", | ||
"scheme": "bearer", | ||
"type": "http" | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/openapi-ts/test/spec/3.1.x/security-http-bearer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"openapi": "3.1.1", | ||
"info": { | ||
"title": "OpenAPI 3.1.1 security bearer example", | ||
"version": "1" | ||
}, | ||
"paths": { | ||
"/foo": { | ||
"get": { | ||
"responses": { | ||
"200": { | ||
"description": "OK" | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"foo": [] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"components": { | ||
"securitySchemes": { | ||
"foo": { | ||
"bearerFormat": "JWT", | ||
"scheme": "bearer", | ||
"type": "http" | ||
} | ||
} | ||
} | ||
} |