diff --git a/catalog/src/controller/contentController.ts b/catalog/src/controller/contentController.ts index dad39ba..4bf2907 100644 --- a/catalog/src/controller/contentController.ts +++ b/catalog/src/controller/contentController.ts @@ -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(); diff --git a/catalog/src/publishing/openApiPublisher.ts b/catalog/src/publishing/openApiPublisher.ts index 5252ac8..a505810 100644 --- a/catalog/src/publishing/openApiPublisher.ts +++ b/catalog/src/publishing/openApiPublisher.ts @@ -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}...` }); }