-
Notifications
You must be signed in to change notification settings - Fork 5
docs: add API documentation for Coder plugin #15
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
Conversation
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.
Thoughts in putting these all in ./docs
instead of ./docs/api-reference
?
@bpmct Yeah, perfectly fine with that. No strong feelings about file structure |
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.
Another question, which is related to "Example of using full Coder API" in #14
Is there a clean way for a plugin developer to use the Coder API/token collector logic to make custom requests to the Coder API? To list templates using the users' token, for example.
My optimal UX (psuedocode:
const CustomComponent = () => {
const Coder = useCoderAPI()
if (Coder.userLoggedOut) {
return <TokenLoginComponent />
} else {
return (<ul>
{{Coder.APIRequest("/templates").map((template) {
return <li>{template.name}</li>
})}}
</ul>
}
}
of course the naming I picked isn't fantastic, but essentially letting plugins devs write their own integrations
@bpmct Not yet. To be honest, there really isn't a perfect way to do it – there's at least some kind of trade-off. I feel like there's two main approaches:
But I do think that (1) is the only approach that makes sense from a flexibility/maintenance standpoint, and it's basically the next new feature I want to add to the plugin. I would like the developer experience to be nice, and for there to be good auto-complete support, though. So two immediately approaches come to mind:
The above code assumes that we're using React Query, which I feel has been really important for making all the authentication and other requests maintainable. But I feel like there's no one-size-fits-all caching strategy we can use for every single endpoint. We could expose the query key directly to let users manage their own caching, but I'll have to see if there's a better option. With how the proxy is set up right now (and I'm hoping we can keep this if we remove the proxy config from the |
From the discussion: let's avoid type safety and expose the API directly since we have autogenerated API docs. Also, can we pass all properties (e.g. request method, request body, anything) into something like |
Can you also edit the README to uncomment and add proper links to the docs as part of this PR? |
Can do to both of them. I should be able to make it so that the function you get back uses (This is sort of a curse – it'd be nice if we could make it so that you can't accidentally pass in the coder header, but I can make it so that there's a quick input check to see if that property was defined, and only let requests through that don't have it – otherwise the user gets an error) |
Co-authored-by: Ben Potter <me@bpmct.net>
…ns into mes/coder-api-docs
const activeConfig = { | ||
...appConfig.workspaces, | ||
...(entityConfig ?? {}), | ||
}; |
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.
With how this was before, you would basically only have one config or the other, even though entityConfig
wouldn't be guaranteed to be fully filled-out
Now it's using the appConfig value as the base, and only overwriting it with the properties that definitely exist
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.
LGTM! Down the road, it might be nice to have an examples/
folder as well in here! For example:
examples/CustomWorkspacesCard.tsx
- example of somebody importing components instead of using CoderWorkspacesCardexamples/Skaffolder.tsx
- example using Coder inside the Skaffolderexamples/CustomAPI.tsx
example of a component making custom API requests (e.g. listing templates)
These docs are extremely nice. And on second thought,
I imagine this would probably be best in the plugin root instead. |
This reverts commit cc674de.
Work in progress still.
Changes made
./docs
directoryforwardRef
from some of these, because Backstage's export system isn't flexible enough to know how to handle them)CoderProvider
and each individualcatalog-info.yaml
file are combined (only caught this while writing out notes for how the functionality was supposed to work)Things left to do
CoderWorkspacesCard
sub-componentsuseApi
to verify if there are any situations when it would realistically throw, and then update the docs forCoderErrorBoundary
Notes