Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/implement response headers v2 #1841

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Pulling in changes for v2
  • Loading branch information
elijah-roberts committed Nov 25, 2020
commit 05b3e74b8edc0af09d152c066c6b62657dd23780
2 changes: 1 addition & 1 deletion examples/internal/clients/abe/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ go_library(
"model_examplepb_a_bit_of_everything_repeated.go",
"model_examplepb_body.go",
"model_examplepb_book.go",
"model_examplepb_check_status_response.go",
"model_examplepb_error_object.go",
"model_examplepb_error_response.go",
"model_examplepb_check_status_response.go",
"model_examplepb_numeric_enum.go",
"model_examplepb_update_v2_request.go",
"model_message_path_enum_nested_path_enum.go",
Expand Down
92 changes: 47 additions & 45 deletions examples/internal/clients/abe/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1506,51 +1506,6 @@ paths:
default:
description: "An unexpected error response."
schema:
$ref: "#/definitions/runtimeError"
/v1/example/a_bit_of_everything/{single_nested.name}:
post:
tags:
- "ABitOfEverythingService"
operationId: "ABitOfEverythingService_DeepPathEcho"
parameters:
- name: "single_nested.name"
in: "path"
description: "name is nested field."
required: true
type: "string"
x-exportParamName: "SingleNestedName"
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/examplepbABitOfEverything"
x-exportParamName: "Body"
responses:
200:
description: "A successful response."
schema:
$ref: "#/definitions/examplepbABitOfEverything"
403:
description: "Returned when the user does not have permission to access\
\ the resource."
schema: {}
404:
description: "Returned when the resource does not exist."
schema:
type: "string"
format: "string"
418:
description: "I'm a teapot."
schema:
$ref: "#/definitions/examplepbNumericEnum"
500:
description: "Server error"
schema:
$ref: "#/definitions/examplepbErrorResponse"
default:
description: "An unexpected error response."
schema:
$ref: "#/definitions/runtimeError"
$ref: "#/definitions/rpcStatus"
/v1/example/a_bit_of_everything/{uuid}:
get:
Expand Down Expand Up @@ -1889,6 +1844,10 @@ paths:
description: "I'm a teapot."
schema:
$ref: "#/definitions/examplepbNumericEnum"
500:
description: "Server error"
schema:
$ref: "#/definitions/examplepbErrorResponse"
default:
description: "An unexpected error response."
schema:
Expand Down Expand Up @@ -1929,6 +1888,10 @@ paths:
description: "I'm a teapot."
schema:
$ref: "#/definitions/examplepbNumericEnum"
500:
description: "Server error"
schema:
$ref: "#/definitions/examplepbErrorResponse"
default:
description: "An unexpected error response."
schema:
Expand Down Expand Up @@ -2792,6 +2755,45 @@ definitions:
createTime: "2000-01-23T04:56:07.000+00:00"
name: "name"
id: "id"
examplepbCheckStatusResponse:
type: "object"
properties:
status:
$ref: "#/definitions/rpcStatus"
example:
status:
code: 0
details:
- typeUrl: "typeUrl"
value: "value"
- typeUrl: "typeUrl"
value: "value"
message: "message"
examplepbErrorObject:
type: "object"
properties:
code:
type: "integer"
format: "integer"
description: "Response code"
title: "code"
message:
type: "string"
description: "Response message"
title: "message"
pattern: "^[a-zA-Z0-9]{1, 32}$"
examplepbErrorResponse:
type: "object"
properties:
correlationId:
type: "string"
format: "uuid"
example: "2438ac3c-37eb-4902-adef-ed16b4431030"
description: "Unique event identifier for server requests"
title: "x-correlation-id"
pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$"
error:
$ref: "#/definitions/examplepbErrorObject"
examplepbNumericEnum:
type: "string"
description: "NumericEnum is one or zero.\n\n - ZERO: ZERO means 0\n - ONE: ONE\
Expand Down
11 changes: 11 additions & 0 deletions examples/internal/clients/abe/api_a_bit_of_everything_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,17 @@ func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceCheckStatus(c
return localVarReturnValue, localVarHttpResponse, newErr
}

if localVarHttpResponse.StatusCode == 500 {
var v ExamplepbErrorResponse
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}

if localVarHttpResponse.StatusCode == 0 {
var v RpcStatus
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
Expand Down
Loading