Skip to content

Commit 03e728f

Browse files
authored
fix endpoints-available-for-github-apps page (#15933)
* fix endpoints-available-for-github-apps page * lint
1 parent e90316e commit 03e728f

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

content/rest/overview/endpoints-available-for-github-apps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ versions:
1111

1212
You must use an installation access token to access endpoints using your {% data variables.product.prodname_github_app %}. For more information, see "[Authenticating with {% data variables.product.prodname_github_apps %}](/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation)."
1313

14-
{% for thing in rest.operationsEnabledForApps[currentVersion] %}
14+
{% for thing in rest.operationsEnabledForGitHubApps[currentVersion] %}
1515
{% assign category = thing[0] %}
1616
{% assign operations = thing[1] %}
1717
{% if operations.size > 0 %}

lib/rest.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
const { chain, get, union, flatten, groupBy } = require('lodash')
22
const { supported } = require('./enterprise-server-releases')
33
const operations = require('@github/rest-api-operations')
4-
// TODO need to update this to the new versions in coordination with openAPI
5-
const { oldVersions } = require('./old-versions-utils')
6-
const allVersions = oldVersions
4+
const { getOldVersionFromNewVersion } = require('./old-versions-utils')
5+
const allVersions = Object.keys(require('./all-versions'))
76

87
// This list is generated for use in the tests,
98
// so we can verify that the names of the markdown files
@@ -18,16 +17,16 @@ const categories = union(dotcomCategories, enterpriseCategories)
1817

1918
// Attach convenience properties to each operation that can't easily be created in Liquid
2019
allVersions.forEach(currentVersion => {
21-
operations[currentVersion].forEach(operation => {
20+
operations[getOldVersionFromNewVersion(currentVersion)].forEach(operation => {
2221
operation.hasRequiredPreviews = get(operation, 'x-github.previews', []).some(preview => preview.required)
2322
})
2423
})
2524

26-
// This is a collection of operations that have `enabledForApps = true`
25+
// This is a collection of operations that have `enabledForGitHubApps = true`
2726
// It's grouped by resource title to make rendering easier
28-
const operationsEnabledForApps = allVersions.reduce((acc, currentVersion) => {
29-
acc[currentVersion] = chain(operations[currentVersion] || [])
30-
.filter(operation => operation['x-github'].enabledForApps)
27+
const operationsEnabledForGitHubApps = allVersions.reduce((acc, currentVersion) => {
28+
acc[currentVersion] = chain(operations[getOldVersionFromNewVersion(currentVersion)] || [])
29+
.filter(operation => operation['x-github'].enabledForGitHubApps)
3130
.orderBy('category')
3231
.value()
3332
acc[currentVersion] = groupBy(acc[currentVersion], 'category')
@@ -37,5 +36,5 @@ const operationsEnabledForApps = allVersions.reduce((acc, currentVersion) => {
3736
module.exports = {
3837
categories,
3938
operations,
40-
operationsEnabledForApps
39+
operationsEnabledForGitHubApps
4140
}

tests/rendering/rest.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ describe('REST references docs', () => {
4040
expect(operation.description).toContain('GitHub Enterprise')
4141
})
4242

43+
test('loads operations enabled for GitHub Apps', async () => {
44+
const operations = await getJSON('/en/free-pro-team@latest/rest/overview/endpoints-available-for-github-apps?json=rest.operationsEnabledForGitHubApps')
45+
expect(operations['free-pro-team@latest'].actions.length).toBeGreaterThan(0)
46+
expect(operations['enterprise-server@2.22'].actions.length).toBeGreaterThan(0)
47+
})
48+
4349
test('no wrongly detected AppleScript syntax highlighting in schema data', async () => {
4450
const { operations } = require('../../lib/rest')
4551
expect(JSON.stringify(operations).includes('hljs language-applescript')).toBe(false)

0 commit comments

Comments
 (0)