Panic when attempting to generate CLI for YNAB's API
まだ誰も着手していません。
評価
- 難易度
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
danielgtaylor/openapi-cli-generator のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
danielgtaylor/openapi-cli-generator#45 · コメント 2 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
danielgtaylor/openapi-cli-generator#44 · リアクション 3 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 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
-
Project submission:オープン
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
slavakurilyak/awesome-ai-agents#845 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
JakeChampion/lang#13132 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] deploy.restart_policy without condition drops the restart policy対応中かも @akshat-lakhera が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
docker/compose#14383 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信