-
Notifications
You must be signed in to change notification settings - Fork 241
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
Conversation
…(incomplete) files.
The Client struct encapsulates the service address.
…ates the OpenAPI Go generator plugin.
The unit test is failing because there's an extra blank line at the end of the plugin output. Investigating... |
There was a problem hiding this 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
switch len(invocationParts) { | ||
case 1: | ||
outputLocation = invocationParts[0] | ||
case 2: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
plugins/plugin.proto
Outdated
@@ -84,18 +96,29 @@ message PluginResponse { | |||
// status code. | |||
repeated string error = 1; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
plugins/plugin.proto
Outdated
@@ -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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
switch name { | ||
case "integer": | ||
if format == "int32" { | ||
return "int32" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
limitations under the License. | ||
*/ | ||
|
||
package test |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
var writer io.Writer | ||
if pluginCall.Output == "-" { | ||
if outputLocation == "!" { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
writer = os.Stdout | ||
} else if name == "=" { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
plugins/plugin.proto
Outdated
|
||
// 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LGTM |
… App Engine and standalone use.
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.