Panic when attempting to generate CLI for YNAB's API
Chưa có ai nhận issue này.
Đá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
- 25/100
Hướng nghiên cứu
Bắt đầu bằng việc tái hiện với Dockerfile và lệnh openapi-cli-generator generate ynab.openapi.yaml. Kiểm tra main.go được tạo cùng các entry point writeFormattedFile và generate được nêu trong stack trace, sau đó so sánh mã nguồn Go được tạo với lỗi parser đã báo cáo. Được xem là hoàn tất khi đặc tả YNAB được cung cấp либо được tạo thành công, либо thất bại với một lỗi rõ ràng không gây panic.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I am attempting to generate a CLI for YNAB's API (spec) via Docker (because I really do not want to setup then tear down a go env for this single use-case).
This isn't straightforward as the YNAB API spec is OpenAPI v2 so I converted it to v3 with this tool (then validated the generated spec with this tool).
I uploaded the resulting v3 YAML as a gist.
I then wrote this, potentially bogus, Dockerfile:
FROM golang
WORKDIR /go/ynab-cli
RUN go get -u github.com/danielgtaylor/openapi-cli-generator && \
curl --silent -o ynab.openapi.yaml https://gist.githubusercontent.com/Phrohdoh/d1ecea1fbe1c8566fad5fd97aa99b346/raw/962661a47d8248aa2edd3618ad6c74d000219fe4/ynab_v1.openapi_v3.yaml && \
openapi-cli-generator init ynab && \
cat main.go | sed 's|// TODO: Add register commands here\.|openapiRegister(false)|g' > main.go
RUN openapi-cli-generator generate ynab.openapi.yaml
RUN go install
CMD ynab-cli
When I run the following from the directory containing my Dockerfile:
$ docker build -t gen-ynab-cli .
I get the following output:
Sending build context to Docker daemon 2.56kB
Step 1/6 : FROM golang
---> b860ab44e93e
Step 2/6 : WORKDIR /go/ynab-cli
---> Using cache
---> dfba7020dd36
Step 3/6 : RUN go get -u github.com/danielgtaylor/openapi-cli-generator && curl --silent -o ynab.openapi.yaml https://gist.githubusercontent.com/Phrohdoh/d1ecea1fbe1c8566fad5fd97aa99b346/raw/962661a47d8248aa2edd3618ad6c74d000219fe4/ynab_v1.openapi_v3.yaml && openapi-cli-generator init ynab && cat main.go | sed 's|// TODO: Add register commands here\.|openapiRegister(false)|g' > main.go && cat main.go
---> Using cache
---> e7a8c5ae42a6
Step 4/6 : RUN openapi-cli-generator generate ynab.openapi.yaml
---> Running in 4250354ef5c6
panic: 25:9: expected ';', found '.' (and 10 more errors)
goroutine 1 [running]:
main.writeFormattedFile(0xc000160c00, 0xf, 0xc0002ae000, 0x10af6, 0x12000)
/go/src/github.com/danielgtaylor/openapi-cli-generator/main.go:586 +0x112
main.generate(0xc0000b7b80, 0xc0000530a0, 0x1, 0x1)
/go/src/github.com/danielgtaylor/openapi-cli-generator/main.go:654 +0x5b0
github.com/spf13/cobra.(*Command).execute(0xc0000b7b80, 0xc000053080, 0x1, 0x1, 0xc0000b7b80, 0xc000053080)
/go/src/github.com/spf13/cobra/command.go:766 +0x2ae
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000b7680, 0xc00008df78, 0x1, 0x1)
/go/src/github.com/spf13/cobra/command.go:850 +0x2fc
github.com/spf13/cobra.(*Command).Execute(...)
/go/src/github.com/spf13/cobra/command.go:800
main.main()
/go/src/github.com/danielgtaylor/openapi-cli-generator/main.go:674 +0x1c0
The command '/bin/sh -c openapi-cli-generator generate ynab.openapi.yaml' returned a non-zero code: 2
With the relevant portion being:
panic: 25:9: expected ';', found '.' (and 10 more errors)
goroutine 1 [running]:
main.writeFormattedFile(0xc000160c00, 0xf, 0xc0002ae000, 0x10af6, 0x12000)
/go/src/github.com/danielgtaylor/openapi-cli-generator/main.go:586 +0x112
main.generate(0xc0000b7b80, 0xc0000530a0, 0x1, 0x1)
/go/src/github.com/danielgtaylor/openapi-cli-generator/main.go:654 +0x5b0
github.com/spf13/cobra.(*Command).execute(0xc0000b7b80, 0xc000053080, 0x1, 0x1, 0xc0000b7b80, 0xc000053080)
/go/src/github.com/spf13/cobra/command.go:766 +0x2ae
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000b7680, 0xc00008df78, 0x1, 0x1)
/go/src/github.com/spf13/cobra/command.go:850 +0x2fc
github.com/spf13/cobra.(*Command).Execute(...)
/go/src/github.com/spf13/cobra/command.go:800
main.main()
/go/src/github.com/danielgtaylor/openapi-cli-generator/main.go:674 +0x1c0
Am I attempting to use this project incorrectly or is the generated v3 YAML doc invalid?
Any help/input would be greatly appreciated!
- Ngôn ngữ chính
- Go
- Star
- 218
- Fork
- 53
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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 khác của danielgtaylor/openapi-cli-generator
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
danielgtaylor/openapi-cli-generator#45 · 2 bình luận · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
danielgtaylor/openapi-cli-generator#44 · 3 reaction ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
-
J how to escape "," symbols?Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
danielgtaylor/openapi-cli-generator#41 · 1 bình luận ·
Tất cả issue của danielgtaylor/openapi-cli-generator
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Rafaeldelinares/gentle-mesh#125 ·
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 76/100
Gentleman-Programming/gentle-ai#5643 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
FootprintAI/Containarium#2869 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
kubevirt/kubevirt#19559 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug raised-by:verifier
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
medici-finance/assay#3817 ·
Maintainer thường phản hồi trong vòng 1 ngày