Skip to content

feat: Validate swagger definitions #5694

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 70 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
a3fbe72
docs: audit, deploymentconfig, files, parameters
mtojek Dec 22, 2022
fbe1d70
Swagger comments in workspacebuilds.go
mtojek Jan 2, 2023
96daf47
structs in workspacebuilds.go
mtojek Jan 2, 2023
663ec87
workspaceagents: instance identity
mtojek Jan 2, 2023
fc00d7e
workspaceagents.go in progress
mtojek Jan 2, 2023
67a85b9
workspaceagents.go in progress
mtojek Jan 2, 2023
ce8c7ea
Agents
mtojek Jan 2, 2023
d2a9af5
workspacebuilds.go
mtojek Jan 2, 2023
f37c6b3
/workspaces
mtojek Jan 3, 2023
250982a
templates.go, templateversions.go
mtojek Jan 3, 2023
ff622a7
templateversion.go in progress
mtojek Jan 3, 2023
9dd385c
cancel
mtojek Jan 3, 2023
f96351a
templateversions
mtojek Jan 3, 2023
15de3b6
wip
mtojek Jan 3, 2023
596cdbd
Merge branch 'main' into 3522-workspacebuilds-1
mtojek Jan 3, 2023
eb4ba48
Merge
mtojek Jan 3, 2023
e314c24
x-apidocgen
mtojek Jan 4, 2023
97cd7ac
NullTime hack not needed anymore
mtojek Jan 4, 2023
ae06598
Fix: x-apidocgen
mtojek Jan 4, 2023
c82eb01
Merge branch '3522-workspacebuilds-1' into 3522-templates-1
mtojek Jan 4, 2023
77815d3
Merge branch '3522-templates-1' into 3522-organizations-1
mtojek Jan 4, 2023
7aa0f65
Members
mtojek Jan 4, 2023
b93398e
Fixes
mtojek Jan 4, 2023
5c96bd5
Fix
mtojek Jan 4, 2023
4667f07
WIP
mtojek Jan 5, 2023
0cd9c4a
Merge branch 'main' into 3522-templates-1
mtojek Jan 5, 2023
5405c0c
WIP
mtojek Jan 9, 2023
801cad1
Merge branch '3522-users-1' into 3522-organizations-1
mtojek Jan 9, 2023
0dc1d2a
Users
mtojek Jan 9, 2023
9285425
Logout
mtojek Jan 9, 2023
6979a7f
User profile
mtojek Jan 9, 2023
62a26f9
Status suspend activate
mtojek Jan 9, 2023
b1f389b
User roles
mtojek Jan 9, 2023
14a1654
User tokens
mtojek Jan 9, 2023
5c22629
Keys
mtojek Jan 9, 2023
91c78f4
SSH key
mtojek Jan 9, 2023
c06a636
All
mtojek Jan 9, 2023
ee6dbb1
Typo
mtojek Jan 9, 2023
8f22f8d
Fix
mtojek Jan 9, 2023
77be926
Entitlements
mtojek Jan 9, 2023
4fcedb0
Groups
mtojek Jan 9, 2023
35eae4e
SCIM
mtojek Jan 9, 2023
a7f6add
Fix
mtojek Jan 9, 2023
0f9b0f6
Merge branch 'main' into 3522-enterprise-1
mtojek Jan 9, 2023
3ecfad7
Fix
mtojek Jan 9, 2023
05b6a98
Clean templates
mtojek Jan 9, 2023
03d9e9a
Merge branch 'main' into 3522-enterprise-1
mtojek Jan 11, 2023
1ebf408
Sort API pages
mtojek Jan 11, 2023
c2977cf
Fix: HashedSecret
mtojek Jan 11, 2023
cbacf76
WIP
mtojek Jan 11, 2023
08f1f26
Merge branch 'main' into 3522-validation
mtojek Jan 11, 2023
b23edb4
WIP
mtojek Jan 11, 2023
2f70137
WIP
mtojek Jan 12, 2023
33d93d6
Fix: cover workspaceagents
mtojek Jan 12, 2023
76701b8
Assert: consistent ID and summary
mtojek Jan 12, 2023
7165276
Assert: success or failure defined
mtojek Jan 12, 2023
12e502a
Fix: parallel
mtojek Jan 12, 2023
b501822
Refactor
mtojek Jan 12, 2023
1d30352
Support enterprise
mtojek Jan 12, 2023
9272c01
Go comment goes to top
mtojek Jan 12, 2023
38b6dad
Security
mtojek Jan 12, 2023
a565c15
assertPathParametersDefined
mtojek Jan 12, 2023
1bc8556
assertUniqueRoutes
mtojek Jan 12, 2023
d0964f9
assertRequestBody
mtojek Jan 12, 2023
b2d838f
More fixes
mtojek Jan 12, 2023
182419a
Fix: exceptions
mtojek Jan 12, 2023
cb78089
Fix field format
mtojek Jan 12, 2023
fa2d030
Address PR comments
mtojek Jan 13, 2023
ecb2d5a
Refactor
mtojek Jan 13, 2023
47b6d3e
Merge branch 'main' into 3522-validation
mtojek Jan 13, 2023
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
Prev Previous commit
Next Next commit
templateversion.go in progress
  • Loading branch information
mtojek committed Jan 3, 2023
commit ff622a7ba085200e45feee07c69dc670392a7083
148 changes: 147 additions & 1 deletion coderd/apidoc/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,79 @@ const docTemplate = `{
}
}
},
"/templateversions/{id}": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Templates"
],
"summary": "Get template version by ID",
"operationId": "get-template-version-by-id",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "Template version ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.TemplateVersion"
}
}
}
}
},
"/templateversions/{id}/schema": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Templates"
],
"summary": "Get template version schema by template version ID",
"operationId": "get-template-version-schema-by-template-version-id",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "Template version ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.ParameterSchema"
}
}
}
}
}
},
"/updatecheck": {
"get": {
"produces": [
Expand Down Expand Up @@ -2270,7 +2343,8 @@ const docTemplate = `{
"properties": {
"copy_from_parameter": {
"description": "CloneID allows copying the value of another parameter.\nThe other param must be related to the same template_id for this to\nsucceed.\nNo other fields are required if using this, as all fields will be copied\nfrom the other parameter.",
"type": "string"
"type": "string",
"format": "uuid"
},
"destination_scheme": {
"type": "string",
Expand Down Expand Up @@ -2964,6 +3038,78 @@ const docTemplate = `{
}
}
},
"codersdk.ParameterSchema": {
"type": "object",
"properties": {
"allow_override_destination": {
"type": "boolean"
},
"allow_override_source": {
"type": "boolean"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"default_destination_scheme": {
"type": "string",
"enum": [
"none",
"environment_variable",
"provisioner_variable"
]
},
"default_refresh": {
"type": "string"
},
"default_source_scheme": {
"type": "string",
"enum": [
"none",
"data"
]
},
"default_source_value": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"job_id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"redisplay_value": {
"type": "boolean"
},
"validation_condition": {
"type": "string"
},
"validation_contains": {
"description": "This is a special array of items provided if the validation condition\nexplicitly states the value must be one of a set.",
"type": "array",
"items": {
"type": "string"
}
},
"validation_error": {
"type": "string"
},
"validation_type_system": {
"type": "string"
},
"validation_value_type": {
"type": "string"
}
}
},
"codersdk.PostWorkspaceAgentVersionRequest": {
"type": "object",
"properties": {
Expand Down
133 changes: 132 additions & 1 deletion coderd/apidoc/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,71 @@
}
}
},
"/templateversions/{id}": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Templates"],
"summary": "Get template version by ID",
"operationId": "get-template-version-by-id",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "Template version ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.TemplateVersion"
}
}
}
}
},
"/templateversions/{id}/schema": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Templates"],
"summary": "Get template version schema by template version ID",
"operationId": "get-template-version-schema-by-template-version-id",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "Template version ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.ParameterSchema"
}
}
}
}
}
},
"/updatecheck": {
"get": {
"produces": ["application/json"],
Expand Down Expand Up @@ -2008,7 +2073,8 @@
"properties": {
"copy_from_parameter": {
"description": "CloneID allows copying the value of another parameter.\nThe other param must be related to the same template_id for this to\nsucceed.\nNo other fields are required if using this, as all fields will be copied\nfrom the other parameter.",
"type": "string"
"type": "string",
"format": "uuid"
},
"destination_scheme": {
"type": "string",
Expand Down Expand Up @@ -2666,6 +2732,71 @@
}
}
},
"codersdk.ParameterSchema": {
"type": "object",
"properties": {
"allow_override_destination": {
"type": "boolean"
},
"allow_override_source": {
"type": "boolean"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"default_destination_scheme": {
"type": "string",
"enum": ["none", "environment_variable", "provisioner_variable"]
},
"default_refresh": {
"type": "string"
},
"default_source_scheme": {
"type": "string",
"enum": ["none", "data"]
},
"default_source_value": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"job_id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"redisplay_value": {
"type": "boolean"
},
"validation_condition": {
"type": "string"
},
"validation_contains": {
"description": "This is a special array of items provided if the validation condition\nexplicitly states the value must be one of a set.",
"type": "array",
"items": {
"type": "string"
}
},
"validation_error": {
"type": "string"
},
"validation_type_system": {
"type": "string"
},
"validation_value_type": {
"type": "string"
}
}
},
"codersdk.PostWorkspaceAgentVersionRequest": {
"type": "object",
"properties": {
Expand Down
16 changes: 16 additions & 0 deletions coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ import (
"github.com/coder/coder/examples"
)

// @Summary Get template version by ID
// @ID get-template-version-by-id
// @Security CoderSessionToken
// @Produce json
// @Tags Templates
// @Param id path string true "Template version ID" format(uuid)
// @Success 200 {object} codersdk.TemplateVersion
// @Router /templateversions/{id} [get]
func (api *API) templateVersion(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var (
Expand Down Expand Up @@ -116,6 +124,14 @@ func (api *API) patchCancelTemplateVersion(rw http.ResponseWriter, r *http.Reque
})
}

// @Summary Get template version schema by template version ID
// @ID get-template-version-schema-by-template-version-id
// @Security CoderSessionToken
// @Produce json
// @Tags Templates
// @Param id path string true "Template version ID" format(uuid)
// @Success 200 {array} codersdk.ParameterSchema
// @Router /templateversions/{id}/schema [get]
func (api *API) templateVersionSchema(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var (
Expand Down
14 changes: 7 additions & 7 deletions codersdk/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const (
type ComputedParameter struct {
Parameter
SourceValue string `json:"source_value"`
SchemaID uuid.UUID `json:"schema_id"`
SchemaID uuid.UUID `json:"schema_id" format:"uuid"`
DefaultSourceValue bool `json:"default_source_value"`
}

Expand All @@ -63,15 +63,15 @@ type Parameter struct {
}

type ParameterSchema struct {
ID uuid.UUID `json:"id"`
CreatedAt time.Time `json:"created_at"`
JobID uuid.UUID `json:"job_id"`
ID uuid.UUID `json:"id" format:"uuid"`
CreatedAt time.Time `json:"created_at" format:"date-time"`
JobID uuid.UUID `json:"job_id" format:"uuid"`
Name string `json:"name"`
Description string `json:"description"`
DefaultSourceScheme ParameterSourceScheme `json:"default_source_scheme"`
DefaultSourceScheme ParameterSourceScheme `json:"default_source_scheme" enums:"none,data"`
DefaultSourceValue string `json:"default_source_value"`
AllowOverrideSource bool `json:"allow_override_source"`
DefaultDestinationScheme ParameterDestinationScheme `json:"default_destination_scheme"`
DefaultDestinationScheme ParameterDestinationScheme `json:"default_destination_scheme" enums:"none,environment_variable,provisioner_variable"`
AllowOverrideDestination bool `json:"allow_override_destination"`
DefaultRefresh string `json:"default_refresh"`
RedisplayValue bool `json:"redisplay_value"`
Expand All @@ -94,7 +94,7 @@ type CreateParameterRequest struct {
// succeed.
// No other fields are required if using this, as all fields will be copied
// from the other parameter.
CloneID uuid.UUID `json:"copy_from_parameter,omitempty" validate:""`
CloneID uuid.UUID `json:"copy_from_parameter,omitempty" validate:"" format:"uuid"`

Name string `json:"name" validate:"required"`
SourceValue string `json:"source_value" validate:"required"`
Expand Down
Loading