Skip to content

Commit e166379

Browse files
committed
remove conversion step
1 parent f1ccf9d commit e166379

File tree

2 files changed

+15
-43
lines changed

2 files changed

+15
-43
lines changed

openapi/openapi.config.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
apis:
22
annotations:
33
root: ./src/annotations.openapi.yaml
4-
output: ./out/annotations-api.yaml
4+
output: ./out/annotations-api.json
55
data-pipelines:
66
root: ./src/data-pipelines.openapi.yaml
7-
output: ./out/data-pipelines-api.yaml
7+
output: ./out/data-pipelines-api.json
88
export:
99
root: ./src/export.openapi.yaml
10-
output: ./out/event-export-api.yaml
10+
output: ./out/event-export-api.json
1111
gdpr:
1212
root: ./src/gdpr.openapi.yaml
13-
output: ./out/gdpr-api-2.yaml
13+
output: ./out/gdpr-api-2.json
1414
identity:
1515
root: ./src/identity.openapi.yaml
16-
output: ./out/identity-api.yaml
16+
output: ./out/identity-api.json
1717
ingestion:
1818
root: ./src/ingestion.openapi.yaml
19-
output: ./out/ingestion-api.yaml
19+
output: ./out/ingestion-api.json
2020
lexicon-schemas:
2121
root: ./src/lexicon-schemas.openapi.yaml
22-
output: ./out/lexicon-schemas-api.yaml
22+
output: ./out/lexicon-schemas-api.json
2323
query:
2424
root: ./src/query.openapi.yaml
25-
output: ./out/query-api.yaml
25+
output: ./out/query-api.json
2626
service-accounts:
2727
root: ./src/service-accounts.openapi.yaml
28-
output: ./out/service-accounts-api.yaml
28+
output: ./out/service-accounts-api.json
2929
warehouse-connectors:
3030
root: ./src/warehouse-connectors.openapi.yaml
31-
output: ./out/warehouse-connectors-api.yaml
31+
output: ./out/warehouse-connectors-api.json
3232

3333
extends:
3434
- recommended

openapi/publish.js

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const process = require("node:process");
44
const util = require("node:util");
55
const YAML = require("yaml");
66

7-
const env = { ...process.env, DEBUG: "rdme*" };
87
const execFile = util.promisify(require("node:child_process").execFile);
98

109
const README_API_KEY = process.env.README_API_KEY;
@@ -29,21 +28,6 @@ async function execAndLog(cmd, args) {
2928
}
3029
}
3130

32-
function getSlugFromJson(file) {
33-
const splitFile = file.split(`.json`);
34-
return splitFile[0];
35-
}
36-
37-
function getSlugFromYaml(file) {
38-
const splitFile = file.split(`.yaml`);
39-
return splitFile[0];
40-
}
41-
42-
function convertSlugToJson(file) {
43-
const slug = getSlugFromYaml(file);
44-
return `${slug}.json`;
45-
}
46-
4731
async function updateSpecs() {
4832
// fetch IDs of openapi specs via readme API
4933
const res = await fetch(
@@ -60,42 +44,30 @@ async function updateSpecs() {
6044
const outBase = path.resolve(__dirname, `out`);
6145
const filenames = fs
6246
.readdirSync(outBase)
63-
.filter((fn) => fn.endsWith(`.yaml`));
47+
.filter((fn) => fn.endsWith(`.json`));
6448

6549
if (!remoteSpecMetas) {
6650
console.error(`!!! No remote specs found, please double check the API`);
6751
process.exit(1);
6852
}
6953

70-
for (specFile of filenames) {
54+
for (specFile of [filenames[0]]) {
7155
// get ID of each spec by matching title between filename and metadata
7256
const fullPath = path.join(outBase, specFile);
7357
const yamlStr = fs.readFileSync(fullPath, "utf8");
7458
const spec = YAML.parse(yamlStr);
75-
const specMeta = remoteSpecMetas.data.find((m) => getSlugFromJson(m.filename) === getSlugFromYaml(specFile));
59+
const specMeta = remoteSpecMetas.data.find((m) => m.filename === specFile);
7660
if (!specMeta) {
7761
console.log(`!!! No spec found for "${spec.info.title}". Please upload it as found in the developer.mixpanel.com runbook.`);
7862
continue;
7963
}
8064

8165
// validate and publish spec
82-
console.log(`Updating ${spec.info.title} (${specFile}`);
66+
console.log(`Updating ${spec.info.title} (${specFile})`);
8367
await execAndLog('npx', ['[email protected]', 'openapi:validate', fullPath]);
84-
// this converts the file to json, since it does this step directly in readme anyway
85-
await execAndLog(
86-
'npx', ['[email protected]', 'openapi', 'convert', fullPath, `--out=${convertSlugToJson(fullPath)}`], {env}
87-
);
8868
// publish the json version
8969
await execAndLog(
90-
'npx', [
91-
92-
'openapi',
93-
'upload',
94-
`${convertSlugToJson(fullPath)}`,
95-
`--key=${README_API_KEY}`,
96-
`--slug=${convertSlugToJson(specFile)}`,
97-
`--confirm-overwrite`
98-
], {env}
70+
'npx', ['[email protected]', 'openapi', 'upload', `${fullPath}`, `--key=${README_API_KEY}`, `--slug=${specFile}`, `--confirm-overwrite`],
9971
);
10072
}
10173
}

0 commit comments

Comments
 (0)