forked from sudorandom/protoc-gen-connect-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major Refactor! Migrate to pb33f/libopenapi (sudorandom#13)
* WIP: major refactor of library being used so we can maintain order * WIP: add wrapper types * WIP: Remove special-cases for empty rpc input/output * WIP: Update empty results * WIP: Support lots more gnostic annotations * WIP: add support for not_in for protovalidate * WIP: Small doc update * WIP: Fix all places where raw yaml is being used. Apparently you need to provide a kind * WIP: Update fixture data * fix: yaml literals weren't rendering when missing the tag 🤦 * chore: remove debug statement * chore: set schema type for not in * chore: update fixtures * chore: update fixtures * chore: don't use float yaml values since some readers won't like those * chore: add a couple test cases for google value * chore: cleanup
- Loading branch information
1 parent
07361b0
commit 449637e
Showing
62 changed files
with
17,969 additions
and
9,153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ install: | |
go install | ||
|
||
buf-generate: install | ||
buf generate | ||
buf generate --path internal/ |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: MyProject | ||
description: "My Project Description" | ||
version: v1.0.0 | ||
# 1) Define the security scheme type (HTTP bearer) | ||
components: | ||
securitySchemes: | ||
bearerAuth: # arbitrary name for the security scheme | ||
type: http | ||
scheme: bearer | ||
bearerFormat: JWT # optional, arbitrary value for documentation purposes | ||
# 2) Apply the security globally to all operations | ||
security: | ||
- bearerAuth: [] # use the same name as above |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ plugins: | |
opt: | ||
- base=auth-base.yaml | ||
- content-types=json | ||
- allow-get | ||
- debug | ||
# - format=json | ||
|
||
|
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,229 +1,163 @@ | ||
openapi: 3.1.0 | ||
info: | ||
contact: | ||
email: [email protected] | ||
name: Ein | ||
url: https://github.com/sudorandom/protoc-gen-connect-openapi | ||
description: This is a service which says hello to you! | ||
license: | ||
name: MIT License | ||
url: https://github.com/sudorandom/protoc-gen-connect-openapi/blob/master/LICENSE | ||
summary: "" | ||
termsOfService: "" | ||
title: Hello World | ||
version: v2 | ||
title: helloworld | ||
paths: | ||
/example.basic.Greeter/SayHello: | ||
/helloworld.Greeter/SayHello: | ||
get: | ||
description: This is a description just for OpenAPI | ||
tags: | ||
- helloworld.Greeter | ||
description: Sends a greeting | ||
parameters: | ||
- name: message | ||
in: query | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/helloworld.HelloRequest' | ||
application/proto: | ||
schema: | ||
$ref: '#/components/schemas/helloworld.HelloRequest' | ||
- schema: | ||
$ref: '#/components/parameters/encoding' | ||
- schema: | ||
$ref: '#/components/parameters/base64' | ||
- schema: | ||
$ref: '#/components/parameters/compression' | ||
- schema: | ||
$ref: '#/components/parameters/connect' | ||
responses: | ||
"200": | ||
$ref: '#/components/responses/example.basic.Greeter.SayHello.example.basic.HelloReply' | ||
default: | ||
$ref: '#/components/responses/connect.error' | ||
tags: | ||
- example.basic.Greeter | ||
parameters: | ||
- $ref: '#/components/parameters/example.basic.Greeter.SayHello.example.basic.HelloRequest' | ||
- $ref: '#/components/parameters/encoding' | ||
- $ref: '#/components/parameters/base64' | ||
- $ref: '#/components/parameters/compression' | ||
- $ref: '#/components/parameters/connect' | ||
/example.basic.Greeter/WriteHello: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/connect.error' | ||
"200": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/helloworld.HelloReply' | ||
/helloworld.Greeter/WriteHello: | ||
post: | ||
tags: | ||
- helloworld.Greeter | ||
description: Writes a greeting (has side effects) | ||
requestBody: | ||
$ref: '#/components/requestBodies/example.basic.Greeter.WriteHello.example.basic.HelloRequest' | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/helloworld.HelloRequest' | ||
required: true | ||
responses: | ||
"200": | ||
$ref: '#/components/responses/example.basic.Greeter.WriteHello.example.basic.HelloReply' | ||
default: | ||
$ref: '#/components/responses/connect.error' | ||
tags: | ||
- example.basic.Greeter | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/connect.error' | ||
"200": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/helloworld.HelloReply' | ||
components: | ||
parameters: | ||
schemas: | ||
helloworld.HelloReply: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
title: message | ||
additionalProperties: false | ||
title: HelloReply | ||
additionalProperties: false | ||
description: The response message containing the greetings | ||
helloworld.HelloRequest: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
title: name | ||
additionalProperties: false | ||
title: HelloRequest | ||
additionalProperties: false | ||
description: The request message containing the user's name. | ||
encoding: | ||
title: encoding | ||
description: Define which encoding or 'Message-Codec' to use | ||
base64: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/base64' | ||
application/proto: | ||
schema: | ||
$ref: '#/components/schemas/base64' | ||
in: query | ||
name: base64 | ||
type: boolean | ||
title: base64 | ||
description: Specifies if the message query param is base64 encoded, which may be required for binary data | ||
compression: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/compression' | ||
application/proto: | ||
schema: | ||
$ref: '#/components/schemas/compression' | ||
in: query | ||
name: compression | ||
title: compression | ||
description: Which compression algorithm to use for this request | ||
connect: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/connect' | ||
application/proto: | ||
schema: | ||
$ref: '#/components/schemas/connect' | ||
in: query | ||
name: connect | ||
title: connect | ||
description: Which version of connect to use. | ||
connect.error: | ||
type: object | ||
properties: | ||
code: | ||
type: string | ||
description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. | ||
message: | ||
type: string | ||
description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. | ||
detail: | ||
$ref: '#/components/schemas/google.protobuf.Any' | ||
title: Connect Error | ||
additionalProperties: true | ||
description: 'Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation' | ||
google.protobuf.Any: | ||
type: object | ||
properties: | ||
'@type': | ||
type: string | ||
additionalProperties: true | ||
additionalProperties: true | ||
description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. | ||
parameters: | ||
encoding: | ||
name: encoding | ||
in: query | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/encoding' | ||
application/proto: | ||
schema: | ||
$ref: '#/components/schemas/encoding' | ||
base64: | ||
name: base64 | ||
in: query | ||
name: encoding | ||
example.basic.Greeter.SayHello.example.basic.HelloRequest: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/example.basic.HelloRequest' | ||
$ref: '#/components/schemas/base64' | ||
application/proto: | ||
schema: | ||
$ref: '#/components/schemas/example.basic.HelloRequest' | ||
$ref: '#/components/schemas/base64' | ||
compression: | ||
name: compression | ||
in: query | ||
name: message | ||
requestBodies: | ||
example.basic.Greeter.WriteHello.example.basic.HelloRequest: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/example.basic.HelloRequest' | ||
application/proto: | ||
schema: | ||
$ref: '#/components/schemas/example.basic.HelloRequest' | ||
required: true | ||
responses: | ||
connect.error: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/connect.error' | ||
application/proto: | ||
schema: | ||
$ref: '#/components/schemas/connect.error' | ||
description: "" | ||
example.basic.Greeter.SayHello.example.basic.HelloReply: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/example.basic.HelloReply' | ||
$ref: '#/components/schemas/compression' | ||
application/proto: | ||
schema: | ||
$ref: '#/components/schemas/example.basic.HelloReply' | ||
description: "" | ||
example.basic.Greeter.WriteHello.example.basic.HelloReply: | ||
$ref: '#/components/schemas/compression' | ||
connect: | ||
name: connect | ||
in: query | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/example.basic.HelloReply' | ||
$ref: '#/components/schemas/connect' | ||
application/proto: | ||
schema: | ||
$ref: '#/components/schemas/example.basic.HelloReply' | ||
description: "" | ||
schemas: | ||
base64: | ||
description: Specifies if the message query param is base64 encoded, which may | ||
be required for binary data | ||
title: base64 | ||
type: boolean | ||
compression: | ||
description: Which compression algorithm to use for this request | ||
enum: | ||
- identity | ||
- gzip | ||
- br | ||
- zstd | ||
title: compression | ||
connect: | ||
description: Which version of connect to use. | ||
enum: | ||
- "1" | ||
title: connect | ||
connect.error: | ||
additionalProperties: false | ||
description: 'Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation' | ||
properties: | ||
code: | ||
description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. | ||
enum: | ||
- CodeCanceled | ||
- CodeUnknown | ||
- CodeInvalidArgument | ||
- CodeDeadlineExceeded | ||
- CodeNotFound | ||
- CodeAlreadyExists | ||
- CodePermissionDenied | ||
- CodeResourceExhausted | ||
- CodeFailedPrecondition | ||
- CodeAborted | ||
- CodeOutOfRange | ||
- CodeInternal | ||
- CodeUnavailable | ||
- CodeDataLoss | ||
- CodeUnauthenticated | ||
examples: | ||
- CodeNotFound | ||
type: string | ||
message: | ||
description: A developer-facing error message, which should be in English. | ||
Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] | ||
field, or localized by the client. | ||
type: string | ||
title: Connect Error | ||
type: object | ||
encoding: | ||
description: Define which encoding or 'Message-Codec' to use | ||
enum: | ||
- proto | ||
- json | ||
title: encoding | ||
example.basic.HelloReply: | ||
additionalProperties: false | ||
description: The response message containing the greetings | ||
properties: | ||
message: | ||
additionalProperties: false | ||
description: "" | ||
title: message | ||
type: string | ||
title: HelloReply | ||
type: object | ||
example.basic.HelloRequest: | ||
additionalProperties: false | ||
description: The request message containing the user's name. | ||
properties: | ||
helloCount: | ||
additionalProperties: false | ||
description: "" | ||
exclusiveMaximum: 42 | ||
title: hello_count | ||
type: integer | ||
name: | ||
additionalProperties: false | ||
description: "" | ||
examples: | ||
- - Ein | ||
maxLength: 100 | ||
minLength: 3 | ||
title: name | ||
type: string | ||
title: HelloRequest | ||
type: object | ||
securitySchemes: | ||
BasicAuth: | ||
scheme: basic | ||
type: http | ||
$ref: '#/components/schemas/connect' | ||
security: [] | ||
tags: | ||
- description: The greeting service definition. | ||
name: example.basic.Greeter | ||
- name: helloworld.Greeter | ||
description: The greeting service definition. | ||
externalDocs: {} |
Oops, something went wrong.