Skip to content

feat: Under-specified objects are Record<string, unknown> #1032

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 2 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ The following flags can be appended to the CLI command.
| `--http-method` | `-m` | `GET` | Provide the HTTP Verb/Method for fetching a schema from a remote URL |
| `--immutable-types` | | `false` | Generates immutable types (readonly properties and readonly array) |
| `--additional-properties` | | `false` | Allow arbitrary properties for all schema objects without `additionalProperties: false` |
| `--empty-objects-unknown` | | `false` | Allow arbitrary properties for schema objects with no specified properties, and no specified `additionalProperties` |
| `--default-non-nullable` | | `false` | Treat schema objects with default values as non-nullable |
| `--export-type` | `-t` | `false` | Export `type` instead of `interface` |
| `--path-params-as-types` | | `false` | Allow dynamic string lookups on the `paths` object |
Expand Down
3 changes: 3 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Options
--export-type, -t (optional) Export "type" instead of "interface"
--immutable-types (optional) Generates immutable types (readonly properties and readonly array)
--additional-properties (optional) Allow arbitrary properties for all schema objects without "additionalProperties: false"
--empty-objects-unknown (optional) Allow arbitrary properties for schema objects with no specified properties, and no specified "additionalProperties"
--default-non-nullable (optional) If a schema object has a default value set, don’t mark it as nullable
--support-array-length (optional) Generate tuples using array minItems / maxItems
--path-params-as-types (optional) Substitute path parameter names with their respective types
Expand All @@ -46,6 +47,7 @@ const flags = parser(args, {
"help",
"version",
"defaultNonNullable",
"emptyObjectsUnknown",
"immutableTypes",
"contentNever",
"exportType",
Expand Down Expand Up @@ -89,6 +91,7 @@ async function generateSchema(pathToSpec) {
// generate schema
const result = await openapiTS(pathToSpec, {
additionalProperties: flags.additionalProperties,
emptyObjectsUnknown: flags.emptyObjectsUnknown,
auth: flags.auth,
defaultNonNullable: flags.defaultNonNullable,
immutableTypes: flags.immutableTypes,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
operationId: apps_get_logs_active_deployment

summary: Retrieve Active Deployment Logs

description: Retrieve the logs of the active deployment if one exists. The
response will include links to either real-time logs of an in-progress or
active deployment or archived logs of a past deployment. Note log_type=BUILD
logs will return logs associated with the current active deployment (being
served). To view build logs associated with in-progress build, the query must
explicitly reference the deployment id.

tags:
- Apps

parameters:
- $ref: parameters.yml#/app_id
- $ref: parameters.yml#/component
- $ref: parameters.yml#/live_updates
- $ref: parameters.yml#/log_type
- $ref: parameters.yml#/time_wait

responses:
"200":
$ref: responses/list_logs.yml

"401":
$ref: ../../shared/responses/unauthorized.yml

'404':
$ref: '../../shared/responses/not_found.yml'

"429":
$ref: "../../shared/responses/too_many_requests.yml"

"500":
$ref: ../../shared/responses/server_error.yml

default:
$ref: ../../shared/responses/unexpected_error.yml

x-codeSamples:
- $ref: 'examples/curl/apps_get_logs_active_deployment.yml'

security:
- bearer_auth:
- 'read'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for updating this example!

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
operationId: apps_get_logs_active_deployment_aggregate

summary: Retrieve Active Deployment Aggregate Logs

description: Retrieve the logs of the active deployment if one exists. The
response will include links to either real-time logs of an in-progress or
active deployment or archived logs of a past deployment. Note log_type=BUILD
logs will return logs associated with the current active deployment (being
served). To view build logs associated with in-progress build, the query must
explicitly reference the deployment id.

tags:
- Apps

parameters:
- $ref: parameters.yml#/app_id
- $ref: parameters.yml#/live_updates
- $ref: parameters.yml#/log_type
- $ref: parameters.yml#/time_wait

responses:
"200":
$ref: responses/list_logs.yml

"401":
$ref: ../../shared/responses/unauthorized.yml

'404':
$ref: '../../shared/responses/not_found.yml'

"429":
$ref: "../../shared/responses/too_many_requests.yml"

"500":
$ref: ../../shared/responses/server_error.yml

default:
$ref: ../../shared/responses/unexpected_error.yml

x-codeSamples:
- $ref: 'examples/curl/apps_get_logs_active_deployment_aggregate.yml'

security:
- bearer_auth:
- 'read'

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
operationId: apps_get_logs_aggregate

summary: Retrieve Aggregate Deployment Logs

description: Retrieve the logs of a past, in-progress, or active deployment. If a
component name is specified, the logs will be limited to only that component. The
response will include links to either real-time logs of an in-progress or active
deployment or archived logs of a past deployment.

tags:
- Apps

parameters:
- $ref: parameters.yml#/app_id
- $ref: parameters.yml#/deployment_id
- $ref: parameters.yml#/live_updates
- $ref: parameters.yml#/log_type
- $ref: parameters.yml#/time_wait

responses:
"200":
$ref: responses/list_logs.yml

"401":
$ref: ../../shared/responses/unauthorized.yml

'404':
$ref: '../../shared/responses/not_found.yml'

"429":
$ref: "../../shared/responses/too_many_requests.yml"

"500":
$ref: ../../shared/responses/server_error.yml

default:
$ref: ../../shared/responses/unexpected_error.yml

x-codeSamples:
- $ref: 'examples/curl/apps_get_logs_aggregate.yml'

security:
- bearer_auth:
- 'read'

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
operationId: apps_get_metrics_bandwidth_daily

summary: 'Retrieve App Daily Bandwidth Metrics'

description: 'Retrieve daily bandwidth usage metrics for a single app.'

tags:
- Apps

parameters:
- $ref: parameters.yml#/app_id
- name: date
description: 'Optional day to query. Only the date component of the timestamp will be considered. Default: yesterday.'
in: query
schema:
type: string
format: date-time
example: 2023-01-17T00:00:00Z

responses:
"200":
$ref: responses/get_metrics_bandwidth_usage.yml

"401":
$ref: ../../shared/responses/unauthorized.yml

"404":
$ref: ../../shared/responses/not_found.yml

"429":
$ref: ../../shared/responses/too_many_requests.yml

"500":
$ref: ../../shared/responses/server_error.yml

default:
$ref: ../../shared/responses/unexpected_error.yml

x-codeSamples:
- $ref: examples/curl/apps_get_metrics_bandwidth_usage.yml

security:
- bearer_auth:
- read
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
operationId: apps_list_metrics_bandwidth_daily

summary: "Retrieve Multiple Apps' Daily Bandwidth Metrics"

description: 'Retrieve daily bandwidth usage metrics for multiple apps.'

tags:
- Apps

requestBody:
content:
application/json:
schema:
$ref: models/app_metrics_bandwidth_usage_request.yml
example:
app_ids:
- 4f6c71e2-1e90-4762-9fee-6cc4a0a9f2cf
- c2a93513-8d9b-4223-9d61-5e7272c81cf5
date: 2023-01-17T00:00:00Z
required: true

responses:
"200":
$ref: responses/list_metrics_bandwidth_usage.yml

"401":
$ref: ../../shared/responses/unauthorized.yml

"404":
$ref: ../../shared/responses/not_found.yml

"429":
$ref: ../../shared/responses/too_many_requests.yml

"500":
$ref: ../../shared/responses/server_error.yml

default:
$ref: ../../shared/responses/unexpected_error.yml

x-codeSamples:
- $ref: examples/curl/apps_list_metrics_bandwidth_usage.yml

security:
- bearer_auth:
- read
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/apps/{app_id}/components/{component_name}/logs"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/apps/{app_id}/logs"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/apps/{app_id}/deployments/{deployment_id}/logs"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/apps/{id}/metrics/bandwidth_daily"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lang: cURL
source: |-
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/apps/metrics/bandwidth_daily" \
-d '{ "app_ids": ["4f6c71e2-1e90-4762-9fee-6cc4a0a9f2cf"] }'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
properties:
"txt_name":
title: "TXT record name"
type: string
readOnly: true
example: "_acme-challenge.app.example.com"
"txt_value":
title: "TXT record value"
type: string
readOnly: true
example: "lXLOcN6cPv0nproViNcUHcahD9TrIPlNgdwesj0pYpk"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type: object
properties:
app_bandwidth_usage:
type: array
items:
$ref: ../models/app_metrics_bandwidth_usage_details.yml
description: 'A list of bandwidth usage details by app.'
date:
type: string
format: date-time
description: 'The date for the metrics data.'
example: 2023-01-17T00:00:00Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type: object
properties:
app_id:
type: string
description: 'The ID of the app.'
example: 4f6c71e2-1e90-4762-9fee-6cc4a0a9f2cf
bandwidth_bytes:
type: string
format: uint64
description: 'The used bandwidth amount in bytes.'
example: '513668'
description: 'Bandwidth usage for an app.'
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
type: object
properties:
app_ids:
type: array
items:
type: string
description: 'A list of app IDs to query bandwidth metrics for.'
maxItems: 100
example:
- 4f6c71e2-1e90-4762-9fee-6cc4a0a9f2cf
- c2a93513-8d9b-4223-9d61-5e7272c81cf5
date:
type: string
format: date-time
description: 'Optional day to query. Only the date component of the timestamp will be considered. Default: yesterday.'
example: 2023-01-17T00:00:00Z
required:
- app_ids
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
description: 'A JSON object with a `app_bandwidth_usage` key'

content:
application/json:
schema:
$ref: ../models/app_metrics_bandwidth_usage.yml
examples:
app_bandwidth_usage:
$ref: examples.yml#/app_bandwidth_usage

headers:
ratelimit-limit:
$ref: ../../../shared/headers.yml#/ratelimit-limit
ratelimit-remaining:
$ref: ../../../shared/headers.yml#/ratelimit-remaining
ratelimit-reset:
$ref: ../../../shared/headers.yml#/ratelimit-reset
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
description: 'A JSON object with a `app_bandwidth_usage` key'

content:
application/json:
schema:
$ref: ../models/app_metrics_bandwidth_usage.yml
examples:
app_bandwidth_usage:
$ref: examples.yml#/app_bandwidth_usage_multiple

headers:
ratelimit-limit:
$ref: ../../../shared/headers.yml#/ratelimit-limit
ratelimit-remaining:
$ref: ../../../shared/headers.yml#/ratelimit-remaining
ratelimit-reset:
$ref: ../../../shared/headers.yml#/ratelimit-reset
Loading