-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Invalid SDK generataion for POST API #266
Comments
I'd recommend to add at least empty request body like However, listening your opinion, it seems too strict. I'll change it. |
What a simple way! Okay. I'll fill it out as you told me. |
// wrong
@TypedBody() body: {} // Cannot read properties of undefined (reading '0') // right
@TypedBody() body: Record<string, never>, Currently, people facing this problem can avoid the problem by specifying the Record type as shown above. |
Upgrade to |
현재 1.0.1 기준으로 @Body나 @TypedBody를 사용하지 않고 POST sdk를 만들면 at v1.0.1, If i don't use Body in POST api. sdk generated like that. 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를 설계했을 때,
When a developer designs a POST API without using a body,
|
I will write Korean and English at the same time. ( I'm not good at writing English. )
Summary
I tested it after updating the version using ncu, but I still faced the same error.
이번에 ncu를 통해서 버전 업데이트를 진행해봤는데도 이 문제가 그대로 남아 있습니다.
Expected behavior:
I think it is impossible to use the POST method without TypedBody. I don't think there must be a body just because it's a POST method.
제 생각에는 TypedBody없이 POST 메서드 사용이 불가능한 거 같습니다. 저는 POST 메서드라고 꼭 Body가 있어야 한다고 생각하진 않았습니다.
Actual behavior:
You don't have to worry because the red underscore is just an eslint, prettier error. If I write down the explanation of the error for those who do not understand Korean,
follow2.METHOD
has'POST'
as a type because I made the API POST method, but the expected type is'GET' | 'DELETE'
, so the SDK is incorrectly generated.빨간색 밑줄은 단지 eslint, prettier 에러입니다. 제가 한국어를 모르는 분들을 위해 설명을 간략히 적자면, 제가 POST 메서드를 만들었기 때문에
follow2.METHOD
는'POST'
타입으로 추론이 정상적으로 되지만, 기대되는 타입은'GET' | 'DELETE'
라고 나옵니다. 이는 정상적으로 SDK가 생성되었다고 생각되지 않습니다.Code occuring the bug
git clone https://github.com/kakasoo/nestia-demo cd nestia-demo npm i npx nestia sdk
The text was updated successfully, but these errors were encountered: