-
Notifications
You must be signed in to change notification settings - Fork 10
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
How to document optional attributes with buildTemplatedApiExceptionDecorator? #17
Comments
Hi @lzkill, with the What do you think about an optional array which can contain the required attributes? For example: export const TemplatedApiException = buildTemplatedApiExceptionDecorator({
statusCode: '$status',
clientCode: 'number',
message: '$description',
errors: [
{
string: 'string',
},
],
path: 'string',
timestamp: '1970-01-01T15:30:11',
}, ['statusCode', 'message', 'timestamp']); |
Hi my friend. I guess this array would pretty much fit my needs. Without this the api consumer is not aware until the first errors start to return. |
Hi @lzkill, we've extended the export const TemplatedApiException = buildTemplatedApiExceptionDecorator(
{
statusCode: '$status',
clientCode: 'number',
message: '$description',
errors: [
{
string: 'string',
},
],
path: 'string',
timestamp: '1970-01-01T15:30:11',
},
{ requiredProperties: ['statusCode', 'message', 'timestamp'] },
); We'll release a new version (v1.3.0) soon :) |
Thank you again, my friend! |
@jsproede What do you think about having a similar array for custom placeholders? |
@lzkill Do you have an example? :) |
Something like this: export const TemplatedApiException = buildTemplatedApiExceptionDecorator(
{
statusCode: '$status',
clientCode: '$clientCode',
message: '$description',
errors: [
{
string: 'string',
},
],
path: 'string',
timestamp: '1970-01-01T15:30:11',
},
{
requiredProperties: ['statusCode', 'message', 'timestamp'],
placeholders: {
'clientCode': (e) => { (e as BaseException).getClientCode(); }
}
},
); (I'm sorry for my poor typescript) |
@lzkill Great idea! I've moved your suggestion regarding custom placeholders into a new issue :) |
Hi @lzkill, I just wanted to notify you, that a new version including the |
Hi my friend. I was already using your first commit. :) Thank you very much for your superb work! |
I have this template decorator:
It matches my exception filter custom json. But some attributes are optional. Hoe can I document this on Swagger?
The text was updated successfully, but these errors were encountered: