Skip to content

Commit 17a375e

Browse files
authored
Fix remote path item object $refs (#1246)
1 parent edf3d29 commit 17a375e

18 files changed

+253
-47
lines changed

.changeset/stupid-pens-bow.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-typescript": patch
3+
---
4+
5+
Fix remote path item object $refs

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

+19-19
Original file line numberDiff line numberDiff line change
@@ -3984,7 +3984,7 @@ export interface external {
39843984
*/
39853985
type?: "custom" | "lets_encrypt";
39863986
};
3987-
/** Custom Certificate Request */ certificate_request_custom: certificate_create_base[] & {
3987+
/** Custom Certificate Request */ certificate_request_custom: external["resources/certificates/models/certificate_create.yml"]["certificate_create_base"] & {
39883988
/**
39893989
* @description The contents of a PEM-formatted private-key corresponding to the SSL certificate.
39903990
* @example -----BEGIN PRIVATE KEY-----
@@ -4113,7 +4113,7 @@ export interface external {
41134113
*/
41144114
certificate_chain?: string;
41154115
};
4116-
/** Let's Encrypt Certificate Request */ certificate_request_lets_encrypt: certificate_create_base[] & {
4116+
/** Let's Encrypt Certificate Request */ certificate_request_lets_encrypt: external["resources/certificates/models/certificate_create.yml"]["certificate_create_base"] & {
41174117
/**
41184118
* @description An array of fully qualified domain names (FQDNs) for which the certificate was issued. A certificate covering all subdomains can be issued using a wildcard (e.g. `*.example.com`).
41194119
* @example [
@@ -7686,14 +7686,14 @@ export interface external {
76867686
*/
76877687
type: "enable_backups" | "disable_backups" | "reboot" | "power_cycle" | "shutdown" | "power_off" | "power_on" | "restore" | "password_reset" | "resize" | "rebuild" | "rename" | "change_kernel" | "enable_ipv6" | "snapshot";
76887688
};
7689-
droplet_action_restore: droplet_action[] & {
7689+
droplet_action_restore: external["resources/droplets/models/droplet_actions.yml"]["droplet_action"] & {
76907690
/**
76917691
* @description The ID of a backup of the current Droplet instance to restore from.
76927692
* @example 12389723
76937693
*/
76947694
image?: number;
76957695
};
7696-
droplet_action_resize: droplet_action[] & {
7696+
droplet_action_resize: external["resources/droplets/models/droplet_actions.yml"]["droplet_action"] & {
76977697
/**
76987698
* @description When `true`, the Droplet's disk will be resized in addition to its RAM and CPU. This is a permanent change and cannot be reversed as a Droplet's disk size cannot be decreased.
76997699
* @example true
@@ -7705,28 +7705,28 @@ export interface external {
77057705
*/
77067706
size?: string;
77077707
};
7708-
droplet_action_rebuild: droplet_action[] & ({
7708+
droplet_action_rebuild: external["resources/droplets/models/droplet_actions.yml"]["droplet_action"] & ({
77097709
/**
77107710
* @description The image ID of a public or private image or the slug identifier for a public image. The Droplet will be rebuilt using this image as its base.
77117711
* @example ubuntu-20-04-x64
77127712
*/
77137713
image?: string | number;
77147714
});
7715-
droplet_action_rename: droplet_action[] & {
7715+
droplet_action_rename: external["resources/droplets/models/droplet_actions.yml"]["droplet_action"] & {
77167716
/**
77177717
* @description The new name for the Droplet.
77187718
* @example nifty-new-name
77197719
*/
77207720
name?: string;
77217721
};
7722-
droplet_action_change_kernel: droplet_action[] & {
7722+
droplet_action_change_kernel: external["resources/droplets/models/droplet_actions.yml"]["droplet_action"] & {
77237723
/**
77247724
* @description A unique number used to identify and reference a specific kernel.
77257725
* @example 12389723
77267726
*/
77277727
kernel?: number;
77287728
};
7729-
droplet_action_snapshot: droplet_action[] & {
7729+
droplet_action_snapshot: external["resources/droplets/models/droplet_actions.yml"]["droplet_action"] & {
77307730
/**
77317731
* @description The name to give the new snapshot of the Droplet.
77327732
* @example Nifty New Snapshot
@@ -9037,10 +9037,10 @@ export interface external {
90379037
};
90389038
floating_ip_action_unassign: {
90399039
type: undefined;
9040-
} & Omit<floatingIPsAction[], "type"> & Record<string, never>;
9040+
} & Omit<external["resources/floating_ips/models/floating_ip_actions.yml"]["floatingIPsAction"], "type"> & Record<string, never>;
90419041
floating_ip_action_assign: {
90429042
type: undefined;
9043-
} & Omit<floatingIPsAction[], "type"> & {
9043+
} & Omit<external["resources/floating_ips/models/floating_ip_actions.yml"]["floatingIPsAction"], "type"> & {
90449044
/**
90459045
* @description The ID of the Droplet that the floating IP will be assigned to.
90469046
* @example 758604968
@@ -9850,7 +9850,7 @@ export interface external {
98509850
*/
98519851
type: "convert" | "transfer";
98529852
};
9853-
image_action_transfer: image_action_base[] & {
9853+
image_action_transfer: external["resources/images/models/image_action.yml"]["image_action_base"] & {
98549854
region: external["shared/attributes/region_slug.yml"];
98559855
};
98569856
};
@@ -10672,7 +10672,7 @@ export interface external {
1067210672
* }
1067310673
* ]
1067410674
*/
10675-
load_balancers?: associated_kubernetes_resource[][];
10675+
load_balancers?: external["resources/kubernetes/models/associated_kubernetes_resources.yml"]["associated_kubernetes_resource"][];
1067610676
/**
1067710677
* @description A list of names and IDs for associated volumes that can be destroyed along with the cluster.
1067810678
* @example [
@@ -10682,7 +10682,7 @@ export interface external {
1068210682
* }
1068310683
* ]
1068410684
*/
10685-
volumes?: associated_kubernetes_resource[][];
10685+
volumes?: external["resources/kubernetes/models/associated_kubernetes_resources.yml"]["associated_kubernetes_resource"][];
1068610686
/**
1068710687
* @description A list of names and IDs for associated volume snapshots that can be destroyed along with the cluster.
1068810688
* @example [
@@ -10692,7 +10692,7 @@ export interface external {
1069210692
* }
1069310693
* ]
1069410694
*/
10695-
volume_snapshots?: associated_kubernetes_resource[][];
10695+
volume_snapshots?: external["resources/kubernetes/models/associated_kubernetes_resources.yml"]["associated_kubernetes_resource"][];
1069610696
};
1069710697
associated_kubernetes_resource: {
1069810698
/**
@@ -13771,10 +13771,10 @@ export interface external {
1377113771
};
1377213772
reserved_ip_action_unassign: {
1377313773
type: undefined;
13774-
} & Omit<reserved_ip_action_type[], "type"> & Record<string, never>;
13774+
} & Omit<external["resources/reserved_ips/models/reserved_ip_actions.yml"]["reserved_ip_action_type"], "type"> & Record<string, never>;
1377513775
reserved_ip_action_assign: {
1377613776
type: undefined;
13777-
} & Omit<reserved_ip_action_type[], "type"> & {
13777+
} & Omit<external["resources/reserved_ips/models/reserved_ip_actions.yml"]["reserved_ip_action_type"], "type"> & {
1377813778
/**
1377913779
* @description The ID of the Droplet that the reserved IP will be assigned to.
1378013780
* @example 758604968
@@ -15984,7 +15984,7 @@ export interface external {
1598415984
}
1598515985
"shared/pages.yml": {
1598615986
pagination: {
15987-
links?: page_links[];
15987+
links?: external["shared/pages.yml"]["page_links"];
1598815988
};
1598915989
page_links: {
1599015990
/**
@@ -15997,8 +15997,8 @@ export interface external {
1599715997
*/
1599815998
pages?: unknown;
1599915999
};
16000-
backward_links: link_to_first_page[] & link_to_prev_page[];
16001-
forward_links: link_to_last_page[] & link_to_next_page[];
16000+
backward_links: external["shared/pages.yml"]["link_to_first_page"] & external["shared/pages.yml"]["link_to_prev_page"];
16001+
forward_links: external["shared/pages.yml"]["link_to_last_page"] & external["shared/pages.yml"]["link_to_next_page"];
1600216002
link_to_first_page: {
1600316003
/**
1600416004
* @description URI of the first page of the results.

packages/openapi-typescript/examples/digital-ocean-api/resources/kubernetes/models/node_pool.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,18 @@ kubernetes_node_pool_base:
6666
type: object
6767
nullable: true
6868
example: null
69-
description: An object containing a set of Kubernetes labels. The keys and
70-
are values are both user-defined.
69+
description: An object of key/value mappings specifying labels to apply
70+
to all nodes in a pool. Labels will automatically be applied to all
71+
existing nodes and any subsequent nodes added to the pool. Note that
72+
when a label is removed, it is not deleted from the nodes in the pool.
7173

7274
taints:
7375
type: array
7476
items:
7577
$ref: "#/kubernetes_node_pool_taint"
7678
description: An array of taints to apply to all nodes in a pool. Taints
7779
will automatically be applied to all existing nodes and any subsequent
78-
nodes added to the pool. When a taint is removed, it is removed from
80+
nodes added to the pool. When a taint is removed, it is deleted from
7981
all nodes in the pool.
8082

8183
auto_scale:

packages/openapi-typescript/examples/stripe-api.ts

+18
Original file line numberDiff line numberDiff line change
@@ -2107,6 +2107,7 @@ export interface components {
21072107
account_business_profile: {
21082108
/** @description [The merchant category code for the account](https://stripe.com/docs/connect/setting-mcc). MCCs are used to classify businesses based on the goods or services they provide. */
21092109
mcc?: string | null;
2110+
monthly_estimated_revenue?: components["schemas"]["account_monthly_estimated_revenue"];
21102111
/** @description The customer-facing business name. */
21112112
name?: string | null;
21122113
/** @description Internal-only description of the product sold or service provided by the business. It's used by Stripe for risk and underwriting purposes. */
@@ -2433,6 +2434,13 @@ export interface components {
24332434
/** @description The URL for the account link. */
24342435
url: string;
24352436
};
2437+
/** AccountMonthlyEstimatedRevenue */
2438+
account_monthly_estimated_revenue: {
2439+
/** @description A non-negative integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). */
2440+
amount: number;
2441+
/** @description Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). */
2442+
currency: string;
2443+
};
24362444
/** AccountPaymentsSettings */
24372445
account_payments_settings: {
24382446
/** @description The default text that appears on credit card statements when a charge is made. This field prefixes any dynamic `statement_descriptor` specified on the charge. */
@@ -16326,6 +16334,11 @@ export interface operations {
1632616334
*/
1632716335
business_profile?: {
1632816336
mcc?: string;
16337+
/** monthly_estimated_revenue_specs */
16338+
monthly_estimated_revenue?: {
16339+
amount: number;
16340+
currency: string;
16341+
};
1632916342
name?: string;
1633016343
product_description?: string;
1633116344
/** address_specs */
@@ -16849,6 +16862,11 @@ export interface operations {
1684916862
*/
1685016863
business_profile?: {
1685116864
mcc?: string;
16865+
/** monthly_estimated_revenue_specs */
16866+
monthly_estimated_revenue?: {
16867+
amount: number;
16868+
currency: string;
16869+
};
1685216870
name?: string;
1685316871
product_description?: string;
1685416872
/** address_specs */

packages/openapi-typescript/examples/stripe-api.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ components:
250250
maxLength: 5000
251251
nullable: true
252252
type: string
253+
monthly_estimated_revenue:
254+
$ref: '#/components/schemas/account_monthly_estimated_revenue'
253255
name:
254256
description: The customer-facing business name.
255257
maxLength: 5000
@@ -291,6 +293,7 @@ components:
291293
title: AccountBusinessProfile
292294
type: object
293295
x-expandableFields:
296+
- monthly_estimated_revenue
294297
- support_address
295298
account_capabilities:
296299
description: ''
@@ -1032,6 +1035,28 @@ components:
10321035
type: object
10331036
x-expandableFields: []
10341037
x-resourceId: account_link
1038+
account_monthly_estimated_revenue:
1039+
description: ''
1040+
properties:
1041+
amount:
1042+
description: >-
1043+
A non-negative integer representing how much to charge in the
1044+
[smallest currency
1045+
unit](https://stripe.com/docs/currencies#zero-decimal).
1046+
type: integer
1047+
currency:
1048+
description: >-
1049+
Three-letter [ISO currency
1050+
code](https://www.iso.org/iso-4217-currency-codes.html), in
1051+
lowercase. Must be a [supported
1052+
currency](https://stripe.com/docs/currencies).
1053+
type: string
1054+
required:
1055+
- amount
1056+
- currency
1057+
title: AccountMonthlyEstimatedRevenue
1058+
type: object
1059+
x-expandableFields: []
10351060
account_payments_settings:
10361061
description: ''
10371062
properties:
@@ -39941,6 +39966,17 @@ paths:
3994139966
mcc:
3994239967
maxLength: 4
3994339968
type: string
39969+
monthly_estimated_revenue:
39970+
properties:
39971+
amount:
39972+
type: integer
39973+
currency:
39974+
type: string
39975+
required:
39976+
- amount
39977+
- currency
39978+
title: monthly_estimated_revenue_specs
39979+
type: object
3994439980
name:
3994539981
maxLength: 5000
3994639982
type: string
@@ -41086,6 +41122,17 @@ paths:
4108641122
mcc:
4108741123
maxLength: 4
4108841124
type: string
41125+
monthly_estimated_revenue:
41126+
properties:
41127+
amount:
41128+
type: integer
41129+
currency:
41130+
type: string
41131+
required:
41132+
- amount
41133+
- currency
41134+
title: monthly_estimated_revenue_specs
41135+
type: object
4108941136
name:
4109041137
maxLength: 5000
4109141138
type: string

packages/openapi-typescript/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"test": "run-p -s test:*",
5050
"test:js": "vitest run",
5151
"test:ts": "tsc --noEmit",
52-
"update:examples": "vite-node ./scripts/update-examples.ts",
52+
"update:examples": "pnpm run download:schemas && vite-node ./scripts/update-examples.ts",
5353
"prepublish": "pnpm run build",
5454
"version": "pnpm run build"
5555
},

packages/openapi-typescript/scripts/download-schemas.ts

+11-13
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,18 @@ import { fileURLToPath } from "node:url";
44
import degit from "degit";
55
import { fetch } from "undici";
66
import { error } from "../src/utils.js";
7-
8-
export const singleFile = {
9-
"github-api": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.yaml",
10-
"github-api-next": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions-next/api.github.com/api.github.com.yaml",
11-
"octokit-ghes-3.6-diff-to-api": "https://raw.githubusercontent.com/octokit/octokit-next.js/main/cache/types-openapi/ghes-3.6-diff-to-api.github.com.json",
12-
"stripe-api": "https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.yaml",
13-
};
14-
export const multiFile = {
15-
"digital-ocean-api": {
16-
repo: "https://github.com/digitalocean/openapi/specification",
17-
entry: "./DigitalOcean-public.v2.yaml",
18-
},
19-
};
7+
import { multiFile, singleFile } from "./schemas.js";
208

219
const ONE_DAY = 1000 * 60 * 60 * 24;
2210
const EXAMPLES_DIR = new URL("../examples/", import.meta.url);
2311

2412
export async function download() {
13+
const allSchemas = Object.keys({ ...singleFile, ...multiFile });
14+
let done = 0;
15+
console.log("Downloading schemas..."); // eslint-disable-line no-console
2516
await Promise.all([
2617
...Object.entries(singleFile).map(async ([k, url]) => {
18+
const start = performance.now();
2719
const ext = path.extname(url);
2820
const dest = new URL(`${k}${ext}`, EXAMPLES_DIR);
2921
if (fs.existsSync(dest)) {
@@ -37,8 +29,11 @@ export async function download() {
3729
}
3830
fs.mkdirSync(new URL(".", dest), { recursive: true });
3931
fs.writeFileSync(dest, await result.text());
32+
done++;
33+
console.log(`✔︎ [${done}/${allSchemas.length}] Downloaded ${k} (${Math.round(performance.now() - start)}ms)`); // eslint-disable-line no-console
4034
}),
4135
...Object.entries(multiFile).map(async ([k, meta]) => {
36+
const start = performance.now();
4237
const dest = new URL(k, EXAMPLES_DIR);
4338
if (fs.existsSync(dest)) {
4439
const { mtime } = fs.statSync(dest);
@@ -48,8 +43,11 @@ export async function download() {
4843
force: true,
4944
});
5045
await emitter.clone(fileURLToPath(new URL(k, EXAMPLES_DIR)));
46+
done++;
47+
console.log(`✔︎ [${done}/${allSchemas.length}] Downloaded ${k} (${Math.round(performance.now() - start)}ms)`); // eslint-disable-line no-console
5148
}),
5249
]);
50+
console.log("Downloading schemas done."); // eslint-disable-line no-console
5351
}
5452

5553
download();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const singleFile = {
2+
"github-api": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.yaml",
3+
"github-api-next": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions-next/api.github.com/api.github.com.yaml",
4+
"octokit-ghes-3.6-diff-to-api": "https://raw.githubusercontent.com/octokit/octokit-next.js/main/cache/types-openapi/ghes-3.6-diff-to-api.github.com.json",
5+
"stripe-api": "https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.yaml",
6+
};
7+
export const multiFile = {
8+
"digital-ocean-api": {
9+
repo: "https://github.com/digitalocean/openapi/specification",
10+
entry: "./DigitalOcean-public.v2.yaml",
11+
},
12+
};

0 commit comments

Comments
 (0)