@oslo-flanders/swagger-generator 1.0.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 +40 -0
- package/bin/runner.d.ts +2 -0
- package/bin/runner.js +7 -0
- package/index.d.ts +5 -0
- package/index.js +22 -0
- package/lib/SwaggerGenerationService.d.ts +19 -0
- package/lib/SwaggerGenerationService.js +271 -0
- package/lib/SwaggerGenerationServiceRunner.d.ts +7 -0
- package/lib/SwaggerGenerationServiceRunner.js +57 -0
- package/lib/config/DependencyInjectionConfig.d.ts +2 -0
- package/lib/config/DependencyInjectionConfig.js +17 -0
- package/lib/config/SwaggerGenerationServiceConfiguration.d.ts +74 -0
- package/lib/config/SwaggerGenerationServiceConfiguration.js +99 -0
- package/lib/constants/Swagger.d.ts +2 -0
- package/lib/constants/Swagger.js +7 -0
- package/lib/enums/Properties.d.ts +1 -0
- package/lib/enums/Properties.js +47 -0
- package/lib/types/Swagger.d.ts +92 -0
- package/lib/types/Swagger.js +3 -0
- package/lib/utils/swaggerUtils.d.ts +5 -0
- package/lib/utils/swaggerUtils.js +32 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# `OSLO Swagger Generator`
|
|
2
|
+
|
|
3
|
+
> Given an OSLO-compliant RDF file, this tool generates a Swagger API from it.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
```bash
|
|
7
|
+
npm install @oslo-flanders/swagger-generator
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Global install
|
|
11
|
+
To use the service from the command line anywhere, you can install it globally.
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g @oslo-flanders/swagger-generator
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## API
|
|
17
|
+
|
|
18
|
+
The service is executed from the CLI and expects the following parameters:
|
|
19
|
+
| Parameter | Description | Required | Possible values |
|
|
20
|
+
| ------------------ | ------------------------------------------------------------ | ------------------ | --------------------------- |
|
|
21
|
+
| `--input` | The URL or local file path of an OSLO-compliant RDF file | :heavy_check_mark: | |
|
|
22
|
+
| `--output` | The name of the output file | :heavy_check_mark: | |
|
|
23
|
+
| `--language` | The language in which the Swagger must be generated (labels) | No | |
|
|
24
|
+
| `--versionSwagger` | Swagger OpenAPI specification version | :heavy_check_mark: | |
|
|
25
|
+
| `--versionAPI` | API version | :heavy_check_mark: | |
|
|
26
|
+
| `--title` | Title of the API document | :heavy_check_mark: | |
|
|
27
|
+
| `--description` | Description of the API document | :heavy_check_mark: | |
|
|
28
|
+
| `--contextURL` | JSON-LD context URL of the datastandard used in the API | :heavy_check_mark: | |
|
|
29
|
+
| `--baseURL` | API base URL for endpoints and PURIs | :heavy_check_mark: | |
|
|
30
|
+
| `--contactName` | Name of the person or organisation to contact about the API | No | |
|
|
31
|
+
| `--contactEmail` | E-mail to contact for questions about the API | No | |
|
|
32
|
+
| `--contactURL` | Link to follow as contact about the API | No | |
|
|
33
|
+
| `--licenseName` | Name of the license of the API | No | |
|
|
34
|
+
| `--licenseURL` | URL of the license of the API | No | |
|
|
35
|
+
| `--silent` | Suppress log messages | No | `true` or `false` (default) |
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
```bash
|
|
39
|
+
oslo-generator-swagger --input report.jsonld --output swagger.json --language nl --versionSwagger 3.0.4 --versionAPI 1.0.0 --title "Mijn API" --description "Mijn API beschrijving." --contextURL http://example.com/context.jsonld --baseURL http://example.com
|
|
40
|
+
```
|
package/bin/runner.d.ts
ADDED
package/bin/runner.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const SwaggerGenerationServiceRunner_1 = require("../lib/SwaggerGenerationServiceRunner");
|
|
5
|
+
// eslint-disable-next-line no-sync
|
|
6
|
+
new SwaggerGenerationServiceRunner_1.SwaggerGenerationServiceRunner().runCliSync(process);
|
|
7
|
+
//# sourceMappingURL=runner.js.map
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
require("reflect-metadata");
|
|
18
|
+
__exportStar(require("./lib/SwaggerGenerationServiceRunner"), exports);
|
|
19
|
+
__exportStar(require("./lib/SwaggerGenerationService"), exports);
|
|
20
|
+
__exportStar(require("./lib/config/DependencyInjectionConfig"), exports);
|
|
21
|
+
__exportStar(require("./lib/config/SwaggerGenerationServiceConfiguration"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IService } from '@oslo-flanders/core';
|
|
2
|
+
import { QuadStore, Logger } from '@oslo-flanders/core';
|
|
3
|
+
import type * as RDF from '@rdfjs/types';
|
|
4
|
+
import { DataFactory } from 'rdf-data-factory';
|
|
5
|
+
import { SwaggerGenerationServiceConfiguration } from './config/SwaggerGenerationServiceConfiguration';
|
|
6
|
+
export declare class SwaggerGenerationService implements IService {
|
|
7
|
+
readonly logger: Logger;
|
|
8
|
+
readonly configuration: SwaggerGenerationServiceConfiguration;
|
|
9
|
+
readonly dataFactory: DataFactory<RDF.Quad>;
|
|
10
|
+
readonly store: QuadStore;
|
|
11
|
+
constructor(logger: Logger, config: SwaggerGenerationServiceConfiguration, store: QuadStore);
|
|
12
|
+
private getContact;
|
|
13
|
+
private getLicense;
|
|
14
|
+
private getTag;
|
|
15
|
+
init(): Promise<void>;
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
createSwagger(): Object;
|
|
18
|
+
writeSwagger(swagger: Object): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SwaggerGenerationService = void 0;
|
|
16
|
+
const core_1 = require("@oslo-flanders/core");
|
|
17
|
+
const promises_1 = require("fs/promises");
|
|
18
|
+
const inversify_1 = require("inversify");
|
|
19
|
+
const rdf_data_factory_1 = require("rdf-data-factory");
|
|
20
|
+
const SwaggerGenerationServiceConfiguration_1 = require("./config/SwaggerGenerationServiceConfiguration");
|
|
21
|
+
const Properties_1 = require("./enums/Properties");
|
|
22
|
+
const swaggerUtils_1 = require("./utils/swaggerUtils");
|
|
23
|
+
const Swagger_1 = require("./constants/Swagger");
|
|
24
|
+
let SwaggerGenerationService = class SwaggerGenerationService {
|
|
25
|
+
constructor(logger, config, store) {
|
|
26
|
+
this.dataFactory = new rdf_data_factory_1.DataFactory();
|
|
27
|
+
this.logger = logger;
|
|
28
|
+
this.configuration = config;
|
|
29
|
+
this.store = store;
|
|
30
|
+
}
|
|
31
|
+
getContact() {
|
|
32
|
+
/* If no contact information is provided, the whole block may not appear */
|
|
33
|
+
if (!this.configuration.contactName &&
|
|
34
|
+
!this.configuration.contactURL &&
|
|
35
|
+
!this.configuration.contactEmail)
|
|
36
|
+
return undefined;
|
|
37
|
+
return {
|
|
38
|
+
name: this.configuration.contactName,
|
|
39
|
+
url: this.configuration.contactURL,
|
|
40
|
+
email: this.configuration.contactEmail,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
getLicense() {
|
|
44
|
+
/* If no license information is provided, the whole block may not appear */
|
|
45
|
+
if (!this.configuration.licenseName && !this.configuration.licenseURL)
|
|
46
|
+
return undefined;
|
|
47
|
+
return {
|
|
48
|
+
name: this.configuration.licenseName,
|
|
49
|
+
url: this.configuration.licenseURL,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
getTag(subject) {
|
|
53
|
+
var _a;
|
|
54
|
+
if ((_a = this.store
|
|
55
|
+
.getAssignedUri(subject)) === null || _a === void 0 ? void 0 : _a.value.startsWith(this.configuration.baseURL)) {
|
|
56
|
+
return 'OSLO datastandaarden';
|
|
57
|
+
}
|
|
58
|
+
return 'Externe datastandaarden';
|
|
59
|
+
}
|
|
60
|
+
async init() {
|
|
61
|
+
return this.store.addQuadsFromFile(this.configuration.input);
|
|
62
|
+
}
|
|
63
|
+
async run() {
|
|
64
|
+
/* Create Swagger as JSON */
|
|
65
|
+
const swagger = this.createSwagger();
|
|
66
|
+
/* Write Swagger to file */
|
|
67
|
+
await this.writeSwagger(swagger);
|
|
68
|
+
}
|
|
69
|
+
createSwagger() {
|
|
70
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
71
|
+
const swagger = {
|
|
72
|
+
openapi: this.configuration.versionSwagger,
|
|
73
|
+
info: {
|
|
74
|
+
title: this.configuration.title,
|
|
75
|
+
description: this.configuration.description,
|
|
76
|
+
contact: this.getContact(),
|
|
77
|
+
license: this.getLicense(),
|
|
78
|
+
version: this.configuration.versionAPI,
|
|
79
|
+
},
|
|
80
|
+
servers: [
|
|
81
|
+
{
|
|
82
|
+
url: this.configuration.baseURL,
|
|
83
|
+
description: 'Basis URL',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
paths: {},
|
|
87
|
+
components: {
|
|
88
|
+
schemas: {},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
/* Create endpoint for each Class */
|
|
92
|
+
let links = {};
|
|
93
|
+
for (const classId of this.store.findSubjects(core_1.ns.rdf('type'), core_1.ns.owl('Class'))) {
|
|
94
|
+
let label = (_a = (0, core_1.getApplicationProfileLabel)(classId, this.store, this.configuration.language)) === null || _a === void 0 ? void 0 : _a.value;
|
|
95
|
+
const definition = (_b = (0, core_1.getApplicationProfileDefinition)(classId, this.store, this.configuration.language)) === null || _b === void 0 ? void 0 : _b.value;
|
|
96
|
+
const usageNote = (_c = (0, core_1.getApplicationProfileDefinition)(classId, this.store, this.configuration.language)) === null || _c === void 0 ? void 0 : _c.value;
|
|
97
|
+
let attributes = {};
|
|
98
|
+
let requiredAttributes = {};
|
|
99
|
+
/* Get all attributes in a recursive manner for inheritance */
|
|
100
|
+
let attributeIds = [];
|
|
101
|
+
attributeIds = (0, swaggerUtils_1.findAllAttributes)(classId, attributeIds, this.store);
|
|
102
|
+
if (!label) {
|
|
103
|
+
this.logger.error(`Unknown class label for ${classId.value}`);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
/* Class labels should be always pascal cased */
|
|
107
|
+
label = (0, swaggerUtils_1.toPascalCase)(label);
|
|
108
|
+
attributes[label] = [];
|
|
109
|
+
requiredAttributes[label] = [];
|
|
110
|
+
links[label] = {};
|
|
111
|
+
/* Find all attributes for object */
|
|
112
|
+
for (const attributeId of attributeIds) {
|
|
113
|
+
let attributeLabel = (_d = (0, core_1.getApplicationProfileLabel)(attributeId, this.store, this.configuration.language)) === null || _d === void 0 ? void 0 : _d.value;
|
|
114
|
+
const attributeMinCount = (0, core_1.getMinCount)(attributeId, this.store);
|
|
115
|
+
const attributeMaxCount = (0, core_1.getMaxCount)(attributeId, this.store);
|
|
116
|
+
const attributeRangeId = this.store.getRange(attributeId);
|
|
117
|
+
const attributeDefinition = (_e = (0, core_1.getApplicationProfileDefinition)(attributeId, this.store, this.configuration.language)) === null || _e === void 0 ? void 0 : _e.value;
|
|
118
|
+
const attributeUsageNote = (_f = (0, core_1.getApplicationProfileUsageNote)(attributeId, this.store, this.configuration.language)) === null || _f === void 0 ? void 0 : _f.value;
|
|
119
|
+
if (!attributeLabel) {
|
|
120
|
+
this.logger.error(`Unknown label for attribute ${attributeId.value}`);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
/* Attribute labels should be always camel cased */
|
|
124
|
+
attributeLabel = (0, swaggerUtils_1.toCamelCase)(attributeLabel);
|
|
125
|
+
if (!attributeRangeId) {
|
|
126
|
+
this.logger.error(`Unknown range for attribute ${attributeId.value}`);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const attributeDatatypeId = (_g = this.store.getAssignedUri(attributeRangeId)) === null || _g === void 0 ? void 0 : _g.value;
|
|
130
|
+
const attributeDatatypeLabel = (_h = (0, core_1.getApplicationProfileLabel)(attributeRangeId, this.store, this.configuration.language)) === null || _h === void 0 ? void 0 : _h.value;
|
|
131
|
+
if (!attributeDatatypeId || !attributeDatatypeLabel) {
|
|
132
|
+
this.logger.error(`Unknown datatype for attribute ${attributeId.value}`);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (!attributeMinCount || !attributeMaxCount) {
|
|
136
|
+
this.logger.error(`Unknown cardinality for attribute ${attributeId.value}`);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
/* Arrays must be introduced into the schema if the max cardinality is 2 or more */
|
|
140
|
+
const type = 'object';
|
|
141
|
+
const description = `${attributeDefinition}${attributeUsageNote ? ' ' + attributeUsageNote : ''}`;
|
|
142
|
+
const properties = (0, Properties_1.mapProperties)(attributeDatatypeId, attributeDatatypeLabel, this.configuration.baseURL);
|
|
143
|
+
const requiredProperties = properties
|
|
144
|
+
? Object.keys(properties)
|
|
145
|
+
: undefined;
|
|
146
|
+
if (attributeMaxCount != '0' && attributeMaxCount != '1') {
|
|
147
|
+
attributes[label][`${label}.${attributeLabel}`] = {
|
|
148
|
+
type: 'array',
|
|
149
|
+
description: `Lijst van ${attributeDatatypeLabel} items.`,
|
|
150
|
+
items: {
|
|
151
|
+
type: type,
|
|
152
|
+
description: description,
|
|
153
|
+
properties: properties,
|
|
154
|
+
required: requiredProperties,
|
|
155
|
+
},
|
|
156
|
+
minItems: parseInt(attributeMinCount),
|
|
157
|
+
maxItems: attributeMaxCount == '*'
|
|
158
|
+
? undefined
|
|
159
|
+
: parseInt(attributeMaxCount),
|
|
160
|
+
};
|
|
161
|
+
/* Regular property with a cardinality of [0..0], [0..1], [1..1] */
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
attributes[label][`${label}.${attributeLabel}`] = {
|
|
165
|
+
type: type,
|
|
166
|
+
description: description,
|
|
167
|
+
properties: properties,
|
|
168
|
+
required: requiredProperties,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/* Only require properties which are not arrays since those have their own cardinality checks */
|
|
172
|
+
if (attributeMinCount == '1')
|
|
173
|
+
requiredAttributes[label].push(`${label}.${attributeLabel}`);
|
|
174
|
+
/* Create all possible links for endpoint */
|
|
175
|
+
if (!(0, core_1.isStandardDatatype)(attributeDatatypeId)) {
|
|
176
|
+
links[label][`${attributeDatatypeLabel}GET`] = {
|
|
177
|
+
operationId: `${attributeDatatypeLabel}GET`,
|
|
178
|
+
parameters: {
|
|
179
|
+
/* Referring to response body always starts with the same prefix */
|
|
180
|
+
id: `$response.body#/${label}.${attributeLabel}/@id`,
|
|
181
|
+
},
|
|
182
|
+
description: `Het \`@id\` attribuut van de waarde van \`${label}.${attributeLabel}\` kan gebruikt worden om het gerefereerde object van het type \`${attributeDatatypeLabel}\` op te halen.`,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/* Create an endpoint for each object to have PURIs for each object */
|
|
187
|
+
swagger.paths[`/id/${label}/{id}`] = {
|
|
188
|
+
get: {
|
|
189
|
+
summary: definition,
|
|
190
|
+
description: usageNote,
|
|
191
|
+
operationId: `${label}GET`,
|
|
192
|
+
tags: [this.getTag(classId)],
|
|
193
|
+
parameters: [
|
|
194
|
+
{
|
|
195
|
+
name: 'id',
|
|
196
|
+
required: true,
|
|
197
|
+
in: 'path',
|
|
198
|
+
description: `Identificator van een ${label} object.`,
|
|
199
|
+
schema: {
|
|
200
|
+
type: 'string',
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
responses: {
|
|
205
|
+
200: {
|
|
206
|
+
description: `${label} object gevonden.`,
|
|
207
|
+
content: {
|
|
208
|
+
[core_1.OutputFormat.JsonLd]: {
|
|
209
|
+
schema: {
|
|
210
|
+
$ref: `#/components/schemas/${label}`,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
links: links[label],
|
|
215
|
+
},
|
|
216
|
+
400: {
|
|
217
|
+
description: `Ontbrekende informatie bij het opvragen een ${label} object.`,
|
|
218
|
+
},
|
|
219
|
+
404: {
|
|
220
|
+
description: `${label} object met gegeven ID niet gevonden.`,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
/* Create components for each schema */
|
|
226
|
+
swagger.components.schemas[label] = {
|
|
227
|
+
type: 'object',
|
|
228
|
+
description: definition,
|
|
229
|
+
properties: {
|
|
230
|
+
'@context': {
|
|
231
|
+
type: 'string',
|
|
232
|
+
format: 'uri',
|
|
233
|
+
enum: [this.configuration.contextURL],
|
|
234
|
+
},
|
|
235
|
+
'@id': {
|
|
236
|
+
type: 'string',
|
|
237
|
+
format: 'uri',
|
|
238
|
+
pattern: `^${this.configuration.baseURL.replace(Swagger_1.RE_SLASH, '\\/').replace(Swagger_1.RE_DOT, '\\.')}id\\/${label}\\/\\d`,
|
|
239
|
+
},
|
|
240
|
+
'@type': {
|
|
241
|
+
type: 'array',
|
|
242
|
+
description: 'Lijst van object types (klasse)',
|
|
243
|
+
items: {
|
|
244
|
+
type: 'string',
|
|
245
|
+
description: `${label} type`,
|
|
246
|
+
enum: [label],
|
|
247
|
+
},
|
|
248
|
+
minItems: 1,
|
|
249
|
+
},
|
|
250
|
+
...attributes[label],
|
|
251
|
+
},
|
|
252
|
+
required: ['@context', '@id', '@type', ...requiredAttributes[label]],
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
return swagger;
|
|
256
|
+
}
|
|
257
|
+
async writeSwagger(swagger) {
|
|
258
|
+
const data = JSON.stringify(swagger, null, 2);
|
|
259
|
+
await (0, promises_1.writeFile)(this.configuration.output, data);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
SwaggerGenerationService = __decorate([
|
|
263
|
+
(0, inversify_1.injectable)(),
|
|
264
|
+
__param(0, (0, inversify_1.inject)(core_1.ServiceIdentifier.Logger)),
|
|
265
|
+
__param(1, (0, inversify_1.inject)(core_1.ServiceIdentifier.Configuration)),
|
|
266
|
+
__param(2, (0, inversify_1.inject)(core_1.ServiceIdentifier.QuadStore)),
|
|
267
|
+
__metadata("design:paramtypes", [Object, SwaggerGenerationServiceConfiguration_1.SwaggerGenerationServiceConfiguration,
|
|
268
|
+
core_1.QuadStore])
|
|
269
|
+
], SwaggerGenerationService);
|
|
270
|
+
exports.SwaggerGenerationService = SwaggerGenerationService;
|
|
271
|
+
//# sourceMappingURL=SwaggerGenerationService.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CliArgv } from '@oslo-flanders/core';
|
|
2
|
+
import { AppRunner } from '@oslo-flanders/core';
|
|
3
|
+
import type { SwaggerGenerationService } from '../lib/SwaggerGenerationService';
|
|
4
|
+
import type { SwaggerGenerationServiceConfiguration } from './config/SwaggerGenerationServiceConfiguration';
|
|
5
|
+
export declare class SwaggerGenerationServiceRunner extends AppRunner<SwaggerGenerationService, SwaggerGenerationServiceConfiguration> {
|
|
6
|
+
runCli(argv: CliArgv): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SwaggerGenerationServiceRunner = void 0;
|
|
7
|
+
const core_1 = require("@oslo-flanders/core");
|
|
8
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
9
|
+
const DependencyInjectionConfig_1 = require("./config/DependencyInjectionConfig");
|
|
10
|
+
class SwaggerGenerationServiceRunner extends core_1.AppRunner {
|
|
11
|
+
async runCli(argv) {
|
|
12
|
+
const yargv = (0, yargs_1.default)(argv.slice(2))
|
|
13
|
+
.usage('node ./bin/runner.js [args]')
|
|
14
|
+
.option('input', {
|
|
15
|
+
describe: 'The input file to generate a Swagger OpenAPI JSON file from.',
|
|
16
|
+
default: 'input.jsonld',
|
|
17
|
+
})
|
|
18
|
+
.option('output', {
|
|
19
|
+
describe: 'Name of the output file.',
|
|
20
|
+
default: 'openapi.json',
|
|
21
|
+
})
|
|
22
|
+
.option('versionSwagger', {
|
|
23
|
+
describe: 'Version of the Swagger specification used for generation.',
|
|
24
|
+
})
|
|
25
|
+
.option('versionAPI', { describe: 'API version.' })
|
|
26
|
+
.option('language', { describe: 'API language tag.', default: 'nl' })
|
|
27
|
+
.option('title', { describe: 'API title.' })
|
|
28
|
+
.option('description', { describe: 'API description.' })
|
|
29
|
+
.option('contextURL', { describe: 'API JSON-LD Context URL.' })
|
|
30
|
+
.option('baseURL', { describe: 'API base URL.' })
|
|
31
|
+
.option('contactName', { describe: 'API contact name.' })
|
|
32
|
+
.option('contactEmail', { describe: 'API contact e-mail.' })
|
|
33
|
+
.option('contactURL', { describe: 'API contact URL.' })
|
|
34
|
+
.option('licenseName', { describe: 'API license name.' })
|
|
35
|
+
.option('licenseURL', { describe: 'API license URL.' })
|
|
36
|
+
.option('silent', {
|
|
37
|
+
describe: 'All logs are suppressed',
|
|
38
|
+
default: false,
|
|
39
|
+
boolean: true,
|
|
40
|
+
})
|
|
41
|
+
.demandOption([
|
|
42
|
+
'input',
|
|
43
|
+
'output',
|
|
44
|
+
'versionSwagger',
|
|
45
|
+
'versionAPI',
|
|
46
|
+
'title',
|
|
47
|
+
'contextURL',
|
|
48
|
+
'baseURL',
|
|
49
|
+
])
|
|
50
|
+
.help('h')
|
|
51
|
+
.alias('h', 'help');
|
|
52
|
+
const params = await yargv.parse();
|
|
53
|
+
this.startApp(params, DependencyInjectionConfig_1.container).catch((error) => console.error(error));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.SwaggerGenerationServiceRunner = SwaggerGenerationServiceRunner;
|
|
57
|
+
//# sourceMappingURL=SwaggerGenerationServiceRunner.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.container = void 0;
|
|
4
|
+
const core_1 = require("@oslo-flanders/core");
|
|
5
|
+
const inversify_1 = require("inversify");
|
|
6
|
+
const SwaggerGenerationService_1 = require("../SwaggerGenerationService");
|
|
7
|
+
const SwaggerGenerationServiceConfiguration_1 = require("./SwaggerGenerationServiceConfiguration");
|
|
8
|
+
exports.container = new inversify_1.Container();
|
|
9
|
+
exports.container.bind(core_1.ServiceIdentifier.Configuration)
|
|
10
|
+
.to(SwaggerGenerationServiceConfiguration_1.SwaggerGenerationServiceConfiguration)
|
|
11
|
+
.inSingletonScope();
|
|
12
|
+
exports.container.bind(core_1.ServiceIdentifier.Service)
|
|
13
|
+
.to(SwaggerGenerationService_1.SwaggerGenerationService)
|
|
14
|
+
.inSingletonScope();
|
|
15
|
+
exports.container.bind(core_1.ServiceIdentifier.QuadStore)
|
|
16
|
+
.to(core_1.QuadStore);
|
|
17
|
+
//# sourceMappingURL=DependencyInjectionConfig.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { IConfiguration, YargsParams } from '@oslo-flanders/core';
|
|
2
|
+
export declare class SwaggerGenerationServiceConfiguration implements IConfiguration {
|
|
3
|
+
/**
|
|
4
|
+
* Local path or URL to (OSLO compliant) RDF file to generate JSON-LD context from
|
|
5
|
+
*/
|
|
6
|
+
private _input;
|
|
7
|
+
/**
|
|
8
|
+
* Local path to write the JSON-LD context to
|
|
9
|
+
*/
|
|
10
|
+
private _output;
|
|
11
|
+
/**
|
|
12
|
+
* The language of the labels that are used in the context
|
|
13
|
+
*/
|
|
14
|
+
private _language;
|
|
15
|
+
/**
|
|
16
|
+
* Swagger version
|
|
17
|
+
*/
|
|
18
|
+
private _versionSwagger;
|
|
19
|
+
/**
|
|
20
|
+
* API metadata: version
|
|
21
|
+
*/
|
|
22
|
+
private _versionAPI;
|
|
23
|
+
/**
|
|
24
|
+
* API metadata: title
|
|
25
|
+
*/
|
|
26
|
+
private _title;
|
|
27
|
+
/**
|
|
28
|
+
* API metadata: description
|
|
29
|
+
*/
|
|
30
|
+
private _description;
|
|
31
|
+
/**
|
|
32
|
+
* API metadata: JSON-LD context URL
|
|
33
|
+
*/
|
|
34
|
+
private _contextURL;
|
|
35
|
+
/**
|
|
36
|
+
* API metadata: base URL
|
|
37
|
+
*/
|
|
38
|
+
private _baseURL;
|
|
39
|
+
/**
|
|
40
|
+
* API metadata: contact name
|
|
41
|
+
*/
|
|
42
|
+
private _contactName;
|
|
43
|
+
/**
|
|
44
|
+
* API metadata: contact URL
|
|
45
|
+
*/
|
|
46
|
+
private _contactURL;
|
|
47
|
+
/**
|
|
48
|
+
* API metadata: contact email
|
|
49
|
+
*/
|
|
50
|
+
private _contactEmail;
|
|
51
|
+
/**
|
|
52
|
+
* API metadata: license name
|
|
53
|
+
*/
|
|
54
|
+
private _licenseName;
|
|
55
|
+
/**
|
|
56
|
+
* API metadata: license URL
|
|
57
|
+
*/
|
|
58
|
+
private _licenseURL;
|
|
59
|
+
createFromCli(params: YargsParams): Promise<void>;
|
|
60
|
+
get input(): string;
|
|
61
|
+
get output(): string;
|
|
62
|
+
get language(): string;
|
|
63
|
+
get versionSwagger(): string;
|
|
64
|
+
get versionAPI(): string;
|
|
65
|
+
get title(): string;
|
|
66
|
+
get description(): string | undefined;
|
|
67
|
+
get contextURL(): string;
|
|
68
|
+
get baseURL(): string;
|
|
69
|
+
get contactName(): string | undefined;
|
|
70
|
+
get contactURL(): string | undefined;
|
|
71
|
+
get contactEmail(): string | undefined;
|
|
72
|
+
get licenseName(): string | undefined;
|
|
73
|
+
get licenseURL(): string | undefined;
|
|
74
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SwaggerGenerationServiceConfiguration = void 0;
|
|
10
|
+
const inversify_1 = require("inversify");
|
|
11
|
+
let SwaggerGenerationServiceConfiguration = class SwaggerGenerationServiceConfiguration {
|
|
12
|
+
async createFromCli(params) {
|
|
13
|
+
this._input = params.input;
|
|
14
|
+
this._output = params.output;
|
|
15
|
+
this._language = params.language;
|
|
16
|
+
this._versionSwagger = params.versionSwagger;
|
|
17
|
+
this._versionAPI = params.versionAPI;
|
|
18
|
+
this._title = params.title;
|
|
19
|
+
this._description = params.description;
|
|
20
|
+
this._contextURL = params.contextURL;
|
|
21
|
+
this._baseURL = params.baseURL;
|
|
22
|
+
this._contactName = params.contactName;
|
|
23
|
+
this._contactURL = params.contactURL;
|
|
24
|
+
this._contactEmail = params.contactEmail;
|
|
25
|
+
this._licenseName = params.licenseName;
|
|
26
|
+
this._licenseURL = params.licenseURL;
|
|
27
|
+
}
|
|
28
|
+
get input() {
|
|
29
|
+
if (!this._input) {
|
|
30
|
+
throw new Error(`Trying to access property "input" before it was set.`);
|
|
31
|
+
}
|
|
32
|
+
return this._input;
|
|
33
|
+
}
|
|
34
|
+
get output() {
|
|
35
|
+
if (!this._output) {
|
|
36
|
+
throw new Error(`Trying to access property "output" before it was set.`);
|
|
37
|
+
}
|
|
38
|
+
return this._output;
|
|
39
|
+
}
|
|
40
|
+
get language() {
|
|
41
|
+
if (!this._language) {
|
|
42
|
+
throw new Error(`Trying to access property "language" before it was set.`);
|
|
43
|
+
}
|
|
44
|
+
return this._language;
|
|
45
|
+
}
|
|
46
|
+
get versionSwagger() {
|
|
47
|
+
if (!this._versionSwagger) {
|
|
48
|
+
throw new Error(`Trying to access property "versionSwagger" before it was set.`);
|
|
49
|
+
}
|
|
50
|
+
return this._versionSwagger;
|
|
51
|
+
}
|
|
52
|
+
get versionAPI() {
|
|
53
|
+
if (!this._versionAPI) {
|
|
54
|
+
throw new Error(`Trying to access property "versionAPI" before it was set.`);
|
|
55
|
+
}
|
|
56
|
+
return this._versionAPI;
|
|
57
|
+
}
|
|
58
|
+
get title() {
|
|
59
|
+
if (!this._title) {
|
|
60
|
+
throw new Error(`Trying to access property "title" before it was set.`);
|
|
61
|
+
}
|
|
62
|
+
return this._title;
|
|
63
|
+
}
|
|
64
|
+
get description() {
|
|
65
|
+
return this._description;
|
|
66
|
+
}
|
|
67
|
+
get contextURL() {
|
|
68
|
+
if (!this._contextURL) {
|
|
69
|
+
throw new Error(`Trying access property "contextURL" before it was set.`);
|
|
70
|
+
}
|
|
71
|
+
return this._contextURL;
|
|
72
|
+
}
|
|
73
|
+
get baseURL() {
|
|
74
|
+
if (!this._baseURL) {
|
|
75
|
+
throw new Error(`Trying access property "baseURL" before it was set.`);
|
|
76
|
+
}
|
|
77
|
+
return this._baseURL;
|
|
78
|
+
}
|
|
79
|
+
get contactName() {
|
|
80
|
+
return this._contactName;
|
|
81
|
+
}
|
|
82
|
+
get contactURL() {
|
|
83
|
+
return this._contactURL;
|
|
84
|
+
}
|
|
85
|
+
get contactEmail() {
|
|
86
|
+
return this._contactEmail;
|
|
87
|
+
}
|
|
88
|
+
get licenseName() {
|
|
89
|
+
return this._licenseName;
|
|
90
|
+
}
|
|
91
|
+
get licenseURL() {
|
|
92
|
+
return this._licenseURL;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
SwaggerGenerationServiceConfiguration = __decorate([
|
|
96
|
+
(0, inversify_1.injectable)()
|
|
97
|
+
], SwaggerGenerationServiceConfiguration);
|
|
98
|
+
exports.SwaggerGenerationServiceConfiguration = SwaggerGenerationServiceConfiguration;
|
|
99
|
+
//# sourceMappingURL=SwaggerGenerationServiceConfiguration.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RE_SLASH = exports.RE_DOT = void 0;
|
|
4
|
+
/* Regex for escaping URIs when using patterns in OpenAPI JSON */
|
|
5
|
+
exports.RE_DOT = /\./gi;
|
|
6
|
+
exports.RE_SLASH = /\//gi;
|
|
7
|
+
//# sourceMappingURL=Swagger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mapProperties: (datatype: string, label: string, baseURI: string) => object;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapProperties = void 0;
|
|
4
|
+
const core_1 = require("@oslo-flanders/core");
|
|
5
|
+
const Swagger_1 = require("../constants/Swagger");
|
|
6
|
+
/* eslint-disable */
|
|
7
|
+
const Properties = new Map([
|
|
8
|
+
[core_1.ns.rdf('langString').value, { '@value': { type: 'string' }, '@language': { type: 'string', enum: ['nl'] } }],
|
|
9
|
+
[core_1.ns.xsd('string').value, { '@value': { type: 'string' } }],
|
|
10
|
+
[core_1.ns.xsd('anyURI').value, { '@id': { type: 'string', format: 'uri' } }],
|
|
11
|
+
[core_1.ns.xsd('dateTime').value, { '@value': { type: 'string', format: 'date-time' }, '@type': { type: 'string', enum: ['DateTime'] } }],
|
|
12
|
+
[core_1.ns.xsd('date').value, { '@value': { type: 'string', format: 'date' }, '@type': { type: 'string', enum: ['Date'] } }],
|
|
13
|
+
[core_1.ns.xsd('boolean').value, { '@value': { type: 'boolean' }, '@type': { type: 'string', enum: ['Boolean'] } }],
|
|
14
|
+
[core_1.ns.xsd('integer').value, { '@value': { type: 'number', format: 'int64' }, '@type': { type: 'string', enum: ['Integer'] } }],
|
|
15
|
+
[core_1.ns.xsd('long').value, { '@value': { type: 'number', format: 'int64', minimum: -9223372036854775808, maximum: 9223372036854775807 }, '@type': { type: 'string', enum: ['Long'] } }],
|
|
16
|
+
[core_1.ns.xsd('float').value, { '@value': { type: 'number', format: 'float' }, '@type': { type: 'string', enum: ['Float'] } }],
|
|
17
|
+
[core_1.ns.xsd('double').value, { '@value': { type: 'number', format: 'double' }, '@type': { type: 'string', enum: ['Double'] } }],
|
|
18
|
+
[core_1.ns.xsd('int').value, { '@value': { type: 'number', format: 'int32', minimum: -2147483648, maximum: 2147483647 }, '@type': { type: 'string', enum: ['Int'] } }],
|
|
19
|
+
[core_1.ns.xsd('short').value, { '@value': { type: 'number', format: 'int32', minimum: -32768, maximum: 32767 }, '@type': { type: 'string', enum: ['Short'] } }],
|
|
20
|
+
[core_1.ns.xsd('byte').value, { '@value': { type: 'number', format: 'int32', minimum: -128, maximum: 127 }, '@type': { type: 'string', enum: ['Byte'] } }],
|
|
21
|
+
[core_1.ns.xsd('hexBinary').value, { '@value': { type: 'string', format: 'binary' }, '@type': { type: 'string', enum: ['HexBinary'] } }],
|
|
22
|
+
[core_1.ns.xsd('base64Binary').value, { '@value': { type: 'string', format: 'byte' }, '@type': { type: 'string', enum: ['Base64Binary'] } }],
|
|
23
|
+
[core_1.ns.xsd('nonNegativeInteger').value, { '@value': { type: 'number', format: 'int64' }, '@type': { type: 'string', enum: ['NonNegativeInteger'] } }],
|
|
24
|
+
[core_1.ns.xsd('nonPositiveInteger').value, { '@value': { type: 'number', format: 'int64' }, '@type': { type: 'string', enum: ['NonPositiveInteger'] } }],
|
|
25
|
+
[core_1.ns.xsd('negativeInteger').value, { '@value': { type: 'number', format: 'int64', maximum: 0 }, '@type': { type: 'string', enum: ['NegativeInteger'] } }],
|
|
26
|
+
[core_1.ns.xsd('positiveInteger').value, { '@value': { type: 'number', format: 'int64', minimum: 1 }, '@type': { type: 'string', enum: ['PositiveInteger'] } }],
|
|
27
|
+
[core_1.ns.xsd('unsignedLong').value, { '@value': { type: 'number', format: 'int64', minimum: 0, maximum: 18446744073709551615 }, '@type': { type: 'string', enum: ['UnsignedLong'] } }],
|
|
28
|
+
[core_1.ns.xsd('unsignedInt').value, { '@value': { type: 'number', format: 'int32', minimum: 0, maximum: 4294967295 }, '@type': { type: 'string', enum: ['UnsignedInt'] } }],
|
|
29
|
+
[core_1.ns.xsd('unsignedShort').value, { '@value': { type: 'number', format: 'int32', minimum: 0, maximum: 65535 }, '@type': { type: 'string', enum: ['UnsignedShort'] } }],
|
|
30
|
+
[core_1.ns.xsd('unsignedByte').value, { '@value': { type: 'number', format: 'int32', minimum: 0, maximum: 255 }, '@type': { type: 'string', enum: ['UnsignedByte'] } }],
|
|
31
|
+
[core_1.ns.xsd('decimal').value, { '@value': { type: 'string', pattern: '(+|-)?([0-9]+(.[0-9]*)?|.[0-9]+)' }, '@type': { type: 'string', enum: ['Decimal'] } }],
|
|
32
|
+
]);
|
|
33
|
+
/* eslint-enable */
|
|
34
|
+
const mapProperties = (datatype, label, baseURI) => {
|
|
35
|
+
if (Properties.has(datatype)) {
|
|
36
|
+
return Properties.get(datatype);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
'@id': {
|
|
40
|
+
type: 'string',
|
|
41
|
+
format: 'uri',
|
|
42
|
+
pattern: `^${baseURI.replace(Swagger_1.RE_SLASH, '\\/').replace(Swagger_1.RE_DOT, '\\.')}id\\/${label}\\/\\d`,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.mapProperties = mapProperties;
|
|
47
|
+
//# sourceMappingURL=Properties.js.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export interface SwaggerRoot {
|
|
2
|
+
openapi: string;
|
|
3
|
+
info: SwaggerInfo;
|
|
4
|
+
servers: SwaggerServer[];
|
|
5
|
+
paths: SwaggerPaths;
|
|
6
|
+
components: SwaggerComponents;
|
|
7
|
+
}
|
|
8
|
+
export interface SwaggerInfo {
|
|
9
|
+
title: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
contact?: SwaggerInfoContact;
|
|
12
|
+
license?: SwaggerInfoLicense;
|
|
13
|
+
version: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SwaggerInfoContact {
|
|
16
|
+
name?: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SwaggerInfoLicense {
|
|
21
|
+
name?: string;
|
|
22
|
+
url?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SwaggerServer {
|
|
25
|
+
url: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
}
|
|
28
|
+
export type SwaggerPaths = Record<string, SwaggerPathsOperations>;
|
|
29
|
+
export interface SwaggerPathsOperations {
|
|
30
|
+
get?: SwaggerPathsOperation;
|
|
31
|
+
post?: SwaggerPathsOperation;
|
|
32
|
+
put?: SwaggerPathsOperation;
|
|
33
|
+
delete?: SwaggerPathsOperation;
|
|
34
|
+
patch?: SwaggerPathsOperation;
|
|
35
|
+
}
|
|
36
|
+
export interface SwaggerPathsOperation {
|
|
37
|
+
tags?: string[];
|
|
38
|
+
summary?: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
operationId?: string;
|
|
41
|
+
parameters?: SwaggerPathsOperationParameter[];
|
|
42
|
+
requestBody?: SwaggerPathsOperationRequestBody;
|
|
43
|
+
responses?: SwaggerPathsOperationResponses;
|
|
44
|
+
}
|
|
45
|
+
export interface SwaggerPathsOperationParameter {
|
|
46
|
+
name?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
in: string;
|
|
49
|
+
required: boolean;
|
|
50
|
+
schema: SwaggerPathsOperationParameterSchema;
|
|
51
|
+
}
|
|
52
|
+
export interface SwaggerPathsOperationParameterSchema {
|
|
53
|
+
type: string;
|
|
54
|
+
}
|
|
55
|
+
export interface SwaggerPathsOperationRequestBody {
|
|
56
|
+
description?: string;
|
|
57
|
+
content: SwaggerPathsOperationRequestBodyContent;
|
|
58
|
+
}
|
|
59
|
+
export type SwaggerPathsOperationRequestBodyContent = Record<string, SwaggerPathsOperationRequestBodyContentValue>;
|
|
60
|
+
export interface SwaggerPathsOperationRequestBodyContentValue {
|
|
61
|
+
schema: SwaggerPathsOperationRequestBodyContentValueSchema;
|
|
62
|
+
example?: SwaggerPathsOperationRequestBodyContentValueExample;
|
|
63
|
+
}
|
|
64
|
+
export interface SwaggerPathsOperationRequestBodyContentValueSchema {
|
|
65
|
+
type: string;
|
|
66
|
+
}
|
|
67
|
+
export type SwaggerPathsOperationRequestBodyContentValueExample = Record<string, string>;
|
|
68
|
+
export interface SwaggerPathsOperationResponses {
|
|
69
|
+
}
|
|
70
|
+
export interface SwaggerComponents {
|
|
71
|
+
schemas: SwaggerComponentsSchemas;
|
|
72
|
+
}
|
|
73
|
+
export type SwaggerComponentsSchemas = Record<string, SwaggerComponentsSchemasValue>;
|
|
74
|
+
export interface SwaggerComponentsSchemasValue {
|
|
75
|
+
type?: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
properties?: SwaggerComponentsValueProperties;
|
|
78
|
+
required?: string[];
|
|
79
|
+
}
|
|
80
|
+
export type SwaggerComponentsValueProperties = Record<string, SwaggerComponentsValuePropertiesValue>;
|
|
81
|
+
export interface SwaggerComponentsValuePropertiesValue {
|
|
82
|
+
type: string;
|
|
83
|
+
description?: string;
|
|
84
|
+
enum?: string[];
|
|
85
|
+
items?: SwaggerComponentsValuePropertiesValueItems;
|
|
86
|
+
}
|
|
87
|
+
export interface SwaggerComponentsValuePropertiesValueItems {
|
|
88
|
+
type: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
properties?: SwaggerComponentsValueProperties;
|
|
91
|
+
required?: string[];
|
|
92
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { QuadStore } from '@oslo-flanders/core';
|
|
2
|
+
import type * as RDF from '@rdfjs/types';
|
|
3
|
+
export declare function findAllAttributes(subject: RDF.Term, attributeIds: RDF.Term[], store: QuadStore): RDF.Term[];
|
|
4
|
+
export declare function toPascalCase(text: string): string;
|
|
5
|
+
export declare function toCamelCase(text: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toCamelCase = exports.toPascalCase = exports.findAllAttributes = void 0;
|
|
4
|
+
const core_1 = require("@oslo-flanders/core");
|
|
5
|
+
function findAllAttributes(subject, attributeIds, store) {
|
|
6
|
+
const parentIds = store.findObjects(subject, core_1.ns.rdfs('subClassOf'));
|
|
7
|
+
attributeIds = [
|
|
8
|
+
...attributeIds,
|
|
9
|
+
...store.findSubjects(core_1.ns.rdfs('domain'), subject),
|
|
10
|
+
];
|
|
11
|
+
for (const parentId of parentIds) {
|
|
12
|
+
attributeIds = findAllAttributes(parentId, attributeIds, store);
|
|
13
|
+
}
|
|
14
|
+
return attributeIds;
|
|
15
|
+
}
|
|
16
|
+
exports.findAllAttributes = findAllAttributes;
|
|
17
|
+
function removeCaret(text) {
|
|
18
|
+
return text.replace(/^\^/u, '');
|
|
19
|
+
}
|
|
20
|
+
function toPascalCase(text) {
|
|
21
|
+
return removeCaret(text)
|
|
22
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/gu, (word, index) => word.toUpperCase())
|
|
23
|
+
.replace(/\s+/gu, '');
|
|
24
|
+
}
|
|
25
|
+
exports.toPascalCase = toPascalCase;
|
|
26
|
+
function toCamelCase(text) {
|
|
27
|
+
return removeCaret(text)
|
|
28
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/gu, (word, index) => index === 0 ? word.toLowerCase() : word.toUpperCase())
|
|
29
|
+
.replace(/\s+/gu, '');
|
|
30
|
+
}
|
|
31
|
+
exports.toCamelCase = toCamelCase;
|
|
32
|
+
//# sourceMappingURL=swaggerUtils.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oslo-flanders/swagger-generator",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Generate OpenAPI Swagger YAML documentation.",
|
|
5
|
+
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
|
|
6
|
+
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-swagger#readme",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"oslo-generator-swagger": "./bin/runner.js"
|
|
11
|
+
},
|
|
12
|
+
"directories": {
|
|
13
|
+
"lib": "lib",
|
|
14
|
+
"bin": "bin",
|
|
15
|
+
"test": "test"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"lib/**/*.d.ts",
|
|
19
|
+
"lib/**/*.js",
|
|
20
|
+
"bin/**/*.d.ts",
|
|
21
|
+
"bin/**/*.js",
|
|
22
|
+
"index.d.ts",
|
|
23
|
+
"index.js"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/Informatievlaanderen/OSLO-UML-Transformer.git"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "npm run build:ts",
|
|
31
|
+
"build:ts": "tsc",
|
|
32
|
+
"test:integration": "node \"../../node_modules/jest/bin/jest.js\" --group=integration --config ../../jest.config.ts ./packages/oslo-generator-swagger/",
|
|
33
|
+
"test:unit": "node \"../../node_modules/jest/bin/jest.js\" --group=unit --config ../../jest.config.ts ./packages/oslo-generator-swagger/"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/Informatievlaanderen/OSLO-UML-Transformer/issues"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@rdfjs/types": "^1.1.0",
|
|
40
|
+
"@types/streamify-array": "^1.0.0"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@oslo-flanders/core": "^1.0.0",
|
|
44
|
+
"inversify": "^6.0.1",
|
|
45
|
+
"n3": "^1.16.2",
|
|
46
|
+
"rdf-data-factory": "^1.1.1",
|
|
47
|
+
"rdf-parse": "^2.3.2",
|
|
48
|
+
"rdf-serialize": "^2.2.2",
|
|
49
|
+
"reflect-metadata": "^0.1.13",
|
|
50
|
+
"streamify-array": "^1.0.1",
|
|
51
|
+
"streamify-string": "^1.0.1",
|
|
52
|
+
"yargs": "^17.6.0"
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "beaa3821b72a7df104ff61af49fed6c1140fadd8"
|
|
55
|
+
}
|