forked from google/gnostic
-
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.
add support for file/document and method/operation annotations. fixes g…
- Loading branch information
1 parent
15e2bfb
commit 73b03aa
Showing
11 changed files
with
524 additions
and
1 deletion.
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
87 changes: 87 additions & 0 deletions
87
cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/message.proto
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,87 @@ | ||
// Copyright 2021 Google LLC. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
syntax = "proto3"; | ||
|
||
package tests.mapfields.message.v1; | ||
|
||
import "google/api/annotations.proto"; | ||
import "openapiv3/annotations.proto"; | ||
|
||
option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/noannotations/message/v1;message"; | ||
|
||
option (openapi.v3.document) = { | ||
info: { | ||
title: "Title from annotation"; | ||
version: "Version from annotation"; | ||
description: "Description from annotation"; | ||
contact: { | ||
name: "Contact Name"; | ||
url: "https://github.com/google/gnostic"; | ||
email: "[email protected]"; | ||
} | ||
license: { | ||
name: "Apache License"; | ||
url: "https://github.com/google/gnostic/blob/master/LICENSE"; | ||
} | ||
} | ||
components: { | ||
security_schemes: { | ||
additional_properties: [ | ||
{ | ||
name: "BasicAuth"; | ||
value: { | ||
security_scheme: { | ||
type: "http"; | ||
scheme: "basic"; | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}; | ||
|
||
service Messaging1 { | ||
rpc UpdateMessage(Message) returns(Message) { | ||
option(google.api.http) = { | ||
patch: "/v1/messages/{message_id}" | ||
body: "*" | ||
}; | ||
option(openapi.v3.operation) = { | ||
security: [ | ||
{ | ||
additional_properties: [ | ||
{ | ||
name: "BasicAuth"; | ||
value: { | ||
value: [] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}; | ||
} | ||
} | ||
|
||
service Messaging2 { | ||
rpc UpdateMessage(Message) returns (Message) {} | ||
} | ||
|
||
message Message { | ||
int64 id = 1; | ||
string label = 2; | ||
} |
58 changes: 58 additions & 0 deletions
58
cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi.yaml
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,58 @@ | ||
# Generated with protoc-gen-openapi | ||
# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi | ||
|
||
openapi: 3.0.3 | ||
info: | ||
title: Title from annotation | ||
description: Description from annotation | ||
contact: | ||
name: Contact Name | ||
url: https://github.com/google/gnostic | ||
email: [email protected] | ||
license: | ||
name: Apache License | ||
url: https://github.com/google/gnostic/blob/master/LICENSE | ||
version: Version from annotation | ||
paths: | ||
/v1/messages/{message_id}: | ||
patch: | ||
tags: | ||
- Messaging1 | ||
operationId: Messaging1_UpdateMessage | ||
parameters: | ||
- name: message_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Message' | ||
required: true | ||
responses: | ||
"200": | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Message' | ||
security: | ||
- BasicAuth: [] | ||
components: | ||
schemas: | ||
Message: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
label: | ||
type: string | ||
securitySchemes: | ||
BasicAuth: | ||
type: http | ||
scheme: basic | ||
tags: | ||
- name: Messaging1 |
58 changes: 58 additions & 0 deletions
58
cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_fq_schema_naming.yaml
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,58 @@ | ||
# Generated with protoc-gen-openapi | ||
# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi | ||
|
||
openapi: 3.0.3 | ||
info: | ||
title: Title from annotation | ||
description: Description from annotation | ||
contact: | ||
name: Contact Name | ||
url: https://github.com/google/gnostic | ||
email: [email protected] | ||
license: | ||
name: Apache License | ||
url: https://github.com/google/gnostic/blob/master/LICENSE | ||
version: Version from annotation | ||
paths: | ||
/v1/messages/{message_id}: | ||
patch: | ||
tags: | ||
- Messaging1 | ||
operationId: Messaging1_UpdateMessage | ||
parameters: | ||
- name: message_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/tests.mapfields.message.v1.Message' | ||
required: true | ||
responses: | ||
"200": | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/tests.mapfields.message.v1.Message' | ||
security: | ||
- BasicAuth: [] | ||
components: | ||
schemas: | ||
tests.mapfields.message.v1.Message: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
label: | ||
type: string | ||
securitySchemes: | ||
BasicAuth: | ||
type: http | ||
scheme: basic | ||
tags: | ||
- name: Messaging1 |
58 changes: 58 additions & 0 deletions
58
cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_json.yaml
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,58 @@ | ||
# Generated with protoc-gen-openapi | ||
# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi | ||
|
||
openapi: 3.0.3 | ||
info: | ||
title: Title from annotation | ||
description: Description from annotation | ||
contact: | ||
name: Contact Name | ||
url: https://github.com/google/gnostic | ||
email: [email protected] | ||
license: | ||
name: Apache License | ||
url: https://github.com/google/gnostic/blob/master/LICENSE | ||
version: Version from annotation | ||
paths: | ||
/v1/messages/{message_id}: | ||
patch: | ||
tags: | ||
- Messaging1 | ||
operationId: Messaging1_UpdateMessage | ||
parameters: | ||
- name: message_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Message' | ||
required: true | ||
responses: | ||
"200": | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Message' | ||
security: | ||
- BasicAuth: [] | ||
components: | ||
schemas: | ||
Message: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
label: | ||
type: string | ||
securitySchemes: | ||
BasicAuth: | ||
type: http | ||
scheme: basic | ||
tags: | ||
- name: Messaging1 |
58 changes: 58 additions & 0 deletions
58
cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_string_enum.yaml
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,58 @@ | ||
# Generated with protoc-gen-openapi | ||
# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi | ||
|
||
openapi: 3.0.3 | ||
info: | ||
title: Title from annotation | ||
description: Description from annotation | ||
contact: | ||
name: Contact Name | ||
url: https://github.com/google/gnostic | ||
email: [email protected] | ||
license: | ||
name: Apache License | ||
url: https://github.com/google/gnostic/blob/master/LICENSE | ||
version: Version from annotation | ||
paths: | ||
/v1/messages/{message_id}: | ||
patch: | ||
tags: | ||
- Messaging1 | ||
operationId: Messaging1_UpdateMessage | ||
parameters: | ||
- name: message_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Message' | ||
required: true | ||
responses: | ||
"200": | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Message' | ||
security: | ||
- BasicAuth: [] | ||
components: | ||
schemas: | ||
Message: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
label: | ||
type: string | ||
securitySchemes: | ||
BasicAuth: | ||
type: http | ||
scheme: basic | ||
tags: | ||
- name: Messaging1 |
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
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
Oops, something went wrong.