Skip to content

Commit d80d94b

Browse files
committed
Fix: improve format
1 parent 75f37c6 commit d80d94b

File tree

7 files changed

+106
-84
lines changed

7 files changed

+106
-84
lines changed

coderd/apidoc/docs.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,12 @@ const docTemplate = `{
481481
"$ref": "#/definitions/codersdk.TemplateBuildTimeStats"
482482
},
483483
"created_at": {
484-
"type": "string"
484+
"type": "string",
485+
"format": "date-time"
485486
},
486487
"created_by_id": {
487-
"type": "string"
488+
"type": "string",
489+
"format": "uuid"
488490
},
489491
"created_by_name": {
490492
"type": "string"
@@ -502,19 +504,22 @@ const docTemplate = `{
502504
"type": "string"
503505
},
504506
"id": {
505-
"type": "string"
507+
"type": "string",
508+
"format": "uuid"
506509
},
507510
"name": {
508511
"type": "string"
509512
},
510513
"organization_id": {
511-
"type": "string"
514+
"type": "string",
515+
"format": "uuid"
512516
},
513517
"provisioner": {
514518
"type": "string"
515519
},
516520
"updated_at": {
517-
"type": "string"
521+
"type": "string",
522+
"format": "date-time"
518523
},
519524
"workspace_owner_count": {
520525
"type": "integer"
@@ -547,13 +552,16 @@ const docTemplate = `{
547552
"type": "string"
548553
},
549554
"created_at": {
550-
"type": "string"
555+
"type": "string",
556+
"format": "date-time"
551557
},
552558
"id": {
553-
"type": "string"
559+
"type": "string",
560+
"format": "uuid"
554561
},
555562
"last_used_at": {
556-
"type": "string"
563+
"type": "string",
564+
"format": "date-time"
557565
},
558566
"latest_build": {
559567
"$ref": "#/definitions/codersdk.WorkspaceBuild"
@@ -565,7 +573,8 @@ const docTemplate = `{
565573
"type": "boolean"
566574
},
567575
"owner_id": {
568-
"type": "string"
576+
"type": "string",
577+
"format": "uuid"
569578
},
570579
"owner_name": {
571580
"type": "string"
@@ -580,7 +589,8 @@ const docTemplate = `{
580589
"type": "string"
581590
},
582591
"template_id": {
583-
"type": "string"
592+
"type": "string",
593+
"format": "uuid"
584594
},
585595
"template_name": {
586596
"type": "string"
@@ -589,7 +599,8 @@ const docTemplate = `{
589599
"type": "integer"
590600
},
591601
"updated_at": {
592-
"type": "string"
602+
"type": "string",
603+
"format": "date-time"
593604
}
594605
}
595606
},

coderd/apidoc/swagger.json

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,12 @@
436436
"$ref": "#/definitions/codersdk.TemplateBuildTimeStats"
437437
},
438438
"created_at": {
439-
"type": "string"
439+
"type": "string",
440+
"format": "date-time"
440441
},
441442
"created_by_id": {
442-
"type": "string"
443+
"type": "string",
444+
"format": "uuid"
443445
},
444446
"created_by_name": {
445447
"type": "string"
@@ -457,19 +459,22 @@
457459
"type": "string"
458460
},
459461
"id": {
460-
"type": "string"
462+
"type": "string",
463+
"format": "uuid"
461464
},
462465
"name": {
463466
"type": "string"
464467
},
465468
"organization_id": {
466-
"type": "string"
469+
"type": "string",
470+
"format": "uuid"
467471
},
468472
"provisioner": {
469473
"type": "string"
470474
},
471475
"updated_at": {
472-
"type": "string"
476+
"type": "string",
477+
"format": "date-time"
473478
},
474479
"workspace_owner_count": {
475480
"type": "integer"
@@ -502,13 +507,16 @@
502507
"type": "string"
503508
},
504509
"created_at": {
505-
"type": "string"
510+
"type": "string",
511+
"format": "date-time"
506512
},
507513
"id": {
508-
"type": "string"
514+
"type": "string",
515+
"format": "uuid"
509516
},
510517
"last_used_at": {
511-
"type": "string"
518+
"type": "string",
519+
"format": "date-time"
512520
},
513521
"latest_build": {
514522
"$ref": "#/definitions/codersdk.WorkspaceBuild"
@@ -520,7 +528,8 @@
520528
"type": "boolean"
521529
},
522530
"owner_id": {
523-
"type": "string"
531+
"type": "string",
532+
"format": "uuid"
524533
},
525534
"owner_name": {
526535
"type": "string"
@@ -535,7 +544,8 @@
535544
"type": "string"
536545
},
537546
"template_id": {
538-
"type": "string"
547+
"type": "string",
548+
"format": "uuid"
539549
},
540550
"template_name": {
541551
"type": "string"
@@ -544,7 +554,8 @@
544554
"type": "integer"
545555
},
546556
"updated_at": {
547-
"type": "string"
557+
"type": "string",
558+
"format": "date-time"
548559
}
549560
}
550561
},

codersdk/templates.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import (
1414
// Template is the JSON representation of a Coder template. This type matches the
1515
// database object for now, but is abstracted for ease of change later on.
1616
type Template struct {
17-
ID uuid.UUID `json:"id"`
18-
CreatedAt time.Time `json:"created_at"`
19-
UpdatedAt time.Time `json:"updated_at"`
20-
OrganizationID uuid.UUID `json:"organization_id"`
17+
ID uuid.UUID `json:"id" format:"uuid"`
18+
CreatedAt time.Time `json:"created_at" format:"date-time"`
19+
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
20+
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
2121
Name string `json:"name"`
2222
DisplayName string `json:"display_name"`
2323
Provisioner ProvisionerType `json:"provisioner"`
@@ -29,7 +29,7 @@ type Template struct {
2929
Description string `json:"description"`
3030
Icon string `json:"icon"`
3131
DefaultTTLMillis int64 `json:"default_ttl_ms"`
32-
CreatedByID uuid.UUID `json:"created_by_id"`
32+
CreatedByID uuid.UUID `json:"created_by_id" format:"uuid"`
3333
CreatedByName string `json:"created_by_name"`
3434

3535
AllowUserCancelWorkspaceJobs bool `json:"allow_user_cancel_workspace_jobs"`

codersdk/workspaces.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import (
1717
// Workspace is a deployment of a template. It references a specific
1818
// version and can be updated.
1919
type Workspace struct {
20-
ID uuid.UUID `json:"id"`
21-
CreatedAt time.Time `json:"created_at"`
22-
UpdatedAt time.Time `json:"updated_at"`
23-
OwnerID uuid.UUID `json:"owner_id"`
20+
ID uuid.UUID `json:"id" format:"uuid"`
21+
CreatedAt time.Time `json:"created_at" format:"date-time"`
22+
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
23+
OwnerID uuid.UUID `json:"owner_id" format:"uuid"`
2424
OwnerName string `json:"owner_name"`
25-
TemplateID uuid.UUID `json:"template_id"`
25+
TemplateID uuid.UUID `json:"template_id" format:"uuid"`
2626
TemplateName string `json:"template_name"`
2727
TemplateDisplayName string `json:"template_display_name"`
2828
TemplateIcon string `json:"template_icon"`
@@ -32,7 +32,7 @@ type Workspace struct {
3232
Name string `json:"name"`
3333
AutostartSchedule *string `json:"autostart_schedule,omitempty"`
3434
TTLMillis *int64 `json:"ttl_ms,omitempty"`
35-
LastUsedAt time.Time `json:"last_used_at"`
35+
LastUsedAt time.Time `json:"last_used_at" format:"date-time"`
3636
}
3737

3838
type WorkspacesRequest struct {

docs/api/schemas.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,18 @@
169169
"p95": 146
170170
}
171171
},
172-
"created_at": "string",
173-
"created_by_id": "string",
172+
"created_at": "2019-08-24T14:15:22Z",
173+
"created_by_id": "9377d689-01fb-4abf-8450-3368d2c1924f",
174174
"created_by_name": "string",
175175
"default_ttl_ms": 0,
176176
"description": "string",
177177
"display_name": "string",
178178
"icon": "string",
179-
"id": "string",
179+
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
180180
"name": "string",
181-
"organization_id": "string",
181+
"organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
182182
"provisioner": "string",
183-
"updated_at": "string",
183+
"updated_at": "2019-08-24T14:15:22Z",
184184
"workspace_owner_count": 0
185185
}
186186
```
@@ -249,9 +249,9 @@
249249
```json
250250
{
251251
"autostart_schedule": "string",
252-
"created_at": "string",
253-
"id": "string",
254-
"last_used_at": "string",
252+
"created_at": "2019-08-24T14:15:22Z",
253+
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
254+
"last_used_at": "2019-08-24T14:15:22Z",
255255
"latest_build": {
256256
"build_number": 0,
257257
"created_at": "string",
@@ -365,15 +365,15 @@
365365
},
366366
"name": "string",
367367
"outdated": true,
368-
"owner_id": "string",
368+
"owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05",
369369
"owner_name": "string",
370370
"template_allow_user_cancel_workspace_jobs": true,
371371
"template_display_name": "string",
372372
"template_icon": "string",
373-
"template_id": "string",
373+
"template_id": "c6d67e98-83ea-49f0-8812-e4abae2b68bc",
374374
"template_name": "string",
375375
"ttl_ms": 0,
376-
"updated_at": "string"
376+
"updated_at": "2019-08-24T14:15:22Z"
377377
}
378378
```
379379

@@ -779,9 +779,9 @@
779779
"workspaces": [
780780
{
781781
"autostart_schedule": "string",
782-
"created_at": "string",
783-
"id": "string",
784-
"last_used_at": "string",
782+
"created_at": "2019-08-24T14:15:22Z",
783+
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
784+
"last_used_at": "2019-08-24T14:15:22Z",
785785
"latest_build": {
786786
"build_number": 0,
787787
"created_at": "string",
@@ -891,15 +891,15 @@
891891
},
892892
"name": "string",
893893
"outdated": true,
894-
"owner_id": "string",
894+
"owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05",
895895
"owner_name": "string",
896896
"template_allow_user_cancel_workspace_jobs": true,
897897
"template_display_name": "string",
898898
"template_icon": "string",
899-
"template_id": "string",
899+
"template_id": "c6d67e98-83ea-49f0-8812-e4abae2b68bc",
900900
"template_name": "string",
901901
"ttl_ms": 0,
902-
"updated_at": "string"
902+
"updated_at": "2019-08-24T14:15:22Z"
903903
}
904904
]
905905
}

docs/api/templates.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,18 @@ curl -X POST http://coder-server:8080/api/v2/organizations/{organization-id}/tem
6464
"p95": 146
6565
}
6666
},
67-
"created_at": "string",
68-
"created_by_id": "string",
67+
"created_at": "2019-08-24T14:15:22Z",
68+
"created_by_id": "9377d689-01fb-4abf-8450-3368d2c1924f",
6969
"created_by_name": "string",
7070
"default_ttl_ms": 0,
7171
"description": "string",
7272
"display_name": "string",
7373
"icon": "string",
74-
"id": "string",
74+
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
7575
"name": "string",
76-
"organization_id": "string",
76+
"organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
7777
"provisioner": "string",
78-
"updated_at": "string",
78+
"updated_at": "2019-08-24T14:15:22Z",
7979
"workspace_owner_count": 0
8080
}
8181
```
@@ -127,18 +127,18 @@ curl -X GET http://coder-server:8080/api/v2/templates/{id} \
127127
"p95": 146
128128
}
129129
},
130-
"created_at": "string",
131-
"created_by_id": "string",
130+
"created_at": "2019-08-24T14:15:22Z",
131+
"created_by_id": "9377d689-01fb-4abf-8450-3368d2c1924f",
132132
"created_by_name": "string",
133133
"default_ttl_ms": 0,
134134
"description": "string",
135135
"display_name": "string",
136136
"icon": "string",
137-
"id": "string",
137+
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
138138
"name": "string",
139-
"organization_id": "string",
139+
"organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
140140
"provisioner": "string",
141-
"updated_at": "string",
141+
"updated_at": "2019-08-24T14:15:22Z",
142142
"workspace_owner_count": 0
143143
}
144144
```

0 commit comments

Comments
 (0)