-
Notifications
You must be signed in to change notification settings - Fork 6k
Support for Golang #325
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
Comments
Obviously, we can't reliably provide implementations for all existing languages since we're not proficient with everything out there. However, such contributions would be gladly accepted! |
Great! Do you have guidelines for such implementations? How hard is it to make one? I've checked the Python generation files, it seems like there is not so much code |
There's no code at all really, it's just mustache templates. I think the easiest way would be to look at the current implementations - https://github.com/swagger-api/swagger-codegen/tree/master/src/main/resources Keep in mind that most work that's done now is towards the next major version of the codegen, so it may be better to contribute to that branch - https://github.com/swagger-api/swagger-codegen/tree/develop_2.0/src/main/resources |
OK thanks |
No, thank you! It would be great to add support for additional languages. Feel free to ask any specific questions as you encounter them. |
I believe @casualjim has worked on this some already |
I might be willing to contribute support for Go, despite my distaste for Scala :P |
well, if you're working with the develop_2.0 branch, the codegen code is pure java. So you don't need to plug your nose :) |
Is any of this work yet available (even if untested)? I'm on a project where this would be useful, and I'm contemplating writing Golang support for Swagger. |
I suggest joining forces with @casualjim who is very far along with his project. |
I'd rather just implement a generator for the existing codegen, rather than write something from the ground up in Go. Unfortunately, I've run into a problem. I'm not sure if I the codegen model supports being able to generate idiomatic Go code. What I want is to have a Go package for each version of each API, and in that package will be the code for the models and the operations. I don't want separate modules for operations and models. Models and operations need to go into the same directory, and that directory needs to be based on the operation name. For example, if I have some operation "foo" then you'd expect to see all the code under "src/my/api/foo/v1", and you'd expect each .go source file in this directory to say "package foo" at the top. Does this make sense? Is there any way I can do this with the current codegen model? This is a good example of the structure I'm trying to mimmic: https://github.com/google/google-api-go-client |
Fork swagger-codegen, send me the URL and I'll send a pull request to help with the structure. |
There are a bunch of reasons why I didn't do it in this codegen package. And mostly it's very challenging for me to get full support for the swager spec in the java version of swagger codegen. At first i tried to keep it so I could at least reuse mustache templates but none of the go mustache packages I could find allows for self-referencing partial mustache templates. And it's something I needed because there are many validations etc that need to be respected. Again I tried many other ways to make mustache work, before moving on to the go template system. Now if you can make it work all the better but those are the reasons I didn't/couldn't. And then I thought it made sense to have one command that helps you in dealing with all kinds of things swagger. |
@casualjim, does your project currently do client generation? That's what I need at the moment. @fehguy, thanks, but this is part of a project at work, so that's not really an option. |
not at present. I have a couple of things left to fix with the server. if nobody else contributes to it then I should be able get to it in a week or so. |
I could help with the golang client, I forked and created a branch called |
@alfonsodev thanks for offering help for the Golang client. To start with, I would suggest you look at the work done by @casualjim as a reference. His latest PR (not merged) for another project (swagger-go) should be a good starting point - go-swagger/go-swagger#6. Let me know if you need any help or have any questions.. |
The client generation has been merged to master now. |
👍 Thanks @casualjim |
FYI. I submitted #1747 to add a Go API client generator. |
#1747 (A beta Go API client) has been merged into master. Please take a look and let us know if you've any feedback. The Go API client is not perfect and if you would like to contribute to make it better, please refer to the following list of tasks that are pending community contribution. |
Is it in the backlog?
The text was updated successfully, but these errors were encountered: