Skip to content

Commit

Permalink
api/schema: Make the openapi ref indirect
Browse files Browse the repository at this point in the history
The global $ref is not supported so we need to configure
them as 2 inputs.
  • Loading branch information
victorges committed Sep 13, 2024
1 parent ace389e commit 86fc906
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
1 change: 0 additions & 1 deletion packages/api/src/schema/api-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ tags:
description: Operations related to tasks api
- name: generate
description: Operations related to AI generate api
$ref: "./ai-api-schema.yaml"
components:
securitySchemes:
apiKey:
Expand Down
19 changes: 8 additions & 11 deletions packages/api/src/schema/compile-schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,14 @@ const schemaDistDir = path.resolve(__dirname, "..", "dist", "schema");
fs.ensureDirSync(validatorDir);
fs.ensureDirSync(schemaDistDir);

const apiSchemaStr = fs.readFileSync(
path.resolve(schemaDir, "api-schema.yaml"),
"utf8",
);
const dbSchemaStr = fs.readFileSync(
path.resolve(schemaDir, "db-schema.yaml"),
"utf8",
);
const apiData = parseYaml(apiSchemaStr);
const dbData = parseYaml(dbSchemaStr);
const data = _.merge({}, apiData, dbData);
const schemaFiles = ["api-schema.yaml", "ai-api-schema.yaml", "db-schema.yaml"];
const subSchemas = [];
for (const file of schemaFiles) {
const schemaStr = fs.readFileSync(path.resolve(schemaDir, file), "utf8");
const data = parseYaml(schemaStr);
subSchemas.push(data);
}
const data = _.merge({}, ...subSchemas);

(async () => {
const yaml = serializeYaml(data);
Expand Down

0 comments on commit 86fc906

Please sign in to comment.