Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
Fixed specification key formation.
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslonov committed Mar 29, 2021
1 parent 9be07b1 commit ed32682
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion catalog/src/controller/contentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ export class ContentController {
const openApiIndexBuilder = new OpenApiIndexBuilder();

for (const fileName of fileNames) {
const specKey = fileName.startsWith("/") ? fileName.substr(1) : fileName;
const filePath = path.resolve(specsFolderPath, fileName);
const spec: OpenApiSpec30 = JSON.parse(await fs.promises.readFile(filePath, defaultFileEncoding));
openApiIndexBuilder.appendSpec(fileName, spec);
openApiIndexBuilder.appendSpec(specKey, spec);
}

const searchIndex = openApiIndexBuilder.buildIndex();
Expand Down
7 changes: 4 additions & 3 deletions catalog/src/publishing/openApiPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ export class OpenApiPublisher implements IPublisher {
const downloadKeys = await this.specsBlobStorage.listBlobs();

for (const blobKey of downloadKeys) {
const specContent = await this.specsBlobStorage.downloadBlob(blobKey);
const specKey = blobKey.startsWith("/") ? blobKey.substr(1) : blobKey;
const specContent = await this.specsBlobStorage.downloadBlob(specKey);
const openApiSpec: OpenApiSpec30 = JSON.parse(Utils.uint8ArrayToString(specContent));

openApiIndexBuilder.appendSpec(blobKey, openApiSpec);
openApiIndexBuilder.appendSpec(specKey, openApiSpec);

await this.outputBlobStorage.uploadBlob(`/specs/${blobKey}`, specContent, "application/json");
await this.outputBlobStorage.uploadBlob(`/specs/${specKey}`, specContent, "application/json");
this.logger.trackEvent("Publishing", { message: `Publishing OpenAPI spec ${openApiSpec.info.title}...` });
}

Expand Down

0 comments on commit ed32682

Please sign in to comment.