Skip to content
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

json: support integer minimum, maximum, exclusiveMinimum, exclusiveMaximum #7797

Merged
merged 30 commits into from
Jun 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
057bbdc
json: support minimum for positive integer values
ochafik Apr 30, 2024
d69ccb0
json: fix min 0
ochafik Apr 30, 2024
c37c484
json: min + max integer constraints
ochafik May 1, 2024
af63f4f
json: handle negative min / max integer bounds
ochafik May 1, 2024
a381deb
json: fix missing paren min/max bug
ochafik May 1, 2024
f8db478
json: proper paren fix
ochafik May 1, 2024
5a86c6f
json: integration test for schemas
ochafik May 18, 2024
431edb8
json: fix bounds tests
ochafik May 18, 2024
b6b6a6c
Update json-schema-to-grammar.cpp
ochafik May 19, 2024
a786c03
Merge remote-tracking branch 'origin/master' into json-bounds2
ochafik Jun 8, 2024
931b543
json: fix negative max
ochafik Jun 8, 2024
4c1c293
json: fix negative min (w/ more than 1 digit)
ochafik Jun 8, 2024
ac2a8f8
Update test-grammar-integration.cpp
ochafik Jun 8, 2024
3549702
json: nit: move string rules together
ochafik Jun 8, 2024
e933680
json: port min/max integer support to Python & JS
ochafik Jun 8, 2024
a0f1904
nit: move + rename _build_min_max_int
ochafik Jun 8, 2024
dcc27d1
fix min in [1, 9]
ochafik Jun 9, 2024
d1f6791
Update test-grammar-integration.cpp
ochafik Jun 9, 2024
cad377d
add C++11-compatible replacement for std::string_view
ochafik Jun 9, 2024
d6483a9
add min/max constrained int field to pydantic json schema example
ochafik Jun 10, 2024
f03e9b9
Merge remote-tracking branch 'origin/master' into json-bounds2
ochafik Jun 12, 2024
6fa7364
Merge remote-tracking branch 'origin/master' into json-bounds2
ochafik Jun 22, 2024
948e55e
fix merge
ochafik Jun 22, 2024
670d5a6
json: add integration tests for min/max bounds
ochafik Jun 22, 2024
9fb8a75
Merge remote-tracking branch 'origin/master' into json-bounds2
ochafik Jun 23, 2024
d7d957d
Merge remote-tracking branch 'origin/master' into json-bounds2
ochafik Jun 24, 2024
3a80d1e
reshuffle/merge min/max integ test cases
ochafik Jun 24, 2024
09a9b75
nits / cleanups
ochafik Jun 24, 2024
48f417d
Merge remote-tracking branch 'origin/master' into json-bounds2
ochafik Jun 25, 2024
36bf003
defensive code against string out of bounds (apparently different beh…
ochafik Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
defensive code against string out of bounds (apparently different beh…
…aviour of libstdc++ vs. clang's libc++, can't read final NULL char w/ former)
  • Loading branch information
ochafik committed Jun 25, 2024
commit 36bf00369a2736473a878b12d773d363b97103d3
8 changes: 6 additions & 2 deletions common/json-schema-to-grammar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class string_view {
}

char operator[](size_t pos) const {
auto index = _start + pos;
if (index >= _end) {
throw std::out_of_range("string_view index out of range");
}
return _str[_start + pos];
}

Expand Down Expand Up @@ -110,13 +114,13 @@ static void _build_min_max_int(int min_value, int max_value, std::stringstream &
std::function<void(const string_view &, const string_view &)> uniform_range =
[&](const string_view & from, const string_view & to) {
size_t i = 0;
while (from[i] == to[i]) {
while (i < from.length() && i < to.length() && from[i] == to[i]) {
i++;
}
if (i > 0) {
out << "\"" << from.substr(0, i).str() << "\"";
}
if (i < from.length()) {
if (i < from.length() && i < to.length()) {
if (i > 0) {
out << " ";
}
Expand Down
Loading