oed-cli 0.1.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oed-cli
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: oed — openEuler Infra command line. Auto-discovered, AI-friendly.
5
5
  Author: oed-cli contributors
6
6
  License: Apache-2.0
@@ -97,7 +97,7 @@ pip install -e .
97
97
  Verify:
98
98
 
99
99
  ```bash
100
- oed --version # → oed, version 0.2.0
100
+ oed --version # → oed, version 0.1.2
101
101
  ```
102
102
 
103
103
  ---
@@ -63,7 +63,7 @@ pip install -e .
63
63
  Verify:
64
64
 
65
65
  ```bash
66
- oed --version # → oed, version 0.2.0
66
+ oed --version # → oed, version 0.1.2
67
67
  ```
68
68
 
69
69
  ---
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "oed-cli"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "oed — openEuler Infra command line. Auto-discovered, AI-friendly."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -2,5 +2,5 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- __version__ = "0.2.0"
5
+ __version__ = "0.1.2"
6
6
  __all__ = ["__version__"]
@@ -34,6 +34,12 @@ def _fill_path(template: str, params: dict[str, Any]) -> tuple[str, list[str]]:
34
34
 
35
35
  Returns the rendered path and the list of placeholder names that were
36
36
  not provided, so the caller can raise a precise error.
37
+
38
+ Huawei APIG marks required path params with a trailing ``+`` in the
39
+ template (``/t/{id+}``); the ``+`` is a spec-side marker that never
40
+ appears in the real request URL or in the declared
41
+ ``parameters[].name``. Strip it so the lookup matches what the
42
+ caller actually provided under ``--<flag>`` / ``--params``.
37
43
  """
38
44
 
39
45
  missing: list[str] = []
@@ -48,13 +54,14 @@ def _fill_path(template: str, params: dict[str, Any]) -> tuple[str, list[str]]:
48
54
  if name_end == -1:
49
55
  parts.append(head + sep + chunk)
50
56
  break
51
- name = chunk[:name_end]
57
+ raw_name = chunk[:name_end]
58
+ name = raw_name.rstrip("+")
52
59
  parts.append(head)
53
60
  if name in params:
54
61
  parts.append(str(params[name]))
55
62
  else:
56
63
  missing.append(name)
57
- parts.append("{" + name + "}")
64
+ parts.append("{" + raw_name + "}")
58
65
  rest = chunk[name_end + 1 :]
59
66
  return "".join(parts), missing
60
67
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oed-cli
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: oed — openEuler Infra command line. Auto-discovered, AI-friendly.
5
5
  Author: oed-cli contributors
6
6
  License: Apache-2.0
@@ -97,7 +97,7 @@ pip install -e .
97
97
  Verify:
98
98
 
99
99
  ```bash
100
- oed --version # → oed, version 0.2.0
100
+ oed --version # → oed, version 0.1.2
101
101
  ```
102
102
 
103
103
  ---
@@ -526,6 +526,49 @@ def test_call_operation_missing_path_param_raises_user_error(patched):
526
526
  call_operation(op) # no id
527
527
 
528
528
 
529
+ def test_call_operation_strips_trailing_plus_in_path_template(patched):
530
+ """Huawei APIG marks required path params with ``{name+}`` in the path
531
+ template (``/t/{id+}``). The declared ``parameters[].name`` is plain
532
+ ``id`` — the ``+`` is a spec-side marker. ``oed forum getTopic --id 19308``
533
+ must therefore resolve the user's ``--id`` value into the rendered URL,
534
+ not complain that ``id+`` is missing."""
535
+
536
+ from oed_cli.dynamic import operations_table
537
+ from oed_cli.invoke import call_operation
538
+
539
+ spec = {
540
+ "openapi": "3.0.1",
541
+ "paths": {
542
+ "/t/{id+}": {
543
+ "get": {
544
+ "operationId": "getTopic",
545
+ "parameters": [
546
+ {"in": "path", "name": "id",
547
+ "required": True, "schema": {"type": "string"}},
548
+ ],
549
+ }
550
+ }
551
+ },
552
+ }
553
+ table = operations_table(spec, "forum", base_url="https://apig.osinfra.cn")
554
+ op = table["getTopic"]
555
+
556
+ payload = call_operation(op, params={"id": "19308"})
557
+ assert patched["captured"]["url"].endswith("/t/19308")
558
+ assert payload["ok"] is True
559
+ assert payload["status"] == 200
560
+
561
+ # Missing-param error must use the clean name (what the user types),
562
+ # not the APIG-side ``id+`` form.
563
+ from oed_cli.errors import UserError
564
+ try:
565
+ call_operation(op)
566
+ except UserError as exc:
567
+ assert exc.to_dict()["message"] == "missing path params: ['id']"
568
+ else:
569
+ pytest.fail("expected UserError for missing path param")
570
+
571
+
529
572
  # ---------- main.py dispatch ----------
530
573
 
531
574
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes