forked from kubernetes/test-infra
-
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.
Fix embedded messages (kubernetes#280)
* Handle readonly and writeonly for all versions above draft-06 * protoc-gen-jsonschema: fix embedded messages with embedded messages All schemas in definitions and definitions from embedded messages will now be written on the root schema. * Fix naming of sub messages * Fix failing test
- Loading branch information
Showing
10 changed files
with
263 additions
and
41 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
apps/protoc-gen-jsonschema/examples/tests/embedded/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,46 @@ | ||
// 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.embedded.message.v1; | ||
|
||
import "google/api/annotations.proto"; | ||
|
||
option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/embedded/message/v1;message"; | ||
|
||
service Messaging { | ||
rpc UpdateMessage(Message) returns (Message) { | ||
option (google.api.http) = { | ||
post : "/v1/messages/{message_id}" | ||
body : "*" | ||
}; | ||
} | ||
} | ||
|
||
message Message { | ||
string message_id = 1; | ||
message Comment { | ||
string id = 1; | ||
string content = 2; | ||
message Reply { | ||
string id = 1; | ||
string comment_id = 2; | ||
string content = 3; | ||
} | ||
repeated Reply replies = 3; | ||
} | ||
repeated Comment comments = 2; | ||
} |
60 changes: 60 additions & 0 deletions
60
apps/protoc-gen-jsonschema/examples/tests/embedded/schemas_json/Message.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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"title": "Message", | ||
"$id": "http://example.com/schemas/Message.json", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"messageId": { | ||
"title": "messageId", | ||
"type": "string" | ||
}, | ||
"comments": { | ||
"title": "comments", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Message_Comment" | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"Message_Comment_Reply": { | ||
"title": "Reply", | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"title": "id", | ||
"type": "string" | ||
}, | ||
"commentId": { | ||
"title": "commentId", | ||
"type": "string" | ||
}, | ||
"content": { | ||
"title": "content", | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"Message_Comment": { | ||
"title": "Comment", | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"title": "id", | ||
"type": "string" | ||
}, | ||
"content": { | ||
"title": "content", | ||
"type": "string" | ||
}, | ||
"replies": { | ||
"title": "replies", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Message_Comment_Reply" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
apps/protoc-gen-jsonschema/examples/tests/embedded/schemas_proto/Message.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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"title": "Message", | ||
"$id": "http://example.com/schemas/Message.json", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"message_id": { | ||
"title": "message_id", | ||
"type": "string" | ||
}, | ||
"comments": { | ||
"title": "comments", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Message_Comment" | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"Message_Comment_Reply": { | ||
"title": "Reply", | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"title": "id", | ||
"type": "string" | ||
}, | ||
"comment_id": { | ||
"title": "comment_id", | ||
"type": "string" | ||
}, | ||
"content": { | ||
"title": "content", | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"Message_Comment": { | ||
"title": "Comment", | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"title": "id", | ||
"type": "string" | ||
}, | ||
"content": { | ||
"title": "content", | ||
"type": "string" | ||
}, | ||
"replies": { | ||
"title": "replies", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Message_Comment_Reply" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
apps/protoc-gen-jsonschema/examples/tests/embedded/testdata_json/Message.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"messageId": "123abc", | ||
"comments": [ | ||
{ | ||
"id": "abc123", | ||
"content": "first comment", | ||
"replies": [ | ||
{ | ||
"id": "xyz123", | ||
"commentId": "abc123", | ||
"content": "first reply to first comment" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "123abc", | ||
"content": "second comment", | ||
"replies": [ | ||
{ | ||
"id": "123xyz", | ||
"commentId": "123abc", | ||
"content": "first reply to second comment" | ||
} | ||
] | ||
} | ||
] | ||
} |
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.