Skip to content

Commit 230d34a

Browse files
committed
Fix: show format in docs
1 parent c13dc1c commit 230d34a

File tree

9 files changed

+58
-40
lines changed

9 files changed

+58
-40
lines changed

coderd/apidoc/docs.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,8 @@ const docTemplate = `{
19831983
"type": "object",
19841984
"properties": {
19851985
"created_at": {
1986-
"type": "string"
1986+
"type": "string",
1987+
"format": "date-time"
19871988
},
19881989
"destination_scheme": {
19891990
"type": "string",
@@ -2020,7 +2021,8 @@ const docTemplate = `{
20202021
]
20212022
},
20222023
"updated_at": {
2023-
"type": "string"
2024+
"type": "string",
2025+
"format": "date-time"
20242026
}
20252027
}
20262028
},
@@ -2340,7 +2342,8 @@ const docTemplate = `{
23402342
"type": "object",
23412343
"properties": {
23422344
"hash": {
2343-
"type": "string"
2345+
"type": "string",
2346+
"format": "uuid"
23442347
}
23452348
}
23462349
},

coderd/apidoc/swagger.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,8 @@
18031803
"type": "object",
18041804
"properties": {
18051805
"created_at": {
1806-
"type": "string"
1806+
"type": "string",
1807+
"format": "date-time"
18071808
},
18081809
"destination_scheme": {
18091810
"type": "string",
@@ -1829,7 +1830,8 @@
18291830
"enum": ["none", "data"]
18301831
},
18311832
"updated_at": {
1832-
"type": "string"
1833+
"type": "string",
1834+
"format": "date-time"
18331835
}
18341836
}
18351837
},
@@ -2147,7 +2149,8 @@
21472149
"type": "object",
21482150
"properties": {
21492151
"hash": {
2150-
"type": "string"
2152+
"type": "string",
2153+
"format": "uuid"
21512154
}
21522155
}
21532156
},

codersdk/files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616

1717
// UploadResponse contains the hash to reference the uploaded file.
1818
type UploadResponse struct {
19-
ID uuid.UUID `json:"hash"`
19+
ID uuid.UUID `json:"hash" format:"uuid"`
2020
}
2121

2222
// Upload uploads an arbitrary file with the content type provided.

codersdk/parameters.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const (
4444
type ComputedParameter struct {
4545
Parameter
4646
SourceValue string `json:"source_value"`
47-
SchemaID uuid.UUID `json:"schema_id"`
47+
SchemaID uuid.UUID `json:"schema_id" format:"uuid"`
4848
DefaultSourceValue bool `json:"default_source_value"`
4949
}
5050

@@ -58,20 +58,20 @@ type Parameter struct {
5858
Name string `json:"name" table:"name"`
5959
SourceScheme ParameterSourceScheme `json:"source_scheme" table:"source scheme" validate:"ne=none" enums:"none,data"`
6060
DestinationScheme ParameterDestinationScheme `json:"destination_scheme" table:"destination scheme" validate:"ne=none" enums:"none,environment_variable,provisioner_variable"`
61-
CreatedAt time.Time `json:"created_at" table:"created at"`
62-
UpdatedAt time.Time `json:"updated_at" table:"updated at"`
61+
CreatedAt time.Time `json:"created_at" table:"created at" format:"date-time"`
62+
UpdatedAt time.Time `json:"updated_at" table:"updated at" format:"date-time"`
6363
}
6464

6565
type ParameterSchema struct {
66-
ID uuid.UUID `json:"id"`
67-
CreatedAt time.Time `json:"created_at"`
68-
JobID uuid.UUID `json:"job_id"`
66+
ID uuid.UUID `json:"id" format:"uuid"`
67+
CreatedAt time.Time `json:"created_at" format:"date-time"`
68+
JobID uuid.UUID `json:"job_id" format:"uuid"`
6969
Name string `json:"name"`
7070
Description string `json:"description"`
71-
DefaultSourceScheme ParameterSourceScheme `json:"default_source_scheme"`
71+
DefaultSourceScheme ParameterSourceScheme `json:"default_source_scheme" enums:"none,data"`
7272
DefaultSourceValue string `json:"default_source_value"`
7373
AllowOverrideSource bool `json:"allow_override_source"`
74-
DefaultDestinationScheme ParameterDestinationScheme `json:"default_destination_scheme"`
74+
DefaultDestinationScheme ParameterDestinationScheme `json:"default_destination_scheme" enums:"none,environment_variable,provisioner_variable"`
7575
AllowOverrideDestination bool `json:"allow_override_destination"`
7676
DefaultRefresh string `json:"default_refresh"`
7777
RedisplayValue bool `json:"redisplay_value"`

docs/api/files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ file: string
3838

3939
```json
4040
{
41-
"hash": "string"
41+
"hash": "19686d84-b10d-4f90-b18e-84fd3fa038fd"
4242
}
4343
```
4444

docs/api/parameters.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ curl -X GET http://coder-server:8080/api/v2/parameters/{scope}/{id} \
3737
```json
3838
[
3939
{
40-
"created_at": "string",
40+
"created_at": "2019-08-24T14:15:22Z",
4141
"destination_scheme": "none",
4242
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
4343
"name": "string",
4444
"scope": "template",
4545
"scope_id": "5d3fe357-12dd-4f62-b004-6d1fb3b8454f",
4646
"source_scheme": "none",
47-
"updated_at": "string"
47+
"updated_at": "2019-08-24T14:15:22Z"
4848
}
4949
]
5050
```
@@ -59,17 +59,17 @@ curl -X GET http://coder-server:8080/api/v2/parameters/{scope}/{id} \
5959

6060
Status Code **200**
6161

62-
| Name | Type | Required | Restrictions | Description |
63-
| ---------------------- | ------ | -------- | ------------ | ------------------------------------------------- |
64-
| `[array item]` | array | false | | [Parameter represents a set value for the scope.] |
65-
| `» created_at` | string | false | | |
66-
| `» destination_scheme` | string | false | | |
67-
| `» id` | string | false | | |
68-
| `» name` | string | false | | |
69-
| `» scope` | string | false | | |
70-
| `» scope_id` | string | false | | |
71-
| `» source_scheme` | string | false | | |
72-
| `» updated_at` | string | false | | |
62+
| Name | Type | Required | Restrictions | Description |
63+
| ---------------------- | ----------------- | -------- | ------------ | ------------------------------------------------- |
64+
| `[array item]` | array | false | | [Parameter represents a set value for the scope.] |
65+
| `» created_at` | string(date-time) | false | | |
66+
| `» destination_scheme` | string | false | | |
67+
| `» id` | string(uuid) | false | | |
68+
| `» name` | string | false | | |
69+
| `» scope` | string | false | | |
70+
| `» scope_id` | string(uuid) | false | | |
71+
| `» source_scheme` | string | false | | |
72+
| `» updated_at` | string(date-time) | false | | |
7373

7474
#### Enumerated Values
7575

@@ -134,14 +134,14 @@ curl -X POST http://coder-server:8080/api/v2/parameters/{scope}/{id} \
134134
135135
```json
136136
{
137-
"created_at": "string",
137+
"created_at": "2019-08-24T14:15:22Z",
138138
"destination_scheme": "none",
139139
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
140140
"name": "string",
141141
"scope": "template",
142142
"scope_id": "5d3fe357-12dd-4f62-b004-6d1fb3b8454f",
143143
"source_scheme": "none",
144-
"updated_at": "string"
144+
"updated_at": "2019-08-24T14:15:22Z"
145145
}
146146
```
147147

docs/api/schemas.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,14 +2092,14 @@ CreateParameterRequest is a structure used to create a new parameter value for a
20922092

20932093
```json
20942094
{
2095-
"created_at": "string",
2095+
"created_at": "2019-08-24T14:15:22Z",
20962096
"destination_scheme": "none",
20972097
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
20982098
"name": "string",
20992099
"scope": "template",
21002100
"scope_id": "5d3fe357-12dd-4f62-b004-6d1fb3b8454f",
21012101
"source_scheme": "none",
2102-
"updated_at": "string"
2102+
"updated_at": "2019-08-24T14:15:22Z"
21032103
}
21042104
```
21052105

@@ -2760,7 +2760,7 @@ Parameter represents a set value for the scope.
27602760

27612761
```json
27622762
{
2763-
"hash": "string"
2763+
"hash": "19686d84-b10d-4f90-b18e-84fd3fa038fd"
27642764
}
27652765
```
27662766

docs/api/templates.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,18 @@ Status Code **200**
165165
| `»» [any property]` | `codersdk.TransitionStats` | false | | |
166166
| `»»» p50` | integer | false | | |
167167
| `»»» p95` | integer | false | | |
168-
| `» created_at` | string | false | | |
169-
| `» created_by_id` | string | false | | |
168+
| `» created_at` | string(date-time) | false | | |
169+
| `» created_by_id` | string(uuid) | false | | |
170170
| `» created_by_name` | string | false | | |
171171
| `» default_ttl_ms` | integer | false | | |
172172
| `» description` | string | false | | |
173173
| `» display_name` | string | false | | |
174174
| `» icon` | string | false | | |
175-
| `» id` | string | false | | |
175+
| `» id` | string(uuid) | false | | |
176176
| `» name` | string | false | | |
177-
| `» organization_id` | string | false | | |
177+
| `» organization_id` | string(uuid) | false | | |
178178
| `» provisioner` | string | false | | |
179-
| `» updated_at` | string | false | | |
179+
| `» updated_at` | string(date-time) | false | | |
180180
| `» workspace_owner_count` | integer | false | | |
181181

182182
To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.

scripts/apidocgen/markdown-template/responses.def

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@
3232
let displayName = p.displayName.replace("**additionalProperties**", "[any property]");
3333
return displayName;
3434
}
35+
36+
function renderResponsePropertyType(p) {
37+
if (p.$ref) {
38+
return '`' + p.$ref + '`';
39+
}
40+
41+
if (p.type == 'array') {
42+
return p.type;
43+
}
44+
45+
return p.safeType;
46+
}
3547
}}
3648
{{ data.responses = data.utils.getResponses(data); }}
3749
{{ data.responseSchemas = false; }}
@@ -85,7 +97,7 @@ Status Code **{{=response.status}}**
8597
{{?}}
8698
|Name|Type|Required|Restrictions|Description|
8799
|---|---|---|---|---|
88-
{{~block.rows :p}}|`{{=renderDisplayName(p)}}`|{{? p.$ref}}`{{=p.$ref}}`{{?}}{{? !p.$ref}}{{=p.type}}{{?}}|{{=p.required}}|{{=p.restrictions||''}}|{{=p.description||''}}|
100+
{{~block.rows :p}}|`{{=renderDisplayName(p)}}`|{{=renderResponsePropertyType(p)}}|{{=p.required}}|{{=p.restrictions||''}}|{{=p.description||''}}|
89101
{{~}}
90102
{{~}}
91103
{{?}}

0 commit comments

Comments
 (0)