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

*: Build APIv2 spec using go-swagger, annotate endpoints #62560

Merged
merged 2 commits into from
Mar 25, 2021

Conversation

itsbilal
Copy link
Member

This change adds a dependency on go-swagger/go-swagger, and
uses it as part of make generate to regenerate the swagger
spec in docs/generated/swagger/spec.json, whenever
one of the APIv2 files in pkg/server/ are changed.

The spec, once generated, can be served as docs using
the command:

bin/swagger serve -p 8080 ./docs/generated/swagger/spec.json

Also adds related annotations to pkg/server/api*.go to populate
said spec.

Part of #55947 , and the docs story around it.

Release note (general change): Add docs for api v2 endpoints.
Release note (build change): Adds go-swagger dependency, updates
Makefile to call it to rebuild spec in docs/generated/swagger/
which will eventually be used for API docs.

@itsbilal itsbilal requested review from knz and dhartunian March 24, 2021 22:13
@itsbilal itsbilal self-assigned this Mar 24, 2021
@itsbilal itsbilal requested a review from a team as a code owner March 24, 2021 22:13
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@itsbilal
Copy link
Member Author

/cc @mikeCRL , @piyush-singh

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 👏 👏

LGTM

you may want to backport this too

Reviewed 4 of 4 files at r1, 13 of 13 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @dhartunian and @itsbilal)


docs/generated/swagger/spec.json, line 23 at r2 (raw file):

    "/health/": {
      "get": {
        "description": "Helper endpoint to check for node helath. If `ready` is true, it also checks\nif this node is fully operational and ready to accept SQL connections.\nOtherwise, this endpoint always returns a successful response (if the API\nserver is up, of course).",

node helath -> node health

This commit adds go-swagger annotations for API v2 endpoints,
so that the swagger spec and by extension docs can be generated
as part of `make generate`.

Due to a limitation in go-swagger, the only map key type that's
supported for swagger models is string, so some maps had to be
modified to use that type instead.

Part of cockroachdb#55947 , and the docs story around it.

Release note (general change): Add docs for api v2 endpoints.
Copy link
Member Author

@itsbilal itsbilal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @dhartunian and @knz)


docs/generated/swagger/spec.json, line 23 at r2 (raw file):

Previously, knz (kena) wrote…

node helath -> node health

Done.

@itsbilal itsbilal force-pushed the swagger-apiv2-docs branch 3 times, most recently from 0cf9e5d to 6f08342 Compare March 25, 2021 19:01
This change adds a dependency on `go-swagger/go-swagger`, and
uses it as part of `make generate` to regenerate the swagger
spec in `docs/generated/swagger/spec.json`, whenever
one of the APIv2 files in `pkg/server/` are changed.

The spec, once generated, can be served as docs using
the command:

    bin/swagger serve -p 8080 ./docs/generated/swagger/spec.json

Release note (build change): Adds go-swagger dependency, updates
Makefile to call it to rebuild spec in docs/generated/swagger/
which will eventually be used for API docs.
@itsbilal
Copy link
Member Author

TFTR!

bors r=knz

@craig
Copy link
Contributor

craig bot commented Mar 25, 2021

Build succeeded:

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

Successfully merging this pull request may close these issues.

3 participants