-
Hey folks. I'm working on hooking up our TypeSpec -> OpenAPI pipeline to generating SDKs with Speakeasy. As part of that, we have to add extension annotations to all of our endpoints that respond with paginated results, e.g.:
I'd like to make it so that teams don't have to remember or copypasta this extension annotation and others like it. I know that I can at least replace "x-speakeasy-pagination" with a string constant, but because object constants are typed, I can't pass one in here as the second argument to extension.
I was actually sort of surprised by this, but I am new to TypeScript as well. I'd appreciate any guidance here. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I think the answer here is to create a custom decorator that does this for me. :) |
Beta Was this translation helpful? Give feedback.
-
Yeah the You can however still use an alias today to reuse that Example import "@typespec/openapi";
using OpenAPI;
alias PaginationConfig = {
type: "url";
outputs: {
nextUrl: "$.pageInfo.next";
};
};
@extension("x-speakeasy-pagination", PaginationConfig)
op list(): void; but yeah a custom decorator could also be a great solution and even cleaner if you really always have the same and just need to do |
Beta Was this translation helpful? Give feedback.
I think the answer here is to create a custom decorator that does this for me. :)