`Bundle` names a path item component after the escaped JSON Pointer token (`~1users`), so its `$ref` doesn't resolve
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #290 của @TristanSpeakEasy — đã merge
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go, openapi
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Start in openapi/bundle.go at extractSimpleNameFromReference, which the issue identifies as returning the escaped final JSON Pointer token unchanged; trace how that name is used to create the path item component and its $ref. Reproduce with the supplied /paths/~1users example, then check that the resulting component name is valid and the reference resolves. Confirm the bundled document passes openapi spec validate and openapi spec inline.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
When a path item is referenced by JSON Pointer into another OpenAPI document (./paths/users.yaml#/paths/~1users), openapi.Bundle (and openapi spec bundle) uses the last pointer token as written, ~1users, as the component name. The bundled document gets components.pathItems.~1users and $ref: '#/components/pathItems/~1users'. Per RFC 6901 that ref names the key /users, which doesn't exist, and ~1users isn't a valid component name either (OAS 3.1 Components keys must match ^[a-zA-Z0-9\.\-_]+$). The bundle fails openapi spec validate, though the input passes.
Reproduction
openapi.yaml:
openapi: 3.1.0
info: {title: t, version: "1"}
paths:
/users:
$ref: ./paths/users.yaml#/paths/~1users
paths/users.yaml:
openapi: 3.1.0
info: {title: users, version: "1"}
paths:
/users:
get:
responses:
"200":
description: ok
$ openapi spec bundle openapi.yaml bundled.yaml
Processing OpenAPI document: openapi.yaml
✅ Successfully bundled all external references into components section
📄 Document written to: bundled.yaml
$ cat bundled.yaml
openapi: 3.1.0
info: {title: t, version: "1"}
paths:
/users:
$ref: '#/components/pathItems/~1users'
components:
pathItems:
~1users:
get:
responses:
"200":
description: ok
$ openapi spec validate bundled.yaml
Validating OpenAPI document: bundled.yaml
❌ OpenAPI document is invalid - 1 errors:
1. [5:11] error validation-invalid-syntax reference.$ref is invalid: invalid reference: component name "/users" must match pattern ^[a-zA-Z0-9.\-_]+$
Validation completed in 1ms
Error: openAPI document validation failed
openapi spec inline bundled.yaml fails the same way: failed to resolve reference #/components/pathItems/~1users: not found -- key /users not found in sequencedmap.Map. A path with a parameter gives ~1users~1{id}. --naming counter gives the same name.
Expected result
A valid component name and a $ref that resolves to it, as for a whole-file ref: $ref: ./paths/users.yaml (a file holding only the path item) bundles to components.pathItems.users, and the bundle validates.
Actual result
components.pathItems.~1users and a $ref that points at /users. The command reports success.
Version
v1.26.1 (main, 9f2ba11) and v1.26.0. CLI from go install github.com/speakeasy-api/openapi/cmd/openapi@latest (v0.0.0-20261029045548-9f2ba118224c); openapi.Bundle called directly gives the same output.
Cause
extractSimpleNameFromReference (openapi/bundle.go:1288) replaces characters outside [a-zA-Z0-9_] in file names, but for a fragment returns the last pointer token unchanged: not unescaped (~1, ~0) and not sanitized.
- Ngôn ngữ chính
- Go
- Star
- 276
- Fork
- 21
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue tương tự
-
Headerless responses block while skipping duplicate status linesCó thể đã có người làm @mynhe đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
projectdiscovery/rawhttp#554 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
lognorman20/monaco#7428 ·
-
docs(prompts): IF BLOCKED workflow-scope branch says to comment on the issue on jira/local trackersĐang mởagent-butler-finding bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
jordansmall/spindrift#6238 ·
Maintainer thường phản hồi trong vòng 1 ngày