@travetto/openapi 3.1.16 → 3.1.18

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/controller.ts +11 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/openapi",
3
- "version": "3.1.16",
3
+ "version": "3.1.18",
4
4
  "description": "OpenAPI integration support for the Travetto framework",
5
5
  "keywords": [
6
6
  "rest",
package/src/controller.ts CHANGED
@@ -4,6 +4,13 @@ import { YamlUtil } from '@travetto/yaml';
4
4
 
5
5
  import { OpenApiService } from './service';
6
6
 
7
+ const CORS_HEADERS = {
8
+ 'Access-Control-Allow-Origin': '*',
9
+ 'Access-Control-Allow-Method': 'GET',
10
+ 'Access-Control-Allow-Headers': '*',
11
+ 'Access-Control-Allow-Credentials': 'true'
12
+ };
13
+
7
14
  /**
8
15
  * Basic controller for surfacing the api spec
9
16
  */
@@ -15,13 +22,14 @@ export class OpenApiController {
15
22
  service: OpenApiService;
16
23
 
17
24
  @Get('openapi.json')
25
+ @SetHeaders(CORS_HEADERS)
18
26
  async getSpec(): Promise<object> {
19
27
  return this.service.getSpec(); // Force output to be simple
20
28
  }
21
29
 
22
30
  @Get('openapi.yaml')
23
- @SetHeaders({ 'Content-Type': 'text/vnd.yaml' })
31
+ @SetHeaders({ 'Content-Type': 'text/vnd.yaml', ...CORS_HEADERS })
24
32
  async getYmlSpec(): Promise<string> {
25
- return YamlUtil.serialize(this.service.getSpec()); // Force output to be simple
33
+ return YamlUtil.serialize(await this.service.getSpec()); // Force output to be simple
26
34
  }
27
- }
35
+ }