Skip to content

readme.md, fixed demo code - #861

Closed
lintaba wants to merge 1 commit into
oapi-codegen:masterfrom
lintaba:patch-1
Closed

readme.md, fixed demo code#861
lintaba wants to merge 1 commit into
oapi-codegen:masterfrom
lintaba:patch-1

Conversation

@lintaba

@lintaba lintaba commented Nov 17, 2022

Copy link
Copy Markdown

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.

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.
Comment thread README.md

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original example runs fine for me, what error did you see?

@lintaba lintaba Nov 23, 2022

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@stevenh stevenh Nov 25, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@Kejam Kejam Nov 25, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if it was updated to use cobra as that has very powerful validation, that is super simple to use.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ghost

ghost commented Jan 18, 2023

Copy link
Copy Markdown

I think this bug is no longer relevant, as we've fixed some configuration regressions and moved to a new config file format.

@ghost ghost closed this Jan 18, 2023
@kkettinger

Copy link
Copy Markdown

I think it is still relevant, as the example in the readme doesn't work.

@stevenh

stevenh commented May 5, 2023

Copy link
Copy Markdown
Contributor

What error are you seeing @kkettinger want to make sure its the same thing.

@kkettinger

Copy link
Copy Markdown

With the readme update (22d1cf4) the example now works for me.

@stevenh

stevenh commented May 5, 2023

Copy link
Copy Markdown
Contributor

Ahh the reason for that is there hasn't been a release if you install with:

go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@master

It will work as expected. As soon as a new release has been cut "latest" will work again, no changes needed.

go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants