Skip to content

Commit 69a245d

Browse files
feat: Under-specified objects are Record<string, unknown> (#1032)
* chore: Run update:examples * feat: Under-specified objects are Record<string, unknown>
1 parent 728c361 commit 69a245d

File tree

63 files changed

+1203
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1203
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ The following flags can be appended to the CLI command.
149149
| `--http-method` | `-m` | `GET` | Provide the HTTP Verb/Method for fetching a schema from a remote URL |
150150
| `--immutable-types` | | `false` | Generates immutable types (readonly properties and readonly array) |
151151
| `--additional-properties` | | `false` | Allow arbitrary properties for all schema objects without `additionalProperties: false` |
152+
| `--empty-objects-unknown` | | `false` | Allow arbitrary properties for schema objects with no specified properties, and no specified `additionalProperties` |
152153
| `--default-non-nullable` | | `false` | Treat schema objects with default values as non-nullable |
153154
| `--export-type` | `-t` | `false` | Export `type` instead of `interface` |
154155
| `--path-params-as-types` | | `false` | Allow dynamic string lookups on the `paths` object |

bin/cli.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Options
2222
--export-type, -t (optional) Export "type" instead of "interface"
2323
--immutable-types (optional) Generates immutable types (readonly properties and readonly array)
2424
--additional-properties (optional) Allow arbitrary properties for all schema objects without "additionalProperties: false"
25+
--empty-objects-unknown (optional) Allow arbitrary properties for schema objects with no specified properties, and no specified "additionalProperties"
2526
--default-non-nullable (optional) If a schema object has a default value set, don’t mark it as nullable
2627
--support-array-length (optional) Generate tuples using array minItems / maxItems
2728
--path-params-as-types (optional) Substitute path parameter names with their respective types
@@ -46,6 +47,7 @@ const flags = parser(args, {
4647
"help",
4748
"version",
4849
"defaultNonNullable",
50+
"emptyObjectsUnknown",
4951
"immutableTypes",
5052
"contentNever",
5153
"exportType",
@@ -89,6 +91,7 @@ async function generateSchema(pathToSpec) {
8991
// generate schema
9092
const result = await openapiTS(pathToSpec, {
9193
additionalProperties: flags.additionalProperties,
94+
emptyObjectsUnknown: flags.emptyObjectsUnknown,
9295
auth: flags.auth,
9396
defaultNonNullable: flags.defaultNonNullable,
9497
immutableTypes: flags.immutableTypes,
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
operationId: apps_get_logs_active_deployment
2+
3+
summary: Retrieve Active Deployment Logs
4+
5+
description: Retrieve the logs of the active deployment if one exists. The
6+
response will include links to either real-time logs of an in-progress or
7+
active deployment or archived logs of a past deployment. Note log_type=BUILD
8+
logs will return logs associated with the current active deployment (being
9+
served). To view build logs associated with in-progress build, the query must
10+
explicitly reference the deployment id.
11+
12+
tags:
13+
- Apps
14+
15+
parameters:
16+
- $ref: parameters.yml#/app_id
17+
- $ref: parameters.yml#/component
18+
- $ref: parameters.yml#/live_updates
19+
- $ref: parameters.yml#/log_type
20+
- $ref: parameters.yml#/time_wait
21+
22+
responses:
23+
"200":
24+
$ref: responses/list_logs.yml
25+
26+
"401":
27+
$ref: ../../shared/responses/unauthorized.yml
28+
29+
'404':
30+
$ref: '../../shared/responses/not_found.yml'
31+
32+
"429":
33+
$ref: "../../shared/responses/too_many_requests.yml"
34+
35+
"500":
36+
$ref: ../../shared/responses/server_error.yml
37+
38+
default:
39+
$ref: ../../shared/responses/unexpected_error.yml
40+
41+
x-codeSamples:
42+
- $ref: 'examples/curl/apps_get_logs_active_deployment.yml'
43+
44+
security:
45+
- bearer_auth:
46+
- 'read'
47+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
operationId: apps_get_logs_active_deployment_aggregate
2+
3+
summary: Retrieve Active Deployment Aggregate Logs
4+
5+
description: Retrieve the logs of the active deployment if one exists. The
6+
response will include links to either real-time logs of an in-progress or
7+
active deployment or archived logs of a past deployment. Note log_type=BUILD
8+
logs will return logs associated with the current active deployment (being
9+
served). To view build logs associated with in-progress build, the query must
10+
explicitly reference the deployment id.
11+
12+
tags:
13+
- Apps
14+
15+
parameters:
16+
- $ref: parameters.yml#/app_id
17+
- $ref: parameters.yml#/live_updates
18+
- $ref: parameters.yml#/log_type
19+
- $ref: parameters.yml#/time_wait
20+
21+
responses:
22+
"200":
23+
$ref: responses/list_logs.yml
24+
25+
"401":
26+
$ref: ../../shared/responses/unauthorized.yml
27+
28+
'404':
29+
$ref: '../../shared/responses/not_found.yml'
30+
31+
"429":
32+
$ref: "../../shared/responses/too_many_requests.yml"
33+
34+
"500":
35+
$ref: ../../shared/responses/server_error.yml
36+
37+
default:
38+
$ref: ../../shared/responses/unexpected_error.yml
39+
40+
x-codeSamples:
41+
- $ref: 'examples/curl/apps_get_logs_active_deployment_aggregate.yml'
42+
43+
security:
44+
- bearer_auth:
45+
- 'read'
46+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
operationId: apps_get_logs_aggregate
2+
3+
summary: Retrieve Aggregate Deployment Logs
4+
5+
description: Retrieve the logs of a past, in-progress, or active deployment. If a
6+
component name is specified, the logs will be limited to only that component. The
7+
response will include links to either real-time logs of an in-progress or active
8+
deployment or archived logs of a past deployment.
9+
10+
tags:
11+
- Apps
12+
13+
parameters:
14+
- $ref: parameters.yml#/app_id
15+
- $ref: parameters.yml#/deployment_id
16+
- $ref: parameters.yml#/live_updates
17+
- $ref: parameters.yml#/log_type
18+
- $ref: parameters.yml#/time_wait
19+
20+
responses:
21+
"200":
22+
$ref: responses/list_logs.yml
23+
24+
"401":
25+
$ref: ../../shared/responses/unauthorized.yml
26+
27+
'404':
28+
$ref: '../../shared/responses/not_found.yml'
29+
30+
"429":
31+
$ref: "../../shared/responses/too_many_requests.yml"
32+
33+
"500":
34+
$ref: ../../shared/responses/server_error.yml
35+
36+
default:
37+
$ref: ../../shared/responses/unexpected_error.yml
38+
39+
x-codeSamples:
40+
- $ref: 'examples/curl/apps_get_logs_aggregate.yml'
41+
42+
security:
43+
- bearer_auth:
44+
- 'read'
45+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
operationId: apps_get_metrics_bandwidth_daily
2+
3+
summary: 'Retrieve App Daily Bandwidth Metrics'
4+
5+
description: 'Retrieve daily bandwidth usage metrics for a single app.'
6+
7+
tags:
8+
- Apps
9+
10+
parameters:
11+
- $ref: parameters.yml#/app_id
12+
- name: date
13+
description: 'Optional day to query. Only the date component of the timestamp will be considered. Default: yesterday.'
14+
in: query
15+
schema:
16+
type: string
17+
format: date-time
18+
example: 2023-01-17T00:00:00Z
19+
20+
responses:
21+
"200":
22+
$ref: responses/get_metrics_bandwidth_usage.yml
23+
24+
"401":
25+
$ref: ../../shared/responses/unauthorized.yml
26+
27+
"404":
28+
$ref: ../../shared/responses/not_found.yml
29+
30+
"429":
31+
$ref: ../../shared/responses/too_many_requests.yml
32+
33+
"500":
34+
$ref: ../../shared/responses/server_error.yml
35+
36+
default:
37+
$ref: ../../shared/responses/unexpected_error.yml
38+
39+
x-codeSamples:
40+
- $ref: examples/curl/apps_get_metrics_bandwidth_usage.yml
41+
42+
security:
43+
- bearer_auth:
44+
- read
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
operationId: apps_list_metrics_bandwidth_daily
2+
3+
summary: "Retrieve Multiple Apps' Daily Bandwidth Metrics"
4+
5+
description: 'Retrieve daily bandwidth usage metrics for multiple apps.'
6+
7+
tags:
8+
- Apps
9+
10+
requestBody:
11+
content:
12+
application/json:
13+
schema:
14+
$ref: models/app_metrics_bandwidth_usage_request.yml
15+
example:
16+
app_ids:
17+
- 4f6c71e2-1e90-4762-9fee-6cc4a0a9f2cf
18+
- c2a93513-8d9b-4223-9d61-5e7272c81cf5
19+
date: 2023-01-17T00:00:00Z
20+
required: true
21+
22+
responses:
23+
"200":
24+
$ref: responses/list_metrics_bandwidth_usage.yml
25+
26+
"401":
27+
$ref: ../../shared/responses/unauthorized.yml
28+
29+
"404":
30+
$ref: ../../shared/responses/not_found.yml
31+
32+
"429":
33+
$ref: ../../shared/responses/too_many_requests.yml
34+
35+
"500":
36+
$ref: ../../shared/responses/server_error.yml
37+
38+
default:
39+
$ref: ../../shared/responses/unexpected_error.yml
40+
41+
x-codeSamples:
42+
- $ref: examples/curl/apps_list_metrics_bandwidth_usage.yml
43+
44+
security:
45+
- bearer_auth:
46+
- read
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lang: cURL
2+
source: |-
3+
curl -X GET \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
"https://api.digitalocean.com/v2/apps/{app_id}/components/{component_name}/logs"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lang: cURL
2+
source: |-
3+
curl -X GET \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
"https://api.digitalocean.com/v2/apps/{app_id}/logs"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lang: cURL
2+
source: |-
3+
curl -X GET \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
"https://api.digitalocean.com/v2/apps/{app_id}/deployments/{deployment_id}/logs"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lang: cURL
2+
source: |-
3+
curl -X GET \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
"https://api.digitalocean.com/v2/apps/{id}/metrics/bandwidth_daily"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
lang: cURL
2+
source: |-
3+
curl -X POST \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
"https://api.digitalocean.com/v2/apps/metrics/bandwidth_daily" \
7+
-d '{ "app_ids": ["4f6c71e2-1e90-4762-9fee-6cc4a0a9f2cf"] }'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
properties:
2+
"txt_name":
3+
title: "TXT record name"
4+
type: string
5+
readOnly: true
6+
example: "_acme-challenge.app.example.com"
7+
"txt_value":
8+
title: "TXT record value"
9+
type: string
10+
readOnly: true
11+
example: "lXLOcN6cPv0nproViNcUHcahD9TrIPlNgdwesj0pYpk"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
type: object
2+
properties:
3+
app_bandwidth_usage:
4+
type: array
5+
items:
6+
$ref: ../models/app_metrics_bandwidth_usage_details.yml
7+
description: 'A list of bandwidth usage details by app.'
8+
date:
9+
type: string
10+
format: date-time
11+
description: 'The date for the metrics data.'
12+
example: 2023-01-17T00:00:00Z
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
type: object
2+
properties:
3+
app_id:
4+
type: string
5+
description: 'The ID of the app.'
6+
example: 4f6c71e2-1e90-4762-9fee-6cc4a0a9f2cf
7+
bandwidth_bytes:
8+
type: string
9+
format: uint64
10+
description: 'The used bandwidth amount in bytes.'
11+
example: '513668'
12+
description: 'Bandwidth usage for an app.'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
type: object
2+
properties:
3+
app_ids:
4+
type: array
5+
items:
6+
type: string
7+
description: 'A list of app IDs to query bandwidth metrics for.'
8+
maxItems: 100
9+
example:
10+
- 4f6c71e2-1e90-4762-9fee-6cc4a0a9f2cf
11+
- c2a93513-8d9b-4223-9d61-5e7272c81cf5
12+
date:
13+
type: string
14+
format: date-time
15+
description: 'Optional day to query. Only the date component of the timestamp will be considered. Default: yesterday.'
16+
example: 2023-01-17T00:00:00Z
17+
required:
18+
- app_ids
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
description: 'A JSON object with a `app_bandwidth_usage` key'
2+
3+
content:
4+
application/json:
5+
schema:
6+
$ref: ../models/app_metrics_bandwidth_usage.yml
7+
examples:
8+
app_bandwidth_usage:
9+
$ref: examples.yml#/app_bandwidth_usage
10+
11+
headers:
12+
ratelimit-limit:
13+
$ref: ../../../shared/headers.yml#/ratelimit-limit
14+
ratelimit-remaining:
15+
$ref: ../../../shared/headers.yml#/ratelimit-remaining
16+
ratelimit-reset:
17+
$ref: ../../../shared/headers.yml#/ratelimit-reset
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
description: 'A JSON object with a `app_bandwidth_usage` key'
2+
3+
content:
4+
application/json:
5+
schema:
6+
$ref: ../models/app_metrics_bandwidth_usage.yml
7+
examples:
8+
app_bandwidth_usage:
9+
$ref: examples.yml#/app_bandwidth_usage_multiple
10+
11+
headers:
12+
ratelimit-limit:
13+
$ref: ../../../shared/headers.yml#/ratelimit-limit
14+
ratelimit-remaining:
15+
$ref: ../../../shared/headers.yml#/ratelimit-remaining
16+
ratelimit-reset:
17+
$ref: ../../../shared/headers.yml#/ratelimit-reset

0 commit comments

Comments
 (0)