Skip to content

Commit b5b5c37

Browse files
authored
docs: describe mutually exclusive create workspace template fields (#12834)
* docs: describe mutually exclusive create workspace template fields Ideally we could do this in the OpenAPI spec, but there is no first class "mutually exclusive" feature in OpenAPI. So in lieu of something more complex, or changing our struct/validation, a description comment should suffice. * chore: Add description to code sample as well
1 parent 5137433 commit b5b5c37

File tree

6 files changed

+18
-0
lines changed

6 files changed

+18
-0
lines changed

coderd/apidoc/docs.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/workspaces.go

+4
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ func (api *API) workspaceByOwnerAndName(rw http.ResponseWriter, r *http.Request)
332332
// Create a new workspace for the currently authenticated user.
333333
//
334334
// @Summary Create user workspace by organization
335+
// @Description Create a new workspace using a template. The request must
336+
// @Description specify either the Template ID or the Template Version ID,
337+
// @Description not both. If the Template ID is specified, the active version
338+
// @Description of the template will be used.
335339
// @ID create-user-workspace-by-organization
336340
// @Security CoderSessionToken
337341
// @Accept json

codersdk/organizations.go

+3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ type CreateTemplateRequest struct {
138138

139139
// CreateWorkspaceRequest provides options for creating a new workspace.
140140
// Either TemplateID or TemplateVersionID must be specified. They cannot both be present.
141+
// @Description CreateWorkspaceRequest provides options for creating a new workspace.
142+
// @Description Only one of TemplateID or TemplateVersionID can be specified, not both.
143+
// @Description If TemplateID is specified, the active version of the template will be used.
141144
type CreateWorkspaceRequest struct {
142145
// TemplateID specifies which template should be used for creating the workspace.
143146
TemplateID uuid.UUID `json:"template_id,omitempty" validate:"required_without=TemplateVersionID,excluded_with=TemplateVersionID" format:"uuid"`

docs/api/schemas.md

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/workspaces.md

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)