Skip to content

Commit

Permalink
Remove extensions from Schema
Browse files Browse the repository at this point in the history
As they are already included in JSONSchema
  • Loading branch information
james-o-johnstone committed Jan 4, 2022
1 parent 897db53 commit dd4b4be
Show file tree
Hide file tree
Showing 6 changed files with 804 additions and 834 deletions.
1,116 changes: 558 additions & 558 deletions examples/internal/proto/examplepb/a_bit_of_everything.pb.go

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions examples/internal/proto/examplepb/a_bit_of_everything.proto
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,18 @@ message ABitOfEverything {
title: "A bit of everything"
description: "Intentionaly complicated message type to cover many features of Protobuf."
required: ["uuid", "int64_value", "double_value"]
extensions: {
key: "x-a-bit-of-everything-foo";
value {
string_value: "bar";
}
}
}
external_docs: {
url: "https://github.com/grpc-ecosystem/grpc-gateway";
description: "Find out more about ABitOfEverything";
}
example: "{\"int64_value\": 12, \"double_value\": 12.3}"
extensions: {
key: "x-a-bit-of-everything-foo";
value {
string_value: "bar";
}
}
};

// Nested is nested type.
Expand Down
8 changes: 0 additions & 8 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2371,14 +2371,6 @@ func openapiSchemaFromProtoSchema(s *openapi_options.Schema, reg *descriptor.Reg
ret.Example = json.RawMessage(s.Example)
}

if s != nil && s.Extensions != nil {
exts, err := processExtensions(s.Extensions)
if err != nil {
panic(err)
}
ret.extensions = exts
}

return ret
}

Expand Down
6 changes: 4 additions & 2 deletions protoc-gen-openapiv2/internal/genopenapi/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1434,8 +1434,10 @@ func TestApplyTemplateExtensions(t *testing.T) {
},
}
openapiSchema := openapi_options.Schema{
Extensions: map[string]*structpb.Value{
"x-schema-foo": {Kind: &structpb.Value_StringValue{StringValue: "baz"}},
JsonSchema: &openapi_options.JSONSchema{
Extensions: map[string]*structpb.Value{
"x-schema-foo": {Kind: &structpb.Value_StringValue{StringValue: "baz"}},
},
},
}
verifyTemplateExtensions := func(t *testing.T, reg *descriptor.Registry, file *descriptor.File,
Expand Down
Loading

0 comments on commit dd4b4be

Please sign in to comment.