Skip to content

Commit

Permalink
#40: updated scale and precision logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit-s96 committed Sep 12, 2023
1 parent e912ca1 commit 1289cb1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/schema/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ function createDefinitions(resources, lookups, additionalProperties = false) {
if (field.type === EDM_DATE_TIME_OFFSET) itemTypeSchema['format'] = 'date-time';
if (field.type === EDM_DATE) itemTypeSchema['format'] = 'date';
if (mappedType === 'integer' || mappedType === 'number') {
if (field.scale) itemTypeSchema['multipleOf'] = 1 / 10 ** field.scale;
if (field.precision) itemTypeSchema['maximum'] = Number('9'.repeat(field.precision));
if (!field.scale) {
if (field.precision) itemTypeSchema['maximum'] = Number('9'.repeat(field.precision));
}
}

if (!isSimpleType(field.type)) {
Expand Down Expand Up @@ -85,8 +86,9 @@ function createDefinitions(resources, lookups, additionalProperties = false) {
if (field.type === EDM_DATE_TIME_OFFSET) schema['format'] = 'date-time';
if (field.type === EDM_DATE) schema['format'] = 'date';
if (fieldType === 'integer' || fieldType === 'number') {
if (field.scale) schema['multipleOf'] = 1 / 10 ** field.scale;
if (field.precision) schema['maximum'] = Number('9'.repeat(field.precision));
if (!field.scale) {
if (field.precision) schema['maximum'] = Number('9'.repeat(field.precision));
}
}

if (!isSimpleType(field.type)) {
Expand Down

0 comments on commit 1289cb1

Please sign in to comment.