-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change from BearerAuth to API Key Auth #3
base: main
Are you sure you want to change the base?
Conversation
@@ -1,15 +1,3 @@ | |||
A conversion of the OpenAI OpenAPI to TypeSpec. | |||
# OpenAPI spec for the OpenAI API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a weird Windows thing, we think, and I can follow up by deleting this file, which I've moved to conversion.md.
main.tsp
Outdated
@@ -27,5 +27,5 @@ using TypeSpec.Http; | |||
}, | |||
version: "2.0.0", | |||
}) | |||
@useAuth(BearerAuth) | |||
@useAuth(ApiKeyAuth<ApiKeyLocation.query, "AUTHORIZATION">) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bterlson, is there a way to tell the ApiKeyAuth piece about a string prefix it needs to add before the API key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is a bearerkey defined in the original api though
securitySchemes:
ApiKeyAuth:
type: http
scheme: 'bearer'
ApiKeyAuth
is just a free name they choosed
See playground with BearerAuth
vs ApiKeyAuth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exact same name can be achieved by using your own model name instead of BearerAuth
if this is important
import "@typespec/http";
using TypeSpec.Http;
@service
@useAuth(ApiKeyAuth)
namespace DemoService;
model ApiKeyAuth is BearerAuth {}
The original OpenAI API definition defines their auth policy as API Key, so changing the TypeSpec to do the same.