diff --git a/Makefile b/Makefile index 5fe3c4850e0..c6a645e0ef7 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,9 @@ OUTPUT_DIR=_output RUNTIME_PROTO=runtime/internal/stream_chunk.proto RUNTIME_GO=$(RUNTIME_PROTO:.proto=.pb.go) +OPENAPIV2_PROTO=protoc-gen-swagger/options/openapiv2.proto protoc-gen-swagger/options/annotations.proto +OPENAPIV2_GO=$(OPENAPIV2_PROTO:.proto=.pb.go) + PKGMAP=Mgoogle/protobuf/descriptor.proto=$(GO_PLUGIN_PKG)/descriptor,Mexamples/sub/message.proto=$(PKG)/examples/sub ADDITIONAL_FLAGS= ifneq "$(GATEWAY_PLUGIN_FLAGS)" "" @@ -83,17 +86,20 @@ generate: $(RUNTIME_GO) .SUFFIXES: .go .proto -$(GO_PLUGIN): +$(GO_PLUGIN): go get $(GO_PLUGIN_PKG) go build -o $@ $(GO_PLUGIN_PKG) $(RUNTIME_GO): $(RUNTIME_PROTO) $(GO_PLUGIN) protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):. $(RUNTIME_PROTO) +$(OPENAPIV2_GO): $(OPENAPIV2_PROTO) $(GO_PLUGIN) + protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):$(GOPATH)/src $(OPENAPIV2_PROTO) + $(GATEWAY_PLUGIN): $(RUNTIME_GO) $(GATEWAY_PLUGIN_SRC) go build -o $@ $(GATEWAY_PLUGIN_PKG) -$(SWAGGER_PLUGIN): $(SWAGGER_PLUGIN_SRC) +$(SWAGGER_PLUGIN): $(SWAGGER_PLUGIN_SRC) $(OPENAPIV2_GO) go build -o $@ $(SWAGGER_PLUGIN_PKG) $(EXAMPLE_SVCSRCS): $(GO_PLUGIN) $(EXAMPLES) @@ -143,5 +149,6 @@ realclean: distclean rm -f $(GO_PLUGIN) rm -f $(SWAGGER_PLUGIN) rm -f $(EXAMPLE_CLIENT_SRCS) + rm -f $(OPENAPIV2_GO) .PHONY: generate examples test lint clean distclean realclean diff --git a/examples/clients/abe/a_bit_of_everything_nested.go b/examples/clients/abe/a_bit_of_everything_nested.go index 909f478b7dc..095e8c5f118 100644 --- a/examples/clients/abe/a_bit_of_everything_nested.go +++ b/examples/clients/abe/a_bit_of_everything_nested.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/a_bit_of_everything_service_api.go b/examples/clients/abe/a_bit_of_everything_service_api.go index 669a12aed76..d66b34f54b2 100644 --- a/examples/clients/abe/a_bit_of_everything_service_api.go +++ b/examples/clients/abe/a_bit_of_everything_service_api.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ @@ -91,7 +91,7 @@ func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -101,6 +101,7 @@ func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -150,7 +151,7 @@ func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) ( } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -160,6 +161,7 @@ func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) ( // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -213,7 +215,7 @@ func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body E } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -223,6 +225,7 @@ func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body E // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -275,7 +278,7 @@ func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIRes } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -285,6 +288,7 @@ func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIRes // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -311,7 +315,8 @@ func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIRes } /** - * + * Echo allows posting a StringMessage value. + * It also exposes multiple bindings. This makes it useful when validating that the OpenAPI v2 API description exposes documentation correctly on all paths defined as additional_bindings in the proto. * * @param value * @return *SubStringMessage @@ -335,7 +340,7 @@ func (a ABitOfEverythingServiceApi) Echo(value string) (*SubStringMessage, *APIR } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -345,6 +350,7 @@ func (a ABitOfEverythingServiceApi) Echo(value string) (*SubStringMessage, *APIR // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -371,14 +377,15 @@ func (a ABitOfEverythingServiceApi) Echo(value string) (*SubStringMessage, *APIR } /** - * + * Echo allows posting a StringMessage value. + * It also exposes multiple bindings. This makes it useful when validating that the OpenAPI v2 API description exposes documentation correctly on all paths defined as additional_bindings in the proto. * - * @param value + * @param body * @return *SubStringMessage */ -func (a ABitOfEverythingServiceApi) Echo_1(value string) (*SubStringMessage, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Echo2(body string) (*SubStringMessage, *APIResponse, error) { - var localVarHttpMethod = strings.ToUpper("Get") + var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables localVarPath := a.Configuration.BasePath + "/v2/example/echo" @@ -392,10 +399,9 @@ func (a ABitOfEverythingServiceApi) Echo_1(value string) (*SubStringMessage, *AP for key := range a.Configuration.DefaultHeader { localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] } - localVarQueryParams.Add("value", a.Configuration.APIClient.ParameterToString(value, "")) // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -405,6 +411,7 @@ func (a ABitOfEverythingServiceApi) Echo_1(value string) (*SubStringMessage, *AP // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -412,12 +419,14 @@ func (a ABitOfEverythingServiceApi) Echo_1(value string) (*SubStringMessage, *AP if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } + // body params + localVarPostBody = &body var successPayload = new(SubStringMessage) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo_0", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + var localVarAPIResponse = &APIResponse{Operation: "Echo2", Method: localVarHttpMethod, RequestURL: localVarURL.String()} if localVarHttpResponse != nil { localVarAPIResponse.Response = localVarHttpResponse.RawResponse localVarAPIResponse.Payload = localVarHttpResponse.Body() @@ -431,14 +440,15 @@ func (a ABitOfEverythingServiceApi) Echo_1(value string) (*SubStringMessage, *AP } /** - * + * Echo allows posting a StringMessage value. + * It also exposes multiple bindings. This makes it useful when validating that the OpenAPI v2 API description exposes documentation correctly on all paths defined as additional_bindings in the proto. * - * @param body + * @param value * @return *SubStringMessage */ -func (a ABitOfEverythingServiceApi) Echo_2(body string) (*SubStringMessage, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Echo3(value string) (*SubStringMessage, *APIResponse, error) { - var localVarHttpMethod = strings.ToUpper("Post") + var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables localVarPath := a.Configuration.BasePath + "/v2/example/echo" @@ -452,9 +462,10 @@ func (a ABitOfEverythingServiceApi) Echo_2(body string) (*SubStringMessage, *API for key := range a.Configuration.DefaultHeader { localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] } + localVarQueryParams.Add("value", a.Configuration.APIClient.ParameterToString(value, "")) // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -464,6 +475,7 @@ func (a ABitOfEverythingServiceApi) Echo_2(body string) (*SubStringMessage, *API // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -471,14 +483,12 @@ func (a ABitOfEverythingServiceApi) Echo_2(body string) (*SubStringMessage, *API if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - // body params - localVarPostBody = &body var successPayload = new(SubStringMessage) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo_1", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + var localVarAPIResponse = &APIResponse{Operation: "Echo3", Method: localVarHttpMethod, RequestURL: localVarURL.String()} if localVarHttpResponse != nil { localVarAPIResponse.Response = localVarHttpResponse.RawResponse localVarAPIResponse.Payload = localVarHttpResponse.Body() @@ -566,7 +576,7 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, singleNestedName strin // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -576,6 +586,7 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, singleNestedName strin // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -626,7 +637,7 @@ func (a ABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEveryth } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -636,6 +647,7 @@ func (a ABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEveryth // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -684,7 +696,7 @@ func (a ABitOfEverythingServiceApi) Timeout() (*ProtobufEmpty, *APIResponse, err } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -694,6 +706,7 @@ func (a ABitOfEverythingServiceApi) Timeout() (*ProtobufEmpty, *APIResponse, err // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -745,7 +758,7 @@ func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEver } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -755,6 +768,7 @@ func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEver // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header diff --git a/examples/clients/abe/api_client.go b/examples/clients/abe/api_client.go index 2825dd48e13..bf3e21a9fb1 100644 --- a/examples/clients/abe/api_client.go +++ b/examples/clients/abe/api_client.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/api_response.go b/examples/clients/abe/api_response.go index 8c14424b574..ee1315f513c 100644 --- a/examples/clients/abe/api_response.go +++ b/examples/clients/abe/api_response.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/configuration.go b/examples/clients/abe/configuration.go index 5cacaadcb9d..ccc319c34aa 100644 --- a/examples/clients/abe/configuration.go +++ b/examples/clients/abe/configuration.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/examplepb_a_bit_of_everything.go b/examples/clients/abe/examplepb_a_bit_of_everything.go index 338ac379878..d8775d9c863 100644 --- a/examples/clients/abe/examplepb_a_bit_of_everything.go +++ b/examples/clients/abe/examplepb_a_bit_of_everything.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/examplepb_numeric_enum.go b/examples/clients/abe/examplepb_numeric_enum.go index bfb776292b3..e953bbe34e8 100644 --- a/examples/clients/abe/examplepb_numeric_enum.go +++ b/examples/clients/abe/examplepb_numeric_enum.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/nested_deep_enum.go b/examples/clients/abe/nested_deep_enum.go index 50bf6235a29..e5fc17d50a4 100644 --- a/examples/clients/abe/nested_deep_enum.go +++ b/examples/clients/abe/nested_deep_enum.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/protobuf_empty.go b/examples/clients/abe/protobuf_empty.go index 0cf664849d2..97c7bf612b8 100644 --- a/examples/clients/abe/protobuf_empty.go +++ b/examples/clients/abe/protobuf_empty.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/sub_string_message.go b/examples/clients/abe/sub_string_message.go index 0331c7abb94..2a0874fc5fa 100644 --- a/examples/clients/abe/sub_string_message.go +++ b/examples/clients/abe/sub_string_message.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/echo/echo_service_api.go b/examples/clients/echo/echo_service_api.go index a37a837adb2..1f562327d3d 100644 --- a/examples/clients/echo/echo_service_api.go +++ b/examples/clients/echo/echo_service_api.go @@ -99,16 +99,20 @@ func (a EchoServiceApi) Echo(id string) (*ExamplepbSimpleMessage, *APIResponse, } /** - * EchoBody method receives a simple message and returns it. + * Echo method receives a simple message and returns it. + * The message posted as the id parameter will also be returned. * - * @param body + * @param id + * @param num * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) Echo2(id string, num string) (*ExamplepbSimpleMessage, *APIResponse, error) { - var localVarHttpMethod = strings.ToUpper("Post") + var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo_body" + localVarPath := a.Configuration.BasePath + "/v1/example/echo/{id}/{num}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + localVarPath = strings.Replace(localVarPath, "{"+"num"+"}", fmt.Sprintf("%v", num), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -139,14 +143,12 @@ func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleM if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - // body params - localVarPostBody = &body var successPayload = new(ExamplepbSimpleMessage) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "EchoBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + var localVarAPIResponse = &APIResponse{Operation: "Echo2", Method: localVarHttpMethod, RequestURL: localVarURL.String()} if localVarHttpResponse != nil { localVarAPIResponse.Response = localVarHttpResponse.RawResponse localVarAPIResponse.Payload = localVarHttpResponse.Body() @@ -160,20 +162,16 @@ func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleM } /** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. + * EchoBody method receives a simple message and returns it. * - * @param id - * @param num + * @param body * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) Echo_1(id string, num string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleMessage, *APIResponse, error) { - var localVarHttpMethod = strings.ToUpper("Get") + var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo/{id}/{num}" - localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) - localVarPath = strings.Replace(localVarPath, "{"+"num"+"}", fmt.Sprintf("%v", num), -1) + localVarPath := a.Configuration.BasePath + "/v1/example/echo_body" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -204,12 +202,14 @@ func (a EchoServiceApi) Echo_1(id string, num string) (*ExamplepbSimpleMessage, if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } + // body params + localVarPostBody = &body var successPayload = new(ExamplepbSimpleMessage) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo_0", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + var localVarAPIResponse = &APIResponse{Operation: "EchoBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()} if localVarHttpResponse != nil { localVarAPIResponse.Response = localVarHttpResponse.RawResponse localVarAPIResponse.Payload = localVarHttpResponse.Body() diff --git a/examples/examplepb/a_bit_of_everything.pb.go b/examples/examplepb/a_bit_of_everything.pb.go index 30afc97d2d6..2727fba7b07 100644 --- a/examples/examplepb/a_bit_of_everything.pb.go +++ b/examples/examplepb/a_bit_of_everything.pb.go @@ -12,6 +12,7 @@ import google_protobuf2 "github.com/golang/protobuf/ptypes/duration" import grpc_gateway_examples_sub "github.com/grpc-ecosystem/grpc-gateway/examples/sub" import sub2 "github.com/grpc-ecosystem/grpc-gateway/examples/sub2" import google_protobuf3 "github.com/golang/protobuf/ptypes/timestamp" +import _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" import ( context "golang.org/x/net/context" @@ -452,6 +453,13 @@ type ABitOfEverythingServiceClient interface { Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + // Echo allows posting a StringMessage value. + // + // It also exposes multiple bindings. + // + // This makes it useful when validating that the OpenAPI v2 API + // description exposes documentation correctly on all paths + // defined as additional_bindings in the proto. Echo(ctx context.Context, in *grpc_gateway_examples_sub.StringMessage, opts ...grpc.CallOption) (*grpc_gateway_examples_sub.StringMessage, error) DeepPathEcho(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) NoBindings(ctx context.Context, in *google_protobuf2.Duration, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) @@ -565,6 +573,13 @@ type ABitOfEverythingServiceServer interface { Update(context.Context, *ABitOfEverything) (*google_protobuf1.Empty, error) Delete(context.Context, *sub2.IdMessage) (*google_protobuf1.Empty, error) GetQuery(context.Context, *ABitOfEverything) (*google_protobuf1.Empty, error) + // Echo allows posting a StringMessage value. + // + // It also exposes multiple bindings. + // + // This makes it useful when validating that the OpenAPI v2 API + // description exposes documentation correctly on all paths + // defined as additional_bindings in the proto. Echo(context.Context, *grpc_gateway_examples_sub.StringMessage) (*grpc_gateway_examples_sub.StringMessage, error) DeepPathEcho(context.Context, *ABitOfEverything) (*ABitOfEverything, error) NoBindings(context.Context, *google_protobuf2.Duration) (*google_protobuf1.Empty, error) @@ -871,87 +886,105 @@ var _AnotherServiceWithNoBindings_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/examplepb/a_bit_of_everything.proto", fileDescriptor1) } var fileDescriptor1 = []byte{ - // 1297 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0xd8, 0x89, 0x13, 0x3f, 0xc7, 0x89, 0x33, 0x69, 0x53, 0xd7, 0x2d, 0x64, 0x71, 0x01, - 0xad, 0x42, 0xb5, 0xab, 0xba, 0x15, 0x6a, 0x23, 0x41, 0x95, 0x34, 0x86, 0x22, 0xda, 0xb4, 0xdd, - 0xfe, 0x41, 0x8a, 0x5a, 0xac, 0xb5, 0x3d, 0xb6, 0x57, 0xf1, 0xee, 0x2c, 0xbb, 0xb3, 0x26, 0x96, - 0x31, 0x07, 0x0e, 0x5c, 0x38, 0x72, 0xef, 0x05, 0x09, 0x71, 0xe1, 0xc8, 0x19, 0xbe, 0x03, 0x5f, - 0x81, 0x03, 0x1f, 0x03, 0xed, 0xcc, 0xec, 0x76, 0xd7, 0x89, 0xe5, 0x26, 0x45, 0xbd, 0xed, 0xcc, - 0x7b, 0xef, 0xf7, 0x7b, 0x7f, 0xe6, 0xbd, 0x99, 0x85, 0xab, 0xe4, 0xc8, 0xb4, 0xdd, 0x3e, 0xf1, - 0x75, 0xf9, 0xe1, 0x36, 0x75, 0xb3, 0xd1, 0xb4, 0x58, 0x83, 0x76, 0x1a, 0x64, 0x40, 0xbc, 0x21, - 0xeb, 0x59, 0x4e, 0x57, 0x73, 0x3d, 0xca, 0x28, 0xde, 0xec, 0x7a, 0x6e, 0x4b, 0xeb, 0x9a, 0x8c, - 0x7c, 0x6b, 0x0e, 0xb5, 0xc8, 0x54, 0x8b, 0x4d, 0x2b, 0x97, 0xbb, 0x94, 0x76, 0xfb, 0x44, 0x37, - 0x5d, 0x4b, 0x37, 0x1d, 0x87, 0x32, 0x93, 0x59, 0xd4, 0xf1, 0x85, 0x79, 0xe5, 0x92, 0x94, 0xf2, - 0x55, 0x33, 0xe8, 0xe8, 0xc4, 0x76, 0xd9, 0x50, 0x0a, 0xdf, 0x9d, 0x14, 0xb6, 0x03, 0x8f, 0x5b, - 0x4b, 0x79, 0x25, 0xf6, 0xd4, 0x0f, 0x9a, 0xba, 0x4d, 0x7c, 0xdf, 0xec, 0x92, 0x08, 0x38, 0x29, - 0xab, 0x4d, 0x08, 0x37, 0x27, 0x81, 0x99, 0x65, 0x13, 0x9f, 0x99, 0xb6, 0x2b, 0x14, 0xaa, 0x7f, - 0xad, 0x42, 0x69, 0x67, 0xd7, 0x62, 0x0f, 0x3a, 0xf5, 0x38, 0x60, 0xfc, 0x02, 0x8a, 0xbe, 0xe5, - 0x74, 0xfb, 0xa4, 0xe1, 0x10, 0x9f, 0x91, 0x76, 0xf9, 0xa2, 0x82, 0xd4, 0x42, 0xed, 0xa6, 0x36, - 0x23, 0x05, 0xda, 0x24, 0x92, 0xb6, 0xcf, 0xed, 0x8d, 0x65, 0x01, 0x27, 0x56, 0x18, 0xc3, 0x7c, - 0x10, 0x58, 0xed, 0x32, 0x52, 0x90, 0x9a, 0x37, 0xf8, 0x37, 0x7e, 0x08, 0x39, 0xc9, 0x95, 0x51, - 0xb2, 0x6f, 0xc4, 0x25, 0x71, 0xf0, 0x26, 0x14, 0x3a, 0x7d, 0x6a, 0xb2, 0xc6, 0xc0, 0xec, 0x07, - 0xa4, 0x9c, 0x55, 0x90, 0x9a, 0x31, 0x80, 0x6f, 0x3d, 0x0b, 0x77, 0xf0, 0x7b, 0xb0, 0xdc, 0xa6, - 0x41, 0xb3, 0x4f, 0xa4, 0xc6, 0xbc, 0x82, 0x54, 0x64, 0x14, 0xc4, 0x9e, 0x50, 0xd9, 0x84, 0x82, - 0xe5, 0xb0, 0x8f, 0x6f, 0x48, 0x8d, 0x05, 0x05, 0xa9, 0x59, 0x03, 0xf8, 0x56, 0x8c, 0x11, 0x24, - 0x35, 0x72, 0x0a, 0x52, 0xe7, 0x8d, 0x42, 0x90, 0x50, 0x11, 0x18, 0xd7, 0x6b, 0x52, 0x63, 0x51, - 0x41, 0xea, 0x02, 0xc7, 0xb8, 0x5e, 0x13, 0x0a, 0x57, 0xa0, 0xd8, 0xb1, 0x8e, 0x48, 0x3b, 0x06, - 0x59, 0x52, 0x90, 0x9a, 0x33, 0x96, 0xe5, 0x66, 0x5a, 0x29, 0xc6, 0xc9, 0x2b, 0x48, 0x5d, 0x94, - 0x4a, 0x11, 0xd2, 0x3b, 0x00, 0x4d, 0x4a, 0xfb, 0x52, 0x03, 0x14, 0xa4, 0x2e, 0x19, 0xf9, 0x70, - 0x27, 0x76, 0xd6, 0x67, 0x9e, 0xe5, 0x74, 0xa5, 0x42, 0x81, 0xe7, 0xbf, 0x20, 0xf6, 0x52, 0xf1, - 0xc4, 0x2c, 0x45, 0x05, 0xa9, 0x45, 0x11, 0x4f, 0x44, 0xf2, 0x25, 0x00, 0x71, 0x02, 0x5b, 0x2a, - 0xac, 0x28, 0x48, 0x5d, 0xa9, 0x5d, 0x9d, 0x59, 0xad, 0xfd, 0xc0, 0x26, 0x9e, 0xd5, 0xaa, 0x3b, - 0x81, 0x6d, 0xe4, 0x43, 0x7b, 0x01, 0xf6, 0x01, 0xac, 0xf8, 0xe9, 0xb8, 0x56, 0x15, 0xa4, 0xae, - 0x1a, 0x45, 0x3f, 0x15, 0x58, 0xac, 0x16, 0xe7, 0xa8, 0xa4, 0x20, 0xb5, 0x14, 0xa9, 0x25, 0xaa, - 0xe1, 0x27, 0xbd, 0x5f, 0x53, 0x90, 0xba, 0x66, 0x14, 0xfc, 0x84, 0xf7, 0x52, 0x25, 0xc6, 0xc1, - 0x0a, 0x52, 0xb1, 0x50, 0x89, 0x50, 0x6a, 0x70, 0xde, 0x23, 0x2e, 0x31, 0x19, 0x69, 0x37, 0x52, - 0xf9, 0x5a, 0x57, 0xb2, 0x6a, 0xde, 0x58, 0x8f, 0x84, 0x8f, 0x13, 0x79, 0xbb, 0x05, 0x05, 0xea, - 0x90, 0x70, 0x6c, 0x84, 0x5d, 0x5d, 0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x0b, 0x07, 0xf9, 0x38, 0xb3, 0xcd, - 0x1c, 0x17, 0x5f, 0xff, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xab, 0xe5, 0x92, 0x0d, 0xc9, 0x0f, 0x00, - 0x00, + // 1590 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcf, 0x6f, 0x1b, 0xc5, + 0x17, 0xcf, 0xd8, 0x89, 0x13, 0x8f, 0xf3, 0xc3, 0x99, 0xb4, 0xa9, 0xeb, 0xe6, 0xfb, 0xcd, 0xd4, + 0x2d, 0x68, 0x15, 0xe2, 0x5d, 0xe2, 0x56, 0xa8, 0xb5, 0x04, 0xc5, 0x49, 0xdc, 0x1f, 0xa2, 0x4d, + 0xdb, 0xed, 0x0f, 0xaa, 0xd0, 0x12, 0xad, 0xed, 0xb1, 0xbd, 0x8d, 0x77, 0x67, 0xd9, 0x9d, 0x4d, + 0x63, 0x19, 0x73, 0xe0, 0x80, 0xd4, 0x6b, 0xb8, 0x21, 0xd1, 0x0b, 0x12, 0x02, 0x09, 0x8e, 0x9c, + 0x38, 0x70, 0xe7, 0xca, 0x5f, 0x80, 0xc4, 0x1f, 0x82, 0x76, 0x66, 0x77, 0xb3, 0xb6, 0x63, 0xa5, + 0x4e, 0x51, 0x4f, 0xde, 0x99, 0xf9, 0xbc, 0xcf, 0xe7, 0xbd, 0x37, 0xf3, 0xde, 0x8c, 0xe1, 0x2a, + 0xd9, 0xd7, 0x0c, 0xab, 0x45, 0x1c, 0xc5, 0xff, 0xb0, 0x2a, 0x8a, 0xb6, 0x53, 0xd1, 0xd9, 0x0e, + 0xad, 0xef, 0x90, 0x3d, 0x62, 0xb7, 0x59, 0x53, 0x37, 0x1b, 0xb2, 0x65, 0x53, 0x46, 0xd1, 0x72, + 0xc3, 0xb6, 0xaa, 0x72, 0x43, 0x63, 0xe4, 0x85, 0xd6, 0x96, 0x03, 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0x54, 0xc8, 0xa7, 0x1e, 0x7b, 0x33, 0xe8, 0x3c, 0x9c, 0xae, 0x51, 0xb7, 0xd2, 0x22, 0x3e, + 0x62, 0x1c, 0x03, 0x09, 0xa8, 0x29, 0x31, 0x27, 0x20, 0xcb, 0x30, 0xa5, 0x9b, 0xec, 0x83, 0xcb, + 0x3e, 0x62, 0x02, 0x03, 0x29, 0xae, 0x42, 0x3e, 0x15, 0x72, 0xb8, 0x51, 0x44, 0x02, 0x03, 0x69, + 0x5c, 0x4d, 0xb9, 0x11, 0x88, 0xe0, 0xb8, 0x54, 0xf0, 0x11, 0x93, 0x18, 0x48, 0x13, 0x9c, 0xe3, + 0x52, 0x41, 0x00, 0x2e, 0xc0, 0x99, 0xba, 0xbe, 0x4f, 0x6a, 0x21, 0xc9, 0x14, 0x06, 0x52, 0x42, + 0x9d, 0xf6, 0x27, 0x7b, 0x41, 0x21, 0x4f, 0x12, 0x03, 0x69, 0xd2, 0x07, 0x05, 0x4c, 0xff, 0x83, + 0xb0, 0x42, 0x69, 0xcb, 0x47, 0x40, 0x0c, 0xa4, 0x29, 0x35, 0xe9, 0xcd, 0x84, 0xce, 0x3a, 0xcc, + 0xd6, 0xcd, 0x86, 0x0f, 0x48, 0xf1, 0xfc, 0xa7, 0xc4, 0x5c, 0x4f, 0x3c, 0xa1, 0xca, 0x0c, 0x06, + 0xd2, 0x8c, 0x88, 0x27, 0x10, 0xf9, 0x04, 0x42, 0x62, 0xba, 0x86, 0x0f, 0x98, 0xc5, 0x40, 0x9a, + 0x2d, 0xac, 0x1e, 0xbb, 0x5b, 0x5b, 0xae, 0x41, 0x6c, 0xbd, 0x5a, 0x36, 0x5d, 0x43, 0x4d, 0x7a, + 0xf6, 0x82, 0xec, 0x1d, 0x38, 0xeb, 0xf4, 0xc6, 0x35, 0x87, 0x81, 0x34, 0xa7, 0xce, 0x38, 0x3d, + 0x81, 0x85, 0xb0, 0x30, 0x47, 0x69, 0x0c, 0xa4, 0x74, 0x00, 0x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 0xb3, 0xf7, 0xe1, 0xf2, 0x51, 0x35, 0xe5, 0x6d, + 0x66, 0x70, 0x01, 0x8f, 0x78, 0xee, 0x0a, 0x9f, 0xc3, 0xa5, 0x92, 0x49, 0x59, 0x93, 0xd8, 0x3e, + 0xc3, 0xa7, 0x3a, 0x6b, 0x46, 0xd2, 0xfd, 0x51, 0x4f, 0xf2, 0x47, 0x4d, 0xde, 0xd8, 0xfa, 0xcf, + 0xb1, 0x83, 0xd2, 0x77, 0x31, 0xc4, 0xe0, 0x42, 0x09, 0xaf, 0xeb, 0xcc, 0x0b, 0x30, 0x72, 0x36, + 0x9e, 0xc0, 0x53, 0x0d, 0xf5, 0xde, 0x46, 0xfe, 0x86, 0xf0, 0x06, 0x5b, 0x36, 0x7d, 0x4e, 0xaa, + 0x6c, 0xd4, 0x28, 0xb2, 0x69, 0x93, 0x9a, 0xe4, 0x63, 0x7f, 0x77, 0x3c, 0x74, 0x21, 0xbe, 0x26, + 0xbf, 0xbf, 0x12, 0x07, 0xb1, 0xf1, 0x42, 0x5a, 0xb3, 0xac, 0x96, 0x5e, 0xe5, 0xa9, 0x54, 0x9e, + 0x3b, 0xd4, 0x2c, 0x2c, 0x46, 0x67, 0xf6, 0xf3, 0x75, 0x4a, 0xf3, 0x86, 0x6e, 0x90, 0xe2, 0x00, + 0xb2, 0x38, 0x04, 0x69, 0xdf, 0x82, 0x67, 0xee, 0x1c, 0xe6, 0x3f, 0x1a, 0xc2, 0xa8, 0xae, 0x6f, + 0x27, 0xc3, 0xd2, 0xa9, 0x24, 0x78, 0xf6, 0x2e, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x88, 0x7d, + 0xbe, 0x6f, 0xd5, 0x12, 0x00, 0x00, } diff --git a/examples/examplepb/a_bit_of_everything.proto b/examples/examplepb/a_bit_of_everything.proto index 91e561e06a8..6250bdd4381 100644 --- a/examples/examplepb/a_bit_of_everything.proto +++ b/examples/examplepb/a_bit_of_everything.proto @@ -8,10 +8,43 @@ import "google/protobuf/duration.proto"; import "examples/sub/message.proto"; import "examples/sub2/message.proto"; import "google/protobuf/timestamp.proto"; +import "protoc-gen-swagger/options/annotations.proto"; + +option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { + info: { + title: "A Bit of Everything"; + version: "1.0"; + contact: { + name: "gRPC-Gateway project"; + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + email: "none@example.com"; + }; + }; + // Overwriting host entry breaks tests, so this is not done here. + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "More about gRPC-Gateway"; + } + schemes: HTTP; + schemes: HTTPS; + schemes: WSS; + consumes: "application/json"; + consumes: "application/x-foo-mime"; + produces: "application/json"; + produces: "application/x-foo-mime"; +}; + // Intentionaly complicated message type to cover much features of Protobuf. // NEXT ID: 27 message ABitOfEverything { + option (grpc.gateway.protoc_gen_swagger.options.openapiv2_schema) = { + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about ABitOfEverything"; + } + }; + // Nested is nested type. message Nested { // name is nested field. @@ -72,7 +105,18 @@ enum NumericEnum { ONE = 1; } +// ABitOfEverything service is used to validate that APIs with complicated +// proto messages and URL templates are still processed correctly. service ABitOfEverythingService { + + option (grpc.gateway.protoc_gen_swagger.options.openapiv2_tag) = { + description: "ABitOfEverythingService description -- which should not be used in place of the documentation comment!" + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about EchoService"; + } + }; + rpc Create(ABitOfEverything) returns (ABitOfEverything) { // TODO add enum_value option (google.api.http) = { @@ -105,7 +149,21 @@ service ABitOfEverythingService { option (google.api.http) = { get: "/v1/example/a_bit_of_everything/query/{uuid}" }; + option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = { + deprecated: true // For testing purposes. + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about GetQuery"; + } + }; } + // Echo allows posting a StringMessage value. + // + // It also exposes multiple bindings. + // + // This makes it useful when validating that the OpenAPI v2 API + // description exposes documentation correctly on all paths + // defined as additional_bindings in the proto. rpc Echo(grpc.gateway.examples.sub.StringMessage) returns (grpc.gateway.examples.sub.StringMessage) { option (google.api.http) = { get: "/v1/example/a_bit_of_everything/echo/{value}" @@ -117,6 +175,12 @@ service ABitOfEverythingService { get: "/v2/example/echo" } }; + option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = { + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more Echo"; + } + }; } rpc DeepPathEcho(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = { diff --git a/examples/examplepb/a_bit_of_everything.swagger.json b/examples/examplepb/a_bit_of_everything.swagger.json index 052b256b505..c42cd34ed13 100644 --- a/examples/examplepb/a_bit_of_everything.swagger.json +++ b/examples/examplepb/a_bit_of_everything.swagger.json @@ -1,18 +1,26 @@ { "swagger": "2.0", "info": { - "title": "examples/examplepb/a_bit_of_everything.proto", - "version": "version not set" + "title": "A Bit of Everything", + "version": "1.0", + "contact": { + "name": "gRPC-Gateway project", + "url": "https://github.com/grpc-ecosystem/grpc-gateway", + "email": "none@example.com" + } }, "schemes": [ "http", - "https" + "https", + "wss" ], "consumes": [ - "application/json" + "application/json", + "application/x-foo-mime" ], "produces": [ - "application/json" + "application/json", + "application/x-foo-mime" ], "paths": { "/v1/example/a_bit_of_everything": { @@ -43,6 +51,8 @@ }, "/v1/example/a_bit_of_everything/echo/{value}": { "get": { + "summary": "Echo allows posting a StringMessage value.", + "description": "It also exposes multiple bindings.\n\nThis makes it useful when validating that the OpenAPI v2 API\ndescription exposes documentation correctly on all paths\ndefined as additional_bindings in the proto.", "operationId": "Echo", "responses": { "200": { @@ -62,7 +72,11 @@ ], "tags": [ "ABitOfEverythingService" - ] + ], + "externalDocs": { + "description": "Find out more Echo", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } } }, "/v1/example/a_bit_of_everything/query/{uuid}": { @@ -264,7 +278,12 @@ ], "tags": [ "ABitOfEverythingService" - ] + ], + "deprecated": true, + "externalDocs": { + "description": "Find out more about GetQuery", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } } }, "/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}": { @@ -498,7 +517,9 @@ }, "/v2/example/echo": { "get": { - "operationId": "Echo", + "summary": "Echo allows posting a StringMessage value.", + "description": "It also exposes multiple bindings.\n\nThis makes it useful when validating that the OpenAPI v2 API\ndescription exposes documentation correctly on all paths\ndefined as additional_bindings in the proto.", + "operationId": "Echo3", "responses": { "200": { "description": "", @@ -517,10 +538,16 @@ ], "tags": [ "ABitOfEverythingService" - ] + ], + "externalDocs": { + "description": "Find out more Echo", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } }, "post": { - "operationId": "Echo", + "summary": "Echo allows posting a StringMessage value.", + "description": "It also exposes multiple bindings.\n\nThis makes it useful when validating that the OpenAPI v2 API\ndescription exposes documentation correctly on all paths\ndefined as additional_bindings in the proto.", + "operationId": "Echo2", "responses": { "200": { "description": "", @@ -541,7 +568,11 @@ ], "tags": [ "ABitOfEverythingService" - ] + ], + "externalDocs": { + "description": "Find out more Echo", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } } }, "/v2/example/timeout": { @@ -707,7 +738,11 @@ "title": "repeated enum value. it is comma-separated in query" } }, - "title": "Intentionaly complicated message type to cover much features of Protobuf.\nNEXT ID: 27" + "title": "Intentionaly complicated message type to cover much features of Protobuf.\nNEXT ID: 27", + "externalDocs": { + "description": "Find out more about ABitOfEverything", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } }, "examplepbNumericEnum": { "type": "string", @@ -731,5 +766,9 @@ } } } + }, + "externalDocs": { + "description": "More about gRPC-Gateway", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } diff --git a/examples/examplepb/echo_service.swagger.json b/examples/examplepb/echo_service.swagger.json index c58fbc54cea..cf617932212 100644 --- a/examples/examplepb/echo_service.swagger.json +++ b/examples/examplepb/echo_service.swagger.json @@ -46,7 +46,7 @@ "get": { "summary": "Echo method receives a simple message and returns it.", "description": "The message posted as the id parameter will also be\nreturned.", - "operationId": "Echo", + "operationId": "Echo2", "responses": { "200": { "description": "", diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index a7ef682ea8b..5bd1c3f9328 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -11,8 +11,10 @@ import ( "strings" "sync" + "github.com/golang/protobuf/proto" pbdescriptor "github.com/golang/protobuf/protoc-gen-go/descriptor" "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor" + swagger_options "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" ) func listEnumNames(enum *descriptor.Enum) (names []string) { @@ -176,6 +178,25 @@ func renderMessagesAsDefinition(messages messageMap, d swaggerDefinitionsObject, if err := updateSwaggerDataFromComments(&schema, msgComments); err != nil { panic(err) } + opts, err := extractSchemaOptionFromMessageDescriptor(msg.DescriptorProto) + if err != nil { + panic(err) + } + if opts != nil { + if opts.ExternalDocs != nil { + if schema.ExternalDocs == nil { + schema.ExternalDocs = &swaggerExternalDocumentationObject{} + } + if opts.ExternalDocs.Description != "" { + schema.ExternalDocs.Description = opts.ExternalDocs.Description + } + if opts.ExternalDocs.Url != "" { + schema.ExternalDocs.URL = opts.ExternalDocs.Url + } + } + + // TODO(ivucica): add remaining fields of schema object + } for _, f := range msg.Fields { fieldValue := schemaOfField(f, reg) @@ -452,7 +473,7 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re // Correctness of svcIdx and methIdx depends on 'services' containing the services in the same order as the 'file.Service' array. for svcIdx, svc := range services { for methIdx, meth := range svc.Methods { - for _, b := range meth.Bindings { + for bIdx, b := range meth.Bindings { // Iterate over all the swagger parameters parameters := swaggerParametersObject{} for _, parameter := range b.PathParams { @@ -527,9 +548,8 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re desc += "(streaming responses)" } operationObject := &swaggerOperationObject{ - Tags: []string{svc.GetName()}, - OperationID: fmt.Sprintf("%s", meth.GetName()), - Parameters: parameters, + Tags: []string{svc.GetName()}, + Parameters: parameters, Responses: swaggerResponsesObject{ "200": swaggerResponseObject{ Description: desc, @@ -541,6 +561,12 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re }, }, } + if bIdx == 0 { + operationObject.OperationID = fmt.Sprintf("%s", meth.GetName()) + } else { + // OperationID must be unique in an OpenAPI v2 definition. + operationObject.OperationID = fmt.Sprintf("%s%d", meth.GetName(), bIdx+1) + } // Fill reference map with referenced request messages for _, param := range operationObject.Parameters { @@ -554,6 +580,28 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re panic(err) } + opts, err := extractOperationOptionFromMethodDescriptor(meth.MethodDescriptorProto) + if opts != nil { + if err != nil { + panic(err) + } + if opts.ExternalDocs != nil { + if operationObject.ExternalDocs == nil { + operationObject.ExternalDocs = &swaggerExternalDocumentationObject{} + } + if opts.ExternalDocs.Description != "" { + operationObject.ExternalDocs.Description = opts.ExternalDocs.Description + } + if opts.ExternalDocs.Url != "" { + operationObject.ExternalDocs.URL = opts.ExternalDocs.Url + } + } + // TODO(ivucica): this would be better supported by looking whether the method is deprecated in the proto file + operationObject.Deprecated = opts.Deprecated + + // TODO(ivucica): add remaining fields of operation object + } + switch b.HTTPMethod { case "DELETE": pathItemObject.Delete = operationObject @@ -620,6 +668,73 @@ func applyTemplate(p param) (string, error) { panic(err) } + // There may be additional options in the swagger option in the proto. + spb, err := extractSwaggerOptionFromFileDescriptor(p.FileDescriptorProto) + if err != nil { + panic(err) + } + if spb != nil { + if spb.Swagger != "" { + s.Swagger = spb.Swagger + } + if spb.Info != nil { + if spb.Info.Title != "" { + s.Info.Title = spb.Info.Title + } + if spb.Info.Version != "" { + s.Info.Version = spb.Info.Version + } + if spb.Info.Contact != nil { + if s.Info.Contact == nil { + s.Info.Contact = &swaggerContactObject{} + } + if spb.Info.Contact.Name != "" { + s.Info.Contact.Name = spb.Info.Contact.Name + } + if spb.Info.Contact.Url != "" { + s.Info.Contact.URL = spb.Info.Contact.Url + } + if spb.Info.Contact.Email != "" { + s.Info.Contact.Email = spb.Info.Contact.Email + } + } + } + if spb.Host != "" { + s.Host = spb.Host + } + if spb.BasePath != "" { + s.BasePath = spb.BasePath + } + if len(spb.Schemes) > 0 { + s.Schemes = make([]string, len(spb.Schemes)) + for i, scheme := range spb.Schemes { + s.Schemes[i] = strings.ToLower(scheme.String()) + } + } + if len(spb.Consumes) > 0 { + s.Consumes = make([]string, len(spb.Consumes)) + copy(s.Consumes, spb.Consumes) + } + if len(spb.Produces) > 0 { + s.Produces = make([]string, len(spb.Produces)) + copy(s.Produces, spb.Produces) + } + if spb.ExternalDocs != nil { + if s.ExternalDocs == nil { + s.ExternalDocs = &swaggerExternalDocumentationObject{} + } + if spb.ExternalDocs.Description != "" { + s.ExternalDocs.Description = spb.ExternalDocs.Description + } + if spb.ExternalDocs.Url != "" { + s.ExternalDocs.URL = spb.ExternalDocs.Url + } + } + + // Additional fields on the OpenAPI v2 spec's "Swagger" object + // should be added here, once supported in the proto. + } + // We now have rendered the entire swagger object. Write the bytes out to a // string so it can be written to disk. var w bytes.Buffer @@ -632,9 +747,9 @@ func applyTemplate(p param) (string, error) { // updateSwaggerDataFromComments updates a Swagger object based on a comment // from the proto file. // -// First paragraph of a comment is used for summary. Remaining paragraphs of a -// comment are used for description. If 'Summary' field is not present on the -// passed swaggerObject, the summary and description are joined by \n\n. +// First paragraph of a comment is used for summary. Remaining paragraphs of +// a comment are used for description. If 'Summary' field is not present on +// the passed swaggerObject, the summary and description are joined by \n\n. // // If there is a field named 'Info', its 'Summary' and 'Description' fields // will be updated instead. @@ -664,17 +779,15 @@ func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) er usingTitle = true } + paragraphs := strings.Split(comment, "\n\n") + // If there is a summary (or summary-equivalent), use the first // paragraph as summary, and the rest as description. if summaryValue.CanSet() { - paragraphs := strings.Split(comment, "\n\n") - summary := strings.TrimSpace(paragraphs[0]) description := strings.TrimSpace(strings.Join(paragraphs[1:], "\n\n")) - if !usingTitle || summary == "" || summary[len(summary)-1] != '.' { - if len(summary) > 0 { - summaryValue.Set(reflect.ValueOf(summary)) - } + if !usingTitle || (len(summary) > 0 && summary[len(summary)-1] != '.') { + summaryValue.Set(reflect.ValueOf(summary)) if len(description) > 0 { if !descriptionValue.CanSet() { return fmt.Errorf("Encountered object type with a summary, but no description") @@ -688,7 +801,7 @@ func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) er // There was no summary field on the swaggerObject. Try to apply the // whole comment into description. if descriptionValue.CanSet() { - descriptionValue.Set(reflect.ValueOf(comment)) + descriptionValue.Set(reflect.ValueOf(strings.Join(paragraphs, "\n\n"))) return nil } @@ -854,3 +967,63 @@ func protoPathIndex(descriptorType reflect.Type, what string) int32 { return int32(path) } + +// extractOperationOptionFromMethodDescriptor extracts the message of type +// swagger_options.Operation from a given proto method's descriptor. +func extractOperationOptionFromMethodDescriptor(meth *pbdescriptor.MethodDescriptorProto) (*swagger_options.Operation, error) { + if meth.Options == nil { + return nil, nil + } + if !proto.HasExtension(meth.Options, swagger_options.E_Openapiv2Operation) { + return nil, nil + } + ext, err := proto.GetExtension(meth.Options, swagger_options.E_Openapiv2Operation) + if err != nil { + return nil, err + } + opts, ok := ext.(*swagger_options.Operation) + if !ok { + return nil, fmt.Errorf("extension is %T; want an Operation", ext) + } + return opts, nil +} + +// extractSchemaOptionFromMessageDescriptor extracts the message of type +// swagger_options.Schema from a given proto message's descriptor. +func extractSchemaOptionFromMessageDescriptor(msg *pbdescriptor.DescriptorProto) (*swagger_options.Schema, error) { + if msg.Options == nil { + return nil, nil + } + if !proto.HasExtension(msg.Options, swagger_options.E_Openapiv2Schema) { + return nil, nil + } + ext, err := proto.GetExtension(msg.Options, swagger_options.E_Openapiv2Schema) + if err != nil { + return nil, err + } + opts, ok := ext.(*swagger_options.Schema) + if !ok { + return nil, fmt.Errorf("extension is %T; want a Schema", ext) + } + return opts, nil +} + +// extractSwaggerOptionFromFileDescriptor extracts the message of type +// swagger_options.Swagger from a given proto method's descriptor. +func extractSwaggerOptionFromFileDescriptor(file *pbdescriptor.FileDescriptorProto) (*swagger_options.Swagger, error) { + if file.Options == nil { + return nil, nil + } + if !proto.HasExtension(file.Options, swagger_options.E_Openapiv2Swagger) { + return nil, nil + } + ext, err := proto.GetExtension(file.Options, swagger_options.E_Openapiv2Swagger) + if err != nil { + return nil, err + } + opts, ok := ext.(*swagger_options.Swagger) + if !ok { + return nil, fmt.Errorf("extension is %T; want a Swagger object", ext) + } + return opts, nil +} diff --git a/protoc-gen-swagger/genswagger/types.go b/protoc-gen-swagger/genswagger/types.go index c328d1c60cc..7263e66b7e0 100644 --- a/protoc-gen-swagger/genswagger/types.go +++ b/protoc-gen-swagger/genswagger/types.go @@ -23,9 +23,8 @@ type swaggerInfoObject struct { TermsOfService string `json:"termsOfService,omitempty"` Version string `json:"version"` - Contact *swaggerContactObject `json:"contact,omitempty"` - License *swaggerLicenseObject `json:"license,omitempty"` - ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"` + Contact *swaggerContactObject `json:"contact,omitempty"` + License *swaggerLicenseObject `json:"license,omitempty"` } // http://swagger.io/specification/#contactObject @@ -49,15 +48,16 @@ type swaggerExternalDocumentationObject struct { // http://swagger.io/specification/#swaggerObject type swaggerObject struct { - Swagger string `json:"swagger"` - Info swaggerInfoObject `json:"info"` - Host string `json:"host,omitempty"` - BasePath string `json:"basePath,omitempty"` - Schemes []string `json:"schemes"` - Consumes []string `json:"consumes"` - Produces []string `json:"produces"` - Paths swaggerPathsObject `json:"paths"` - Definitions swaggerDefinitionsObject `json:"definitions"` + Swagger string `json:"swagger"` + Info swaggerInfoObject `json:"info"` + Host string `json:"host,omitempty"` + BasePath string `json:"basePath,omitempty"` + Schemes []string `json:"schemes"` + Consumes []string `json:"consumes"` + Produces []string `json:"produces"` + Paths swaggerPathsObject `json:"paths"` + Definitions swaggerDefinitionsObject `json:"definitions"` + ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"` } // http://swagger.io/specification/#pathsObject @@ -80,6 +80,7 @@ type swaggerOperationObject struct { Responses swaggerResponsesObject `json:"responses"` Parameters swaggerParametersObject `json:"parameters,omitempty"` Tags []string `json:"tags,omitempty"` + Deprecated bool `json:"deprecated,omitempty"` ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"` } @@ -170,6 +171,8 @@ type swaggerSchemaObject struct { Description string `json:"description,omitempty"` Title string `json:"title,omitempty"` + + ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"` } // http://swagger.io/specification/#referenceObject diff --git a/protoc-gen-swagger/options/annotations.pb.go b/protoc-gen-swagger/options/annotations.pb.go new file mode 100644 index 00000000000..7bc93b91c63 --- /dev/null +++ b/protoc-gen-swagger/options/annotations.pb.go @@ -0,0 +1,83 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: protoc-gen-swagger/options/annotations.proto + +package options + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import google_protobuf1 "github.com/golang/protobuf/protoc-gen-go/descriptor" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +var E_Openapiv2Swagger = &proto.ExtensionDesc{ + ExtendedType: (*google_protobuf1.FileOptions)(nil), + ExtensionType: (*Swagger)(nil), + Field: 1042, + Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger", + Tag: "bytes,1042,opt,name=openapiv2_swagger,json=openapiv2Swagger", + Filename: "protoc-gen-swagger/options/annotations.proto", +} + +var E_Openapiv2Operation = &proto.ExtensionDesc{ + ExtendedType: (*google_protobuf1.MethodOptions)(nil), + ExtensionType: (*Operation)(nil), + Field: 1042, + Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_operation", + Tag: "bytes,1042,opt,name=openapiv2_operation,json=openapiv2Operation", + Filename: "protoc-gen-swagger/options/annotations.proto", +} + +var E_Openapiv2Schema = &proto.ExtensionDesc{ + ExtendedType: (*google_protobuf1.MessageOptions)(nil), + ExtensionType: (*Schema)(nil), + Field: 1042, + Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_schema", + Tag: "bytes,1042,opt,name=openapiv2_schema,json=openapiv2Schema", + Filename: "protoc-gen-swagger/options/annotations.proto", +} + +var E_Openapiv2Tag = &proto.ExtensionDesc{ + ExtendedType: (*google_protobuf1.ServiceOptions)(nil), + ExtensionType: (*Tag)(nil), + Field: 1042, + Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_tag", + Tag: "bytes,1042,opt,name=openapiv2_tag,json=openapiv2Tag", + Filename: "protoc-gen-swagger/options/annotations.proto", +} + +func init() { + proto.RegisterExtension(E_Openapiv2Swagger) + proto.RegisterExtension(E_Openapiv2Operation) + proto.RegisterExtension(E_Openapiv2Schema) + proto.RegisterExtension(E_Openapiv2Tag) +} + +func init() { proto.RegisterFile("protoc-gen-swagger/options/annotations.proto", fileDescriptor1) } + +var fileDescriptor1 = []byte{ + // 311 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x4b, 0x03, 0x31, + 0x10, 0x85, 0xe9, 0x45, 0x64, 0x55, 0xac, 0xeb, 0x45, 0x8a, 0x68, 0x6f, 0x8a, 0xb4, 0x89, 0xd4, + 0xdb, 0xde, 0x54, 0xf0, 0x26, 0x85, 0x6d, 0x4f, 0x5e, 0x4a, 0x9a, 0x8e, 0xd3, 0x40, 0x9b, 0x09, + 0x49, 0xda, 0x52, 0xe8, 0xd1, 0x5f, 0xe0, 0x2f, 0x16, 0x93, 0xed, 0x56, 0xd6, 0x2a, 0x7b, 0xdb, + 0x99, 0x9d, 0xf7, 0xbe, 0xc7, 0x23, 0x49, 0xc7, 0x58, 0xf2, 0x24, 0xbb, 0x08, 0xba, 0xeb, 0x56, + 0x02, 0x11, 0x2c, 0x27, 0xe3, 0x15, 0x69, 0xc7, 0x85, 0xd6, 0xe4, 0x45, 0xf8, 0x66, 0xe1, 0x2c, + 0xbd, 0x41, 0x6b, 0x24, 0x43, 0xe1, 0x61, 0x25, 0xd6, 0x71, 0x27, 0x47, 0x08, 0x7a, 0x54, 0x48, + 0x59, 0x21, 0x6d, 0xdd, 0xfd, 0x63, 0x4b, 0x06, 0xb4, 0x30, 0x6a, 0xd9, 0x8b, 0x06, 0xad, 0x36, + 0x12, 0xe1, 0x0c, 0x78, 0x98, 0xc6, 0x8b, 0x77, 0x3e, 0x01, 0x27, 0xad, 0x32, 0x9e, 0x6c, 0xbc, + 0xc8, 0x36, 0xc9, 0x59, 0x29, 0xda, 0xa2, 0xd2, 0x4b, 0x16, 0x75, 0x6c, 0xab, 0x63, 0x2f, 0x6a, + 0x06, 0xfd, 0x08, 0xb9, 0xf8, 0x3c, 0x6c, 0x37, 0x6e, 0x8f, 0x7a, 0xf7, 0xac, 0x66, 0x62, 0x36, + 0x88, 0x73, 0xde, 0x2c, 0x49, 0xc5, 0x26, 0xfb, 0x68, 0x24, 0xe7, 0x3b, 0x3c, 0x19, 0xb0, 0xa1, + 0x93, 0xf4, 0xea, 0x57, 0x80, 0x57, 0xf0, 0x53, 0x9a, 0x54, 0x22, 0xf4, 0x6a, 0x47, 0xe8, 0x6f, + 0xad, 0xf3, 0xb4, 0xe4, 0x95, 0xbb, 0x6c, 0x93, 0x34, 0x7f, 0x94, 0x20, 0xa7, 0x30, 0x17, 0xe9, + 0xf5, 0x9e, 0x08, 0xce, 0x09, 0xac, 0xd6, 0xc0, 0xeb, 0xd7, 0x10, 0x8c, 0xf3, 0xd3, 0x5d, 0x0b, + 0x61, 0x91, 0xb9, 0xe4, 0x64, 0x47, 0xf7, 0x02, 0xf7, 0xa0, 0x07, 0x60, 0x97, 0x4a, 0x56, 0xd1, + 0x9d, 0xda, 0xe8, 0xa1, 0xc0, 0xfc, 0xb8, 0x84, 0x0c, 0x05, 0x3e, 0x3d, 0xbf, 0x3d, 0xa2, 0xf2, + 0xd3, 0xc5, 0x98, 0x49, 0x9a, 0xf3, 0x6f, 0x9f, 0x2e, 0x48, 0x72, 0x6b, 0xe7, 0xa1, 0x18, 0x0b, + 0x5b, 0xfe, 0xf7, 0x73, 0x1b, 0x1f, 0x84, 0x7f, 0x0f, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x80, + 0x7f, 0xc1, 0x6a, 0xea, 0x02, 0x00, 0x00, +} diff --git a/protoc-gen-swagger/options/annotations.proto b/protoc-gen-swagger/options/annotations.proto new file mode 100644 index 00000000000..8746192b7a8 --- /dev/null +++ b/protoc-gen-swagger/options/annotations.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +package grpc.gateway.protoc_gen_swagger.options; + +option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"; + +import "protoc-gen-swagger/options/openapiv2.proto"; +import "google/protobuf/descriptor.proto"; + +extend google.protobuf.FileOptions { + // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. + Swagger openapiv2_swagger = 1042; +} +extend google.protobuf.MethodOptions { + // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. + Operation openapiv2_operation = 1042; +} +extend google.protobuf.MessageOptions { + // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. + Schema openapiv2_schema = 1042; +} +extend google.protobuf.ServiceOptions { + // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. + Tag openapiv2_tag = 1042; +} diff --git a/protoc-gen-swagger/options/openapiv2.pb.go b/protoc-gen-swagger/options/openapiv2.pb.go new file mode 100644 index 00000000000..7564c52e500 --- /dev/null +++ b/protoc-gen-swagger/options/openapiv2.pb.go @@ -0,0 +1,739 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: protoc-gen-swagger/options/openapiv2.proto + +/* +Package options is a generated protocol buffer package. + +It is generated from these files: + protoc-gen-swagger/options/openapiv2.proto + protoc-gen-swagger/options/annotations.proto + +It has these top-level messages: + Swagger + Operation + Info + Contact + ExternalDocumentation + Schema + JSONSchema + Tag +*/ +package options + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import google_protobuf "github.com/golang/protobuf/ptypes/any" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type Swagger_SwaggerScheme int32 + +const ( + Swagger_UNKNOWN Swagger_SwaggerScheme = 0 + Swagger_HTTP Swagger_SwaggerScheme = 1 + Swagger_HTTPS Swagger_SwaggerScheme = 2 + Swagger_WS Swagger_SwaggerScheme = 3 + Swagger_WSS Swagger_SwaggerScheme = 4 +) + +var Swagger_SwaggerScheme_name = map[int32]string{ + 0: "UNKNOWN", + 1: "HTTP", + 2: "HTTPS", + 3: "WS", + 4: "WSS", +} +var Swagger_SwaggerScheme_value = map[string]int32{ + "UNKNOWN": 0, + "HTTP": 1, + "HTTPS": 2, + "WS": 3, + "WSS": 4, +} + +func (x Swagger_SwaggerScheme) String() string { + return proto.EnumName(Swagger_SwaggerScheme_name, int32(x)) +} +func (Swagger_SwaggerScheme) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 0} } + +type JSONSchema_JSONSchemaSimpleTypes int32 + +const ( + JSONSchema_UNKNOWN JSONSchema_JSONSchemaSimpleTypes = 0 + JSONSchema_ARRAY JSONSchema_JSONSchemaSimpleTypes = 1 + JSONSchema_BOOLEAN JSONSchema_JSONSchemaSimpleTypes = 2 + JSONSchema_INTEGER JSONSchema_JSONSchemaSimpleTypes = 3 + JSONSchema_NULL JSONSchema_JSONSchemaSimpleTypes = 4 + JSONSchema_NUMBER JSONSchema_JSONSchemaSimpleTypes = 5 + JSONSchema_OBJECT JSONSchema_JSONSchemaSimpleTypes = 6 + JSONSchema_STRING JSONSchema_JSONSchemaSimpleTypes = 7 +) + +var JSONSchema_JSONSchemaSimpleTypes_name = map[int32]string{ + 0: "UNKNOWN", + 1: "ARRAY", + 2: "BOOLEAN", + 3: "INTEGER", + 4: "NULL", + 5: "NUMBER", + 6: "OBJECT", + 7: "STRING", +} +var JSONSchema_JSONSchemaSimpleTypes_value = map[string]int32{ + "UNKNOWN": 0, + "ARRAY": 1, + "BOOLEAN": 2, + "INTEGER": 3, + "NULL": 4, + "NUMBER": 5, + "OBJECT": 6, + "STRING": 7, +} + +func (x JSONSchema_JSONSchemaSimpleTypes) String() string { + return proto.EnumName(JSONSchema_JSONSchemaSimpleTypes_name, int32(x)) +} +func (JSONSchema_JSONSchemaSimpleTypes) EnumDescriptor() ([]byte, []int) { + return fileDescriptor0, []int{6, 0} +} + +// `Swagger` is a representation of OpenAPI v2 specification's Swagger object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject +// +// TODO(ivucica): document fields +type Swagger struct { + Swagger string `protobuf:"bytes,1,opt,name=swagger" json:"swagger,omitempty"` + Info *Info `protobuf:"bytes,2,opt,name=info" json:"info,omitempty"` + Host string `protobuf:"bytes,3,opt,name=host" json:"host,omitempty"` + BasePath string `protobuf:"bytes,4,opt,name=base_path,json=basePath" json:"base_path,omitempty"` + Schemes []Swagger_SwaggerScheme `protobuf:"varint,5,rep,packed,name=schemes,enum=grpc.gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme" json:"schemes,omitempty"` + Consumes []string `protobuf:"bytes,6,rep,name=consumes" json:"consumes,omitempty"` + Produces []string `protobuf:"bytes,7,rep,name=produces" json:"produces,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,14,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` +} + +func (m *Swagger) Reset() { *m = Swagger{} } +func (m *Swagger) String() string { return proto.CompactTextString(m) } +func (*Swagger) ProtoMessage() {} +func (*Swagger) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *Swagger) GetSwagger() string { + if m != nil { + return m.Swagger + } + return "" +} + +func (m *Swagger) GetInfo() *Info { + if m != nil { + return m.Info + } + return nil +} + +func (m *Swagger) GetHost() string { + if m != nil { + return m.Host + } + return "" +} + +func (m *Swagger) GetBasePath() string { + if m != nil { + return m.BasePath + } + return "" +} + +func (m *Swagger) GetSchemes() []Swagger_SwaggerScheme { + if m != nil { + return m.Schemes + } + return nil +} + +func (m *Swagger) GetConsumes() []string { + if m != nil { + return m.Consumes + } + return nil +} + +func (m *Swagger) GetProduces() []string { + if m != nil { + return m.Produces + } + return nil +} + +func (m *Swagger) GetExternalDocs() *ExternalDocumentation { + if m != nil { + return m.ExternalDocs + } + return nil +} + +// `Operation` is a representation of OpenAPI v2 specification's Operation object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject +// +// TODO(ivucica): document fields +type Operation struct { + Tags []string `protobuf:"bytes,1,rep,name=tags" json:"tags,omitempty"` + Summary string `protobuf:"bytes,2,opt,name=summary" json:"summary,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description" json:"description,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,4,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` + OperationId string `protobuf:"bytes,5,opt,name=operation_id,json=operationId" json:"operation_id,omitempty"` + Consumes []string `protobuf:"bytes,6,rep,name=consumes" json:"consumes,omitempty"` + Produces []string `protobuf:"bytes,7,rep,name=produces" json:"produces,omitempty"` + Schemes []string `protobuf:"bytes,10,rep,name=schemes" json:"schemes,omitempty"` + Deprecated bool `protobuf:"varint,11,opt,name=deprecated" json:"deprecated,omitempty"` +} + +func (m *Operation) Reset() { *m = Operation{} } +func (m *Operation) String() string { return proto.CompactTextString(m) } +func (*Operation) ProtoMessage() {} +func (*Operation) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *Operation) GetTags() []string { + if m != nil { + return m.Tags + } + return nil +} + +func (m *Operation) GetSummary() string { + if m != nil { + return m.Summary + } + return "" +} + +func (m *Operation) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *Operation) GetExternalDocs() *ExternalDocumentation { + if m != nil { + return m.ExternalDocs + } + return nil +} + +func (m *Operation) GetOperationId() string { + if m != nil { + return m.OperationId + } + return "" +} + +func (m *Operation) GetConsumes() []string { + if m != nil { + return m.Consumes + } + return nil +} + +func (m *Operation) GetProduces() []string { + if m != nil { + return m.Produces + } + return nil +} + +func (m *Operation) GetSchemes() []string { + if m != nil { + return m.Schemes + } + return nil +} + +func (m *Operation) GetDeprecated() bool { + if m != nil { + return m.Deprecated + } + return false +} + +// `Info` is a representation of OpenAPI v2 specification's Info object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject +// +// TODO(ivucica): document fields +type Info struct { + Title string `protobuf:"bytes,1,opt,name=title" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` + TermsOfService string `protobuf:"bytes,3,opt,name=terms_of_service,json=termsOfService" json:"terms_of_service,omitempty"` + Contact *Contact `protobuf:"bytes,4,opt,name=contact" json:"contact,omitempty"` + Version string `protobuf:"bytes,6,opt,name=version" json:"version,omitempty"` +} + +func (m *Info) Reset() { *m = Info{} } +func (m *Info) String() string { return proto.CompactTextString(m) } +func (*Info) ProtoMessage() {} +func (*Info) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } + +func (m *Info) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *Info) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *Info) GetTermsOfService() string { + if m != nil { + return m.TermsOfService + } + return "" +} + +func (m *Info) GetContact() *Contact { + if m != nil { + return m.Contact + } + return nil +} + +func (m *Info) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +// `Contact` is a representation of OpenAPI v2 specification's Contact object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject +// +// TODO(ivucica): document fields +type Contact struct { + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url" json:"url,omitempty"` + Email string `protobuf:"bytes,3,opt,name=email" json:"email,omitempty"` +} + +func (m *Contact) Reset() { *m = Contact{} } +func (m *Contact) String() string { return proto.CompactTextString(m) } +func (*Contact) ProtoMessage() {} +func (*Contact) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } + +func (m *Contact) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Contact) GetUrl() string { + if m != nil { + return m.Url + } + return "" +} + +func (m *Contact) GetEmail() string { + if m != nil { + return m.Email + } + return "" +} + +// `ExternalDocumentation` is a representation of OpenAPI v2 specification's +// ExternalDocumentation object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject +// +// TODO(ivucica): document fields +type ExternalDocumentation struct { + Description string `protobuf:"bytes,1,opt,name=description" json:"description,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url" json:"url,omitempty"` +} + +func (m *ExternalDocumentation) Reset() { *m = ExternalDocumentation{} } +func (m *ExternalDocumentation) String() string { return proto.CompactTextString(m) } +func (*ExternalDocumentation) ProtoMessage() {} +func (*ExternalDocumentation) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } + +func (m *ExternalDocumentation) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *ExternalDocumentation) GetUrl() string { + if m != nil { + return m.Url + } + return "" +} + +// `Schema` is a representation of OpenAPI v2 specification's Schema object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject +// +// TODO(ivucica): document fields +type Schema struct { + JsonSchema *JSONSchema `protobuf:"bytes,1,opt,name=json_schema,json=jsonSchema" json:"json_schema,omitempty"` + Discriminator string `protobuf:"bytes,2,opt,name=discriminator" json:"discriminator,omitempty"` + ReadOnly bool `protobuf:"varint,3,opt,name=read_only,json=readOnly" json:"read_only,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,5,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` + Example *google_protobuf.Any `protobuf:"bytes,6,opt,name=example" json:"example,omitempty"` +} + +func (m *Schema) Reset() { *m = Schema{} } +func (m *Schema) String() string { return proto.CompactTextString(m) } +func (*Schema) ProtoMessage() {} +func (*Schema) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } + +func (m *Schema) GetJsonSchema() *JSONSchema { + if m != nil { + return m.JsonSchema + } + return nil +} + +func (m *Schema) GetDiscriminator() string { + if m != nil { + return m.Discriminator + } + return "" +} + +func (m *Schema) GetReadOnly() bool { + if m != nil { + return m.ReadOnly + } + return false +} + +func (m *Schema) GetExternalDocs() *ExternalDocumentation { + if m != nil { + return m.ExternalDocs + } + return nil +} + +func (m *Schema) GetExample() *google_protobuf.Any { + if m != nil { + return m.Example + } + return nil +} + +// `JSONSchema` represents properties from JSON Schema taken, and as used, in +// the OpenAPI v2 spec. +// +// This includes changes made by OpenAPI v2. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject +// +// See also: https://cswr.github.io/JsonSchema/spec/basic_types/, +// https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json +// +// TODO(ivucica): document fields +type JSONSchema struct { + Title string `protobuf:"bytes,5,opt,name=title" json:"title,omitempty"` + Description string `protobuf:"bytes,6,opt,name=description" json:"description,omitempty"` + Default string `protobuf:"bytes,7,opt,name=default" json:"default,omitempty"` + MultipleOf float64 `protobuf:"fixed64,10,opt,name=multiple_of,json=multipleOf" json:"multiple_of,omitempty"` + Maximum float64 `protobuf:"fixed64,11,opt,name=maximum" json:"maximum,omitempty"` + ExclusiveMaximum bool `protobuf:"varint,12,opt,name=exclusive_maximum,json=exclusiveMaximum" json:"exclusive_maximum,omitempty"` + Minimum float64 `protobuf:"fixed64,13,opt,name=minimum" json:"minimum,omitempty"` + ExclusiveMinimum bool `protobuf:"varint,14,opt,name=exclusive_minimum,json=exclusiveMinimum" json:"exclusive_minimum,omitempty"` + MaxLength uint64 `protobuf:"varint,15,opt,name=max_length,json=maxLength" json:"max_length,omitempty"` + MinLength uint64 `protobuf:"varint,16,opt,name=min_length,json=minLength" json:"min_length,omitempty"` + Pattern string `protobuf:"bytes,17,opt,name=pattern" json:"pattern,omitempty"` + MaxItems uint64 `protobuf:"varint,20,opt,name=max_items,json=maxItems" json:"max_items,omitempty"` + MinItems uint64 `protobuf:"varint,21,opt,name=min_items,json=minItems" json:"min_items,omitempty"` + UniqueItems bool `protobuf:"varint,22,opt,name=unique_items,json=uniqueItems" json:"unique_items,omitempty"` + MaxProperties uint64 `protobuf:"varint,24,opt,name=max_properties,json=maxProperties" json:"max_properties,omitempty"` + MinProperties uint64 `protobuf:"varint,25,opt,name=min_properties,json=minProperties" json:"min_properties,omitempty"` + Required []string `protobuf:"bytes,26,rep,name=required" json:"required,omitempty"` + // Items in 'array' must be unique. + Array []string `protobuf:"bytes,34,rep,name=array" json:"array,omitempty"` + Type []JSONSchema_JSONSchemaSimpleTypes `protobuf:"varint,35,rep,packed,name=type,enum=grpc.gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes" json:"type,omitempty"` +} + +func (m *JSONSchema) Reset() { *m = JSONSchema{} } +func (m *JSONSchema) String() string { return proto.CompactTextString(m) } +func (*JSONSchema) ProtoMessage() {} +func (*JSONSchema) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } + +func (m *JSONSchema) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *JSONSchema) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *JSONSchema) GetDefault() string { + if m != nil { + return m.Default + } + return "" +} + +func (m *JSONSchema) GetMultipleOf() float64 { + if m != nil { + return m.MultipleOf + } + return 0 +} + +func (m *JSONSchema) GetMaximum() float64 { + if m != nil { + return m.Maximum + } + return 0 +} + +func (m *JSONSchema) GetExclusiveMaximum() bool { + if m != nil { + return m.ExclusiveMaximum + } + return false +} + +func (m *JSONSchema) GetMinimum() float64 { + if m != nil { + return m.Minimum + } + return 0 +} + +func (m *JSONSchema) GetExclusiveMinimum() bool { + if m != nil { + return m.ExclusiveMinimum + } + return false +} + +func (m *JSONSchema) GetMaxLength() uint64 { + if m != nil { + return m.MaxLength + } + return 0 +} + +func (m *JSONSchema) GetMinLength() uint64 { + if m != nil { + return m.MinLength + } + return 0 +} + +func (m *JSONSchema) GetPattern() string { + if m != nil { + return m.Pattern + } + return "" +} + +func (m *JSONSchema) GetMaxItems() uint64 { + if m != nil { + return m.MaxItems + } + return 0 +} + +func (m *JSONSchema) GetMinItems() uint64 { + if m != nil { + return m.MinItems + } + return 0 +} + +func (m *JSONSchema) GetUniqueItems() bool { + if m != nil { + return m.UniqueItems + } + return false +} + +func (m *JSONSchema) GetMaxProperties() uint64 { + if m != nil { + return m.MaxProperties + } + return 0 +} + +func (m *JSONSchema) GetMinProperties() uint64 { + if m != nil { + return m.MinProperties + } + return 0 +} + +func (m *JSONSchema) GetRequired() []string { + if m != nil { + return m.Required + } + return nil +} + +func (m *JSONSchema) GetArray() []string { + if m != nil { + return m.Array + } + return nil +} + +func (m *JSONSchema) GetType() []JSONSchema_JSONSchemaSimpleTypes { + if m != nil { + return m.Type + } + return nil +} + +// `Tag` is a representation of OpenAPI v2 specification's Tag object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject +// +// TODO(ivucica): document fields +type Tag struct { + // TODO(ivucica): Description should be extracted from comments on the proto + // service object. + Description string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,3,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` +} + +func (m *Tag) Reset() { *m = Tag{} } +func (m *Tag) String() string { return proto.CompactTextString(m) } +func (*Tag) ProtoMessage() {} +func (*Tag) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } + +func (m *Tag) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *Tag) GetExternalDocs() *ExternalDocumentation { + if m != nil { + return m.ExternalDocs + } + return nil +} + +func init() { + proto.RegisterType((*Swagger)(nil), "grpc.gateway.protoc_gen_swagger.options.Swagger") + proto.RegisterType((*Operation)(nil), "grpc.gateway.protoc_gen_swagger.options.Operation") + proto.RegisterType((*Info)(nil), "grpc.gateway.protoc_gen_swagger.options.Info") + proto.RegisterType((*Contact)(nil), "grpc.gateway.protoc_gen_swagger.options.Contact") + proto.RegisterType((*ExternalDocumentation)(nil), "grpc.gateway.protoc_gen_swagger.options.ExternalDocumentation") + proto.RegisterType((*Schema)(nil), "grpc.gateway.protoc_gen_swagger.options.Schema") + proto.RegisterType((*JSONSchema)(nil), "grpc.gateway.protoc_gen_swagger.options.JSONSchema") + proto.RegisterType((*Tag)(nil), "grpc.gateway.protoc_gen_swagger.options.Tag") + proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme", Swagger_SwaggerScheme_name, Swagger_SwaggerScheme_value) + proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes", JSONSchema_JSONSchemaSimpleTypes_name, JSONSchema_JSONSchemaSimpleTypes_value) +} + +func init() { proto.RegisterFile("protoc-gen-swagger/options/openapiv2.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 1175 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xed, 0x6e, 0xdb, 0x36, + 0x17, 0x7e, 0x65, 0xd3, 0x36, 0x7d, 0x6c, 0xe7, 0x65, 0xd5, 0x74, 0x63, 0xd3, 0x8f, 0xb9, 0x5e, + 0x87, 0x19, 0x2d, 0xe2, 0x0c, 0xe9, 0xff, 0x01, 0x49, 0x67, 0x74, 0x51, 0x53, 0xbb, 0x90, 0x5d, + 0x74, 0x1b, 0x30, 0x18, 0x8c, 0x4c, 0x3b, 0x1c, 0x24, 0x4a, 0x95, 0xa8, 0xd4, 0xbe, 0x8d, 0x5d, + 0xcf, 0x2e, 0x63, 0xf7, 0xb0, 0x3b, 0xd8, 0x8f, 0xfd, 0x1a, 0x48, 0x51, 0xf9, 0x72, 0x37, 0x04, + 0x45, 0xf7, 0xcb, 0x3c, 0xcf, 0x73, 0xce, 0x23, 0x9e, 0x0f, 0x92, 0x86, 0x27, 0x49, 0x1a, 0xab, + 0x38, 0xd8, 0x5d, 0x72, 0xb9, 0x9b, 0xbd, 0x67, 0xcb, 0x25, 0x4f, 0xf7, 0xe2, 0x44, 0x89, 0x58, + 0x66, 0x7b, 0x71, 0xc2, 0x25, 0x4b, 0xc4, 0xd9, 0xfe, 0xc0, 0x38, 0xb9, 0x5f, 0x2f, 0xd3, 0x24, + 0x18, 0x2c, 0x99, 0xe2, 0xef, 0xd9, 0xba, 0xc0, 0x82, 0xd9, 0x92, 0xcb, 0x99, 0x0d, 0x1c, 0xd8, + 0xc0, 0x9d, 0xbb, 0xcb, 0x38, 0x5e, 0x86, 0x7c, 0xcf, 0xb8, 0x9c, 0xe4, 0x8b, 0x3d, 0x26, 0xad, + 0x7f, 0xef, 0xcf, 0x2a, 0x34, 0x26, 0x85, 0xbb, 0x4b, 0xa1, 0x61, 0x23, 0xa9, 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b9, 0xef, 0x21, 0x7c, 0x9f, 0x3c, 0xf0, 0x10, 0x7e, 0x40, + 0x1e, 0x7a, 0x08, 0x3f, 0x24, 0x3d, 0x0f, 0xe1, 0xc7, 0xe4, 0x89, 0x87, 0xf0, 0x13, 0xf2, 0xd4, + 0x43, 0xf8, 0x29, 0x19, 0xf4, 0x7e, 0x75, 0xa0, 0x3a, 0x65, 0xcb, 0x1b, 0xbc, 0x07, 0x1b, 0x37, + 0x48, 0xf5, 0xd3, 0xdf, 0x20, 0x45, 0xba, 0x87, 0xcf, 0x7f, 0x3a, 0x58, 0x0a, 0x75, 0x9a, 0x9f, + 0x0c, 0x82, 0x38, 0xda, 0xd3, 0xfa, 0xbb, 0x3c, 0x88, 0xb3, 0x75, 0xa6, 0xb8, 0x35, 0xed, 0xe7, + 0xf6, 0xfe, 0xf9, 0x7f, 0xeb, 0x49, 0xdd, 0x70, 0xcf, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xf8, + 0x2b, 0xe7, 0x47, 0xdc, 0x0a, 0x00, 0x00, +} diff --git a/protoc-gen-swagger/options/openapiv2.proto b/protoc-gen-swagger/options/openapiv2.proto new file mode 100644 index 00000000000..6c1854613dd --- /dev/null +++ b/protoc-gen-swagger/options/openapiv2.proto @@ -0,0 +1,223 @@ +syntax = "proto3"; + +package grpc.gateway.protoc_gen_swagger.options; + +option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"; + +import "google/protobuf/any.proto"; + +// `Swagger` is a representation of OpenAPI v2 specification's Swagger object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject +// +// TODO(ivucica): document fields +message Swagger { + string swagger = 1; + Info info = 2; + string host = 3; + string base_path = 4; + enum SwaggerScheme { + UNKNOWN = 0; + HTTP = 1; + HTTPS = 2; + WS = 3; + WSS = 4; + } + repeated SwaggerScheme schemes = 5; + repeated string consumes = 6; + repeated string produces = 7; + // field 8 is reserved for 'paths'. + reserved 8; + // field 9 is reserved for 'definitions', which at this time are already + // exposed as and customizable as proto messages. + reserved 9; + // field 10 is reserved for 'responses'. + reserved 10; + // field 11 is reserved for 'securityDefinitions'. + reserved 11; + // field 12 is reserved for repeated 'security'. + reserved 12; + // field 13 is reserved for 'tags', which are supposed to be exposed as and + // customizable as proto services. TODO(ivucica): add processing of proto + // service objects into OpenAPI v2 Tag objects. + reserved 13; + ExternalDocumentation external_docs = 14; +} + +// `Operation` is a representation of OpenAPI v2 specification's Operation object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject +// +// TODO(ivucica): document fields +message Operation { + repeated string tags = 1; + string summary = 2; + string description = 3; + ExternalDocumentation external_docs = 4; + string operation_id = 5; + repeated string consumes = 6; + repeated string produces = 7; + // field 8 is reserved for 'parameters'. + reserved 8; + // field 9 is reserved for 'responses'. + reserved 9; + repeated string schemes = 10; + bool deprecated = 11; + // field 12 is reserved for 'security'. + reserved 12; + +} + +// `Info` is a representation of OpenAPI v2 specification's Info object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject +// +// TODO(ivucica): document fields +message Info { + string title = 1; + string description = 2; + string terms_of_service = 3; + Contact contact = 4; + // field 5 is reserved for 'license'. + reserved 5; + string version = 6; +} + +// `Contact` is a representation of OpenAPI v2 specification's Contact object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject +// +// TODO(ivucica): document fields +message Contact { + string name = 1; + string url = 2; + string email = 3; +} + +// `ExternalDocumentation` is a representation of OpenAPI v2 specification's +// ExternalDocumentation object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject +// +// TODO(ivucica): document fields +message ExternalDocumentation { + string description = 1; + string url = 2; +} + +// `Schema` is a representation of OpenAPI v2 specification's Schema object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject +// +// TODO(ivucica): document fields +message Schema { + JSONSchema json_schema = 1; + string discriminator = 2; + bool read_only = 3; + // field 4 is reserved for 'xml'. + reserved 4; + ExternalDocumentation external_docs = 5; + google.protobuf.Any example = 6; +} + +// `JSONSchema` represents properties from JSON Schema taken, and as used, in +// the OpenAPI v2 spec. +// +// This includes changes made by OpenAPI v2. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject +// +// See also: https://cswr.github.io/JsonSchema/spec/basic_types/, +// https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json +// +// TODO(ivucica): document fields +message JSONSchema { + // field 1 is reserved for '$id', omitted from OpenAPI v2. + reserved 1; + // field 2 is reserved for '$schema', omitted from OpenAPI v2. + reserved 2; + // field 3 is reserved for '$ref', although it is unclear how it would be used. + reserved 3; + // field 4 is reserved for '$comment', omitted from OpenAPI v2. + reserved 4; + string title = 5; + string description = 6; + string default = 7; + // field 8 is reserved for 'readOnly', which has an OpenAPI v2-specific meaning and is defined there. + reserved 8; + // field 9 is reserved for 'examples', which is omitted from OpenAPI v2 in favor of 'example' field. + reserved 9; + double multiple_of = 10; + double maximum = 11; + bool exclusive_maximum = 12; + double minimum = 13; + bool exclusive_minimum = 14; + uint64 max_length = 15; + uint64 min_length = 16; + string pattern = 17; + // field 18 is reserved for 'additionalItems', omitted from OpenAPI v2. + reserved 18; + // field 19 is reserved for 'items', but in OpenAPI-specific way. TODO(ivucica): add 'items'? + reserved 19; + uint64 max_items = 20; + uint64 min_items = 21; + bool unique_items = 22; + // field 23 is reserved for 'contains', omitted from OpenAPI v2. + reserved 23; + uint64 max_properties = 24; + uint64 min_properties = 25; + repeated string required = 26; + // field 27 is reserved for 'additionalProperties', but in OpenAPI-specific way. TODO(ivucica): add 'additionalProperties'? + reserved 27; + // field 28 is reserved for 'definitions', omitted from OpenAPI v2. + reserved 28; + // field 29 is reserved for 'properties', but in OpenAPI-specific way. TODO(ivucica): add 'additionalProperties'? + reserved 29; + // following fields are reserved, as the properties have been omitted from OpenAPI v2: + // patternProperties, dependencies, propertyNames, const + reserved 30 to 33; + // Items in 'array' must be unique. + repeated string array = 34; + + enum JSONSchemaSimpleTypes { + UNKNOWN = 0; + ARRAY = 1; + BOOLEAN = 2; + INTEGER = 3; + NULL = 4; + NUMBER = 5; + OBJECT = 6; + STRING = 7; + } + + repeated JSONSchemaSimpleTypes type = 35; + // following fields are reserved, as the properties have been omitted from OpenAPI v2: + // format, contentMediaType, contentEncoding, if, then, else + reserved 36 to 41; + // field 42 is reserved for 'allOf', but in OpenAPI-specific way. TODO(ivucica): add 'allOf'? + reserved 42; + // following fields are reserved, as the properties have been omitted from OpenAPI v2: + // anyOf, oneOf, not + reserved 43 to 45; +} + +// `Tag` is a representation of OpenAPI v2 specification's Tag object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject +// +// TODO(ivucica): document fields +message Tag { + // field 1 is reserved for 'name'. In our generator, this is (to be) extracted + // from the name of proto service, and thus not exposed to the user, as + // changing tag object's name would break the link to the references to the + // tag in individual operation specifications. + // + // TODO(ivucica): Add 'name' property. Use it to allow override of the name of + // global Tag object, then use that name to reference the tag throughout the + // Swagger file. + reserved 1; + // TODO(ivucica): Description should be extracted from comments on the proto + // service object. + string description = 2; + ExternalDocumentation external_docs = 3; +}