Skip to content

Commit

Permalink
Added script for counting oneOf responses.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkaliszuk committed Nov 30, 2023
1 parent 4eec2ad commit b0e3c99
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"remove-deprecated-from-openapi": "ts-node ./scripts/remove-deprecated-from-openapi.ts",
"generate-open-api-with-specific-endpoints": "ts-node ./scripts/generate-open-api-with-specific-endpoints.ts",
"manage-project": "ts-node ./scripts/build-md-tables-from-openapi.ts && ts-node ./scripts/manage-project.ts",
"readme-upload-missing-images": "ts-node ./scripts/readme-upload-missing-images.ts"
"readme-upload-missing-images": "ts-node ./scripts/readme-upload-missing-images.ts",
"count-responses-with-multiple-options": "ts-node ./scripts/count-responses-with-multiple-options.ts"
},
"dependencies": {
"axios": "^1.5.1",
Expand Down
19 changes: 19 additions & 0 deletions scripts/count-responses-with-multiple-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import path from "path";
import fsPromises from "fs/promises";

const main = async () => {
const openApiPath = path.join(__dirname, "../reference/OpenAPI.json");
const openAPIContent = JSON.parse(
(await fsPromises.readFile(openApiPath)).toString()
);

const schemas = openAPIContent.components.schemas;

const schemasWithOneOf = Object.keys(schemas)
.filter(schemaName => schemaName.includes("ResponseBody"))
.filter(schemaName => schemas[schemaName].oneOf)

console.log("Responses schemas with oneOf = ", schemasWithOneOf);
}

main()

0 comments on commit b0e3c99

Please sign in to comment.