samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.85k stars 95 forks source link

fetcher input type bug in Post api without body #270

Closed rojiwon123 closed 1 year ago

rojiwon123 commented 1 year ago

현재 1.0.1 기준으로 @Body나 @TypedBody를 사용하지 않고 POST sdk를 만들면 Input type은 안생기는데, stringify는 Input타입을 사용하고 있는 버그가 발생했습니다.

at v1.0.1, If i don't use Body in POST api. sdk generated like that. Input type is undefined, but stringify use the type.

export namespace signInGithub
{
    export type Output = IAuthUsecase.SignInResponse;

    export const METHOD = "POST" as const;
    export const PATH: string = "/sign-in/github";
    export const ENCRYPTED: Fetcher.IEncrypted = {
        request: false,
        response: false,
    };

    export function path(): string
    {
        return `/sign-in/github`;
    }
    export const stringify = (input: Input) => typia.assertStringify(input); // Inpu is undefined type.
}

제가 생각한 수정 방향입니다!

개발자가 body를 사용하지 않는 POST API를 설계했을 때,

  1. sdk는 알아서 Input Type을 undefined, unknown, {} 등으로 정의한다.
    • Input Type이 정의되므로 현재 발생된 문제 해결)
  2. Input Type을 생성하지 않은 것 처럼, stringify도 생성하지 않는다.

When a developer designs a POST API without using a body,

  1. the SDK automatically defines the Input Type as undefined, unknown, {}.
    • As the Input Type is defined, any issues that may arise from this can be resolved.
  2. Similarly, since the Input Type is not created, the SDK does not generate a stringify method.

Originally posted by @industriously in https://github.com/samchon/nestia/issues/266#issuecomment-1456823891

samchon commented 1 year ago

Will fix by second way. Thanks for report