readme.md, fixed demo code - #861
Conversation
Demo generating code caused issues. Had been able to find 1 solution in a Japanese page. Maybe it will be more useful for beginners in this way.
|
|
||
| go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest | ||
| oapi-codegen petstore-expanded.yaml > petstore.gen.go | ||
| oapi-codegen petstore-expanded.yaml -package packagename -o petstore.gen.go |
There was a problem hiding this comment.
The original example runs fine for me, what error did you see?
There was a problem hiding this comment.
Error message: configuration error: package name must be specified
$ go version
go version go1.19.3 darwin/amd64
$ go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest
$ ls
specs.yaml
$ oapi-codegen specs.yaml
configuration error: package name must be specified
$ oapi-codegen -package packagename specs.yaml >/dev/null
$a minimal specs.yaml has been attached: specs.txt
let me know if you need any further info
There was a problem hiding this comment.
Thanks for the example, I had an older version and looks like the configuration changes introduced a regression so there's no default.
I've done a quick PR #873 which fixes this regression as well as improving it for named files, which is the common case. Would be great if you could test it.
There was a problem hiding this comment.
thanks.
Could you send me something about how to test it? (not sure how to install a package from a different branch/repo than the default one, havent done before)
There was a problem hiding this comment.
I noticed if you used openapi 3 right command will be:
oapi-codegen -package api -o api/name.go api/name.yaml
Otherwise I cathed: Only one OpenAPI 3.0 spec file is accepted and it must be the last CLI argument
Spent one hour for solved all problem:(
There was a problem hiding this comment.
Would be nice if it was updated to use cobra as that has very powerful validation, that is super simple to use.
There was a problem hiding this comment.
thanks. Could you send me something about how to test it? (not sure how to install a package from a different branch/repo than the default one, havent done before)
The following should be general gist:
git remote add stevenh https://github.com/stevenh/oapi-codegen.git
git fetch stevenh
git checkout fix/package-detect
go install ./cmd/oapi-codegen|
I think this bug is no longer relevant, as we've fixed some configuration regressions and moved to a new config file format. |
|
I think it is still relevant, as the example in the readme doesn't work. |
|
What error are you seeing @kkettinger want to make sure its the same thing. |
|
With the readme update (22d1cf4) the example now works for me. |
|
Ahh the reason for that is there hasn't been a release if you install with: It will work as expected. As soon as a new release has been cut "latest" will work again, no changes needed. |
Demo generating code caused issues. Had been able to find 1 solution in a Japanese page. Maybe it will be more useful for beginners in this way.