@travetto/openapi 4.1.4 → 5.0.0-rc.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 ArcSine Technologies
3
+ Copyright (c) 2023 ArcSine Technologies
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -24,11 +24,12 @@ All of the high level configurations can be found in the following structure:
24
24
 
25
25
  **Code: Config: OpenAPI Configuration**
26
26
  ```typescript
27
+ import path from 'node:path';
28
+
27
29
  import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/oas31';
28
30
 
29
31
  import { Config } from '@travetto/config';
30
- import { path, RuntimeIndex, RuntimeContext } from '@travetto/manifest';
31
- import { Env } from '@travetto/base';
32
+ import { Env, RuntimeContext } from '@travetto/base';
32
33
  import { Required } from '@travetto/schema';
33
34
 
34
35
  /**
@@ -97,7 +98,7 @@ export class ApiSpecConfig {
97
98
  if (!this.output || this.output === '-') {
98
99
  this.persist = false;
99
100
  } else {
100
- this.output = path.resolve(RuntimeIndex.mainModule.sourcePath, this.output);
101
+ this.output = path.resolve(RuntimeContext.mainSourcePath, this.output);
101
102
  this.persist ??= Env.dynamic;
102
103
  }
103
104
  if (this.persist) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/openapi",
3
- "version": "4.1.4",
3
+ "version": "5.0.0-rc.1",
4
4
  "description": "OpenAPI integration support for the Travetto framework",
5
5
  "keywords": [
6
6
  "rest",
@@ -26,15 +26,15 @@
26
26
  "directory": "module/openapi"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/config": "^4.1.2",
30
- "@travetto/rest": "^4.1.4",
31
- "@travetto/schema": "^4.1.1",
32
- "@travetto/yaml": "^4.1.1",
29
+ "@travetto/config": "^5.0.0-rc.1",
30
+ "@travetto/rest": "^5.0.0-rc.1",
31
+ "@travetto/schema": "^5.0.0-rc.0",
32
+ "yaml": "^2.4.5",
33
33
  "openapi3-ts": "^4.3.3"
34
34
  },
35
35
  "peerDependencies": {
36
- "@travetto/cli": "^4.1.2",
37
- "@travetto/command": "^4.1.1"
36
+ "@travetto/cli": "^5.0.0-rc.1",
37
+ "@travetto/command": "^5.0.0-rc.0"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@travetto/cli": {
package/src/config.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import path from 'node:path';
2
+
1
3
  import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/oas31';
2
4
 
3
5
  import { Config } from '@travetto/config';
4
- import { path, RuntimeIndex, RuntimeContext } from '@travetto/manifest';
5
- import { Env } from '@travetto/base';
6
+ import { Env, RuntimeContext } from '@travetto/base';
6
7
  import { Required } from '@travetto/schema';
7
8
 
8
9
  /**
@@ -71,7 +72,7 @@ export class ApiSpecConfig {
71
72
  if (!this.output || this.output === '-') {
72
73
  this.persist = false;
73
74
  } else {
74
- this.output = path.resolve(RuntimeIndex.mainModule.sourcePath, this.output);
75
+ this.output = path.resolve(RuntimeContext.mainSourcePath, this.output);
75
76
  this.persist ??= Env.dynamic;
76
77
  }
77
78
  if (this.persist) {
package/src/controller.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ConfigureInterceptor, Controller, CorsInterceptor, Get, SetHeaders, Undocumented } from '@travetto/rest';
2
2
  import { Inject } from '@travetto/di';
3
- import { YamlUtil } from '@travetto/yaml';
3
+ import { stringify } from 'yaml';
4
4
 
5
5
  import { OpenApiService } from './service';
6
6
 
@@ -23,6 +23,6 @@ export class OpenApiController {
23
23
  @Get('openapi.yaml')
24
24
  @SetHeaders({ 'Content-Type': 'text/vnd.yaml' })
25
25
  async getYmlSpec(): Promise<string> {
26
- return YamlUtil.serialize(await this.service.getSpec()); // Force output to be simple
26
+ return stringify(await this.service.getSpec()); // Force output to be simple
27
27
  }
28
28
  }
package/src/service.ts CHANGED
@@ -4,7 +4,7 @@ import { Util } from '@travetto/base';
4
4
  import { Injectable, Inject } from '@travetto/di';
5
5
  import { ControllerRegistry, ControllerVisitUtil, RestConfig } from '@travetto/rest';
6
6
  import { SchemaRegistry } from '@travetto/schema';
7
- import { YamlUtil } from '@travetto/yaml';
7
+ import { stringify } from 'yaml';
8
8
 
9
9
  import { ApiHostConfig, ApiInfoConfig, ApiSpecConfig } from './config';
10
10
  import { OpenapiVisitor } from './spec-generate';
@@ -78,7 +78,7 @@ export class OpenApiService {
78
78
 
79
79
  const output = this.apiSpecConfig.output.endsWith('.json') ?
80
80
  JSON.stringify(spec, undefined, 2) :
81
- YamlUtil.serialize(spec);
81
+ stringify(spec);
82
82
 
83
83
  await Util.bufferedFileWrite(this.apiSpecConfig.output, output);
84
84
  } catch (err) {
@@ -321,7 +321,7 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
321
321
 
322
322
  const pConf = this.#getEndpointBody(ep.responseType, this.#getHeaderValue(ep, 'content-type'));
323
323
  const code = Object.keys(pConf.content).length ? 200 : 201;
324
- op.responses[code] = pConf;
324
+ op.responses![code] = pConf;
325
325
 
326
326
  const schema = SchemaRegistry.getMethodSchema(ep.class, ep.handlerName);
327
327
  for (const field of schema) {
@@ -1,8 +1,8 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import { spawn } from 'node:child_process';
3
+ import path from 'node:path';
3
4
 
4
- import { ExecUtil } from '@travetto/base';
5
- import { path, RuntimeContext } from '@travetto/manifest';
5
+ import { ExecUtil, RuntimeContext } from '@travetto/base';
6
6
  import { cliTpl } from '@travetto/cli';
7
7
 
8
8
  /**
@@ -1,4 +1,5 @@
1
- import { path } from '@travetto/manifest';
1
+ import path from 'node:path';
2
+
2
3
  import { CliCommandShape, CliCommand, CliFlag } from '@travetto/cli';
3
4
  import { DockerContainer } from '@travetto/command';
4
5
  import { ExecUtil } from '@travetto/base';
@@ -1,10 +1,10 @@
1
1
  import fs from 'node:fs/promises';
2
+ import path from 'node:path';
2
3
 
3
4
  import { CliCommandShape, CliCommand } from '@travetto/cli';
4
5
  import { Env } from '@travetto/base';
5
6
  import { RootRegistry } from '@travetto/registry';
6
7
  import { DependencyRegistry } from '@travetto/di';
7
- import { path } from '@travetto/manifest';
8
8
 
9
9
  /**
10
10
  * CLI for outputting the open api spec to a local file