Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ into objects which match the OpenAPI 3.0 definition. The code generator in this
directory does a lot of that for you. You would run it like so:

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


Let's go through that `petstore.gen.go` file to show you everything which was
generated.
Expand Down