Skip to content
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

Autogenerated docs for REST API #3522

Closed
28 of 29 tasks
bpmct opened this issue Aug 15, 2022 · 9 comments · Fixed by #5694
Closed
28 of 29 tasks

Autogenerated docs for REST API #3522

bpmct opened this issue Aug 15, 2022 · 9 comments · Fixed by #5694
Assignees
Labels
docs Area: docs

Comments

@bpmct
Copy link
Member

bpmct commented Aug 15, 2022

Currently, you can examine ./codersdk to see the various REST API queries supported by Coder. If you're interested in official documentation for the REST API (like similar to our approach for Coder Classic), please leave upvote this issue or contact us.

@mtojek:

Track progress

OSS

/api/v2:

Enterprise

/api/v2: #5625

  • /entitlements (1 method)
  • /replicas (2 methods)
  • /licenses (4 methods)
  • /organizations/{organization}/groups (3 methods)
  • /organizations/{organization}/provisionerdaemons (2 methods)
  • /groups/{group} (3 methods)
  • /workspace-quota (1 method)
  • /service-banner /appearance (2 methods)
  • /scim/v2 (6 methods)

Validation

UI improvements

Other

@kylecarbs
Copy link
Member

The godoc reference has a pretty nice view too!

@Emyrk
Copy link
Member

Emyrk commented Aug 16, 2022

At some point we'll have to nail down our apis and version them properly

@kylecarbs kylecarbs added the docs Area: docs label Aug 24, 2022
@bpmct bpmct changed the title Docs for REST API Docs for CLI and REST API Sep 19, 2022
@bpmct
Copy link
Member Author

bpmct commented Sep 19, 2022

GitLab has nice auto-generated documentation for their CLI as well. https://glab.readthedocs.io/en/latest/completion/index.html

@bpmct bpmct mentioned this issue Sep 19, 2022
3 tasks
@bpmct bpmct changed the title Docs for CLI and REST API Autogenerated docs for REST API (and CLI?) Sep 19, 2022
@github-actions
Copy link

This issue is becoming stale. In order to keep the tracker readable and actionable, I'm going close to this issue in 7 days if there isn't more activity.

@github-actions github-actions bot added the stale This issue is like stale bread. label Nov 19, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2022
@bpmct bpmct reopened this Dec 1, 2022
@github-actions github-actions bot removed the stale This issue is like stale bread. label Dec 2, 2022
@mtojek
Copy link
Member

mtojek commented Dec 9, 2022

Looking into this

@mtojek
Copy link
Member

mtojek commented Dec 9, 2022

I checked possible options and unfortunately, the best approach seems to be tagging API operations via Go comments and generating OpenAPI/swagger description with swag.

An alternative approach is the chi-go/docgen (official project?), which is supposed to generate Markdown/Swagger directly from chi Router, but it isn't aware of request/response entities and status codes + it leaves a lot of noise (Recover, Middleware, Logger, Prometheus, etc.).

Screenshot 2022-12-09 at 14 01 42

Once we have the swagger description ready, we can generate the Markdown file with widdershins. I'm not sure about the visual effect, but it looks promissing.

EDIT:

I'm proceeding with the comments approach.

@Emyrk
Copy link
Member

Emyrk commented Dec 9, 2022

I checked possible options and unfortunately, the best approach seems to be tagging API operations via Go comments and generating OpenAPI/swagger description with swag.

I would warn about this approach. We did this in v1 and the auto generated SDK's are not ideal. Then the comments and the code go out of sync if you don't use the SDK.

An alternative approach is the chi-go/docgen (official project?), which is supposed to generate Markdown/Swagger directly from chi Router, but it isn't aware of request/response entities and status codes + it leaves a lot of noise (Recover, Middleware, Logger, Prometheus, etc.).

I have used a tool in the past where it looks at the request/response from our unit tests to generate docs. I wonder if we can auto gen this from our SDK, not the routes.

Like maybe from our sdk functions won't be too bad to parse? A lot of edge cases 😢

func (c *Client) Upload(ctx context.Context, contentType string, content []byte) (UploadResponse, error) {

@mtojek
Copy link
Member

mtojek commented Dec 9, 2022

Thanks for the good chat, @Emyrk and @johnstcn! I will go the standard way (@comment) but will implement a linter/validator. In the end, we could detect outdated undocumented API functions, wrong HTTP methods, and missing fields in request entities.

@mtojek
Copy link
Member

mtojek commented Dec 19, 2022

Ok, time for part 2.

will implement a linter/validator. In the end, we could detect outdated undocumented API functions, wrong HTTP methods, and missing fields in request entities.

plus document other API methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Area: docs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants