-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom options to allow more control of swagger/openapi output (#145
) Creates additional options that can be applied to RPCs and messages that provide additional information in the OpenAPIv2 spec. These new options allow for the inclusion of Swagger object information (maps to a .proto file): * `info` * `host` * `base_path` * `schemes` * `consumes` * `produces` * `external_docs` Service information: * `tags` * `summary` * `description` * `external_docs` * `operation_id` * `consumes` * `produces` * `schemes` Operation information (maps to a method): * `tags` * `summary` * `description` * `external_docs` * `operation_id` * `consumes` * `produces` * `schemes` Schema information (maps to a message): * `json_schema` * `descriptor` * `read_only` * `external_docs` * `example` Additionally: * Change from 'Swagger: ' to 'OpenAPI: ' prefix. It should also be relatively simple to add any field that is missing to the new OpenAPI proto objects.
- Loading branch information
Showing
22 changed files
with
1,612 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [email protected] | ||
* Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [email protected] | ||
* 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,19 +411,22 @@ 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 | ||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) | ||
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,21 +475,20 @@ 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 | ||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [email protected] | ||
* Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [email protected] | ||
* Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [email protected] | ||
* Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [email protected] | ||
* Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
*/ | ||
|
||
|
Oops, something went wrong.