Skip to content

Remove undefined from additionalProperties union #1799

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
Aug 2, 2024
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
5 changes: 5 additions & 0 deletions .changeset/spotty-donuts-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-typescript": minor
---

Don’t generate `| undefined` for additionalProperties
2 changes: 1 addition & 1 deletion docs/data/contributors.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions docs/scripts/update-contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,12 @@ async function main() {
? OPENAPI_REACT_QUERY_CONTRIBUTORS
: OPENAPI_TS_CONTRIBUTORS;
for (const username of userlist) {
i++;
// skip profiles that have been updated within the past week
const { lastFetch } = contributors[repo].find((u) => u.username === username) ?? { lastFetch: 0 };
if (Date.now() - lastFetch < ONE_MONTH) {
// biome-ignore lint/suspicious/noConsoleLog: this is a script
console.log(`[${i}/${total}] (Skipped ${username})`);
continue;
}

Expand All @@ -212,11 +215,10 @@ async function main() {
lastFetch: new Date().getTime(),
};
upsert(contributors[repo], userData);
i++;
// biome-ignore lint/suspicious/noConsoleLog: this is a script
// biome-ignore lint/suspicious/noConsoleLog: this is a script
console.log(`[${i}/${total}] Updated for ${username}`);
fs.writeFileSync(new URL("../data/contributors.json", import.meta.url), JSON.stringify(contributors)); // update file while fetching (sync happens safely in between fetches)
await new Promise((resolve) => setTimeout(resolve, 900)); // sleep to prevent 429
await new Promise((resolve) => setTimeout(resolve, 1000)); // sleep to prevent 429
} catch (err) {
throw new Error(err);
}
Expand Down
749 changes: 694 additions & 55 deletions packages/openapi-typescript/examples/digital-ocean-api.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ tags:
simplifies the creation and management of highly available database clusters. Currently, it
offers support for [PostgreSQL](http://www.digitalocean.com/docs/databases/postgresql/),
[Redis](https://www.digitalocean.com/docs/databases/redis/),
[MySQL](https://www.digitalocean.com/docs/databases/mysql/), and
[MongoDB](https://www.digitalocean.com/docs/databases/mongodb/).
[MySQL](https://www.digitalocean.com/docs/databases/mysql/),
[MongoDB](https://www.digitalocean.com/docs/databases/mongodb/), and
[OpenSearch](https://docs.digitalocean.com/products/databases/opensearch/).

By sending requests to the `/v2/databases` endpoint, you can list, create, or delete
database clusters as well as scale the size of a cluster, add or remove read-only replicas,
Expand Down Expand Up @@ -839,6 +840,21 @@ paths:
$ref: 'resources/databases/databases_update_kafka_topic.yml'
delete:
$ref: 'resources/databases/databases_delete_kafka_topic.yml'

/v2/databases/{database_cluster_uuid}/logsink:
get:
$ref: 'resources/databases/databases_list_logsink.yml'
post:
$ref: 'resources/databases/databases_create_logsink.yml'

/v2/databases/{database_cluster_uuid}/logsink/{logsink_id}:
get:
$ref: 'resources/databases/databases_get_logsink.yml'
put:
$ref: 'resources/databases/databases_update_logsink.yml'
delete:
$ref: 'resources/databases/databases_delete_logsink.yml'


/v2/databases/metrics/credentials:
get:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ responses:

security:
- bearer_auth:
- 'app:create'
- 'app:read'

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ source: |-
"token": "abcdefghijklmnopqrstuvwxyz0123456789"
},
"open_search": {
"endpoint": "myopensearchendpoint.com:9300"
"endpoint": "https://myopensearchendpoint.com:9300"
"index_name": "logs"
"basic_auth": {
"user": "doadmin",
Expand Down Expand Up @@ -134,7 +134,7 @@ source: |-
"token": "abcdefghijklmnopqrstuvwxyz0123456789"
},
"open_search": {
"endpoint": "myopensearchendpoint.com:9300"
"endpoint": "https://myopensearchendpoint.com:9300"
"index_name": "logs"
"basic_auth": {
"user": "doadmin",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
type: object
properties:
cluster_name:
description: The name of the underlying DigitalOcean DBaaS cluster. This is required
description:
The name of the underlying DigitalOcean DBaaS cluster. This is required
for production databases. For dev databases, if cluster_name is not set, a new
cluster will be provisioned.
type: string
Expand All @@ -21,22 +22,24 @@ properties:
type: string
default: UNSET
enum:
- UNSET
- MYSQL
- PG
- REDIS
- MONGODB
- KAFKA
- UNSET
- MYSQL
- PG
- REDIS
- MONGODB
- KAFKA
- OPENSEARCH
description: |-
- MYSQL: MySQL
- PG: PostgreSQL
- REDIS: Redis
- MONGODB: MongoDB
- KAFKA: Kafka
- OPENSEARCH: OpenSearch
example: PG

name:
description: The name. Must be unique across all components within the same app.
description: The database's name. The name must be unique across all components within the same app and cannot use capital letters.
maxLength: 32
minLength: 2
pattern: ^[a-z][a-z0-9-]{0,30}[a-z0-9]$
Expand All @@ -54,4 +57,4 @@ properties:
example: "12"

required:
- name
- name
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ type: object
properties:
endpoint:
type: string
description: >-
OpenSearch API Endpoint. Only HTTPS is supported. Format: `https://<host>:<port>`.
description: |-
OpenSearch API Endpoint. Only HTTPS is supported. Format: https://<host>:<port>.
Cannot be specified if `cluster_name` is also specified.
example: "https://example.com:9300"
basic_auth:
$ref: app_log_destination_open_search_spec_basic_auth.yml
Expand All @@ -14,6 +15,10 @@ properties:
The index name to use for the logs. If not set, the default index name
is "logs".
example: logs
cluster_name:
type: string
description: |-
The name of a DigitalOcean DBaaS OpenSearch cluster to use as a log forwarding destination.
Cannot be specified if `endpoint` is also specified.
example: my-opensearch-cluster
description: OpenSearch configuration.
required:
- endpoint
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ type: object
properties:
user:
type: string
description: Username to authenticate with.
description: |-
Username to authenticate with. Only required when `endpoint` is set.
Defaults to `doadmin` when `cluster_name` is set.
example: apps_user
password:
type: string
description: Password for user defined in User.
description: |-
Password for user defined in User. Is required when `endpoint` is set.
Cannot be set if using a DigitalOcean DBaaS OpenSearch cluster.
example: password1
description: Configure Username and/or Password for Basic authentication.
required:
- user
- password
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ properties:
maxLength: 256
minLength: 1
example: https://www.example.com
deprecated: true

regex:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ description: >-

Note: Backups are not supported for Redis clusters.

OpenSearch is in closed beta. To request access, [contact support](https://cloudsupport.digitalocean.com).

tags:
- Databases

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
operationId: databases_create_logsink

summary: >
Create Logsink for a Database Cluster

description: |
To create logsink for a database cluster, send a POST request to
`/v2/databases/$DATABASE_ID/logsink`.

tags:
- Databases

parameters:
- $ref: "parameters.yml#/database_cluster_uuid"

requestBody:
required: true
content:
application/json:
schema:
allOf:
- $ref: models/logsink_create.yml
required:
- sink_name
- sink_type
- config
examples:
Create an opensearch logsink:
value:
sink_name: "logs-sink"
sink_type: "opensearch"
config:
url: https://user:[email protected]:25060
index_prefix: "opensearch-logs"
index_days_max: 5
Create an elasticsearch logsink:
value:
sink_name: "logs-sink"
sink_type: "elasticsearch"
config:
url: https://user:[email protected]:25060
index_prefix: "elasticsearch-logs"
index_days_max: 5
Create a rsyslog logsink:
value:
sink_name: "logs-sink"
sink_type: "rsyslog"
config:
server: 192.168.0.1
port: 514
tls: false
format: rfc5424

responses:
"201":
$ref: "responses/logsink.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/databases_create_logsink.yml"

security:
- bearer_auth:
- 'database:create'
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
operationId: databases_delete_logsink

summary: >
Delete Logsink for a Database Cluster

description: |
To delete a logsink for a database cluster, send a DELETE request to
`/v2/databases/$DATABASE_ID/logsink/$LOGSINK_ID`.

tags:
- Databases

parameters:
- $ref: "parameters.yml#/database_cluster_uuid"
- $ref: "parameters.yml#/logsink_id"

responses:
"200":
$ref: "../../shared/responses/no_content.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/databases_delete_logsink.yml"

security:
- bearer_auth:
- 'database:delete'
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
operationId: databases_get_logsink

summary: >
Get Logsink for a Database Cluster

description: |
To get a logsink for a database cluster, send a GET request to
`/v2/databases/$DATABASE_ID/logsink/$LOGSINK_ID`.

tags:
- Databases

parameters:
- $ref: "parameters.yml#/database_cluster_uuid"
- $ref: "parameters.yml#/logsink_id"

responses:
"201":
$ref: "responses/logsink.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/databases_get_logsink.yml"

security:
- bearer_auth:
- 'database:read'
Loading