Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1237: clone mode fails when tags.Example comes. #1238

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@nestia/station",
"version": "4.6.1",
"version": "4.6.2",
"description": "Nestia station",
"scripts": {
"build": "node deploy build",
Expand Down
28 changes: 5 additions & 23 deletions packages/sdk/src/generates/internal/SdkTypeTagProgrammer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ts from "typescript";
import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
import { IMetadataTypeTag } from "typia/lib/schemas/metadata/IMetadataTypeTag";

Expand All @@ -19,28 +18,11 @@ export namespace SdkTypeTagProgrammer {
library: `typia/lib/tags/${instance}`,
instance,
}),
instance === "Example"
? []
: [
ts.factory.createLiteralTypeNode(
typeof tag.value === "boolean"
? tag.value
? ts.factory.createTrue()
: ts.factory.createFalse()
: typeof tag.value === "bigint"
? tag.value < BigInt(0)
? ts.factory.createPrefixUnaryExpression(
ts.SyntaxKind.MinusToken,
ts.factory.createBigIntLiteral(
(-tag.value).toString(),
),
)
: ts.factory.createBigIntLiteral(tag.value.toString())
: typeof tag.value === "number"
? ExpressionFactory.number(tag.value)
: ts.factory.createStringLiteral(tag.value),
),
],
[
ts.factory.createLiteralTypeNode(
LiteralFactory.write(tag.value) as any,
),
],
);
return ts.factory.createTypeReferenceNode(
importer.external({
Expand Down
39 changes: 39 additions & 0 deletions test/features/clone/src/api/functional/bbs/articles/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @packageDocumentation
* @module api.functional.bbs.articles
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
//================================================================
import type { IConnection } from "@nestia/fetcher";
import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher";

import type { IBbsArticle } from "../../../structures/IBbsArticle";

/**
* @controller BbsArticleController.random
* @path GET /bbs/articles/random
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
export async function random(connection: IConnection): Promise<random.Output> {
return PlainFetcher.fetch(connection, {
...random.METADATA,
template: random.METADATA.path,
path: random.path(),
});
}
export namespace random {
export type Output = IBbsArticle;

export const METADATA = {
method: "GET",
path: "/bbs/articles/random",
request: null,
response: {
type: "application/json",
encrypted: false,
},
status: 200,
} as const;

export const path = () => "/bbs/articles/random";
}
7 changes: 7 additions & 0 deletions test/features/clone/src/api/functional/bbs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @packageDocumentation
* @module api.functional.bbs
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
//================================================================
export * as articles from "./articles";
2 changes: 2 additions & 0 deletions test/features/clone/src/api/functional/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher";

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

export * as bbs from "./bbs";

/**
* @controller AppController.getHello
* @path GET /
Expand Down
9 changes: 9 additions & 0 deletions test/features/clone/src/api/structures/IAttachmentFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Example } from "typia/lib/tags/Example";
import type { MaxLength } from "typia/lib/tags/MaxLength";
import type { MinLength } from "typia/lib/tags/MinLength";

export type IAttachmentFile = {
name: string & MaxLength<255> & Example<"logo">;
extension: null | (string & MinLength<1> & MaxLength<8>);
url: string;
};
13 changes: 13 additions & 0 deletions test/features/clone/src/api/structures/IBbsArticle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Format } from "typia/lib/tags/Format";
import type { MaxLength } from "typia/lib/tags/MaxLength";
import type { MinLength } from "typia/lib/tags/MinLength";

import type { IAttachmentFile } from "./IAttachmentFile";

export type IBbsArticle = {
id: string & Format<"uuid">;
title: string & MinLength<3> & MaxLength<50>;
body: string;
files: IAttachmentFile[];
created_at: string & Format<"date-time">;
};
24 changes: 24 additions & 0 deletions test/features/clone/src/controllers/BbsArticleController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TypedRoute } from "@nestia/core";
import { Controller } from "@nestjs/common";
import typia, { tags } from "typia";

@Controller("bbs/articles")
export class BbsArticleController {
@TypedRoute.Get("random")
public async random(): Promise<IBbsArticle> {
return typia.random<IBbsArticle>();
}
}
interface IBbsArticle {
id: string & tags.Format<"uuid">;
title: string & tags.MinLength<3> & tags.MaxLength<50>;
body: string;
files: IAttachmentFile[];
created_at: string & tags.Format<"date-time">;
}

interface IAttachmentFile {
name: string & tags.MaxLength<255> & tags.Example<"logo">;
extension: null | (string & tags.MinLength<1> & tags.MaxLength<8>);
url: string;
}
39 changes: 7 additions & 32 deletions test/features/route/src/api/structures/IBbsArticle.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,15 @@
export interface IBbsArticle {
/**
* @format uuid
*/
id: string;

/**
* @minLength 3
* @maxLength 50
*/
title: string;
import { tags } from "typia";

export interface IBbsArticle {
id: string & tags.Format<"uuid">;
title: string & tags.MinLength<3> & tags.MaxLength<50>;
body: string;

files: IAttachmentFile[];

/**
* @format date-time
*/
created_at: string;
created_at: string & tags.Format<"date-time">;
}

export interface IAttachmentFile {
/**
* @minLength 1
* @maxLength 255
*/
name: string | null;

/**
* @minLength 1
* @maxLength 8
*/
extension: string | null;

/**
* @format uri
*/
name: string & tags.MaxLength<255> & tags.Example<"logo">;
extension: null | (string & tags.MinLength<1> & tags.MaxLength<8>);
url: string;
}
Loading