Skip to content

Commit

Permalink
Don't import maxLength on floats (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriehSchneier authored Jul 10, 2024
1 parent 9d2b831 commit 1c6f5de
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Binary file modified internal/bundles/assets/import_openapi_cli.arraiz
Binary file not shown.
13 changes: 9 additions & 4 deletions pkg/importer/openapi/openapi_to_sysl_proto.arrai
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,15 @@ let specialAnno = {
let constraint =
let c = (
length:
let maxLength = t('maxLength')?:{};
let minLength = t('minLength')?:{};
cond {maxLength: ('max': maxLength), _: ()} +>
cond {minLength: ('min': minLength), _: ()}
cond {
type = primitive('FLOAT'):
(), # no length on a float
_:
let maxLength = t('maxLength')?:{};
let minLength = t('minLength')?:{};
cond {maxLength: ('max': maxLength), _: ()} +>
cond {minLength: ('min': minLength), _: ()},
}
,
bit_width:
let format = intOrFloatRegex.sub('', t('format')?.s:{});
Expand Down
4 changes: 4 additions & 0 deletions pkg/importer/tests/openapi3/min-max.sysl
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ TestApp "Simple":
@json_tag = "i"
j <: string(1..2)?:
@json_tag = "j"
k <: float?:
@json_tag = "k"
l <: int(6)?:
@json_tag = "l"
6 changes: 6 additions & 0 deletions pkg/importer/tests/openapi3/min-max.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ components:
type: integer
j:
$ref: '#/components/schemas/toRefWithLength'
k:
type: number
maxLength: 6 # invalid, but sysl shouldn't crash
l:
type: integer
maxLength: 6 # invalid, but sysl shouldn't crash

0 comments on commit 1c6f5de

Please sign in to comment.