@travetto/openapi 8.0.0-alpha.0 → 8.0.0-alpha.10

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/README.md CHANGED
@@ -31,6 +31,7 @@ import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/oas
31
31
  import { Config } from '@travetto/config';
32
32
  import { Runtime } from '@travetto/runtime';
33
33
  import { Required } from '@travetto/schema';
34
+ import { PostConstruct } from '@travetto/di';
34
35
 
35
36
  /**
36
37
  * API Information, infers as much as possible from the package.json
@@ -50,7 +51,8 @@ export class ApiInfoConfig {
50
51
  @Required(false)
51
52
  version: string;
52
53
 
53
- postConstruct(): void {
54
+ @PostConstruct()
55
+ finalizeConfig(): void {
54
56
  this.title ??= Runtime.main.name;
55
57
  this.version ??= Runtime.main.version;
56
58
  this.description ??= Runtime.main.description;
@@ -94,7 +96,8 @@ export class ApiSpecConfig {
94
96
  */
95
97
  exposeAllSchemas: boolean = false;
96
98
 
97
- async postConstruct(): Promise<void> {
99
+ @PostConstruct()
100
+ async finalizeConfig(): Promise<void> {
98
101
  if (!this.output || this.output === '-') {
99
102
  this.persist = false;
100
103
  } else {
@@ -125,7 +128,7 @@ Usage: openapi:spec [options]
125
128
  Options:
126
129
  -o, --output <string> Output files
127
130
  -m, --module <module> Module to run for
128
- -h, --help display help for command
131
+ --help display help for command
129
132
  ```
130
133
 
131
134
  The command will run your application, in non-server mode, to collect all the endpoints and model information, to produce the `openapi.yml`. Once produced, the code will store the output in the specified location.
@@ -147,7 +150,7 @@ Options:
147
150
  -i, --input <string> Input file (default: "./openapi.yml")
148
151
  -o, --output <string> Output folder (default: "./api-client")
149
152
  -d, --docker-image <string> Docker Image to user (default: "openapitools/openapi-generator-cli:latest")
150
- -h, --help display help for command
153
+ --help display help for command
151
154
  ```
152
155
 
153
156
  This tool relies upon a custom build of [OpenAPI client generation tools](https://github.com/OpenAPITools/openapi-generator), which supports watching. This allows for fast responsive client generation as the shape of the API changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/openapi",
3
- "version": "8.0.0-alpha.0",
3
+ "version": "8.0.0-alpha.10",
4
4
  "type": "module",
5
5
  "description": "OpenAPI integration support for the Travetto framework",
6
6
  "keywords": [
@@ -27,14 +27,14 @@
27
27
  "directory": "module/openapi"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/config": "^8.0.0-alpha.0",
31
- "@travetto/schema": "^8.0.0-alpha.0",
32
- "@travetto/web": "^8.0.0-alpha.0",
30
+ "@travetto/config": "^8.0.0-alpha.9",
31
+ "@travetto/schema": "^8.0.0-alpha.9",
32
+ "@travetto/web": "^8.0.0-alpha.10",
33
33
  "openapi3-ts": "^4.5.0",
34
34
  "yaml": "^2.8.2"
35
35
  },
36
36
  "peerDependencies": {
37
- "@travetto/cli": "^8.0.0-alpha.0"
37
+ "@travetto/cli": "^8.0.0-alpha.14"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@travetto/cli": {
package/src/config.ts CHANGED
@@ -5,6 +5,7 @@ import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/oas
5
5
  import { Config } from '@travetto/config';
6
6
  import { Runtime } from '@travetto/runtime';
7
7
  import { Required } from '@travetto/schema';
8
+ import { PostConstruct } from '@travetto/di';
8
9
 
9
10
  /**
10
11
  * API Information, infers as much as possible from the package.json
@@ -24,7 +25,8 @@ export class ApiInfoConfig {
24
25
  @Required(false)
25
26
  version: string;
26
27
 
27
- postConstruct(): void {
28
+ @PostConstruct()
29
+ finalizeConfig(): void {
28
30
  this.title ??= Runtime.main.name;
29
31
  this.version ??= Runtime.main.version;
30
32
  this.description ??= Runtime.main.description;
@@ -68,7 +70,8 @@ export class ApiSpecConfig {
68
70
  */
69
71
  exposeAllSchemas: boolean = false;
70
72
 
71
- async postConstruct(): Promise<void> {
73
+ @PostConstruct()
74
+ async finalizeConfig(): Promise<void> {
72
75
  if (!this.output || this.output === '-') {
73
76
  this.persist = false;
74
77
  } else {
package/src/service.ts CHANGED
@@ -4,7 +4,7 @@ import { stringify } from 'yaml';
4
4
 
5
5
  import { ManifestFileUtil } from '@travetto/manifest';
6
6
  import { BinaryMetadataUtil, JSONUtil } from '@travetto/runtime';
7
- import { Injectable, Inject } from '@travetto/di';
7
+ import { Injectable, Inject, PostConstruct } from '@travetto/di';
8
8
  import { ControllerVisitUtil, type WebConfig } from '@travetto/web';
9
9
 
10
10
  import type { ApiHostConfig, ApiInfoConfig, ApiSpecConfig } from './config.ts';
@@ -43,7 +43,8 @@ export class OpenApiService {
43
43
  /**
44
44
  * Initialize after schemas are readied
45
45
  */
46
- async postConstruct(): Promise<void> {
46
+ @PostConstruct()
47
+ async finalizeConfig(): Promise<void> {
47
48
  if (!this.apiHostConfig.servers && this.webConfig.baseUrl) {
48
49
  this.apiHostConfig.servers = [{ url: this.webConfig.baseUrl }];
49
50
  }
@@ -12,7 +12,7 @@ export class OpenApiClientHelp {
12
12
 
13
13
  static async getListOfFormats(dockerImage: string): Promise<string[]> {
14
14
  const formatCache = Runtime.toolPath('openapi-formats.json');
15
- if (!await fs.stat(formatCache).catch(() => false)) {
15
+ if (!await fs.stat(formatCache, { throwIfNoEntry: false })) {
16
16
  const { stdout } = await ExecUtil.getResult(spawn('docker', ['run', '--rm', dockerImage, 'list']));
17
17
  const lines = stdout
18
18
  .split('DOCUMENTATION')[0]
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
 
4
- import { type CliCommandShape, CliCommand } from '@travetto/cli';
4
+ import { type CliCommandShape, CliCommand, CliModuleFlag } from '@travetto/cli';
5
5
  import { JSONUtil, Env } from '@travetto/runtime';
6
6
  import { Registry } from '@travetto/registry';
7
7
  import { DependencyRegistryIndex } from '@travetto/di';
@@ -9,13 +9,16 @@ import { DependencyRegistryIndex } from '@travetto/di';
9
9
  /**
10
10
  * CLI for outputting the open api spec to a local file
11
11
  */
12
- @CliCommand({ with: { module: true } })
12
+ @CliCommand()
13
13
  export class OpenApiSpecCommand implements CliCommandShape {
14
14
 
15
15
  /** Output files */
16
16
  output?: string;
17
17
 
18
- preMain(): void {
18
+ @CliModuleFlag({ short: 'm' })
19
+ module: string;
20
+
21
+ finalize(): void {
19
22
  Env.DEBUG.set(false);
20
23
  }
21
24