Panic when attempting to generate CLI for YNAB's API
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 25/100
调研方向
从使用 Dockerfile 复现以及运行 openapi-cli-generator generate ynab.openapi.yaml 命令开始。检查生成的 main.go 以及堆栈跟踪中提到的入口点 writeFormattedFile 和 generate,然后将生成的 Go 源代码与报告的解析器错误进行比较。当提供的 YNAB 规范能够成功生成,或以清晰且不会触发 panic 的错误失败时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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!
- 主要语言
- Go
- 星标
- 218
- 派生
- 53
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
danielgtaylor/openapi-cli-generator 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 35/100
danielgtaylor/openapi-cli-generator#45 · 2 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 45/100
danielgtaylor/openapi-cli-generator#44 · 3 个 reaction ·
-
难度 5/5 一周以上 新手友好度 25/100
-
难度 3/5 1-2 天 新手友好度 25/100
-
难度 3/5 1-2 天 新手友好度 35/100
danielgtaylor/openapi-cli-generator#41 · 1 条评论 ·
查看 danielgtaylor/openapi-cli-generator 的全部 Issue
相似的 Issue
-
cleanup hacktoberfest priority: low skill: good first issue testing
难度 2/5 1-3 小时 新手友好度 78/100
hyperledger-labs/fabric-smart-client#2197 ·
维护者通常 1 天内回复
-
New term request
难度 2/5 1-3 小时 新手友好度 62/100
geneontology/go-ontology#32791 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 69/100
aws/amazon-ecs-agent#5177 ·
维护者通常 2 天内回复
-
release-followup
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
kind/bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复