@travetto/openapi 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/service.ts +6 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/openapi",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "OpenAPI integration support for the Travetto framework",
5
5
  "keywords": [
6
6
  "rest",
package/src/service.ts CHANGED
@@ -1,6 +1,8 @@
1
+ import os from 'os';
1
2
  import fs from 'fs/promises';
2
3
  import type { OpenAPIObject } from 'openapi3-ts';
3
4
 
5
+ import { Util } from '@travetto/base';
4
6
  import { path } from '@travetto/manifest';
5
7
  import { Injectable, Inject } from '@travetto/di';
6
8
  import { ControllerRegistry, RestConfig } from '@travetto/rest';
@@ -81,7 +83,10 @@ export class OpenApiService {
81
83
 
82
84
  // TODO: Should use file abstraction
83
85
  await fs.mkdir(path.dirname(this.apiSpecConfig.output), { recursive: true });
84
- await fs.writeFile(this.apiSpecConfig.output, output);
86
+ const tempFile = path.resolve(os.tmpdir(), `${Util.uuid()}.yml`)
87
+ await fs.writeFile(tempFile, output);
88
+ await fs.copyFile(tempFile, this.apiSpecConfig.output);
89
+ await fs.unlink(tempFile);
85
90
  } catch (err) {
86
91
  console.error('Unable to persist openapi spec', err);
87
92
  }