@nestia/sdk 2.6.4 → 3.0.0-dev.20240412

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.
Files changed (56) hide show
  1. package/lib/INestiaConfig.d.ts +5 -8
  2. package/lib/analyses/ExceptionAnalyzer.js +2 -2
  3. package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
  4. package/lib/analyses/PathAnalyzer.d.ts +0 -2
  5. package/lib/executable/internal/NestiaConfigLoader.js +190 -132
  6. package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
  7. package/lib/generates/SwaggerGenerator.d.ts +2 -2
  8. package/lib/generates/SwaggerGenerator.js +15 -15
  9. package/lib/generates/SwaggerGenerator.js.map +1 -1
  10. package/lib/generates/internal/SdkAliasCollection.js +1 -1
  11. package/lib/generates/internal/SdkFunctionProgrammer.js +2 -2
  12. package/lib/generates/internal/SdkNamespaceProgrammer.js +2 -2
  13. package/lib/generates/internal/SdkTypeProgrammer.js +10 -10
  14. package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
  15. package/lib/generates/internal/SwaggerSchemaGenerator.d.ts +4 -4
  16. package/lib/generates/internal/SwaggerSchemaGenerator.js +3 -3
  17. package/lib/generates/internal/SwaggerSchemaGenerator.js.map +1 -1
  18. package/lib/structures/ISwaggerLazyProperty.d.ts +2 -2
  19. package/lib/structures/ISwaggerLazySchema.d.ts +2 -2
  20. package/package.json +6 -5
  21. package/src/INestiaConfig.ts +258 -261
  22. package/src/analyses/ExceptionAnalyzer.ts +2 -2
  23. package/src/generates/SwaggerGenerator.ts +35 -38
  24. package/src/generates/internal/SdkTypeProgrammer.ts +12 -11
  25. package/src/generates/internal/SwaggerSchemaGenerator.ts +22 -23
  26. package/src/structures/ISwaggerError.ts +8 -8
  27. package/src/structures/ISwaggerLazyProperty.ts +7 -7
  28. package/src/structures/ISwaggerLazySchema.ts +7 -7
  29. package/lib/structures/ISwagger.d.ts +0 -49
  30. package/lib/structures/ISwagger.js +0 -3
  31. package/lib/structures/ISwagger.js.map +0 -1
  32. package/lib/structures/ISwaggerComponents.d.ts +0 -26
  33. package/lib/structures/ISwaggerComponents.js +0 -3
  34. package/lib/structures/ISwaggerComponents.js.map +0 -1
  35. package/lib/structures/ISwaggerInfo.d.ts +0 -71
  36. package/lib/structures/ISwaggerInfo.js +0 -3
  37. package/lib/structures/ISwaggerInfo.js.map +0 -1
  38. package/lib/structures/ISwaggerRoute.d.ts +0 -50
  39. package/lib/structures/ISwaggerRoute.js +0 -3
  40. package/lib/structures/ISwaggerRoute.js.map +0 -1
  41. package/lib/structures/ISwaggerSecurityScheme.d.ts +0 -56
  42. package/lib/structures/ISwaggerSecurityScheme.js +0 -3
  43. package/lib/structures/ISwaggerSecurityScheme.js.map +0 -1
  44. package/lib/structures/ISwaggerServer.d.ts +0 -15
  45. package/lib/structures/ISwaggerServer.js +0 -3
  46. package/lib/structures/ISwaggerServer.js.map +0 -1
  47. package/lib/structures/ISwaggerTag.d.ts +0 -9
  48. package/lib/structures/ISwaggerTag.js +0 -3
  49. package/lib/structures/ISwaggerTag.js.map +0 -1
  50. package/src/structures/ISwagger.ts +0 -66
  51. package/src/structures/ISwaggerComponents.ts +0 -29
  52. package/src/structures/ISwaggerInfo.ts +0 -80
  53. package/src/structures/ISwaggerRoute.ts +0 -54
  54. package/src/structures/ISwaggerSecurityScheme.ts +0 -65
  55. package/src/structures/ISwaggerServer.ts +0 -16
  56. package/src/structures/ISwaggerTag.ts +0 -9
@@ -2,22 +2,19 @@ import fs from "fs";
2
2
  import path from "path";
3
3
  import { Singleton } from "tstl";
4
4
  import ts from "typescript";
5
- import typia, { IJsonApplication, IJsonComponents } from "typia";
5
+ import typia, { IJsonApplication } from "typia";
6
6
  import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
7
7
  import { JsonApplicationProgrammer } from "typia/lib/programmers/json/JsonApplicationProgrammer";
8
8
 
9
9
  import { INestiaConfig } from "../INestiaConfig";
10
10
  import { IRoute } from "../structures/IRoute";
11
- import { ISwagger } from "../structures/ISwagger";
12
- import { ISwaggerError } from "../structures/ISwaggerError";
13
- import { ISwaggerInfo } from "../structures/ISwaggerInfo";
14
- import { ISwaggerLazyProperty } from "../structures/ISwaggerLazyProperty";
15
- import { ISwaggerLazySchema } from "../structures/ISwaggerLazySchema";
16
- import { ISwaggerRoute } from "../structures/ISwaggerRoute";
17
- import { ISwaggerSecurityScheme } from "../structures/ISwaggerSecurityScheme";
18
11
  import { FileRetriever } from "../utils/FileRetriever";
19
12
  import { MapUtil } from "../utils/MapUtil";
20
13
  import { SwaggerSchemaGenerator } from "./internal/SwaggerSchemaGenerator";
14
+ import { OpenApi } from "@samchon/openapi";
15
+ import { ISwaggerError } from "../structures/ISwaggerError";
16
+ import { ISwaggerLazyProperty } from "../structures/ISwaggerLazyProperty";
17
+ import { ISwaggerLazySchema } from "../structures/ISwaggerLazySchema";
21
18
 
22
19
  export namespace SwaggerGenerator {
23
20
  export interface IProps {
@@ -27,7 +24,7 @@ export namespace SwaggerGenerator {
27
24
  lazySchemas: Array<ISwaggerLazySchema>;
28
25
  lazyProperties: Array<ISwaggerLazyProperty>;
29
26
  errors: ISwaggerError[];
30
- swagger: ISwagger;
27
+ swagger: OpenApi.IDocument;
31
28
  }
32
29
 
33
30
  export const generate =
@@ -63,13 +60,13 @@ export namespace SwaggerGenerator {
63
60
  const errors: ISwaggerError[] = [];
64
61
  const lazySchemas: Array<ISwaggerLazySchema> = [];
65
62
  const lazyProperties: Array<ISwaggerLazyProperty> = [];
66
- const swagger: ISwagger = await initialize(config);
67
- const pathDict: Map<string, Record<string, ISwaggerRoute>> = new Map();
63
+ const swagger: OpenApi.IDocument = await initialize(config);
64
+ const pathDict: Map<string, Record<string, OpenApi.IOperation>> = new Map();
68
65
 
69
66
  for (const route of routeList) {
70
67
  if (route.jsDocTags.find((tag) => tag.name === "internal")) continue;
71
68
 
72
- const path: Record<string, ISwaggerRoute> = MapUtil.take(
69
+ const path: Record<string, OpenApi.IOperation> = MapUtil.take(
73
70
  pathDict,
74
71
  get_path(route.path, route.parameters),
75
72
  () => ({}),
@@ -88,9 +85,7 @@ export namespace SwaggerGenerator {
88
85
  for (const [path, routes] of pathDict) swagger.paths[path] = routes;
89
86
 
90
87
  // FILL JSON-SCHEMAS
91
- const application: IJsonApplication = JsonApplicationProgrammer.write({
92
- purpose: "swagger",
93
- })(lazySchemas.map(({ metadata }) => metadata));
88
+ const application: IJsonApplication<"3.1"> = JsonApplicationProgrammer.write("3.1")(lazySchemas.map(({ metadata }) => metadata)) as IJsonApplication<"3.1">;
94
89
  swagger.components = {
95
90
  ...(swagger.components ?? {}),
96
91
  ...(application.components ?? {}),
@@ -104,8 +99,8 @@ export namespace SwaggerGenerator {
104
99
  (
105
100
  application.components.schemas?.[
106
101
  p.object
107
- ] as IJsonComponents.IObject
108
- )?.properties[p.property],
102
+ ] as OpenApi.IJsonSchema.IObject
103
+ )?.properties?.[p.property] ?? {},
109
104
  );
110
105
 
111
106
  // CONFIGURE SECURITY
@@ -131,18 +126,18 @@ export namespace SwaggerGenerator {
131
126
  at: new Singleton(() => {
132
127
  const functor: Map<Function, Endpoint> = new Map();
133
128
  for (const route of routeList) {
134
- const method = route.method.toLowerCase();
135
- const path = get_path(route.path, route.parameters);
129
+ const method: OpenApi.Method = route.method.toLowerCase() as OpenApi.Method;
130
+ const path: string = get_path(route.path, route.parameters);
136
131
  functor.set(route.target.function, {
137
132
  method,
138
133
  path,
139
- route: swagger.paths[path][method],
134
+ route: swagger.paths![path][method]!,
140
135
  });
141
136
  }
142
137
  return functor;
143
138
  }),
144
- get: new Singleton(() => (key: Accessor): ISwaggerRoute | undefined => {
145
- const method: string = key.method.toLowerCase();
139
+ get: new Singleton(() => (key: Accessor): OpenApi.IOperation | undefined => {
140
+ const method: OpenApi.Method = key.method.toLowerCase() as OpenApi.Method;
146
141
  const path: string =
147
142
  "/" +
148
143
  key.path
@@ -152,7 +147,7 @@ export namespace SwaggerGenerator {
152
147
  str.startsWith(":") ? `{${str.substring(1)}}` : str,
153
148
  )
154
149
  .join("/");
155
- return swagger.paths[path]?.[method];
150
+ return swagger.paths?.[path]?.[method];
156
151
  }),
157
152
  };
158
153
  for (const route of routeList) {
@@ -167,8 +162,8 @@ export namespace SwaggerGenerator {
167
162
  continue;
168
163
 
169
164
  const path: string = get_path(route.path, route.parameters);
170
- const method: string = route.method.toLowerCase();
171
- const target: ISwaggerRoute = swagger.paths[path][method];
165
+ const method: OpenApi.Method = route.method.toLowerCase() as OpenApi.Method;
166
+ const target: OpenApi.IOperation = swagger.paths![path][method]!;
172
167
  const closure: Function | Function[] = Reflect.getMetadata(
173
168
  "nestia/SwaggerCustomizer",
174
169
  route.controller.prototype,
@@ -205,7 +200,7 @@ export namespace SwaggerGenerator {
205
200
  (routeList: IRoute[]): void | never => {
206
201
  const securityMap: Map<
207
202
  string,
208
- { scheme: ISwaggerSecurityScheme; scopes: Set<string> }
203
+ { scheme: OpenApi.ISecurityScheme; scopes: Set<string> }
209
204
  > = new Map();
210
205
  for (const [key, value] of Object.entries(config.security ?? {}))
211
206
  securityMap.set(key, {
@@ -263,9 +258,9 @@ export namespace SwaggerGenerator {
263
258
  --------------------------------------------------------- */
264
259
  const initialize = async (
265
260
  config: INestiaConfig.ISwaggerConfig,
266
- ): Promise<ISwagger> => {
261
+ ): Promise<OpenApi.IDocument> => {
267
262
  const pack = new Singleton(
268
- async (): Promise<Partial<ISwaggerInfo> | null> => {
263
+ async (): Promise<Partial<OpenApi.IDocument.IInfo> | null> => {
269
264
  const location: string | null = await FileRetriever.file(
270
265
  "package.json",
271
266
  )(process.cwd());
@@ -309,7 +304,7 @@ export namespace SwaggerGenerator {
309
304
  );
310
305
 
311
306
  return {
312
- openapi: "3.0.1",
307
+ openapi: "3.1.0",
313
308
  servers: config.servers ?? [
314
309
  {
315
310
  url: "https://github.com/samchon/nestia",
@@ -330,7 +325,9 @@ export namespace SwaggerGenerator {
330
325
  license: config.info?.license ?? (await pack.get())?.license,
331
326
  },
332
327
  paths: {},
333
- components: {},
328
+ components: {
329
+ schemas: {},
330
+ },
334
331
  tags: config.tags ?? [],
335
332
  };
336
333
  };
@@ -346,7 +343,7 @@ export namespace SwaggerGenerator {
346
343
 
347
344
  const generate_route =
348
345
  (props: IProps) =>
349
- (route: IRoute): ISwaggerRoute => {
346
+ (route: IRoute): OpenApi.IOperation => {
350
347
  // FIND REQUEST BODY
351
348
  const body = route.parameters.find((param) => param.category === "body");
352
349
 
@@ -387,12 +384,12 @@ export namespace SwaggerGenerator {
387
384
  ...getJsDocTexts("tag").map((tag) => tag.split(" ")[0]),
388
385
  ]);
389
386
  for (const tag of tagSet)
390
- if (props.swagger.tags.find((elem) => elem.name === tag) === undefined)
391
- props.swagger.tags.push({ name: tag });
387
+ if (props.swagger.tags!.find((elem) => elem.name === tag) === undefined)
388
+ props.swagger.tags!.push({ name: tag });
392
389
  for (const texts of getJsDocTexts("tag")) {
393
390
  const [name, ...description] = texts.split(" ");
394
391
  if (description.length)
395
- props.swagger.tags.find((elem) => elem.name === name)!.description ??=
392
+ props.swagger.tags!.find((elem) => elem.name === name)!.description ??=
396
393
  description.join(" ");
397
394
  }
398
395
 
@@ -436,7 +433,7 @@ export namespace SwaggerGenerator {
436
433
 
437
434
  function fill_security(
438
435
  security: Required<INestiaConfig.ISwaggerConfig>["security"],
439
- swagger: ISwagger,
436
+ swagger: OpenApi.IDocument,
440
437
  ): void {
441
438
  swagger.components.securitySchemes = {};
442
439
  for (const [key, value] of Object.entries(security))
@@ -444,8 +441,8 @@ export namespace SwaggerGenerator {
444
441
  }
445
442
 
446
443
  function emend_security(
447
- input: ISwaggerSecurityScheme,
448
- ): ISwaggerSecurityScheme {
444
+ input: OpenApi.ISecurityScheme,
445
+ ): OpenApi.ISecurityScheme {
449
446
  if (input.type === "apiKey")
450
447
  return {
451
448
  ...input,
@@ -463,5 +460,5 @@ interface Accessor {
463
460
  interface Endpoint {
464
461
  method: string;
465
462
  path: string;
466
- route: ISwaggerRoute;
463
+ route: OpenApi.IOperation;
467
464
  }
@@ -16,6 +16,7 @@ import { Escaper } from "typia/lib/utils/Escaper";
16
16
  import { INestiaConfig } from "../../INestiaConfig";
17
17
  import { FilePrinter } from "./FilePrinter";
18
18
  import { ImportDictionary } from "./ImportDictionary";
19
+ import { MetadataConstantValue } from "typia/lib/schemas/metadata/MetadataConstantValue";
19
20
 
20
21
  export namespace SdkTypeProgrammer {
21
22
  /* -----------------------------------------------------------
@@ -110,14 +111,14 @@ export namespace SdkTypeProgrammer {
110
111
  /* -----------------------------------------------------------
111
112
  ATOMICS
112
113
  ----------------------------------------------------------- */
113
- const write_constant = (value: boolean | bigint | number | string) => {
114
- if (typeof value === "boolean")
114
+ const write_constant = (value: MetadataConstantValue) => {
115
+ if (typeof value.value === "boolean")
115
116
  return ts.factory.createLiteralTypeNode(
116
117
  value ? ts.factory.createTrue() : ts.factory.createFalse(),
117
118
  );
118
- else if (typeof value === "bigint")
119
+ else if (typeof value.value === "bigint")
119
120
  return ts.factory.createLiteralTypeNode(
120
- value < BigInt(0)
121
+ value.value < BigInt(0)
121
122
  ? ts.factory.createPrefixUnaryExpression(
122
123
  ts.SyntaxKind.MinusToken,
123
124
  ts.factory.createBigIntLiteral((-value).toString()),
@@ -127,7 +128,7 @@ export namespace SdkTypeProgrammer {
127
128
  else if (typeof value === "number")
128
129
  return ts.factory.createLiteralTypeNode(ExpressionFactory.number(value));
129
130
  return ts.factory.createLiteralTypeNode(
130
- ts.factory.createStringLiteral(value),
131
+ ts.factory.createStringLiteral(value.value as string),
131
132
  );
132
133
  };
133
134
 
@@ -146,12 +147,12 @@ export namespace SdkTypeProgrammer {
146
147
  return tuple;
147
148
  })();
148
149
  if (elem.isSoleLiteral())
149
- if (last[1] === null) last[1] = String(elem.constants[0].values[0]);
150
+ if (last[1] === null) last[1] = String(elem.constants[0].values[0].value);
150
151
  else
151
152
  spans.push([
152
153
  ts.factory.createLiteralTypeNode(
153
154
  ts.factory.createStringLiteral(
154
- String(elem.constants[0].values[0]),
155
+ String(elem.constants[0].values[0].value),
155
156
  ),
156
157
  ),
157
158
  null,
@@ -161,7 +162,7 @@ export namespace SdkTypeProgrammer {
161
162
  }
162
163
  return ts.factory.createTemplateLiteralType(
163
164
  ts.factory.createTemplateHead(
164
- head ? (meta[0].constants[0].values[0] as string) : "",
165
+ head ? (meta[0].constants[0].values[0].value as string) : "",
165
166
  ),
166
167
  spans
167
168
  .filter(([node]) => node !== null)
@@ -233,12 +234,12 @@ export namespace SdkTypeProgrammer {
233
234
  FilePrinter.description(
234
235
  ts.factory.createPropertySignature(
235
236
  undefined,
236
- Escaper.variable(String(p.key.constants[0].values[0]))
237
+ Escaper.variable(String(p.key.constants[0].values[0].value))
237
238
  ? ts.factory.createIdentifier(
238
- String(p.key.constants[0].values[0]),
239
+ String(p.key.constants[0].values[0].value),
239
240
  )
240
241
  : ts.factory.createStringLiteral(
241
- String(p.key.constants[0].values[0]),
242
+ String(p.key.constants[0].values[0].value),
242
243
  ),
243
244
  p.value.isRequired() === false
244
245
  ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
@@ -1,6 +1,5 @@
1
1
  import { Singleton, VariadicSingleton } from "tstl";
2
2
  import ts from "typescript";
3
- import { IJsonSchema } from "typia";
4
3
  import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
5
4
  import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
6
5
  import { JsonApplicationProgrammer } from "typia/lib/programmers/json/JsonApplicationProgrammer";
@@ -9,11 +8,11 @@ import { ValidationPipe } from "typia/lib/typings/ValidationPipe";
9
8
 
10
9
  import { INestiaConfig } from "../../INestiaConfig";
11
10
  import { IRoute } from "../../structures/IRoute";
11
+ import { SwaggerSchemaValidator } from "./SwaggerSchemaValidator";
12
+ import { OpenApi } from "@samchon/openapi";
12
13
  import { ISwaggerError } from "../../structures/ISwaggerError";
13
14
  import { ISwaggerLazyProperty } from "../../structures/ISwaggerLazyProperty";
14
15
  import { ISwaggerLazySchema } from "../../structures/ISwaggerLazySchema";
15
- import { ISwaggerRoute } from "../../structures/ISwaggerRoute";
16
- import { SwaggerSchemaValidator } from "./SwaggerSchemaValidator";
17
16
 
18
17
  export namespace SwaggerSchemaGenerator {
19
18
  export interface IProps {
@@ -27,8 +26,8 @@ export namespace SwaggerSchemaGenerator {
27
26
 
28
27
  export const response =
29
28
  (props: IProps) =>
30
- (route: IRoute): ISwaggerRoute.IResponseBody => {
31
- const output: ISwaggerRoute.IResponseBody = {};
29
+ (route: IRoute): Record<string, OpenApi.IOperation.IResponse> => {
30
+ const output: Record<string, OpenApi.IOperation.IResponse> = {};
32
31
 
33
32
  //----
34
33
  // EXCEPTION STATUSES
@@ -161,7 +160,7 @@ export namespace SwaggerSchemaGenerator {
161
160
  export const body =
162
161
  (props: IProps) =>
163
162
  (route: IRoute) =>
164
- (param: IRoute.IParameter): ISwaggerRoute.IRequestBody => {
163
+ (param: IRoute.IParameter): OpenApi.IOperation.IRequestBody => {
165
164
  // ANALZE TYPE WITH VALIDATION
166
165
  const result = MetadataFactory.analyze(props.checker)({
167
166
  escape: true,
@@ -197,7 +196,7 @@ export namespace SwaggerSchemaGenerator {
197
196
  );
198
197
 
199
198
  // RETURNS WITH LAZY CONSTRUCTION
200
- const schema: IJsonSchema = coalesce(props)(result);
199
+ const schema: OpenApi.IJsonSchema = coalesce(props)(result);
201
200
  return {
202
201
  description: encrypted
203
202
  ? `${warning.get(!!description, "request")}${description ?? ""}`
@@ -223,7 +222,7 @@ export namespace SwaggerSchemaGenerator {
223
222
  export const parameter =
224
223
  (props: IProps) =>
225
224
  (route: IRoute) =>
226
- (param: IRoute.IParameter): ISwaggerRoute.IParameter[] =>
225
+ (param: IRoute.IParameter): OpenApi.IOperation.IParameter[] =>
227
226
  param.category === "headers"
228
227
  ? headers(props)(route)(param)
229
228
  : param.category === "param"
@@ -233,7 +232,7 @@ export namespace SwaggerSchemaGenerator {
233
232
  const path =
234
233
  (props: IProps) =>
235
234
  (route: IRoute) =>
236
- (param: IRoute.IParameter): ISwaggerRoute.IParameter => {
235
+ (param: IRoute.IParameter): OpenApi.IOperation.IParameter => {
237
236
  // ANALZE TYPE WITH VALIDATION
238
237
  const result = MetadataFactory.analyze(props.checker)({
239
238
  escape: false,
@@ -257,7 +256,7 @@ export namespace SwaggerSchemaGenerator {
257
256
  const headers =
258
257
  (props: IProps) =>
259
258
  (route: IRoute) =>
260
- (param: IRoute.IParameter): ISwaggerRoute.IParameter[] =>
259
+ (param: IRoute.IParameter): OpenApi.IOperation.IParameter[] =>
261
260
  decomposible(props)(route)(param)(
262
261
  MetadataFactory.analyze(props.checker)({
263
262
  escape: false,
@@ -270,7 +269,7 @@ export namespace SwaggerSchemaGenerator {
270
269
  const query =
271
270
  (props: IProps) =>
272
271
  (route: IRoute) =>
273
- (param: IRoute.IParameter): ISwaggerRoute.IParameter[] =>
272
+ (param: IRoute.IParameter): OpenApi.IOperation.IParameter[] =>
274
273
  decomposible(props)(route)(param)(
275
274
  MetadataFactory.analyze(props.checker)({
276
275
  escape: false,
@@ -286,8 +285,8 @@ export namespace SwaggerSchemaGenerator {
286
285
  (param: IRoute.IParameter) =>
287
286
  (
288
287
  result: ValidationPipe<Metadata, MetadataFactory.IError>,
289
- ): ISwaggerRoute.IParameter[] => {
290
- const decoded: ISwaggerRoute.IParameter = lazy(props)(route)(
288
+ ): OpenApi.IOperation.IParameter[] => {
289
+ const decoded: OpenApi.IOperation.IParameter = lazy(props)(route)(
291
290
  param,
292
291
  result,
293
292
  );
@@ -309,19 +308,19 @@ export namespace SwaggerSchemaGenerator {
309
308
  return result.data.objects[0].properties
310
309
  .filter((p) => p.jsDocTags.every((tag) => tag.name !== "hidden"))
311
310
  .map((p) => {
312
- const schema: IJsonSchema = {};
311
+ const schema: OpenApi.IJsonSchema = {};
313
312
  props.lazyProperties.push({
314
313
  schema,
315
314
  object: result.data.objects[0].name,
316
- property: p.key.constants[0].values[0] as string,
315
+ property: p.key.constants[0].values[0].value as string,
317
316
  });
318
317
  return {
319
- name: p.key.constants[0].values[0] as string,
320
- in: param.category === "headers" ? "header" : param.category,
318
+ name: p.key.constants[0].values[0].value as string,
319
+ in: param.category === "headers" ? "header" : param.category as "path",
321
320
  schema,
322
321
  description: p.description ?? undefined,
323
322
  required: p.value.isRequired(),
324
- };
323
+ } satisfies OpenApi.IOperation.IParameter;
325
324
  });
326
325
  };
327
326
 
@@ -331,8 +330,8 @@ export namespace SwaggerSchemaGenerator {
331
330
  (
332
331
  param: IRoute.IParameter,
333
332
  result: ValidationPipe<Metadata, MetadataFactory.IError>,
334
- ): ISwaggerRoute.IParameter => {
335
- const schema: IJsonSchema = coalesce(props)(result);
333
+ ): OpenApi.IOperation.IParameter => {
334
+ const schema: OpenApi.IJsonSchema = coalesce(props)(result);
336
335
  return {
337
336
  name: param.field ?? param.name,
338
337
  in:
@@ -340,7 +339,7 @@ export namespace SwaggerSchemaGenerator {
340
339
  ? "header"
341
340
  : param.category === "param"
342
341
  ? "path"
343
- : param.category,
342
+ : "query",
344
343
  schema,
345
344
  description: describe(route, "param", param.name) ?? "",
346
345
  required: result.success ? result.data.isRequired() : true,
@@ -349,8 +348,8 @@ export namespace SwaggerSchemaGenerator {
349
348
 
350
349
  const coalesce =
351
350
  (props: IProps) =>
352
- (result: ValidationPipe<Metadata, MetadataFactory.IError>): IJsonSchema => {
353
- const schema: IJsonSchema = {} as any;
351
+ (result: ValidationPipe<Metadata, MetadataFactory.IError>): OpenApi.IJsonSchema => {
352
+ const schema: OpenApi.IJsonSchema = {} as any;
354
353
  props.lazySchemas.push({
355
354
  metadata: result.success ? result.data : any.get(),
356
355
  schema,
@@ -1,8 +1,8 @@
1
- import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
2
-
3
- import { IRoute } from "./IRoute";
4
-
5
- export interface ISwaggerError extends MetadataFactory.IError {
6
- route: IRoute;
7
- from: string;
8
- }
1
+ import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
2
+
3
+ import { IRoute } from "./IRoute";
4
+
5
+ export interface ISwaggerError extends MetadataFactory.IError {
6
+ route: IRoute;
7
+ from: string;
8
+ }
@@ -1,7 +1,7 @@
1
- import { IJsonSchema } from "typia";
2
-
3
- export interface ISwaggerLazyProperty {
4
- schema: IJsonSchema;
5
- object: string;
6
- property: string;
7
- }
1
+ import { OpenApi } from "@samchon/openapi";
2
+
3
+ export interface ISwaggerLazyProperty {
4
+ schema: OpenApi.IJsonSchema;
5
+ object: string;
6
+ property: string;
7
+ }
@@ -1,7 +1,7 @@
1
- import { IJsonSchema } from "typia";
2
- import { Metadata } from "typia/lib/schemas/metadata/Metadata";
3
-
4
- export interface ISwaggerLazySchema {
5
- metadata: Metadata;
6
- schema: IJsonSchema;
7
- }
1
+ import { OpenApi } from "@samchon/openapi";
2
+ import { Metadata } from "typia/lib/schemas/metadata/Metadata";
3
+
4
+ export interface ISwaggerLazySchema {
5
+ metadata: Metadata;
6
+ schema: OpenApi.IJsonSchema;
7
+ }
@@ -1,49 +0,0 @@
1
- import { ISwaggerComponents } from "./ISwaggerComponents";
2
- import { ISwaggerInfo } from "./ISwaggerInfo";
3
- import { ISwaggerRoute } from "./ISwaggerRoute";
4
- import { ISwaggerServer } from "./ISwaggerServer";
5
- import { ISwaggerTag } from "./ISwaggerTag";
6
- /**
7
- * Swagger Document.
8
- *
9
- * `ISwagger` is a data structure representing content of `swagger.json` file
10
- * generated by Nestia. Note that, this is not an universal structure, but a dedicated
11
- * structure only for Nestia.
12
- *
13
- * @author Jeongho Nam - https://github.com/samchon
14
- */
15
- export interface ISwagger {
16
- /**
17
- * The version of the OpenAPI document.
18
- *
19
- * Nestia always generate OpenAPI 3.0.x document.
20
- */
21
- openapi: `3.0.${number}`;
22
- /**
23
- * List of servers that provide the API.
24
- */
25
- servers: ISwaggerServer[];
26
- /**
27
- * Information about the API.
28
- */
29
- info: ISwaggerInfo;
30
- /**
31
- * The available paths and operations for the API.
32
- *
33
- * The 1st key is the path, and the 2nd key is the HTTP method.
34
- */
35
- paths: Record<string, Record<string, ISwaggerRoute>>;
36
- /**
37
- * An object to hold reusable data structures.
38
- *
39
- * It stores both DTO schemas and security schemes.
40
- *
41
- * For reference, `nestia` defines every object and alias types as reusable DTO
42
- * schemas. The alias type means that defined by `type` keyword in TypeScript.
43
- */
44
- components: ISwaggerComponents;
45
- /**
46
- * List of tags.
47
- */
48
- tags: ISwaggerTag[];
49
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ISwagger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ISwagger.js","sourceRoot":"","sources":["../../src/structures/ISwagger.ts"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
1
- import { IJsonComponents } from "typia";
2
- import { ISwaggerSecurityScheme } from "./ISwaggerSecurityScheme";
3
- /**
4
- * Reusable components in Swagger.
5
- *
6
- * `ISwaggerComponents` is a data structure representing content of `components` object
7
- * in `swagger.json` file generated by Nestia. Note that, this is not an universal
8
- * structure, but a dedicated structure only for Nestia.
9
- *
10
- * @author Jeongho Nam - https://github.com/samchon
11
- */
12
- export interface ISwaggerComponents {
13
- /**
14
- * An object to hold reusable DTO schemas.
15
- *
16
- * For reference, `nestia` stores every object and alias types as reusable DTO
17
- * schemas. The alias type means that defined by `type` keyword in TypeScript.
18
- */
19
- schemas?: Record<string, IJsonComponents.IAlias>;
20
- /**
21
- * An object to hold reusable security schemes.
22
- *
23
- * This property be configured by user in `nestia.config.ts` file.
24
- */
25
- securitySchemes?: Record<string, ISwaggerSecurityScheme>;
26
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ISwaggerComponents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ISwaggerComponents.js","sourceRoot":"","sources":["../../src/structures/ISwaggerComponents.ts"],"names":[],"mappings":""}
@@ -1,71 +0,0 @@
1
- /**
2
- * Information about the API.
3
- *
4
- * @author Samchon
5
- */
6
- export interface ISwaggerInfo {
7
- /**
8
- * The title of the API.
9
- */
10
- title: string;
11
- /**
12
- * A short description of the API.
13
- */
14
- description?: string;
15
- /**
16
- * A URL to the Terms of Service for the API.
17
- *
18
- * @format uri
19
- */
20
- termsOfService?: string;
21
- /**
22
- * The contact information for the exposed API.
23
- */
24
- contact?: ISwaggerInfo.IContact;
25
- /**
26
- * The license information for the exposed API.
27
- */
28
- license?: ISwaggerInfo.ILicense;
29
- /**
30
- * Version of the API.
31
- */
32
- version: string;
33
- }
34
- export declare namespace ISwaggerInfo {
35
- /**
36
- * Contact information for the exposed API.
37
- */
38
- interface IContact {
39
- /**
40
- * The identifying name of the contact person/organization.
41
- */
42
- name?: string;
43
- /**
44
- * The URL pointing to the contact information.
45
- *
46
- * @format uri
47
- */
48
- url?: string;
49
- /**
50
- * The email address of the contact person/organization.
51
- *
52
- * @format email
53
- */
54
- email?: string;
55
- }
56
- /**
57
- * License information for the exposed API.
58
- */
59
- interface ILicense {
60
- /**
61
- * The license name used for the API.
62
- */
63
- name: string;
64
- /**
65
- * A URL to the license used for the API.
66
- *
67
- * @format uri
68
- */
69
- url?: string;
70
- }
71
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ISwaggerInfo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ISwaggerInfo.js","sourceRoot":"","sources":["../../src/structures/ISwaggerInfo.ts"],"names":[],"mappings":""}