You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6cd5e5a
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix: rewrite $ref in top level oneOf/anyOf/allOf branches during variant generation (#83)
* rewrite $ref in top-level oneOf/anyOf branches during variant generation
(cherry picked from commit 2a9beb9)
* update
(cherry picked from commit e652462)
* test: add coverage for composition variant propagation and rewriting
(cherry picked from commit 34c3107)
* fix: tolerate line-wrapped Annotated[...] in inject_array_contains
_create_single_variant now rewrites $ref inside top-level oneOf/anyOf/
allOf/items branches (see the preceding two commits, cherry-picked from
#35), which lengthens some array-root item type references, e.g.
total.Total becomes total_create_request.TotalCreateRequest for
TotalsCreateRequest. That extra length pushes ruff's formatter to wrap
Annotated[...] onto multiple lines with a trailing comma before the
closing bracket.
inject_array_contains spliced AfterValidator(...) in right before that
closing bracket without checking for the trailing comma, landing the
new element after an orphaned comma with nothing between them - a
SyntaxError, not just a formatting nit. Because tests/test_codegen_pipeline.py
imported the generated Totals*Request classes inside a bare
"except ImportError", the SyntaxError went uncaught and took the whole
test module down at collection time, failing every test in the file.
Fix the splice to insert after the last real token before the closing
bracket instead of blindly before it, reusing an existing trailing
comma when present. Also widen the import guard to catch SyntaxError
so one broken generated file degrades to HAVE_SDK = False instead of
failing collection for the whole module.
* chore: regenerate models against pinned UCP spec 2026-04-08
Runs generate_models.sh 2026-04-08 (README compat table: SDK 0.4.x ->
UCP schema 2026-04-08) against the three preceding commits (the #35
ref-rewrite cherry-picks plus the inject_array_contains fix). Only
totals_create_request.py/totals_update_request.py change beyond what
the cherry-picks already carried, because those two needed both fixes
together: the ref rewrite (to point at total_create_request.json
instead of total.json) and the trailing-comma-safe splice (to still
parse once that longer reference pushes Annotated[...] onto multiple
lines).
---------
Co-authored-by: xiaoxuan-hub <i.travel@live.com>
Co-authored-by: damaz91 <federico.damato91@gmail.com>
Co-authored-by: Vishal Katyal <vishal@katyal.ai>
# Licensed under the Apache License, Version 2.0 (the "License");
4
+
# you may not use this file except in compliance with the License.
5
+
# You may obtain a copy of the License at
6
+
#
7
+
# http://www.apache.org/licenses/LICENSE-2.0
8
+
#
9
+
# Unless required by applicable law or agreed to in writing, software
10
+
# distributed under the License is distributed on an "AS IS" BASIS,
11
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+
# See the License for the specific language governing permissions and
13
+
# limitations under the License.
14
+
15
+
# generated by datamodel-codegen
16
+
# pylint: disable=all
17
+
# pyformat: disable
18
+
19
+
from __future__ importannotations
20
+
21
+
fromtypingimportAnnotated
22
+
23
+
frompydanticimportField
24
+
fromtyping_extensionsimportTypeAliasType
25
+
26
+
ErrorCodeCreateRequest=TypeAliasType(
27
+
"ErrorCodeCreateRequest",
28
+
Annotated[
29
+
str,
30
+
Field(
31
+
...,
32
+
examples=[
33
+
"not_found",
34
+
"out_of_stock",
35
+
"item_unavailable",
36
+
"address_undeliverable",
37
+
"payment_failed",
38
+
"eligibility_invalid",
39
+
"identity_required",
40
+
"insufficient_scope",
41
+
],
42
+
title="Error Code Create Request",
43
+
),
44
+
],
45
+
)
46
+
"""
47
+
Error code identifying the type of error. Standard errors are defined in specification (see examples), and have standardized semantics; freeform codes are permitted.
# Licensed under the Apache License, Version 2.0 (the "License");
4
+
# you may not use this file except in compliance with the License.
5
+
# You may obtain a copy of the License at
6
+
#
7
+
# http://www.apache.org/licenses/LICENSE-2.0
8
+
#
9
+
# Unless required by applicable law or agreed to in writing, software
10
+
# distributed under the License is distributed on an "AS IS" BASIS,
11
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+
# See the License for the specific language governing permissions and
13
+
# limitations under the License.
14
+
15
+
# generated by datamodel-codegen
16
+
# pylint: disable=all
17
+
# pyformat: disable
18
+
19
+
from __future__ importannotations
20
+
21
+
fromtypingimportAnnotated
22
+
23
+
frompydanticimportField
24
+
fromtyping_extensionsimportTypeAliasType
25
+
26
+
ErrorCodeUpdateRequest=TypeAliasType(
27
+
"ErrorCodeUpdateRequest",
28
+
Annotated[
29
+
str,
30
+
Field(
31
+
...,
32
+
examples=[
33
+
"not_found",
34
+
"out_of_stock",
35
+
"item_unavailable",
36
+
"address_undeliverable",
37
+
"payment_failed",
38
+
"eligibility_invalid",
39
+
"identity_required",
40
+
"insufficient_scope",
41
+
],
42
+
title="Error Code Update Request",
43
+
),
44
+
],
45
+
)
46
+
"""
47
+
Error code identifying the type of error. Standard errors are defined in specification (see examples), and have standardized semantics; freeform codes are permitted.
# Licensed under the Apache License, Version 2.0 (the "License");
4
+
# you may not use this file except in compliance with the License.
5
+
# You may obtain a copy of the License at
6
+
#
7
+
# http://www.apache.org/licenses/LICENSE-2.0
8
+
#
9
+
# Unless required by applicable law or agreed to in writing, software
10
+
# distributed under the License is distributed on an "AS IS" BASIS,
11
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+
# See the License for the specific language governing permissions and
13
+
# limitations under the License.
14
+
15
+
# generated by datamodel-codegen
16
+
# pylint: disable=all
17
+
# pyformat: disable
18
+
19
+
from __future__ importannotations
20
+
21
+
fromtypingimportAnnotated
22
+
23
+
frompydanticimportField
24
+
fromtyping_extensionsimportTypeAliasType
25
+
26
+
InfoCodeCreateRequest=TypeAliasType(
27
+
"InfoCodeCreateRequest",
28
+
Annotated[
29
+
str,
30
+
Field(
31
+
...,
32
+
examples=[
33
+
"identity_optional",
34
+
"signal",
35
+
"free_shipping",
36
+
"not_found",
37
+
],
38
+
title="Info Code Create Request",
39
+
),
40
+
],
41
+
)
42
+
"""
43
+
Info code identifying the type of informational message. Standard codes are defined in capability specs (see examples), and have standardized semantics; freeform codes are permitted.
# Licensed under the Apache License, Version 2.0 (the "License");
4
+
# you may not use this file except in compliance with the License.
5
+
# You may obtain a copy of the License at
6
+
#
7
+
# http://www.apache.org/licenses/LICENSE-2.0
8
+
#
9
+
# Unless required by applicable law or agreed to in writing, software
10
+
# distributed under the License is distributed on an "AS IS" BASIS,
11
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+
# See the License for the specific language governing permissions and
13
+
# limitations under the License.
14
+
15
+
# generated by datamodel-codegen
16
+
# pylint: disable=all
17
+
# pyformat: disable
18
+
19
+
from __future__ importannotations
20
+
21
+
fromtypingimportAnnotated
22
+
23
+
frompydanticimportField
24
+
fromtyping_extensionsimportTypeAliasType
25
+
26
+
InfoCodeUpdateRequest=TypeAliasType(
27
+
"InfoCodeUpdateRequest",
28
+
Annotated[
29
+
str,
30
+
Field(
31
+
...,
32
+
examples=[
33
+
"identity_optional",
34
+
"signal",
35
+
"free_shipping",
36
+
"not_found",
37
+
],
38
+
title="Info Code Update Request",
39
+
),
40
+
],
41
+
)
42
+
"""
43
+
Info code identifying the type of informational message. Standard codes are defined in capability specs (see examples), and have standardized semantics; freeform codes are permitted.
0 commit comments