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
Next Next commit
fix: Resolve PR requests
* a bunch of whitespace/format changes... have since added this to my IDE
* remove any.Any objects, and convert them to string
* move runtime regex strings to global variables
* update examples
* update tests
  • Loading branch information
elijah-roberts committed Oct 14, 2020
commit dfa5c226f1419959dea7a5aeb8a8b30e354e8f94
1 change: 1 addition & 0 deletions examples/internal/clients/abe/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2685,6 +2685,7 @@ definitions:
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}$"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.20
2.4.8
217 changes: 101 additions & 116 deletions examples/internal/clients/generateunboundmethods/api/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,136 +1,121 @@
openapi: 3.0.1
---
swagger: "2.0"
info:
title: examples/internal/proto/examplepb/generate_unbound_methods.proto
description: |-
Generate Unannotated Methods Echo Service
Similar to echo_service.proto but without annotations and without external configuration.

Generate Unannotated Methods Echo Service API consists of a single service which returns
a message.
version: version not set
servers:
- url: /
description: "Generate Unannotated Methods Echo Service\nSimilar to echo_service.proto\
\ but without annotations and without external configuration.\n\nGenerate Unannotated\
\ Methods Echo Service API consists of a single service which returns\na message."
version: "version not set"
title: "examples/internal/proto/examplepb/generate_unbound_methods.proto"
consumes:
- "application/json"
produces:
- "application/json"
paths:
/grpc.gateway.examples.internal.examplepb.GenerateUnboundMethodsEchoService/Echo:
post:
tags:
- GenerateUnboundMethodsEchoService
summary: Echo method receives a simple message and returns it.
description: |-
The message posted as the id parameter will also be
returned.
operationId: GenerateUnboundMethodsEchoService_Echo
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/examplepbGenerateUnboundMethodsSimpleMessage'
- "GenerateUnboundMethodsEchoService"
summary: "Echo method receives a simple message and returns it."
description: "The message posted as the id parameter will also be\nreturned."
operationId: "GenerateUnboundMethodsEchoService_Echo"
parameters:
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage"
x-exportParamName: "Body"
responses:
"200":
description: A successful response.
content:
application/json:
schema:
$ref: '#/components/schemas/examplepbGenerateUnboundMethodsSimpleMessage'
200:
description: "A successful response."
schema:
$ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage"
default:
description: An unexpected error response.
content:
application/json:
schema:
$ref: '#/components/schemas/runtimeError'
x-codegen-request-body-name: body
description: "An unexpected error response."
schema:
$ref: "#/definitions/runtimeError"
/grpc.gateway.examples.internal.examplepb.GenerateUnboundMethodsEchoService/EchoBody:
post:
tags:
- GenerateUnboundMethodsEchoService
summary: EchoBody method receives a simple message and returns it.
operationId: GenerateUnboundMethodsEchoService_EchoBody
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/examplepbGenerateUnboundMethodsSimpleMessage'
- "GenerateUnboundMethodsEchoService"
summary: "EchoBody method receives a simple message and returns it."
operationId: "GenerateUnboundMethodsEchoService_EchoBody"
parameters:
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage"
x-exportParamName: "Body"
responses:
"200":
description: A successful response.
content:
application/json:
schema:
$ref: '#/components/schemas/examplepbGenerateUnboundMethodsSimpleMessage'
200:
description: "A successful response."
schema:
$ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage"
default:
description: An unexpected error response.
content:
application/json:
schema:
$ref: '#/components/schemas/runtimeError'
x-codegen-request-body-name: body
description: "An unexpected error response."
schema:
$ref: "#/definitions/runtimeError"
/grpc.gateway.examples.internal.examplepb.GenerateUnboundMethodsEchoService/EchoDelete:
post:
tags:
- GenerateUnboundMethodsEchoService
summary: EchoDelete method receives a simple message and returns it.
operationId: GenerateUnboundMethodsEchoService_EchoDelete
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/examplepbGenerateUnboundMethodsSimpleMessage'
- "GenerateUnboundMethodsEchoService"
summary: "EchoDelete method receives a simple message and returns it."
operationId: "GenerateUnboundMethodsEchoService_EchoDelete"
parameters:
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage"
x-exportParamName: "Body"
responses:
"200":
description: A successful response.
content:
application/json:
schema:
$ref: '#/components/schemas/examplepbGenerateUnboundMethodsSimpleMessage'
200:
description: "A successful response."
schema:
$ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage"
default:
description: An unexpected error response.
content:
application/json:
schema:
$ref: '#/components/schemas/runtimeError'
x-codegen-request-body-name: body
components:
schemas:
examplepbGenerateUnboundMethodsSimpleMessage:
type: object
properties:
id:
type: string
description: Id represents the message identifier.
num:
type: string
format: int64
duration:
type: string
description: GenerateUnboundMethodsSimpleMessage represents a simple message
sent to the unannotated GenerateUnboundMethodsEchoService service.
example:
duration: duration
num: num
id: id
protobufAny:
type: object
properties:
type_url:
type: string
value:
pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$
type: string
format: byte
runtimeError:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
$ref: '#/components/schemas/protobufAny'
description: "An unexpected error response."
schema:
$ref: "#/definitions/runtimeError"
definitions:
examplepbGenerateUnboundMethodsSimpleMessage:
type: "object"
properties:
id:
type: "string"
description: "Id represents the message identifier."
num:
type: "string"
format: "int64"
duration:
type: "string"
description: "GenerateUnboundMethodsSimpleMessage represents a simple message\
\ sent to the unannotated GenerateUnboundMethodsEchoService service."
example:
duration: "duration"
num: "num"
id: "id"
protobufAny:
type: "object"
properties:
type_url:
type: "string"
value:
type: "string"
format: "byte"
pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
runtimeError:
type: "object"
properties:
error:
type: "string"
code:
type: "integer"
format: "int32"
message:
type: "string"
details:
type: "array"
items:
$ref: "#/definitions/protobufAny"
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
* examples/internal/proto/examplepb/generate_unbound_methods.proto
*
Expand All @@ -7,6 +6,7 @@
* API version: version not set
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

package generateunboundmethods

import (
Expand All @@ -23,11 +23,13 @@ var (
)

type GenerateUnboundMethodsEchoServiceApiService service
/*

/*
GenerateUnboundMethodsEchoServiceApiService Echo method receives a simple message and returns it.
The message posted as the id parameter will also be returned.
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param body

@return ExamplepbGenerateUnboundMethodsSimpleMessage
*/
func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEchoServiceEcho(ctx context.Context, body ExamplepbGenerateUnboundMethodsSimpleMessage) (ExamplepbGenerateUnboundMethodsSimpleMessage, *http.Response, error) {
Expand Down Expand Up @@ -94,6 +96,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho
body: localVarBody,
error: localVarHttpResponse.Status,
}

if localVarHttpResponse.StatusCode == 200 {
var v ExamplepbGenerateUnboundMethodsSimpleMessage
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
Expand All @@ -104,6 +107,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}

if localVarHttpResponse.StatusCode == 0 {
var v RuntimeError
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
Expand All @@ -114,15 +118,18 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}

return localVarReturnValue, localVarHttpResponse, newErr
}

return localVarReturnValue, localVarHttpResponse, nil
}
/*

/*
GenerateUnboundMethodsEchoServiceApiService EchoBody method receives a simple message and returns it.
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param body

@return ExamplepbGenerateUnboundMethodsSimpleMessage
*/
func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEchoServiceEchoBody(ctx context.Context, body ExamplepbGenerateUnboundMethodsSimpleMessage) (ExamplepbGenerateUnboundMethodsSimpleMessage, *http.Response, error) {
Expand Down Expand Up @@ -189,6 +196,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho
body: localVarBody,
error: localVarHttpResponse.Status,
}

if localVarHttpResponse.StatusCode == 200 {
var v ExamplepbGenerateUnboundMethodsSimpleMessage
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
Expand All @@ -199,6 +207,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}

if localVarHttpResponse.StatusCode == 0 {
var v RuntimeError
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
Expand All @@ -209,15 +218,18 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}

return localVarReturnValue, localVarHttpResponse, newErr
}

return localVarReturnValue, localVarHttpResponse, nil
}
/*

/*
GenerateUnboundMethodsEchoServiceApiService EchoDelete method receives a simple message and returns it.
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param body

@return ExamplepbGenerateUnboundMethodsSimpleMessage
*/
func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEchoServiceEchoDelete(ctx context.Context, body ExamplepbGenerateUnboundMethodsSimpleMessage) (ExamplepbGenerateUnboundMethodsSimpleMessage, *http.Response, error) {
Expand Down Expand Up @@ -284,6 +296,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho
body: localVarBody,
error: localVarHttpResponse.Status,
}

if localVarHttpResponse.StatusCode == 200 {
var v ExamplepbGenerateUnboundMethodsSimpleMessage
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
Expand All @@ -294,6 +307,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}

if localVarHttpResponse.StatusCode == 0 {
var v RuntimeError
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
Expand All @@ -304,6 +318,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}

return localVarReturnValue, localVarHttpResponse, newErr
}

Expand Down
Loading