-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Type/Interface used with request body validation is ignored #2641
Comments
I am afraid TypeScript does not capture information about interfaces at runtime. Interfaces exist at compile time only. You have two options:
|
Thank you for the quick response. I have tried the first option. Unfortunately, it gives the following error: You can find it in this repo However, the second option (which I have been already using) is working without a problem: content: {
'application/json': {
schema: {
type: 'object',
additionalProperties: false,
properties: {
id: {type: 'string'},
age: {type: 'number'}
},
required: ['id', 'age'],
},
}, But of course, it will be better in my view to have a model used for validation instead of manually adding the properties. So it would be great if we get option 1 to work. |
That problem looks unrelated to model validation, at least I don't see any obvious reason how using I am afraid I don't have bandwidth to look into this in more details right now. If you manage to find any new information, then feel free to open a new issue. Just make sure to create a sandbox app per our bug reporting instructions. |
Description / Steps to reproduce / Feature proposal
Given the following interface defined inside a controller:
and here is the endpoint definition:
When this endpoint receives the following input for example (which has properties not defined in the interface):
{ anyKey: anyValue }
it accept it and ignore the validation
it should not allow the below values - because they are not included/against our interface idAndAge
{ anyKey: anyValue }
please check this repo , if you'd like to test the issue
The text was updated successfully, but these errors were encountered: