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

Add min/max to Structure, various improvements #45

Closed lr-conrs closed 4 years ago

lr-conrs commented 4 years ago

Yarn changes

Docs changes

I ran the yarn command to generate railroad based off of src, so updated the docs to point to that, as well as the big grammar file.

Dockerfile changes

Similar to yarn changes, I've adapted the dockerfile to also use node directly and only deal with the built javascript. This has realized quite the speed increase.

$ time docker run --rm  local-test-reslang help
[...]
real    0m0.894s
user    0m0.035s
sys 0m0.016s
$ time docker run --rm gcr.io/liveramp-eng/reslang:master help
real    0m4.075s
user    0m0.037s
sys 0m0.021s

The reason for most of the speed gain is the fact that we no longer compile the source for every single request, instead only packaging and executing the compiled Javascript.

Reslang changes

I've added the ability to specify min-properties and max-properties on a structure. This will allow the Data Store team the ability to make representing invalid pricing data impossible, by restricting pricing information such that only one price of a given type can ever be added, but also enforcing that an empty set of prices is not valid.

TODO: It doesn't make sense to have these properties if the type is "union"