Bug: Tsoa removing properties from body incorrectly
We are using tsoa to build a BFF, so we are using the default noImplicitAdditionalProperties config so we only define the values that we need and the other ones are just send to the other service automatically.
We found a case where tsoa is removing not defined properties incorrectly:
The bug is probably related to a specific usage of Partial, Omit and union types.
Here is a repository with the bug for you guys to test.
Hello there eduardo-pellenz 👋
Thank you for opening your very first issue in this project.
We will try to get back to you as soon as we can.👀
I think I encountered the same issue and spend 3 hours to narrow it down at least to a manageable size:
import { Body, Controller, Put, Route } from "tsoa";
type ValueFormatModel = {
contentIfNotSet?: string;
};
type SetFieldFormatStepConfigModel = {
newFormat: Partial<
| ({
prefix?: string;
} & ValueFormatModel)
| ValueFormatModel
>;
};
type StepModel = {
id?: string;
} & SetFieldFormatStepConfigModel;
@Route("users")
export class HelloController extends Controller {
@Put()
public async putReplaySteps(
@Body()
body: StepModel
): Promise<any> {
return body;
}
}
Input is:
{
"newFormat": {
"contentIfNotSet": "3",
"prefix": "g"
}
}
Output is
{
"newFormat": {
"contentIfNotSet": "3"
}
}
@eduardo-pellenz Your repository isn't actually accessible publicly btw.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
No indication the issue was solved