Skip to content

Commit bb2e234

Browse files
authored
update openapi test (github#27127)
1 parent 8fa7656 commit bb2e234

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

script/rest/test-open-api-schema.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import readFileAsync from '../../lib/readfile-async.js'
1313
import getOperations from './utils/get-operations.js'
1414
import frontmatter from '../../lib/read-frontmatter.js'
1515
import _ from 'lodash'
16+
import { supported } from '../../lib/enterprise-server-releases.js'
1617

17-
let LOWEST_SUPPORTED_GHES_VERSION = Number.MAX_VALUE
18-
let HIGHEST_SUPPORTED_GHES_VERSION = Number.MIN_VALUE
18+
const supportedVersions = supported.map(Number)
19+
const LOWEST_SUPPORTED_GHES_VERSION = Math.min(...supportedVersions)
20+
const HIGHEST_SUPPORTED_GHES_VERSION = Math.max(...supportedVersions)
1921

2022
const dereferencedPath = path.join(process.cwd(), 'lib/rest/static/dereferenced')
2123
const contentPath = path.join(process.cwd(), 'content/rest')
@@ -45,7 +47,7 @@ export async function getDiffOpenAPIContentRest() {
4547
if (Object.keys(differences).length > 0) {
4648
for (const schemaName in differences) {
4749
errorMessages[schemaName] = {}
48-
for (const category in differences[schemaName]) {
50+
for (const category of differences[schemaName]) {
4951
if (!errorMessages[schemaName]) errorMessages[schemaName] = category
5052
errorMessages[schemaName][category] = {
5153
contentDir: contentCheck[schemaName][category],
@@ -62,11 +64,6 @@ async function addVersionKeys() {
6264
const schema = JSON.parse(await readFile(path.join(dereferencedPath, filename)))
6365
const key = filename.replace('.deref.json', '')
6466
contentCheck[key] = {}
65-
if (key.startsWith('ghes')) {
66-
const version = parseFloat(key.split('-')[1]).toFixed(1)
67-
LOWEST_SUPPORTED_GHES_VERSION = Math.min(LOWEST_SUPPORTED_GHES_VERSION, version)
68-
HIGHEST_SUPPORTED_GHES_VERSION = Math.max(HIGHEST_SUPPORTED_GHES_VERSION, version)
69-
}
7067
dereferencedSchemas[key] = schema
7168
}
7269
// GitHub Enterprise Cloud is just github.com bc it is not in the OpenAPI schema yet. Once it is, this should be updated
@@ -178,7 +175,9 @@ function getSchemaName(version, versionValues) {
178175
if (versionValues === '*') versions.push('github.ae')
179176
} else if (version === 'ghes') {
180177
if (versionValues === '*') {
181-
versions.push('ghes-3.1', 'ghes-3.2', 'ghes-3.3', 'ghes-3.4')
178+
for (const numVer of supported) {
179+
versions.push('ghes-' + numVer)
180+
}
182181
} else {
183182
let ver = ''
184183
let includeVersion = false

0 commit comments

Comments
 (0)