Skip to content

Commit

Permalink
Implement openapi response headers annotations (grpc-ecosystem#1841)
Browse files Browse the repository at this point in the history
* Update v1 renovate config (grpc-ecosystem#1738)

Not even sure if renovate cares to check this branch
but it can't hurt.

* Update gorelease base for v1 (grpc-ecosystem#1748)

* feat: protoc-gen-swagger: Implement Response Header(s) object, Implement Field Enum,Example&Format attributes grpc-ecosystem#1729

* fix: resolve linting errors

* fix: running  per CI

* 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

* fix: Running go mode tidy to cleanup go.mod and go.sum

* fix: Resolving PR comments
* remove regex logic, and update functions to use simple booleans
* cleanup example proto
* enforce CanonicalMIMEHeaderKey for header name

* Update protoc-gen-swagger/genswagger/template.go

simplifying string check

Co-authored-by: Johan Brandhorst-Satzkorn <[email protected]>

* Update protoc-gen-swagger/genswagger/template.go

fix: remove string comparisons

Co-authored-by: Johan Brandhorst-Satzkorn <[email protected]>

* fix: resolving MR requests

* fix: unqouting error

* Update protoc-gen-swagger/genswagger/template.go

Co-authored-by: Johan Brandhorst-Satzkorn <[email protected]>

* Update protoc-gen-swagger/genswagger/template.go

Co-authored-by: Johan Brandhorst-Satzkorn <[email protected]>

* fix: adding requested changes
* parse unsigned ints with strconv.ParseUint
* update unqoute logic

* Updating integer switch

* Minor nits

* Remove extra newlines

* Pulling in changes for v2

Co-authored-by: Johan Brandhorst-Satzkorn <[email protected]>
  • Loading branch information
elijah-roberts and johanbrandhorst committed Nov 25, 2020
1 parent 757a7e0 commit 865774a
Show file tree
Hide file tree
Showing 15 changed files with 2,984 additions and 1,112 deletions.
2 changes: 2 additions & 0 deletions examples/internal/clients/abe/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ go_library(
"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_numeric_enum.go",
"model_examplepb_update_v2_request.go",
"model_message_path_enum_nested_path_enum.go",
Expand Down
129 changes: 129 additions & 0 deletions examples/internal/clients/abe/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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 @@ -97,6 +101,10 @@ paths:
description: "I'm a teapot."
schema:
$ref: "#/definitions/examplepbNumericEnum"
500:
description: "Server error"
schema:
$ref: "#/definitions/examplepbErrorResponse"
503:
description: "Returned when the resource is temporarily unavailable."
schema: {}
Expand Down Expand Up @@ -404,6 +412,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 @@ -711,6 +723,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 @@ -1005,6 +1021,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 @@ -1318,6 +1338,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 @@ -1475,6 +1499,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 @@ -1508,6 +1536,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 @@ -1545,6 +1577,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 @@ -1576,6 +1612,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 @@ -1772,6 +1812,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 @@ -1800,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 @@ -1840,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 @@ -1891,6 +1943,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 @@ -1936,6 +1992,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 @@ -1980,6 +2040,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 @@ -2019,6 +2083,10 @@ paths:
description: "I'm a teapot."
schema:
$ref: "#/definitions/examplepbNumericEnum"
500:
description: "Server error"
schema:
$ref: "#/definitions/examplepbErrorResponse"
503:
description: "Returned when the resource is temporarily unavailable."
schema: {}
Expand Down Expand Up @@ -2064,6 +2132,10 @@ paths:
description: "I'm a teapot."
schema:
$ref: "#/definitions/examplepbNumericEnum"
500:
description: "Server error"
schema:
$ref: "#/definitions/examplepbErrorResponse"
503:
description: "Returned when the resource is temporarily unavailable."
schema: {}
Expand Down Expand Up @@ -2098,6 +2170,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 @@ -2125,6 +2201,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 @@ -2155,6 +2235,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 @@ -2193,6 +2277,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 @@ -2220,6 +2308,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 @@ -2258,6 +2350,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 @@ -2293,6 +2389,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 @@ -2331,6 +2431,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 @@ -2665,6 +2769,31 @@ definitions:
- 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
Loading

0 comments on commit 865774a

Please sign in to comment.