vovk 3.0.0-draft.467 → 3.0.0-draft.468
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/cjs/openapi/vovkSchemaToOpenAPI.d.ts +16 -5
- package/cjs/openapi/vovkSchemaToOpenAPI.js +50 -38
- package/cjs/utils/resolveGeneratorConfigValues.d.ts +6 -6
- package/mjs/openapi/vovkSchemaToOpenAPI.d.ts +16 -5
- package/mjs/openapi/vovkSchemaToOpenAPI.js +50 -38
- package/mjs/utils/resolveGeneratorConfigValues.d.ts +6 -6
- package/package.json +1 -1
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import { type VovkSchema, type VovkOutputConfig } from '../types';
|
|
3
|
-
export declare function vovkSchemaToOpenAPI({ rootEntry, schema: fullSchema,
|
|
2
|
+
import { type VovkSchema, type VovkOutputConfig, VovkStrictConfig, VovkReadmeConfig, VovkSamplesConfig, VovkPackageJson } from '../types';
|
|
3
|
+
export declare function vovkSchemaToOpenAPI({ config, rootEntry, schema: fullSchema, outputConfigs, isBundle, segmentName: givenSegmentName, projectPackageJson, }: {
|
|
4
|
+
config: VovkStrictConfig | undefined;
|
|
4
5
|
rootEntry?: string;
|
|
5
6
|
schema: VovkSchema;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
outputConfigs: VovkOutputConfig[];
|
|
8
|
+
isBundle: boolean;
|
|
9
|
+
segmentName: string | null;
|
|
10
|
+
projectPackageJson: VovkPackageJson | undefined;
|
|
11
|
+
}): {
|
|
12
|
+
readme: VovkReadmeConfig;
|
|
13
|
+
openAPIObject: OpenAPIObject;
|
|
14
|
+
samples: VovkSamplesConfig;
|
|
15
|
+
origin: string;
|
|
16
|
+
package: VovkPackageJson;
|
|
17
|
+
imports: VovkOutputConfig['imports'];
|
|
18
|
+
reExports: VovkOutputConfig['reExports'];
|
|
19
|
+
};
|
|
@@ -44,13 +44,17 @@ function extractComponents(schema) {
|
|
|
44
44
|
const processedSchema = process(schema);
|
|
45
45
|
return [processedSchema, components];
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
// returns OpenAPIObject along with resolved configs
|
|
48
|
+
function vovkSchemaToOpenAPI({ config, rootEntry = 'api', schema: fullSchema, outputConfigs, isBundle, segmentName: givenSegmentName, projectPackageJson, }) {
|
|
48
49
|
const paths = {};
|
|
49
50
|
const components = {};
|
|
50
|
-
const { openAPIObject, samples: samplesConfig, package: packageJson, } = (0, resolveGeneratorConfigValues_1.resolveGeneratorConfigValues)({
|
|
51
|
+
const { openAPIObject, samples: samplesConfig, package: packageJson, readme: readmeConfig, origin, imports, reExports, } = (0, resolveGeneratorConfigValues_1.resolveGeneratorConfigValues)({
|
|
52
|
+
config,
|
|
51
53
|
schema: fullSchema,
|
|
52
|
-
outputConfigs
|
|
54
|
+
outputConfigs,
|
|
55
|
+
isBundle,
|
|
53
56
|
segmentName: givenSegmentName ?? null,
|
|
57
|
+
projectPackageJson,
|
|
54
58
|
});
|
|
55
59
|
for (const [segmentName, segmentSchema] of givenSegmentName
|
|
56
60
|
? [[givenSegmentName, fullSchema.segments[givenSegmentName]]]
|
|
@@ -194,45 +198,53 @@ function vovkSchemaToOpenAPI({ rootEntry = 'api', schema: fullSchema, configs, s
|
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
return {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
201
|
+
readme: readmeConfig,
|
|
202
|
+
samples: samplesConfig,
|
|
203
|
+
package: packageJson,
|
|
204
|
+
imports,
|
|
205
|
+
reExports,
|
|
206
|
+
origin,
|
|
207
|
+
openAPIObject: {
|
|
208
|
+
...openAPIObject,
|
|
209
|
+
components: {
|
|
210
|
+
...openAPIObject?.components,
|
|
211
|
+
schemas: {
|
|
212
|
+
...(openAPIObject?.components?.schemas ?? components),
|
|
213
|
+
HttpStatus: {
|
|
214
|
+
type: 'integer',
|
|
215
|
+
description: 'HTTP status code',
|
|
216
|
+
enum: Object.keys(types_1.HttpStatus)
|
|
217
|
+
.map((k) => types_1.HttpStatus[k])
|
|
218
|
+
.filter(Boolean)
|
|
219
|
+
.filter((v) => typeof v === 'number'),
|
|
220
|
+
},
|
|
221
|
+
VovkErrorResponse: {
|
|
222
|
+
type: 'object',
|
|
223
|
+
description: 'Vovk error response',
|
|
224
|
+
properties: {
|
|
225
|
+
cause: {
|
|
226
|
+
description: 'Error cause of any shape',
|
|
227
|
+
},
|
|
228
|
+
statusCode: {
|
|
229
|
+
$ref: '#/components/schemas/HttpStatus',
|
|
230
|
+
},
|
|
231
|
+
message: {
|
|
232
|
+
type: 'string',
|
|
233
|
+
description: 'Error message',
|
|
234
|
+
},
|
|
235
|
+
isError: {
|
|
236
|
+
type: 'boolean',
|
|
237
|
+
const: true,
|
|
238
|
+
description: 'Indicates that this object represents an error',
|
|
239
|
+
},
|
|
228
240
|
},
|
|
241
|
+
required: ['statusCode', 'message', 'isError'],
|
|
242
|
+
additionalProperties: false,
|
|
229
243
|
},
|
|
230
|
-
|
|
231
|
-
additionalProperties: false,
|
|
244
|
+
...openAPIObject?.components?.schemas,
|
|
232
245
|
},
|
|
233
|
-
...openAPIObject?.components?.schemas,
|
|
234
246
|
},
|
|
247
|
+
paths,
|
|
235
248
|
},
|
|
236
|
-
paths,
|
|
237
249
|
};
|
|
238
250
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { PackageJson } from 'type-fest';
|
|
2
|
-
import type { VovkOutputConfig, VovkReadmeConfig, VovkSamplesConfig, VovkSchema, VovkStrictConfig } from '../types';
|
|
2
|
+
import type { VovkOutputConfig, VovkPackageJson, VovkReadmeConfig, VovkSamplesConfig, VovkSchema, VovkStrictConfig } from '../types';
|
|
3
3
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
4
4
|
export declare function resolveGeneratorConfigValues({ config, schema, outputConfigs, segmentName, isBundle, projectPackageJson, }: {
|
|
5
|
-
config
|
|
5
|
+
config: VovkStrictConfig | undefined;
|
|
6
6
|
schema: VovkSchema;
|
|
7
|
-
outputConfigs
|
|
7
|
+
outputConfigs: VovkOutputConfig[];
|
|
8
8
|
segmentName: string | null;
|
|
9
|
-
isBundle
|
|
10
|
-
projectPackageJson
|
|
9
|
+
isBundle: boolean;
|
|
10
|
+
projectPackageJson: PackageJson | undefined;
|
|
11
11
|
}): {
|
|
12
12
|
readme: VovkReadmeConfig;
|
|
13
13
|
openAPIObject: OpenAPIObject;
|
|
14
14
|
samples: VovkSamplesConfig;
|
|
15
15
|
origin: string;
|
|
16
|
-
package:
|
|
16
|
+
package: VovkPackageJson;
|
|
17
17
|
imports: VovkOutputConfig['imports'];
|
|
18
18
|
reExports: VovkOutputConfig['reExports'];
|
|
19
19
|
};
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import { type VovkSchema, type VovkOutputConfig } from '../types';
|
|
3
|
-
export declare function vovkSchemaToOpenAPI({ rootEntry, schema: fullSchema,
|
|
2
|
+
import { type VovkSchema, type VovkOutputConfig, VovkStrictConfig, VovkReadmeConfig, VovkSamplesConfig, VovkPackageJson } from '../types';
|
|
3
|
+
export declare function vovkSchemaToOpenAPI({ config, rootEntry, schema: fullSchema, outputConfigs, isBundle, segmentName: givenSegmentName, projectPackageJson, }: {
|
|
4
|
+
config: VovkStrictConfig | undefined;
|
|
4
5
|
rootEntry?: string;
|
|
5
6
|
schema: VovkSchema;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
outputConfigs: VovkOutputConfig[];
|
|
8
|
+
isBundle: boolean;
|
|
9
|
+
segmentName: string | null;
|
|
10
|
+
projectPackageJson: VovkPackageJson | undefined;
|
|
11
|
+
}): {
|
|
12
|
+
readme: VovkReadmeConfig;
|
|
13
|
+
openAPIObject: OpenAPIObject;
|
|
14
|
+
samples: VovkSamplesConfig;
|
|
15
|
+
origin: string;
|
|
16
|
+
package: VovkPackageJson;
|
|
17
|
+
imports: VovkOutputConfig['imports'];
|
|
18
|
+
reExports: VovkOutputConfig['reExports'];
|
|
19
|
+
};
|
|
@@ -44,13 +44,17 @@ function extractComponents(schema) {
|
|
|
44
44
|
const processedSchema = process(schema);
|
|
45
45
|
return [processedSchema, components];
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
// returns OpenAPIObject along with resolved configs
|
|
48
|
+
function vovkSchemaToOpenAPI({ config, rootEntry = 'api', schema: fullSchema, outputConfigs, isBundle, segmentName: givenSegmentName, projectPackageJson, }) {
|
|
48
49
|
const paths = {};
|
|
49
50
|
const components = {};
|
|
50
|
-
const { openAPIObject, samples: samplesConfig, package: packageJson, } = (0, resolveGeneratorConfigValues_1.resolveGeneratorConfigValues)({
|
|
51
|
+
const { openAPIObject, samples: samplesConfig, package: packageJson, readme: readmeConfig, origin, imports, reExports, } = (0, resolveGeneratorConfigValues_1.resolveGeneratorConfigValues)({
|
|
52
|
+
config,
|
|
51
53
|
schema: fullSchema,
|
|
52
|
-
outputConfigs
|
|
54
|
+
outputConfigs,
|
|
55
|
+
isBundle,
|
|
53
56
|
segmentName: givenSegmentName ?? null,
|
|
57
|
+
projectPackageJson,
|
|
54
58
|
});
|
|
55
59
|
for (const [segmentName, segmentSchema] of givenSegmentName
|
|
56
60
|
? [[givenSegmentName, fullSchema.segments[givenSegmentName]]]
|
|
@@ -194,45 +198,53 @@ function vovkSchemaToOpenAPI({ rootEntry = 'api', schema: fullSchema, configs, s
|
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
return {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
201
|
+
readme: readmeConfig,
|
|
202
|
+
samples: samplesConfig,
|
|
203
|
+
package: packageJson,
|
|
204
|
+
imports,
|
|
205
|
+
reExports,
|
|
206
|
+
origin,
|
|
207
|
+
openAPIObject: {
|
|
208
|
+
...openAPIObject,
|
|
209
|
+
components: {
|
|
210
|
+
...openAPIObject?.components,
|
|
211
|
+
schemas: {
|
|
212
|
+
...(openAPIObject?.components?.schemas ?? components),
|
|
213
|
+
HttpStatus: {
|
|
214
|
+
type: 'integer',
|
|
215
|
+
description: 'HTTP status code',
|
|
216
|
+
enum: Object.keys(types_1.HttpStatus)
|
|
217
|
+
.map((k) => types_1.HttpStatus[k])
|
|
218
|
+
.filter(Boolean)
|
|
219
|
+
.filter((v) => typeof v === 'number'),
|
|
220
|
+
},
|
|
221
|
+
VovkErrorResponse: {
|
|
222
|
+
type: 'object',
|
|
223
|
+
description: 'Vovk error response',
|
|
224
|
+
properties: {
|
|
225
|
+
cause: {
|
|
226
|
+
description: 'Error cause of any shape',
|
|
227
|
+
},
|
|
228
|
+
statusCode: {
|
|
229
|
+
$ref: '#/components/schemas/HttpStatus',
|
|
230
|
+
},
|
|
231
|
+
message: {
|
|
232
|
+
type: 'string',
|
|
233
|
+
description: 'Error message',
|
|
234
|
+
},
|
|
235
|
+
isError: {
|
|
236
|
+
type: 'boolean',
|
|
237
|
+
const: true,
|
|
238
|
+
description: 'Indicates that this object represents an error',
|
|
239
|
+
},
|
|
228
240
|
},
|
|
241
|
+
required: ['statusCode', 'message', 'isError'],
|
|
242
|
+
additionalProperties: false,
|
|
229
243
|
},
|
|
230
|
-
|
|
231
|
-
additionalProperties: false,
|
|
244
|
+
...openAPIObject?.components?.schemas,
|
|
232
245
|
},
|
|
233
|
-
...openAPIObject?.components?.schemas,
|
|
234
246
|
},
|
|
247
|
+
paths,
|
|
235
248
|
},
|
|
236
|
-
paths,
|
|
237
249
|
};
|
|
238
250
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { PackageJson } from 'type-fest';
|
|
2
|
-
import type { VovkOutputConfig, VovkReadmeConfig, VovkSamplesConfig, VovkSchema, VovkStrictConfig } from '../types';
|
|
2
|
+
import type { VovkOutputConfig, VovkPackageJson, VovkReadmeConfig, VovkSamplesConfig, VovkSchema, VovkStrictConfig } from '../types';
|
|
3
3
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
4
4
|
export declare function resolveGeneratorConfigValues({ config, schema, outputConfigs, segmentName, isBundle, projectPackageJson, }: {
|
|
5
|
-
config
|
|
5
|
+
config: VovkStrictConfig | undefined;
|
|
6
6
|
schema: VovkSchema;
|
|
7
|
-
outputConfigs
|
|
7
|
+
outputConfigs: VovkOutputConfig[];
|
|
8
8
|
segmentName: string | null;
|
|
9
|
-
isBundle
|
|
10
|
-
projectPackageJson
|
|
9
|
+
isBundle: boolean;
|
|
10
|
+
projectPackageJson: PackageJson | undefined;
|
|
11
11
|
}): {
|
|
12
12
|
readme: VovkReadmeConfig;
|
|
13
13
|
openAPIObject: OpenAPIObject;
|
|
14
14
|
samples: VovkSamplesConfig;
|
|
15
15
|
origin: string;
|
|
16
|
-
package:
|
|
16
|
+
package: VovkPackageJson;
|
|
17
17
|
imports: VovkOutputConfig['imports'];
|
|
18
18
|
reExports: VovkOutputConfig['reExports'];
|
|
19
19
|
};
|