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
Fix incorrect openapi type for datetime, date and password #8334
Fix incorrect openapi type for datetime, date and password #8334
Conversation
Signed-off-by: henrych4 <singyinhenry@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #8334 +/- ##
==========================================
- Coverage 33.20% 33.19% -0.01%
==========================================
Files 1220 1220
Lines 13616 13618 +2
Branches 1356 1357 +1
==========================================
Hits 4521 4521
- Misses 8211 8212 +1
- Partials 884 885 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for you contribution ! I have some remarks :)
maxLength, | ||
minLength, | ||
enum: enumeration, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to just modify the else
block.
Something like:
} else {
acc.properties[current] = {
type,
format: getFormat(attribute.type),
description,
default: defaultValue,
minimum,
maxmimun,
maxLength,
minLength,
enum: enumeration,
};
}
(In your code the value of type
is 'string'
for date and password, so it would not work for those two. The right variable to use would be attribute.type
.)
(I think we need to modify the function getType
so it handles datetime
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thanks for the comment, the code looks much better now.
default: | ||
return type; | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the handling of date
and password
explicit please? And make the default value undefined
as the function would be wrong for other types.
Something like:
getFormat: type => {
switch (type) {
case 'date':
return 'date';
case 'datetime':
return 'date-time';
case 'password':
return 'password';
default:
return undefined;
}
},
Signed-off-by: henrych4 <singyinhenry@gmail.com>
case 'email': | ||
case 'text': | ||
case 'enumeration': | ||
case 'date': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to remove password and date. Just to add datetime
here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henrych4 You forgot to add datetime
:)
Signed-off-by: henrych4 <singyinhenry@gmail.com>
Signed-off-by: henrych4 <singyinhenry@gmail.com>
8cef6f2
to
541f40c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you ! I tested it, it works well :)
While testing I saw that the type time
was not handled neither in getType
. Can you just add case 'time:'
at the same place as case 'datetime'
please ? :) No need to update getFormat
as doesn't this it has an official format.
Signed-off-by: henrych4 <singyinhenry@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, nice addition ! :)
Signed-off-by: henrych4 singyinhenry@gmail.com
Description of what you did:
Reopen #7623 and update with respect to the comments to fix #7149