Skip to content

feat: Build framework for generating API docs #5383

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

Merged
merged 99 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
92f4f83
WIP
mtojek Dec 9, 2022
f92bf47
Gen
mtojek Dec 9, 2022
c9de1a6
WIP
mtojek Dec 9, 2022
bd6ed04
chi swagger
mtojek Dec 9, 2022
484f1e9
WIP
mtojek Dec 9, 2022
9a2493b
WIP
mtojek Dec 9, 2022
fe48812
WIP
mtojek Dec 12, 2022
dab3704
GetWorkspaces
mtojek Dec 12, 2022
b43e6c3
GetWorkspaces
mtojek Dec 12, 2022
8358457
Markdown
mtojek Dec 12, 2022
d32b7b7
Use widdershins
mtojek Dec 12, 2022
a087ace
WIP
mtojek Dec 12, 2022
90dea8c
WIP
mtojek Dec 12, 2022
eef09e6
WIP
mtojek Dec 12, 2022
37e51cd
Markdown template
mtojek Dec 12, 2022
aa27c9f
Fix: makefile
mtojek Dec 12, 2022
23307e5
fmt
mtojek Dec 12, 2022
f4349e1
Fix: comment
mtojek Dec 12, 2022
09ca65a
Merge branch 'main' into 3522-autogenerate-docs-2
mtojek Dec 13, 2022
357c044
Enable swagger conditionally
mtojek Dec 13, 2022
0dcad6c
fix: site
mtojek Dec 13, 2022
cb9da6d
Default false
mtojek Dec 13, 2022
1844264
Flag tests
mtojek Dec 13, 2022
1a7ba5c
fix
mtojek Dec 13, 2022
3c51729
fix
mtojek Dec 13, 2022
ba00bfc
template fixes
mtojek Dec 13, 2022
cc5d9ac
Fix
mtojek Dec 13, 2022
ae0e284
Fix
mtojek Dec 13, 2022
fb4ef9f
Fix
mtojek Dec 13, 2022
d022f99
WIP
mtojek Dec 13, 2022
23a1dc3
Formatted
mtojek Dec 13, 2022
1a1ccc4
Cleanup
mtojek Dec 13, 2022
c49f146
Templates
mtojek Dec 14, 2022
54b06d4
BEGIN END SECTION
mtojek Dec 14, 2022
5fe7f59
subshell exit code
mtojek Dec 14, 2022
8c8ce44
Fix
mtojek Dec 14, 2022
423650b
Merge branch 'main' into 3522-autogenerate-docs-2
mtojek Dec 14, 2022
c3902d5
Fix merge
mtojek Dec 14, 2022
b7c22dc
WIP
mtojek Dec 14, 2022
5f68605
Fix
mtojek Dec 14, 2022
7208269
Fix fmt
mtojek Dec 14, 2022
c69c157
Fix
mtojek Dec 14, 2022
14a659e
Generic api.md page
mtojek Dec 15, 2022
1c8b44f
Merge branch 'main' into 3522-autogenerate-docs-2
mtojek Dec 15, 2022
04540f8
Fix merge
mtojek Dec 15, 2022
bb57436
Link pages
mtojek Dec 15, 2022
84a5de4
Fix
mtojek Dec 15, 2022
c7c93ab
Fix
mtojek Dec 15, 2022
574e79d
Fix: links
mtojek Dec 15, 2022
87689fc
Add icon
mtojek Dec 15, 2022
9b1ed37
Write manifest file
mtojek Dec 15, 2022
f58a114
Fix fmt
mtojek Dec 15, 2022
18effcd
Fix: enterprise
mtojek Dec 15, 2022
ebf2e9e
Fix: Swagger.Enable
mtojek Dec 15, 2022
2564f31
Fix: rename apidocs to apidoc
mtojek Dec 15, 2022
c69a0d9
Fix: find -not -prune
mtojek Dec 15, 2022
a9a62b3
Fix: json not available
mtojek Dec 15, 2022
79285d2
Fix: rename Coderd API to Coder API
mtojek Dec 15, 2022
59d9334
Fix: npm exec
mtojek Dec 15, 2022
80dbf3d
Fix: api dir
mtojek Dec 15, 2022
d8cb335
Fix: by ID
mtojek Dec 15, 2022
8a0aa36
Fix: string uuid
mtojek Dec 15, 2022
e4db936
Fix: include deleted
mtojek Dec 15, 2022
cfb86da
Fix: indirect go.mod
mtojek Dec 15, 2022
638f5ba
Fix: source lib.sh
mtojek Dec 15, 2022
5bac489
Fix: shellcheck
mtojek Dec 15, 2022
2853405
Fix: pushd popd
mtojek Dec 15, 2022
c090ef8
Fix: fmt
mtojek Dec 15, 2022
e310b79
Fix: improve workspaces
mtojek Dec 15, 2022
c7533fa
Fix: swagger-enable
mtojek Dec 15, 2022
83aa9d3
Fix
mtojek Dec 15, 2022
6309f07
Fix: mention only HTTP 200
mtojek Dec 15, 2022
8bc8a25
Fix: IDs
mtojek Dec 15, 2022
209d9cc
Fix: https
mtojek Dec 15, 2022
be283e5
Fix: icon
mtojek Dec 16, 2022
f7c4d97
Merge branch 'main' into 3522-autogenerate-docs-2
mtojek Dec 16, 2022
0d917dc
More APis
mtojek Dec 16, 2022
a07e2ab
Fix: format swagger.json
mtojek Dec 16, 2022
82a680d
Fix: SwaggerEndpoint
mtojek Dec 16, 2022
73a7013
Fix: SCRIPT_DIR
mtojek Dec 16, 2022
7ab3a1f
Fix: PROJECT_ROOT
mtojek Dec 16, 2022
fcaba60
Fix: use code tags in schemas.md
mtojek Dec 16, 2022
1677409
Fix: examples
mtojek Dec 16, 2022
75f37c6
Fix: examples
mtojek Dec 16, 2022
d80d94b
Fix: improve format
mtojek Dec 16, 2022
4a52aa8
Fix: date-time,enums
mtojek Dec 16, 2022
a719007
Fix: include_deleted
mtojek Dec 16, 2022
5de5b3a
Fix: array of
mtojek Dec 16, 2022
802b2b4
Fix: parameter, response
mtojek Dec 16, 2022
83a815b
Fix: string time or null
mtojek Dec 16, 2022
7282eca
Workspaces: more docs
mtojek Dec 19, 2022
ddd2d7d
Workspaces: more docs
mtojek Dec 19, 2022
95718aa
Fix: renderDisplayName
mtojek Dec 19, 2022
1f5e17e
Fix: ActiveUserCount
mtojek Dec 19, 2022
fb59fbd
Fix
mtojek Dec 19, 2022
7aa7f1c
Fix: typo
mtojek Dec 19, 2022
9c97e0c
Merge branch 'main' into 3522-autogenerate-docs-2
mtojek Dec 19, 2022
3f182cc
Templates: docs
mtojek Dec 19, 2022
1f28dc6
Notice: incomplete
mtojek Dec 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,14 @@ gen: \
provisionersdk/proto/provisioner.pb.go \
provisionerd/proto/provisionerd.pb.go \
site/src/api/typesGenerated.ts \
docs/admin/prometheus.md
docs/admin/prometheus.md \
coderd/apidoc/swagger.json
.PHONY: gen

# Mark all generated files as fresh so make thinks they're up-to-date. This is
# used during releases so we don't run generation scripts.
Comment on lines 410 to 411
Copy link
Member

Choose a reason for hiding this comment

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

sanity check: New API docs (swagger and markdown) are being generated (and committed) during each release? Is this also how we generate our Prometheus docs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both actions, Prometheus and API docs, use the same target, make gen, so every generated doc is stored in the repository. If you see possible drawbacks, we can sync offline.

gen/mark-fresh:
files="coderd/database/dump.sql coderd/database/querier.go provisionersdk/proto/provisioner.pb.go provisionerd/proto/provisionerd.pb.go site/src/api/typesGenerated.ts docs/admin/prometheus.md"
files="coderd/database/dump.sql coderd/database/querier.go provisionersdk/proto/provisioner.pb.go provisionerd/proto/provisionerd.pb.go site/src/api/typesGenerated.ts docs/admin/prometheus.md coderd/apidoc/swagger.json"
for file in $$files; do
echo "$$file"
if [ ! -f "$$file" ]; then
Expand Down Expand Up @@ -457,6 +458,11 @@ docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/me
cd site
yarn run format:write ../docs/admin/prometheus.md

coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen -not \( -path './scripts/apidocgen/node_modules' -prune \) -type f) $(wildcard coderd/*.go) $(wildcard codersdk/*.go)
./scripts/apidocgen/generate.sh
cd site
yarn run format:write ../docs/api ../docs/manifest.json ../coderd/apidoc/swagger.json

update-golden-files: cli/testdata/.gen-golden
.PHONY: update-golden-files

Expand Down
8 changes: 8 additions & 0 deletions cli/deployment/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,14 @@ func newConfig() *codersdk.DeploymentConfig {
Flag: "max-token-lifetime",
Default: 24 * 30 * time.Hour,
},
Swagger: &codersdk.SwaggerConfig{
Enable: &codersdk.DeploymentConfigField[bool]{
Name: "Enable swagger endpoint",
Usage: "Expose the swagger endpoint via /swagger.",
Flag: "swagger-enable",
Default: false,
},
},
}
}

Expand Down
4 changes: 4 additions & 0 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,10 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
), cfg.Prometheus.Address.Value, "prometheus")()
}

if cfg.Swagger.Enable.Value {
options.SwaggerEndpoint = cfg.Swagger.Enable.Value
}

// We use a separate coderAPICloser so the Enterprise API
// can have it's own close functions. This is cleaner
// than abstracting the Coder API itself.
Expand Down
2 changes: 2 additions & 0 deletions cli/testdata/coder_server_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ Flags:
"ecdsa", or "rsa4096".
Consumes $CODER_SSH_KEYGEN_ALGORITHM
(default "ed25519")
--swagger-enable Expose the swagger endpoint via /swagger.
Consumes $CODER_SWAGGER_ENABLE
--telemetry Whether telemetry is enabled or not.
Coder collects anonymized usage data to
help improve our product.
Expand Down
Loading