LiveRamp / reslang

A language for describing resource-oriented APIs & turning them into Swagger or resource diagrams. Oriented around the concepts we want to expose in the APIs.
Apache License 2.0
23 stars 7 forks source link

Handle multiplicity in array types #9

Closed lr-conrs closed 4 years ago

lr-conrs commented 4 years ago

It would be nice to add constraints surrounding contents of arrays. Often, maybe even all the time, if an array is required in a payload, it also must have at least one member.

Context is in the thread of this Slack message. https://liveramp.slack.com/archives/CPBAEKS9X/p1582832093016800

lr-conrs commented 4 years ago

As a secondary note, I think it would be a good idea to think about always setting a minItems of 1 for any array in a structure (optional or not). The optionality of the key whose type is array could signal whether empty or not is a valid state.

The same can be said for "string" types. Having a required string with "" in it -- is it really set for as far as the common use case is concerned?

liveandrew commented 4 years ago

added support for multiplicities in arrays. e.g. string[1..20] or int [..30] or float[10..] etc etc

added to this commit: 5d3d239c268413e7325b84bc4b8e4f58c5043922

a string type isn't an array in swagger. there is a format notion, which reslang could support. e.g. [A-Z]+ etc. also numbers can have a max and min range. raise a separate ticket if you require support for these, along with a use case and urgency (i.e. i need this NOW type thing)