Skip to content

Commit 3f43c45

Browse files
authored
Add a flag to skip Schema prefix when rendering root types (#1958)
* Add a flag to skip Schema prefix when rendering root types * Add missing option in tests * Add test case * Fix linting issues * Update examples * Update docs * Update examples
1 parent c9ba9dc commit 3f43c45

File tree

122 files changed

+40685
-12459
lines changed

Some content is hidden

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

122 files changed

+40685
-12459
lines changed

docs/cli.md

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ The following flags are supported in the CLI:
120120
| `--immutable` | | `false` | Generates immutable types (readonly properties and readonly array) |
121121
| `--path-params-as-types` | | `false` | Allow dynamic string lookups on the `paths` object |
122122
| `--root-types` | | `false` | Exports types from `components` as root level type aliases |
123+
| `--root-types-no-schema-prefix` | | `false` | Do not add "Schema" prefix to types at the root level (should only be used with --root-types) |
123124

124125
### pathParamsAsTypes
125126

packages/openapi-typescript/bin/cli.js

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Options
3131
--alphabetize Sort object keys alphabetically
3232
--exclude-deprecated Exclude deprecated types
3333
--root-types (optional) Export schemas types at root level
34+
--root-types-no-schema-prefix (optional)
35+
Do not add "Schema" prefix to types at the root level (should only be used with --root-types)
3436
`;
3537

3638
const OUTPUT_FILE = "FILE";
@@ -56,6 +58,9 @@ if (args.includes("-it")) {
5658
if (args.includes("--redoc")) {
5759
errorAndExit(`The --redoc config flag has been renamed to "--redocly" (or -c as shorthand).`);
5860
}
61+
if (args.includes("--root-types-no-schema-prefix") && !args.includes("--root-types")) {
62+
console.warn("--root-types-no-schema-prefix has no effect without --root-types flag");
63+
}
5964

6065
const flags = parser(args, {
6166
boolean: [
@@ -76,6 +81,7 @@ const flags = parser(args, {
7681
"immutable",
7782
"pathParamsAsTypes",
7883
"rootTypes",
84+
"rootTypesNoSchemaPrefix",
7985
],
8086
string: ["output", "redocly"],
8187
alias: {
@@ -136,6 +142,7 @@ async function generateSchema(schema, { redocly, silent = false }) {
136142
immutable: flags.immutable,
137143
pathParamsAsTypes: flags.pathParamsAsTypes,
138144
rootTypes: flags.rootTypes,
145+
rootTypesNoSchemaPrefix: flags.rootTypesNoSchemaPrefix,
139146
redocly,
140147
silent,
141148
}),

packages/openapi-typescript/examples/digital-ocean-api.ts

+1,277-122
Large diffs are not rendered by default.

packages/openapi-typescript/examples/digital-ocean-api/DigitalOcean-public.v2.yaml

+88-26
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tags:
2323
description: |-
2424
1-Click applications are pre-built Droplet images or Kubernetes apps with software,
2525
features, and configuration details already set up for you. They can be found in the
26-
[DigitalOcean Marketplace](https://www.digitalocean.com/docs/marketplace).
26+
[DigitalOcean Marketplace](https://marketplace.digitalocean.com/).
2727
2828
- name: Account
2929
description: Provides information about your current account.
@@ -66,7 +66,7 @@ tags:
6666
**Balance:** By sending requests to the `/v2/customers/my/balance` endpoint, you can
6767
retrieve the balance information for the requested customer account.
6868
69-
**Invoices:** [Invoices](https://www.digitalocean.com/docs/accounts/billing/invoices/)
69+
**Invoices:** [Invoices](https://docs.digitalocean.com/platform/billing/invoices/)
7070
are generated on the first of each month for every DigitalOcean
7171
customer. An invoice preview is generated daily, which can be accessed
7272
with the `preview` keyword in place of `$INVOICE_UUID`. To interact with
@@ -81,7 +81,7 @@ tags:
8181
8282
- name: Block Storage
8383
description: |-
84-
[DigitalOcean Block Storage Volumes](https://www.digitalocean.com/docs/volumes/)
84+
[DigitalOcean Block Storage Volumes](https://docs.digitalocean.com/products/volumes/)
8585
provide expanded storage capacity for your Droplets and can be moved
8686
between Droplets within a specific region.
8787
@@ -106,18 +106,20 @@ tags:
106106
- name: CDN Endpoints
107107
description: |-
108108
Content hosted in DigitalOcean's object storage solution,
109-
[Spaces](https://www.digitalocean.com/docs/spaces/overview/),
109+
[Spaces](https://docs.digitalocean.com/products/spaces/),
110110
can optionally be served by our globally distributed Content Delivery
111111
Network (CDN). By sending requests to `/v2/cdn/endpoints`, you can list,
112112
create, or delete CDN Endpoints as well as purge cached content. To use a
113113
custom subdomain to access the CDN Endpoint, provide the ID of a
114114
DigitalOcean managed TLS certificate and the fully qualified domain name
115-
for the custom subdomain.
115+
for the custom subdomain.
116+
117+
CDN endpoints have a rate limit of five requests per 10 seconds.
116118
117119
- name: Certificates
118120
description: |-
119121
In order to perform SSL termination on load balancers, DigitalOcean offers
120-
two types of [SSL certificate management](https://www.digitalocean.com/docs/accounts/security/#certificates):
122+
two types of [SSL certificate management](https://docs.digitalocean.com/platform/teams/manage-certificates):
121123
122124
* **Custom**: User-generated certificates may be uploaded to DigitalOcean
123125
where they will be placed in a fully encrypted and isolated storage system.
@@ -130,7 +132,7 @@ tags:
130132
- name: Container Registry
131133
description: |-
132134
DigitalOcean offers the ability for you to create a
133-
[private container registry](https://www.digitalocean.com/docs/images/container-registry/quickstart/)
135+
[private container registry](https://docs.digitalocean.com/products/container-registry/)
134136
to store your Docker images for use with your Kubernetes clusters. This
135137
container registry runs inside the same datacenters as your cluster,
136138
ensuring reliable and performant rollout of image deployments.
@@ -140,12 +142,12 @@ tags:
140142
141143
- name: Databases
142144
description: |-
143-
DigitalOcean's [managed database service](https://www.digitalocean.com/docs/databases)
145+
DigitalOcean's [managed database service](https://docs.digitalocean.com/products/databases)
144146
simplifies the creation and management of highly available database clusters. Currently, it
145-
offers support for [PostgreSQL](http://www.digitalocean.com/docs/databases/postgresql/),
146-
[Redis](https://www.digitalocean.com/docs/databases/redis/),
147-
[MySQL](https://www.digitalocean.com/docs/databases/mysql/),
148-
[MongoDB](https://www.digitalocean.com/docs/databases/mongodb/), and
147+
offers support for [PostgreSQL](http://docs.digitalocean.com/products/databases/postgresql/),
148+
[Redis](https://docs.digitalocean.com/products/databases/redis/),
149+
[MySQL](https://docs.digitalocean.com/products/databases/mysql/),
150+
[MongoDB](https://docs.digitalocean.com/products/databases/mongodb/), and
149151
[OpenSearch](https://docs.digitalocean.com/products/databases/opensearch/).
150152
151153
By sending requests to the `/v2/databases` endpoint, you can list, create, or delete
@@ -170,7 +172,7 @@ tags:
170172
and manage DNS zone files by adding and modifying individual records for a
171173
domain.
172174
173-
The [DigitalOcean DNS management interface](https://www.digitalocean.com/docs/networking/dns/)
175+
The [DigitalOcean DNS management interface](https://docs.digitalocean.com/products/networking/dns/)
174176
allows you to configure the following DNS records:
175177
176178
Name | Description |
@@ -189,7 +191,7 @@ tags:
189191
description: |-
190192
Domain resources are domain names that you have purchased from a domain
191193
name registrar that you are managing through the
192-
[DigitalOcean DNS interface](https://www.digitalocean.com/docs/networking/dns/).
194+
[DigitalOcean DNS interface](https://docs.digitalocean.com/products/networking/dns/).
193195
194196
This resource establishes top-level control over each domain. Actions that
195197
affect individual domain records should be taken on the
@@ -217,7 +219,7 @@ tags:
217219
218220
- name: Droplets
219221
description: |-
220-
A [Droplet](https://www.digitalocean.com/docs/droplets/) is a DigitalOcean
222+
A [Droplet](https://docs.digitalocean.com/products/droplets/) is a DigitalOcean
221223
virtual machine. By sending requests to the Droplet endpoint, you can
222224
list, create, or delete Droplets.
223225
@@ -228,7 +230,7 @@ tags:
228230
229231
- name: Firewalls
230232
description: |-
231-
[DigitalOcean Cloud Firewalls](https://www.digitalocean.com/docs/networking/firewalls/)
233+
[DigitalOcean Cloud Firewalls](https://docs.digitalocean.com/products/networking/firewalls/)
232234
provide the ability to restrict network access to and from a Droplet
233235
allowing you to define which ports will accept inbound or outbound
234236
connections. By sending requests to the `/v2/firewalls` endpoint, you can
@@ -271,7 +273,7 @@ tags:
271273
will contain the field `reserved_ips` in addition to the `floating_ips` field.
272274
Floating IPs retrieved using the Projects API will retain the original name.
273275
274-
[DigitalOcean Floating IPs](https://www.digitalocean.com/docs/networking/floating-ips/)
276+
[DigitalOcean Floating IPs](https://docs.digitalocean.com/products/networking/reserved-ips/)
275277
are publicly-accessible static IP addresses that can be mapped to one of
276278
your Droplets. They can be used to create highly available setups or other
277279
configurations requiring movable addresses.
@@ -296,34 +298,34 @@ tags:
296298
297299
- name: Images
298300
description: |-
299-
A DigitalOcean [image](https://www.digitalocean.com/docs/images/) can be
301+
A DigitalOcean [image](https://docs.digitalocean.com/products/images/) can be
300302
used to create a Droplet and may come in a number of flavors. Currently,
301303
there are five types of images: snapshots, backups, applications,
302304
distributions, and custom images.
303305
304-
* [Snapshots](https://www.digitalocean.com/docs/images/snapshots/) provide
306+
* [Snapshots](https://docs.digitalocean.com/products/snapshots/) provide
305307
a full copy of an existing Droplet instance taken on demand.
306308
307-
* [Backups](https://www.digitalocean.com/docs/images/backups/) are similar
309+
* [Backups](https://docs.digitalocean.com/products/backups/) are similar
308310
to snapshots but are created automatically at regular intervals when
309311
enabled for a Droplet.
310312
311-
* [Custom images](https://www.digitalocean.com/docs/images/custom-images/)
313+
* [Custom images](https://docs.digitalocean.com/products/custom-images/)
312314
are Linux-based virtual machine images (raw, qcow2, vhdx, vdi, and vmdk
313315
formats are supported) that you may upload for use on DigitalOcean.
314316
315317
* Distributions are the public Linux distributions that are available to
316318
be used as a base to create Droplets.
317319
318-
* Applications, or [1-Click Apps](https://www.digitalocean.com/docs/one-clicks/),
320+
* Applications, or [1-Click Apps](https://docs.digitalocean.com/products/marketplace/),
319321
are distributions pre-configured with additional software.
320322
321323
To interact with images, you will generally send requests to the images
322324
endpoint at /v2/images.
323325
324326
- name: Kubernetes
325327
description: |-
326-
[DigitalOcean Kubernetes](https://www.digitalocean.com/docs/kubernetes/)
328+
[DigitalOcean Kubernetes](https://docs.digitalocean.com/products/kubernetes/)
327329
allows you to quickly deploy scalable and secure Kubernetes clusters. By
328330
sending requests to the `/v2/kubernetes/clusters` endpoint, you can list,
329331
create, or delete clusters as well as scale node pools up and down,
@@ -332,7 +334,7 @@ tags:
332334
333335
- name: Load Balancers
334336
description: |-
335-
[DigitalOcean Load Balancers](https://www.digitalocean.com/docs/networking/load-balancers/)
337+
[DigitalOcean Load Balancers](https://docs.digitalocean.com/products/networking/load-balancers/)
336338
provide a way to distribute traffic across multiple Droplets. By sending
337339
requests to the `/v2/load_balancers` endpoint, you can list, create, or
338340
delete load balancers as well as add or remove Droplets, forwarding rules,
@@ -449,7 +451,7 @@ tags:
449451
450452
- name: Snapshots
451453
description: |-
452-
[Snapshots](https://www.digitalocean.com/docs/images/snapshots/) are saved
454+
[Snapshots](https://docs.digitalocean.com/products/snapshots/) are saved
453455
instances of a Droplet or a block storage volume, which is reflected in
454456
the `resource_type` attribute. In order to avoid problems with compressing
455457
filesystems, each defines a `min_disk_size` attribute which is the minimum
@@ -478,9 +480,16 @@ tags:
478480
479481
To interact with Uptime, you will generally send requests to the Uptime endpoint at `/v2/uptime/`.
480482
483+
- name: VPC Peerings
484+
description: |-
485+
[VPC Peerings](https://docs.digitalocean.com/products/networking/vpc/how-to/create-peering/)
486+
join two VPC networks with a secure, private connection. This allows
487+
resources in those networks to connect to each other's private IP addresses
488+
as if they were in the same network.
489+
481490
- name: VPCs
482491
description: |-
483-
[VPCs (virtual private clouds)](https://www.digitalocean.com/docs/networking/vpc/)
492+
[VPCs (virtual private clouds)](https://docs.digitalocean.com/products/networking/vpc/)
484493
allow you to create virtual networks containing resources that can
485494
communicate with each other in full isolation using private IP addresses.
486495
@@ -1393,6 +1402,32 @@ paths:
13931402
get:
13941403
$ref: 'resources/monitoring/monitoring_get_lb_droplets_downtime.yml'
13951404

1405+
/v2/monitoring/sinks/destinations:
1406+
post:
1407+
$ref: 'resources/monitoring/monitoring_create_destination.yml'
1408+
get:
1409+
$ref: 'resources/monitoring/monitoring_list_destinations.yml'
1410+
1411+
/v2/monitoring/sinks/destinations/{destination_uuid}:
1412+
get:
1413+
$ref: 'resources/monitoring/monitoring_get_destination.yml'
1414+
post:
1415+
$ref: 'resources/monitoring/monitoring_update_destination.yml'
1416+
delete:
1417+
$ref: 'resources/monitoring/monitoring_delete_destination.yml'
1418+
1419+
/v2/monitoring/sinks:
1420+
post:
1421+
$ref: 'resources/monitoring/monitoring_create_sink.yml'
1422+
get:
1423+
$ref: 'resources/monitoring/monitoring_list_sinks.yml'
1424+
1425+
/v2/monitoring/sinks/{sink_uuid}:
1426+
get:
1427+
$ref: 'resources/monitoring/monitoring_get_sink.yml'
1428+
delete:
1429+
$ref: 'resources/monitoring/monitoring_delete_sink.yml'
1430+
13961431
/v2/projects:
13971432
get:
13981433
$ref: 'resources/projects/projects_list.yml'
@@ -1635,6 +1670,33 @@ paths:
16351670
get:
16361671
$ref: 'resources/vpcs/vpcs_list_members.yml'
16371672

1673+
/v2/vpcs/{vpc_id}/peerings:
1674+
get:
1675+
$ref: 'resources/vpcs/vpcs_list_peerings.yml'
1676+
1677+
post:
1678+
$ref: 'resources/vpcs/vpcs_create_peerings.yml'
1679+
1680+
/v2/vpcs/{vpc_id}/peerings/{vpc_peering_id}:
1681+
patch:
1682+
$ref: 'resources/vpcs/vpcs_update_peerings.yml'
1683+
1684+
/v2/vpc_peerings:
1685+
get:
1686+
$ref: 'resources/vpc_peerings/vpc_peerings_list.yml'
1687+
1688+
post:
1689+
$ref: 'resources/vpc_peerings/vpc_peerings_create.yml'
1690+
1691+
/v2/vpc_peerings/{vpc_peering_id}:
1692+
get:
1693+
$ref: 'resources/vpc_peerings/vpc_peerings_get.yml'
1694+
1695+
patch:
1696+
$ref: 'resources/vpc_peerings/vpc_peerings_update.yml'
1697+
1698+
delete:
1699+
$ref: 'resources/vpc_peerings/vpc_peerings_delete.yml'
16381700

16391701
/v2/uptime/checks:
16401702
get:

packages/openapi-typescript/examples/digital-ocean-api/resources/actions/models/action.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ properties:
4949
$ref: '../../regions/models/region.yml'
5050

5151
region_slug:
52-
allOf:
53-
- $ref: '../../regions/models/region.yml#/properties/slug'
54-
- type: string
55-
nullable: true
52+
type: string
53+
nullable: true
54+
description: A human-readable string that is used as a unique identifier
55+
for each region.
56+
example: nyc3

packages/openapi-typescript/examples/digital-ocean-api/resources/apps/models/app_component_base.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ properties:
5555
environment_slug:
5656
type: string
5757
description: An environment slug describing the type of this app. For a full list,
58-
please refer to [the product documentation](https://www.digitalocean.com/docs/app-platform/).
58+
please refer to [the product documentation](https://docs.digitalocean.com/products/app-platform/).
5959
example: node-js
6060

6161
log_destinations:

0 commit comments

Comments
 (0)