Skip to content

Commit 50210d1

Browse files
authored
refactor openapi scripts (github#34803)
1 parent 03c3857 commit 50210d1

Some content is hidden

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

48 files changed

+17529
-45615
lines changed

.github/workflows/openapi-decorate.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Sync OpenAPI schema
22

3-
# **What it does**: Once a day, this workflow syncs the dereferenced files from github/rest-api-description and creates a pull request if there are updates to any of the static files we generate from the OpenAPI.
4-
# **Why we have it**: So we can consume OpenAPI changes.
3+
# **What it does**: Once a day, this workflow syncs the REST, Webhooks, and GitHub Apps automated pipelines with the github/rest-api-description repository, and creates a pull request if there are updates to any of the data files we generate from the OpenAPI.
4+
# **Why we have it**: So we can automate updates to REST, Webhooks, and GitHub Apps documentation
55
# **Who does it impact**: Anyone making OpenAPI changes in `github/github`, and wanting to get them published on the docs site.
66

77
on:
@@ -49,19 +49,17 @@ jobs:
4949

5050
- uses: ./.github/actions/node-npm-setup
5151

52-
- name: Copy dereferenced OpenAPI files
52+
- name: Get the rest-api-description SHA being synced
5353
id: rest-api-description
5454
run: |
55-
mkdir ./src/rest/data/dereferenced
56-
find rest-api-description/descriptions-next -type f -name "*.deref.json" -exec sh -c 'cp $1 ./src/rest/data/dereferenced' sh {} \;
5755
cd rest-api-description
5856
OPENAPI_COMMIT_SHA=$(git rev-parse HEAD)
5957
echo "OPENAPI_COMMIT_SHA=$OPENAPI_COMMIT_SHA" >> $GITHUB_OUTPUT
6058
echo "Copied files from github/rest-api-description repo. Commit SHA: $OPENAPI_COMMIT_SHA"
6159
62-
- name: Decorate the dereferenced OpenAPI schemas
60+
- name: Sync the REST, Webhooks, and GitHub Apps schemas
6361
run: |
64-
src/rest/scripts/update-files.js --decorate-only --open-source
62+
src/rest/scripts/update-files.js --source-repo rest-api-description --output rest github-apps webhooks rest-redirects
6563
git status
6664
echo "Deleting the cloned github/rest-api-description repo..."
6765
rm -rf rest-api-description

lib/all-versions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const plans = [
2626
latestRelease: latestNonNumberedRelease,
2727
nonEnterpriseDefault: true, // permanent way to refer to this plan if the name changes
2828
hasNumberedReleases: false,
29-
openApiBaseName: 'api.github.com', // used for REST
29+
openApiBaseName: 'fpt', // used for REST
3030
miscBaseName: 'dotcom', // used for GraphQL and webhooks
3131
},
3232
{
@@ -59,7 +59,7 @@ const plans = [
5959
// It lets us do semantic comparison internally while only exposing `@latest` in the UI.
6060
internalLatestRelease: '3.4',
6161
hasNumberedReleases: false,
62-
openApiBaseName: 'github.ae',
62+
openApiBaseName: 'ghae',
6363
miscBaseName: 'ghae',
6464
},
6565
]

lib/redirects/static/client-side-rest-api-redirects.json

Lines changed: 0 additions & 1172 deletions
This file was deleted.

middleware/anchor-redirect.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import express from 'express'
2+
import path from 'path'
23

34
import { readCompressedJsonFileFallbackLazily } from '../lib/read-json-file.js'
45
import { defaultCacheControl } from './cache-control.js'
6+
import { REST_DATA_DIR } from '../src/rest/lib/index.js'
57

68
const clientSideRestAPIRedirects = readCompressedJsonFileFallbackLazily(
7-
'./lib/redirects/static/client-side-rest-api-redirects.json'
9+
path.join(REST_DATA_DIR, 'client-side-rest-api-redirects.json')
810
)
911

1012
const router = express.Router()

script/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,6 @@ Run this script to pull openAPI files from github/github, dereference them, and
609609

610610

611611

612-
---
613-
614-
615-
### [`rest/utils/rest-api-overrides.json`](rest/utils/rest-api-overrides.json)
616-
617-
618-
619612
---
620613

621614

src/github-apps/data/api.github.com.2022-11-28/server-to-server-rest.json renamed to src/github-apps/data/fpt-2022-11-28/server-to-server-rest.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,6 @@
893893
"requestPath": "/installation/token"
894894
}
895895
],
896-
"billing": [],
897896
"branches": [
898897
{
899898
"slug": "list-branches",
@@ -1716,7 +1715,6 @@
17161715
"requestPath": "/emojis"
17171716
}
17181717
],
1719-
"gists": [],
17201718
"git": [
17211719
{
17221720
"slug": "create-a-blob",
@@ -2493,7 +2491,6 @@
24932491
"requestPath": "/users/{username}/orgs"
24942492
}
24952493
],
2496-
"packages": [],
24972494
"pages": [
24982495
{
24992496
"slug": "get-a-github-pages-site",

src/github-apps/data/github.ae/server-to-server-rest.json renamed to src/github-apps/data/ghae/server-to-server-rest.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,8 +1133,6 @@
11331133
"requestPath": "/emojis"
11341134
}
11351135
],
1136-
"enterprise-admin": [],
1137-
"gists": [],
11381136
"git": [
11391137
{
11401138
"slug": "create-a-blob",
@@ -1545,7 +1543,6 @@
15451543
"requestPath": "/repos/{owner}/{repo}/stats/punch_card"
15461544
}
15471545
],
1548-
"migrations": [],
15491546
"orgs": [
15501547
{
15511548
"slug": "list-organizations",

src/github-apps/data/ghec.2022-11-28/server-to-server-rest.json renamed to src/github-apps/data/ghec-2022-11-28/server-to-server-rest.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,8 +1845,6 @@
18451845
"requestPath": "/emojis"
18461846
}
18471847
],
1848-
"enterprise-admin": [],
1849-
"gists": [],
18501848
"git": [
18511849
{
18521850
"slug": "create-a-blob",
@@ -2677,7 +2675,6 @@
26772675
"requestPath": "/users/{username}/orgs"
26782676
}
26792677
],
2680-
"packages": [],
26812678
"pages": [
26822679
{
26832680
"slug": "get-a-github-enterprise-cloud-pages-site",

src/github-apps/data/ghes-3.4/server-to-server-rest.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,6 @@
14391439
"requestPath": "/repos/{owner}/{repo}/pre-receive-hooks/{pre_receive_hook_id}"
14401440
}
14411441
],
1442-
"gists": [],
14431442
"git": [
14441443
{
14451444
"slug": "create-a-blob",
@@ -1850,8 +1849,6 @@
18501849
"requestPath": "/repos/{owner}/{repo}/stats/punch_card"
18511850
}
18521851
],
1853-
"migrations": [],
1854-
"oauth-authorizations": [],
18551852
"orgs": [
18561853
{
18571854
"slug": "list-organizations",

src/github-apps/data/ghes-3.5/server-to-server-rest.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,6 @@
15471547
"requestPath": "/repos/{owner}/{repo}/pre-receive-hooks/{pre_receive_hook_id}"
15481548
}
15491549
],
1550-
"gists": [],
15511550
"git": [
15521551
{
15531552
"slug": "create-a-blob",
@@ -1958,8 +1957,6 @@
19581957
"requestPath": "/repos/{owner}/{repo}/stats/punch_card"
19591958
}
19601959
],
1961-
"migrations": [],
1962-
"oauth-authorizations": [],
19631960
"orgs": [
19641961
{
19651962
"slug": "list-organizations",

0 commit comments

Comments
 (0)