Open
Description
What is the problem this feature would solve?
I'd like to add details.security
to a group of routes.
What is the feature you are proposing to solve the problem?
Using a guard like below would be possible:
new Elysia()
.guard({
detail: {
security: [
{ bearer: ["read"] },
{ api: ["read"] }
],
},
})
.get("/:id", () => {}, {
detail: {
description: "Route desc"
}
})
Currently, detail.security
can only be specified in the route's 3rd argument.
What alternatives have you considered?
Have macro or other ways to specify security details (cf #666)
PS: I think the macro way would be more flexible, since you could specify macros that would add scopes in the swagger. ex:
new Elysia()
.macro({
scope(scopes: string[]) {
return {
resolve: async ({ headers: { authorization } }) => {
return { user: {} };
},
details: {
security: [ { bearer: scopes } ],
},
};
},
})
.get("/:id", () => {}, {
scope: ["read"]
});
Even if this macro way is implemented, i feel like guard
should work for security, as it not working feels like an oversight.