Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go API Client: Invalid Go package name, contains hyphens #3837

Open
Noah-Huppert opened this issue May 12, 2024 · 9 comments
Open

Go API Client: Invalid Go package name, contains hyphens #3837

Noah-Huppert opened this issue May 12, 2024 · 9 comments

Comments

@Noah-Huppert
Copy link

Noah-Huppert commented May 12, 2024

The auto-generated Go API client has the package embyclient-rest-go in every source file. This is not a valid Go package name. An alternative valid package name would be embyclient_rest_go or embyclient if we want to follow best practices for package naming

@LukePulverenti
Copy link
Member

@softworkz

@Noah-Huppert
Copy link
Author

Noah-Huppert commented May 22, 2024

I found a few other issues with the Golang API. It seems like there were some duplicate struct names as well. Here is the openapi-generator config I used to successfully create a compilable version of the Golang API:

generatorName: go
inputSpec: # <your emby openapi.json>
outputDir: ./embyclient/
packageName: embyclient

# Required for Golang imports to work
gitHost: github.com
gitUserId: # <your git username>
gitRepoId: # <your git repo>

validateSpec: False
modelNamePrefix: Model

# Go generator
isGoSubmodule: True
withGoMod: False
structPrefix: True
enumClassPrefix: True

I then had to run this find and replace on the output files due to a bug where the openapi-generator seems to add the modelNamePrefix twice when referring to model structs:

sed -i 's/ModelModel/Model/g' embyclient/*.go

@softworkz
Copy link
Contributor

I fixed the package name. Can you please check whether it's working now?

Publish.zip

@Noah-Huppert
Copy link
Author

I fixed the package name. Can you please check whether it's working now?

Publish.zip

Sure thing. I'll give it a test when I have a moment free.

@LukePulverenti
Copy link
Member

@Noah-Huppert ?

@Noah-Huppert
Copy link
Author

Noah-Huppert commented Jul 22, 2024 via email

@LukePulverenti
Copy link
Member

@Noah-Huppert ?

@Noah-Huppert
Copy link
Author

Noah-Huppert commented Nov 16, 2024

@Noah-Huppert ?

Thanks for the new Publish.zip and apologies for my delay. Here is the output of go run when I import the Publish.zip contents as a directory named embyclient.

embyclient/model_color_formats.go:98:2: syntax error: unexpected literal 0, expected name
embyclient/model_color_formats.go:100:4: binary literal has no digits
embyclient/model_video_media_types.go:33:2: syntax error: unexpected literal 012, expected name

All the errors are bc you can't have variable that starts with a number in go

@LukePulverenti
Copy link
Member

@softworkz

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

No branches or pull requests

3 participants