Skip to content

Commit e3be9f4

Browse files
committed
fix: make page number strictly positive
Signed-off-by: Panos Vagenas <[email protected]>
1 parent 0cdcc9b commit e3be9f4

File tree

3 files changed

+77
-5
lines changed

3 files changed

+77
-5
lines changed

docling_core/types/doc/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""Define common models across CCS objects."""
77
from typing import Annotated, Literal, Optional, Union
88

9-
from pydantic import BaseModel, Field, StrictStr
9+
from pydantic import BaseModel, Field, PositiveInt, StrictStr
1010

1111
from docling_core.search.mapping import es_field
1212
from docling_core.utils.alias import AliasModel
@@ -39,7 +39,7 @@ class S3Resource(BaseModel):
3939

4040
mime: str
4141
path: str
42-
page: Optional[int] = None
42+
page: Optional[PositiveInt] = None
4343

4444

4545
class S3Data(AliasModel):
@@ -68,7 +68,7 @@ class Prov(AliasModel):
6868
"""Provenance."""
6969

7070
bbox: BoundingBox
71-
page: int
71+
page: PositiveInt
7272
span: Span
7373
ref_s3_data: Optional[StrictStr] = Field(
7474
default=None, alias="__ref_s3_data", json_schema_extra=es_field(suppress=True)
@@ -96,7 +96,7 @@ class PageDimensions(BaseModel):
9696
"""Page dimensions."""
9797

9898
height: float
99-
page: int
99+
page: PositiveInt
100100
width: float
101101

102102

@@ -196,4 +196,4 @@ class PageReference(BaseModel):
196196

197197
hash: str = Field(json_schema_extra=es_field(type="keyword", ignore_above=8191))
198198
model: str = Field(json_schema_extra=es_field(suppress=True))
199-
page: int = Field(json_schema_extra=es_field(type="short"))
199+
page: PositiveInt = Field(json_schema_extra=es_field(type="short"))

docs/Document.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@
11881188
"type": "number"
11891189
},
11901190
"page": {
1191+
"exclusiveMinimum": 0,
11911192
"title": "Page",
11921193
"type": "integer"
11931194
},
@@ -1219,6 +1220,7 @@
12191220
"x-es-suppress": true
12201221
},
12211222
"page": {
1223+
"exclusiveMinimum": 0,
12221224
"title": "Page",
12231225
"type": "integer",
12241226
"x-es-type": "short"
@@ -1245,6 +1247,7 @@
12451247
"type": "array"
12461248
},
12471249
"page": {
1250+
"exclusiveMinimum": 0,
12481251
"title": "Page",
12491252
"type": "integer"
12501253
},
@@ -1547,6 +1550,7 @@
15471550
"page": {
15481551
"anyOf": [
15491552
{
1553+
"exclusiveMinimum": 0,
15501554
"type": "integer"
15511555
},
15521556
{

docs/Document.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3598,6 +3598,10 @@ Must be one of:
35983598
| **Type** | `integer` |
35993599
| **Required** | Yes |
36003600

3601+
| Restrictions | |
3602+
| ------------ | ------ |
3603+
| **Minimum** | &gt; 0 |
3604+
36013605
</blockquote>
36023606
</details>
36033607

@@ -3995,6 +3999,10 @@ Must be one of:
39953999
| **Type** | `integer` |
39964000
| **Required** | Yes |
39974001

4002+
| Restrictions | |
4003+
| ------------ | ------ |
4004+
| **Minimum** | &gt; 0 |
4005+
39984006
</blockquote>
39994007
</details>
40004008

@@ -4404,6 +4412,10 @@ Must be one of:
44044412
| **Type** | `integer` |
44054413
| **Required** | Yes |
44064414

4415+
| Restrictions | |
4416+
| ------------ | ------ |
4417+
| **Minimum** | &gt; 0 |
4418+
44074419
</blockquote>
44084420
</details>
44094421

@@ -5732,6 +5744,10 @@ Must be one of:
57325744
| **Type** | `integer` |
57335745
| **Required** | Yes |
57345746

5747+
| Restrictions | |
5748+
| ------------ | ------ |
5749+
| **Minimum** | &gt; 0 |
5750+
57355751
</blockquote>
57365752
</details>
57375753

@@ -6149,6 +6165,10 @@ Must be one of:
61496165
| **Type** | `integer` |
61506166
| **Required** | Yes |
61516167

6168+
| Restrictions | |
6169+
| ------------ | ------ |
6170+
| **Minimum** | &gt; 0 |
6171+
61526172
</blockquote>
61536173
</details>
61546174

@@ -6540,6 +6560,10 @@ Must be one of:
65406560
| **Type** | `integer` |
65416561
| **Required** | Yes |
65426562

6563+
| Restrictions | |
6564+
| ------------ | ------ |
6565+
| **Minimum** | &gt; 0 |
6566+
65436567
</blockquote>
65446568
</details>
65456569

@@ -7020,6 +7044,10 @@ Must be one of:
70207044
| **Type** | `integer` |
70217045
| **Required** | Yes |
70227046

7047+
| Restrictions | |
7048+
| ------------ | ------ |
7049+
| **Minimum** | &gt; 0 |
7050+
70237051
</blockquote>
70247052
</details>
70257053

@@ -7228,6 +7256,10 @@ Must be one of:
72287256
| **Type** | `integer` |
72297257
| **Required** | Yes |
72307258

7259+
| Restrictions | |
7260+
| ------------ | ------ |
7261+
| **Minimum** | &gt; 0 |
7262+
72317263
</blockquote>
72327264
</details>
72337265

@@ -7557,6 +7589,10 @@ Must be one of:
75577589
| **Type** | `integer` |
75587590
| **Required** | Yes |
75597591

7592+
| Restrictions | |
7593+
| ------------ | ------ |
7594+
| **Minimum** | &gt; 0 |
7595+
75607596
</blockquote>
75617597
</details>
75627598

@@ -7971,6 +8007,10 @@ Must be one of:
79718007
| **Type** | `integer` |
79728008
| **Required** | Yes |
79738009

8010+
| Restrictions | |
8011+
| ------------ | ------ |
8012+
| **Minimum** | &gt; 0 |
8013+
79748014
</blockquote>
79758015
</details>
79768016

@@ -8248,6 +8288,10 @@ Must be one of:
82488288
| **Type** | `integer` |
82498289
| **Required** | No |
82508290

8291+
| Restrictions | |
8292+
| ------------ | ------ |
8293+
| **Minimum** | &gt; 0 |
8294+
82518295
</blockquote>
82528296
<blockquote>
82538297

@@ -8403,6 +8447,10 @@ Must be one of:
84038447
| **Type** | `integer` |
84048448
| **Required** | No |
84058449

8450+
| Restrictions | |
8451+
| ------------ | ------ |
8452+
| **Minimum** | &gt; 0 |
8453+
84068454
</blockquote>
84078455
<blockquote>
84088456

@@ -8558,6 +8606,10 @@ Must be one of:
85588606
| **Type** | `integer` |
85598607
| **Required** | No |
85608608

8609+
| Restrictions | |
8610+
| ------------ | ------ |
8611+
| **Minimum** | &gt; 0 |
8612+
85618613
</blockquote>
85628614
<blockquote>
85638615

@@ -8692,6 +8744,10 @@ Must be one of:
86928744
| **Type** | `integer` |
86938745
| **Required** | No |
86948746

8747+
| Restrictions | |
8748+
| ------------ | ------ |
8749+
| **Minimum** | &gt; 0 |
8750+
86958751
</blockquote>
86968752
<blockquote>
86978753

@@ -8826,6 +8882,10 @@ Must be one of:
88268882
| **Type** | `integer` |
88278883
| **Required** | No |
88288884

8885+
| Restrictions | |
8886+
| ------------ | ------ |
8887+
| **Minimum** | &gt; 0 |
8888+
88298889
</blockquote>
88308890
<blockquote>
88318891

@@ -8960,6 +9020,10 @@ Must be one of:
89609020
| **Type** | `integer` |
89619021
| **Required** | No |
89629022

9023+
| Restrictions | |
9024+
| ------------ | ------ |
9025+
| **Minimum** | &gt; 0 |
9026+
89639027
</blockquote>
89649028
<blockquote>
89659029

@@ -9115,6 +9179,10 @@ Must be one of:
91159179
| **Type** | `integer` |
91169180
| **Required** | No |
91179181

9182+
| Restrictions | |
9183+
| ------------ | ------ |
9184+
| **Minimum** | &gt; 0 |
9185+
91189186
</blockquote>
91199187
<blockquote>
91209188

0 commit comments

Comments
 (0)