@oslo-flanders/swagger-generator 1.4.0 → 1.5.0

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
@@ -38,6 +38,7 @@ The service is executed from the CLI and expects the following parameters:
38
38
  | `--excludeClasses` | Classes to exclude from the generated Swagger | No | Persoon Organisatie Test |
39
39
  | `--excludeProperties` | Properties to exclude from the generated Swagger | No | voornaam achternaam |
40
40
  | `--outputFormat` | Output format for the generated files. Can be specified multiple times to generate multiple formats at once. | No | `application/json` (default) or `application/yaml` |
41
+ | `--disableLinks` | Disable the creation of links | No | `true` or `false` (default) |
41
42
  | `--silent` | Suppress log messages | No | `true` or `false` (default) |
42
43
 
43
44
  ## Usage
@@ -13,7 +13,7 @@ export declare class SwaggerGenerationService implements IService {
13
13
  private schemaExists;
14
14
  init(): Promise<void>;
15
15
  run(): Promise<void>;
16
- createSwagger(schemas: any, links: any): Object;
16
+ createSwagger(schemas: any, links?: any): Object;
17
17
  createSchemas(): Object;
18
18
  createLinks(): Object;
19
19
  writeOutput(outputFormat: OutputFormat, obj: Object, outputPath: string): Promise<void>;
@@ -110,7 +110,9 @@ let SwaggerGenerationService = class SwaggerGenerationService {
110
110
  var _a;
111
111
  /* Create schemas and links once, then write for each output format */
112
112
  const schemas = this.createSchemas();
113
- const links = this.createLinks();
113
+ const links = this.configuration.disableLinks
114
+ ? {}
115
+ : this.createLinks();
114
116
  /* Create self-standing referenceable components */
115
117
  const components = {
116
118
  openapi: this.configuration.versionSwagger,
@@ -121,7 +123,10 @@ let SwaggerGenerationService = class SwaggerGenerationService {
121
123
  license: this.getLicense(),
122
124
  version: this.configuration.versionAPI,
123
125
  },
124
- components: { schemas, links },
126
+ components: {
127
+ schemas,
128
+ ...(Object.keys(links).length > 0 ? { links } : {}),
129
+ },
125
130
  };
126
131
  /* Create Swagger endpoint paths as example */
127
132
  const swagger = this.createSwagger(schemas, links);
@@ -135,7 +140,7 @@ let SwaggerGenerationService = class SwaggerGenerationService {
135
140
  await this.writeOutput(format, swagger, `swagger/example${ext}`);
136
141
  }
137
142
  }
138
- createSwagger(schemas, links) {
143
+ createSwagger(schemas, links = {}) {
139
144
  var _a, _b, _c;
140
145
  const swagger = {
141
146
  openapi: this.configuration.versionSwagger,
@@ -205,7 +210,9 @@ let SwaggerGenerationService = class SwaggerGenerationService {
205
210
  },
206
211
  },
207
212
  },
208
- links: filteredLinks,
213
+ ...(Object.keys(filteredLinks).length > 0
214
+ ? { links: filteredLinks }
215
+ : {}),
209
216
  },
210
217
  /* Error codes follow the RFC 7807 */
211
218
  400: {
@@ -41,6 +41,11 @@ class SwaggerGenerationServiceRunner extends core_1.AppRunner {
41
41
  describe: 'A list of property names to exclude from the output.',
42
42
  type: 'string',
43
43
  array: true,
44
+ })
45
+ .option('disableLinks', {
46
+ describe: 'Disable the creation of links.',
47
+ default: false,
48
+ boolean: true,
44
49
  })
45
50
  .option('silent', {
46
51
  describe: 'All logs are suppressed',
@@ -69,6 +69,10 @@ export declare class SwaggerGenerationServiceConfiguration implements IConfigura
69
69
  * Output formats
70
70
  */
71
71
  private _outputFormat;
72
+ /**
73
+ * Whether to disable the creation of links
74
+ */
75
+ private _disableLinks;
72
76
  createFromCli(params: YargsParams): Promise<void>;
73
77
  get input(): string;
74
78
  get output(): string;
@@ -87,4 +91,5 @@ export declare class SwaggerGenerationServiceConfiguration implements IConfigura
87
91
  get excludeClasses(): string[];
88
92
  get excludeProperties(): string[];
89
93
  get outputFormat(): OutputFormat[];
94
+ get disableLinks(): boolean;
90
95
  }
@@ -28,6 +28,7 @@ let SwaggerGenerationServiceConfiguration = class SwaggerGenerationServiceConfig
28
28
  this._excludeClasses = params.excludeClasses;
29
29
  this._excludeProperties = params.excludeProperties;
30
30
  this._outputFormat = params.outputFormat;
31
+ this._disableLinks = params.disableLinks;
31
32
  }
32
33
  get input() {
33
34
  if (!this._input) {
@@ -104,6 +105,9 @@ let SwaggerGenerationServiceConfiguration = class SwaggerGenerationServiceConfig
104
105
  get outputFormat() {
105
106
  return this._outputFormat || [core_1.OutputFormat.Json];
106
107
  }
108
+ get disableLinks() {
109
+ return !!this._disableLinks;
110
+ }
107
111
  };
108
112
  SwaggerGenerationServiceConfiguration = __decorate([
109
113
  (0, inversify_1.injectable)()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslo-flanders/swagger-generator",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Generate OpenAPI Swagger YAML documentation.",
5
5
  "author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
6
6
  "homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-swagger#readme",