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

Add Go code generator plugin #23

Merged
merged 36 commits into from
Feb 2, 2017
Merged

Add Go code generator plugin #23

merged 36 commits into from
Feb 2, 2017

Conversation

timburks
Copy link
Contributor

@timburks timburks commented Jan 30, 2017

This set of commits adds a code generation plugin (written in Go) that generates Go code for API clients and servers for specified OpenAPI models. The plugin is not complete but intended as an illustration of a code generation plugin that could be built to work with openapic.

The plugins/go/openapi_go_generator/examples/bookstore contains an example and instructions for demonstrating the plugin.

This PR also includes a modification to openapic to pass plugin parameters as comma-separated key-value pairs.

The Client struct encapsulates the service address.
@timburks timburks requested a review from guptasu January 30, 2017 19:37
@timburks timburks self-assigned this Jan 30, 2017
@timburks
Copy link
Contributor Author

The unit test is failing because there's an extra blank line at the end of the plugin output. Investigating...

Copy link
Contributor

@guptasu guptasu left a comment

Choose a reason for hiding this comment

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

Overall looks great. Didn't get into the details of templates and service code, just looked at them briefly and they seem good. Reviewed the plugin and the option passing code. Have couple of minor comments there.

case 1:
outputLocation = invocationParts[0]
case 2:
parameters := strings.Split(invocationParts[0], ",")

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

switch len(invocationParts) {
case 1:
outputLocation = invocationParts[0]
case 2:

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -84,18 +96,29 @@ message PluginResponse {
// status code.
repeated string error = 1;

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -84,18 +96,29 @@ message PluginResponse {
// status code.
repeated string error = 1;

// text output
// text output, typically written to stdout by openapic.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

switch name {
case "integer":
if format == "int32" {
return "int32"

This comment was marked as spam.

This comment was marked as spam.

limitations under the License.
*/

package test

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

var writer io.Writer
if pluginCall.Output == "-" {
if outputLocation == "!" {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

writer = os.Stdout
} else if name == "=" {

This comment was marked as spam.

This comment was marked as spam.


// The plugin parameter passed on the command-line.
string parameter = 2;
// The plugin invocation string, usually specified as a command-line option to the OpenAPI compiler.

This comment was marked as spam.

This comment was marked as spam.

@guptasu
Copy link
Contributor

guptasu commented Feb 2, 2017

LGTM

@timburks timburks merged commit 72ada8f into google:master Feb 2, 2017
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.

None yet

2 participants