Make all REST categories have subcategories (#38559)

Co-authored-by: Rachael Sewell <rachmari@github.com>
This commit is contained in:
Sarah Edwards 2023-06-27 09:22:19 -07:00 коммит произвёл GitHub
Родитель 0cea02890e
Коммит 29db669cc9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
38 изменённых файлов: 355 добавлений и 75 удалений

Просмотреть файл

@ -13,7 +13,7 @@ module.exports = {
babelOptions: { configFile: './.babelrc' },
sourceType: 'module',
},
ignorePatterns: ['tmp/*', '!/.*', '/.next/', 'script/bookmarklets/*'],
ignorePatterns: ['tmp/*', '!/.*', '/.next/', 'script/bookmarklets/*', 'rest-api-description/'],
rules: {
'import/no-extraneous-dependencies': ['error', { packageDir: '.' }],
},

Просмотреть файл

Просмотреть файл

@ -0,0 +1,15 @@
---
title: Billing
intro: Use the REST API to get billing information for an enterprise.
topics:
- API
versions:
fpt: '*'
ghec: '*'
ghes: '*'
children:
- /billing
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

@ -0,0 +1,20 @@
---
title: Code Scanning
intro: >-
Use the REST API to retrieve and update {% data
variables.product.prodname_code_scanning %} alerts from a repository.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
- Code scanning
- REST
children:
- /code-scanning
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

@ -0,0 +1,18 @@
---
title: Codes of conduct
intro: Use the REST API to get information about codes of conduct.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /codes-of-conduct
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,17 @@
---
title: Deploy keys
intro: Use the REST API to create and manage deploy keys.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
allowTitleToDifferFromFilename: true
children:
- /deploy-keys
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,20 @@
---
title: Emojis
intro: >-
Use the REST API to list and view all the available emojis to use on {% data
variables.product.product_name %}.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /emojis
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,18 @@
---
title: Gitignore
intro: >-
Use the REST API to get `.gitignore` templates that can be used to ignore
files and directories.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /gitignore
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

@ -0,0 +1,18 @@
---
title: Licenses
intro: >-
Use the REST API to retrieve popular open source licenses and information
about a particular project's license file.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /licenses
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,18 @@
---
title: Markdown
intro: Use the REST API to render a markdown document as an HTML page or as raw text.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /markdown
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,21 @@
---
title: Meta
intro: >-
Use the REST API to get meta information about {% data
variables.product.product_name %}, including the IP addresses of {% data
variables.product.product_name %} services.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /meta
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,13 @@
---
title: OAuth authorizations
intro: Use the REST API to manage the access {% data variables.product.prodname_oauth_app %}s have to your account.
versions:
ghes: '*'
topics:
- API
children:
- /oauth-authorizations
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

@ -0,0 +1,17 @@
---
title: Packages
intro: >-
Use the REST API to interact with {% data variables.product.prodname_registry
%}.
versions:
fpt: '*'
ghec: '*'
ghes: '>=3.9'
topics:
- API
children:
- /packages
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,20 @@
---
title: Pages
intro: >-
Use the REST API to interact with {% data variables.product.prodname_pages %}
sites and builds.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /pages
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,16 @@
---
title: Rate limit
intro: Use the REST API to check your current rate limit status.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /rate-limit
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,18 @@
---
title: Reactions
intro: >-
Use the REST API to interact with reactions on {% data
variables.product.prodname_dotcom %}.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /reactions
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,15 @@
---
title: SCIM
intro: >-
Use the REST API to control and manage your GitHub organization members access
with SCIM.
versions:
ghec: '*'
topics:
- API
children:
- /scim
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,18 @@
---
title: Search
intro: >-
Use the REST API to search for specific items on {% data
variables.product.product_name %}.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /search
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

Просмотреть файл

@ -0,0 +1,16 @@
---
title: Secret scanning
intro: Use the REST API to retrieve and update secret alerts from a repository.
versions:
fpt: '*'
ghae: '*'
ghec: '*'
ghes: '*'
topics:
- API
children:
- /secret-scanning
autogenerated: rest
---
<!-- Content after this section is automatically generated -->

Просмотреть файл

@ -85,31 +85,8 @@ async function getDataFrontmatter(dataDirectory, schemaFilename) {
async function getMarkdownContent(versions) {
const markdownUpdates = {}
for (const category of Object.keys(versions)) {
const subcategories = Object.keys(versions[category])
// When there is only a single subcategory and the name
// matches the category, this is an override due to a
// subcategory not being defined. In this case,
// the markdown file will be in the content/rest directory.
// The file path will be content/rest/<category>.md
if (subcategories.length === 1 && category === subcategories[0]) {
// this will be a file in the root of the rest directory
const filepath = path.join('content/rest', `${category}.md`)
markdownUpdates[filepath] = {
data: {
title: category,
shortTitle: category,
intro: '',
versions: await convertVersionsToFrontmatter(
versions[category][subcategories[0]].versions
),
...frontmatterDefaults,
},
content: '',
}
continue
}
for (const [category, subcategoryObject] of Object.entries(versions)) {
const subcategories = Object.keys(subcategoryObject)
// The file path will be content/rest/<category>/<subcategory>.md
for (const subcategory of subcategories) {
const filepath = path.join('content/rest', category, `${subcategory}.md`)

Просмотреть файл

@ -1,7 +1,7 @@
import { jest, test } from '@jest/globals'
import { slug } from 'github-slugger'
import { getDOM } from '../../../tests/helpers/e2etest.js'
import { get, getDOM } from '../../../tests/helpers/e2etest.js'
import { isApiVersioned, allVersions } from '../../../lib/all-versions.js'
import { getDiffOpenAPIContentRest } from '../scripts/test-open-api-schema.js'
import getRest from '#src/rest/lib/index.js'
@ -25,6 +25,59 @@ describe('REST references docs', () => {
}
})
// These tests exists because of issue #1960
test('rest subcategory with fpt in URL', async () => {
for (const category of [
'migrations',
'actions',
'activity',
'apps',
'billing',
'checks',
'codes-of-conduct',
'code-scanning',
'codespaces',
'emojis',
'gists',
'git',
'gitignore',
'interactions',
'issues',
'licenses',
'markdown',
'meta',
'orgs',
'projects',
'pulls',
'rate-limit',
'reactions',
'repos',
'scim',
'search',
'teams',
'users',
]) {
// Without language prefix
{
const res = await get(`/free-pro-team@latest/rest/reference/${category}`)
expect(res.statusCode).toBe(302)
expect(
res.headers.location === `/en/rest/${category}` ||
res.headers.location === `/en/rest/${category}/${category}`
)
}
// With language prefix
{
const res = await get(`/en/free-pro-team@latest/rest/reference/${category}`)
expect(res.statusCode).toBe(301)
expect(
res.headers.location === `/en/rest/${category}` ||
res.headers.location === `/en/rest/${category}/${category}`
)
}
}
})
test('test the latest version of the OpenAPI schema categories/subcategories to see if it matches the content/rest directory', async () => {
const differences = await getDiffOpenAPIContentRest()
const errorMessage = formatErrors(differences)

Просмотреть файл

@ -411,54 +411,6 @@ describe('redirects', () => {
})
})
// These tests exists because of issue #1960
describe('rest reference redirects with default product', () => {
test('rest subcategory with fpt in URL', async () => {
for (const category of [
'migrations',
'actions',
'activity',
'apps',
'billing',
'checks',
'codes-of-conduct',
'code-scanning',
'codespaces',
'emojis',
'gists',
'git',
'gitignore',
'interactions',
'issues',
'licenses',
'markdown',
'meta',
'orgs',
'projects',
'pulls',
'rate-limit',
'reactions',
'repos',
'search',
'teams',
'users',
]) {
// Without language prefix
{
const res = await get(`/free-pro-team@latest/rest/reference/${category}`)
expect(res.statusCode).toBe(302)
expect(res.headers.location).toBe(`/en/rest/${category}`)
}
// With language prefix
{
const res = await get(`/en/free-pro-team@latest/rest/reference/${category}`)
expect(res.statusCode).toBe(301)
expect(res.headers.location).toBe(`/en/rest/${category}`)
}
}
})
})
describe('redirects with double-slashes', () => {
test('prefix double-slash', async () => {
const res = await get(`//en`)