Skip to content

Commit b72c9b8

Browse files
committed
Fix #1237: clone mode fails when tags.Example comes.
1 parent 47fca79 commit b72c9b8

File tree

9 files changed

+107
-56
lines changed

9 files changed

+107
-56
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@nestia/station",
4-
"version": "4.6.1",
4+
"version": "4.6.2",
55
"description": "Nestia station",
66
"scripts": {
77
"build": "node deploy build",

packages/sdk/src/generates/internal/SdkTypeTagProgrammer.ts

+5-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ts from "typescript";
2-
import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
32
import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
43
import { IMetadataTypeTag } from "typia/lib/schemas/metadata/IMetadataTypeTag";
54

@@ -19,28 +18,11 @@ export namespace SdkTypeTagProgrammer {
1918
library: `typia/lib/tags/${instance}`,
2019
instance,
2120
}),
22-
instance === "Example"
23-
? []
24-
: [
25-
ts.factory.createLiteralTypeNode(
26-
typeof tag.value === "boolean"
27-
? tag.value
28-
? ts.factory.createTrue()
29-
: ts.factory.createFalse()
30-
: typeof tag.value === "bigint"
31-
? tag.value < BigInt(0)
32-
? ts.factory.createPrefixUnaryExpression(
33-
ts.SyntaxKind.MinusToken,
34-
ts.factory.createBigIntLiteral(
35-
(-tag.value).toString(),
36-
),
37-
)
38-
: ts.factory.createBigIntLiteral(tag.value.toString())
39-
: typeof tag.value === "number"
40-
? ExpressionFactory.number(tag.value)
41-
: ts.factory.createStringLiteral(tag.value),
42-
),
43-
],
21+
[
22+
ts.factory.createLiteralTypeNode(
23+
LiteralFactory.write(tag.value) as any,
24+
),
25+
],
4426
);
4527
return ts.factory.createTypeReferenceNode(
4628
importer.external({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @packageDocumentation
3+
* @module api.functional.bbs.articles
4+
* @nestia Generated by Nestia - https://github.com/samchon/nestia
5+
*/
6+
//================================================================
7+
import type { IConnection } from "@nestia/fetcher";
8+
import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher";
9+
10+
import type { IBbsArticle } from "../../../structures/IBbsArticle";
11+
12+
/**
13+
* @controller BbsArticleController.random
14+
* @path GET /bbs/articles/random
15+
* @nestia Generated by Nestia - https://github.com/samchon/nestia
16+
*/
17+
export async function random(connection: IConnection): Promise<random.Output> {
18+
return PlainFetcher.fetch(connection, {
19+
...random.METADATA,
20+
template: random.METADATA.path,
21+
path: random.path(),
22+
});
23+
}
24+
export namespace random {
25+
export type Output = IBbsArticle;
26+
27+
export const METADATA = {
28+
method: "GET",
29+
path: "/bbs/articles/random",
30+
request: null,
31+
response: {
32+
type: "application/json",
33+
encrypted: false,
34+
},
35+
status: 200,
36+
} as const;
37+
38+
export const path = () => "/bbs/articles/random";
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @packageDocumentation
3+
* @module api.functional.bbs
4+
* @nestia Generated by Nestia - https://github.com/samchon/nestia
5+
*/
6+
//================================================================
7+
export * as articles from "./articles";

test/features/clone/src/api/functional/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher";
99

1010
import type { GetHelloResponseDto } from "../structures/GetHelloResponseDto";
1111

12+
export * as bbs from "./bbs";
13+
1214
/**
1315
* @controller AppController.getHello
1416
* @path GET /
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Example } from "typia/lib/tags/Example";
2+
import type { MaxLength } from "typia/lib/tags/MaxLength";
3+
import type { MinLength } from "typia/lib/tags/MinLength";
4+
5+
export type IAttachmentFile = {
6+
name: string & MaxLength<255> & Example<"logo">;
7+
extension: null | (string & MinLength<1> & MaxLength<8>);
8+
url: string;
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { Format } from "typia/lib/tags/Format";
2+
import type { MaxLength } from "typia/lib/tags/MaxLength";
3+
import type { MinLength } from "typia/lib/tags/MinLength";
4+
5+
import type { IAttachmentFile } from "./IAttachmentFile";
6+
7+
export type IBbsArticle = {
8+
id: string & Format<"uuid">;
9+
title: string & MinLength<3> & MaxLength<50>;
10+
body: string;
11+
files: IAttachmentFile[];
12+
created_at: string & Format<"date-time">;
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { TypedRoute } from "@nestia/core";
2+
import { Controller } from "@nestjs/common";
3+
import typia, { tags } from "typia";
4+
5+
@Controller("bbs/articles")
6+
export class BbsArticleController {
7+
@TypedRoute.Get("random")
8+
public async random(): Promise<IBbsArticle> {
9+
return typia.random<IBbsArticle>();
10+
}
11+
}
12+
interface IBbsArticle {
13+
id: string & tags.Format<"uuid">;
14+
title: string & tags.MinLength<3> & tags.MaxLength<50>;
15+
body: string;
16+
files: IAttachmentFile[];
17+
created_at: string & tags.Format<"date-time">;
18+
}
19+
20+
interface IAttachmentFile {
21+
name: string & tags.MaxLength<255> & tags.Example<"logo">;
22+
extension: null | (string & tags.MinLength<1> & tags.MaxLength<8>);
23+
url: string;
24+
}
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,15 @@
1-
export interface IBbsArticle {
2-
/**
3-
* @format uuid
4-
*/
5-
id: string;
6-
7-
/**
8-
* @minLength 3
9-
* @maxLength 50
10-
*/
11-
title: string;
1+
import { tags } from "typia";
122

3+
export interface IBbsArticle {
4+
id: string & tags.Format<"uuid">;
5+
title: string & tags.MinLength<3> & tags.MaxLength<50>;
136
body: string;
14-
157
files: IAttachmentFile[];
16-
17-
/**
18-
* @format date-time
19-
*/
20-
created_at: string;
8+
created_at: string & tags.Format<"date-time">;
219
}
2210

2311
export interface IAttachmentFile {
24-
/**
25-
* @minLength 1
26-
* @maxLength 255
27-
*/
28-
name: string | null;
29-
30-
/**
31-
* @minLength 1
32-
* @maxLength 8
33-
*/
34-
extension: string | null;
35-
36-
/**
37-
* @format uri
38-
*/
12+
name: string & tags.MaxLength<255> & tags.Example<"logo">;
13+
extension: null | (string & tags.MinLength<1> & tags.MaxLength<8>);
3914
url: string;
4015
}

0 commit comments

Comments
 (0)