Skip to content

Commit

Permalink
Hold #1016 for a while, because it needs a lot of change in typia.
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Sep 10, 2024
1 parent 1f6a19d commit 861b225
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/features/clone-type-create-duplicate/sdk/HttpError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { HttpError } from "@nestia/fetcher";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { IConnection } from "@nestia/fetcher";
1 change: 1 addition & 0 deletions test/features/clone-type-create-duplicate/sdk/Primitive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { Primitive } from "@nestia/fetcher";
1 change: 1 addition & 0 deletions test/features/clone-type-create-duplicate/sdk/Resolved.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { Resolved } from "@nestia/fetcher";
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @packageDocumentation
* @module api.functional.auth
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
//================================================================
import type { IConnection } from "@nestia/fetcher";
import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher";

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

/**
* 계정 프로필 정보 불러오기
*
* @summary get account profile
* @tag auth
* @throws 401
*
* @controller AuthController.account
* @path GET /auth/account
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
export async function account(
connection: IConnection,
): Promise<account.Output> {
return PlainFetcher.fetch(connection, {
...account.METADATA,
template: account.METADATA.path,
path: account.path(),
});
}
export namespace account {
export type Output = IAuth.IAccount;

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

export const path = () => "/auth/account";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @packageDocumentation
* @module api.functional
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
//================================================================
export * as auth from "./auth";
export * as user from "./user";
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* @packageDocumentation
* @module api.functional.user
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
//================================================================
import type { IConnection } from "@nestia/fetcher";
import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher";

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

/**
* get authorized user's profile
*
* @summary get user's profile
* @tag user
* @security bearer
* @return user profile
* @throws 401
*
* @controller UserController.profile
* @path GET /user/profile
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
export async function profile(
connection: IConnection,
): Promise<profile.Output> {
return PlainFetcher.fetch(connection, {
...profile.METADATA,
template: profile.METADATA.path,
path: profile.path(),
});
}
export namespace profile {
export type Output = IUser.IProfile.o1;

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

export const path = () => "/user/profile";
}
4 changes: 4 additions & 0 deletions test/features/clone-type-create-duplicate/sdk/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as api from "./module";

export * from "./module";
export default api;
6 changes: 6 additions & 0 deletions test/features/clone-type-create-duplicate/sdk/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type * from "./IConnection";
export type * from "./Primitive";
export type * from "./Resolved";
export * from "./HttpError";

export * as functional from "./functional";
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export namespace Exception {
export type Unauthorized = {
code: "UNAUTHORIZED";
message: string;
};
export namespace Unauthorized {
export type o1 = {
code: "UNAUTHORIZED";
message: string;
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { IUser } from "./IUser";

export namespace IAuth {
export type IAccount = {
user: IUser.IProfile;
account_id: string;
};
}
16 changes: 16 additions & 0 deletions test/features/clone-type-create-duplicate/sdk/structures/IUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Format } from "typia/lib/tags/Format";

export namespace IUser {
export type IProfile = {
id: string & Format<"uuid">;
name: string;
created_at: string & Format<"date-time">;
};
export namespace IProfile {
export type o1 = {
id: string & Format<"uuid">;
name: string;
created_at: string & Format<"date-time">;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export const test = async () => {
const swagger = await import("../../../swagger.json");
const ok = ["Exception.Unauthorized", "IAuth.IAccount", "IUser.IProfile"];
if (Object.keys(swagger.components.schemas).some((key) => !ok.includes(key)))
throw Error("schema was generated duplicately");
console.error("schema was generated duplicately");
};
1 change: 1 addition & 0 deletions test/features/clone-type-create-duplicate/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"openapi":"3.0.0","servers":[{"url":"http://localhost:4000","description":"Local Server"}],"info":{"title":"nestia test template","description":"클론모드에서 발생하는 타입 중복 생성 문제 테스트","version":"3.13.0-dev.2024910","license":{"name":"MIT"}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}},"schemas":{"IAuth.IAccount":{"type":"object","properties":{"user":{"$ref":"#/components/schemas/IUser.IProfile"},"account_id":{"type":"string"}},"required":["user","account_id"]},"IUser.IProfile":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"created_at":{"type":"string","format":"date-time"}},"required":["id","name","created_at"]},"Exception.Unauthorized":{"type":"object","properties":{"code":{"type":"string","enum":["UNAUTHORIZED"]},"message":{"type":"string"}},"required":["code","message"]},"IUser.IProfile.o1":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"created_at":{"type":"string","format":"date-time"}},"required":["id","name","created_at"]},"Exception.Unauthorized.o1":{"type":"object","properties":{"code":{"type":"string","enum":["UNAUTHORIZED"]},"message":{"type":"string"}},"required":["code","message"]}}},"paths":{"/auth/account":{"get":{"summary":"get account profile","description":"계정 프로필 정보 불러오기","tags":["auth"],"parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IAuth.IAccount"}}}},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Exception.Unauthorized"}}}}}}},"/user/profile":{"get":{"summary":"get user's profile","description":"get authorized user's profile","tags":["user"],"parameters":[],"responses":{"200":{"description":"user profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IUser.IProfile.o1"}}}},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Exception.Unauthorized.o1"}}}}},"security":[{"bearer":[]}]}}},"tags":[{"name":"auth"},{"name":"user"}]}

0 comments on commit 861b225

Please sign in to comment.