-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
protoc gen oas v2 cleanup #2996
protoc gen oas v2 cleanup #2996
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, most of these look great!
@@ -1227,18 +1225,18 @@ func renderServices(services []*descriptor.Service, paths openapiPathsObject, re | |||
return err | |||
} | |||
if schema.Title != "" { | |||
desc = mergeDescription(schema) | |||
desc.WriteString(mergeDescription(schema)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this actually incorrect? The old code overwrote desc
but this appends to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case desc with WriteString without allocate. If we use string - we have allocate in case like this s += "add text"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not saying I disagree with the use of WriteString, I'm just wondering if this is the equivalent logic, doesn't WriteString
append, where this logic before would replace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted this to source
@@ -2265,7 +2248,7 @@ var packageProtoPath = protoPathIndex(reflect.TypeOf((*descriptorpb.FileDescript | |||
var serviceProtoPath = protoPathIndex(reflect.TypeOf((*descriptorpb.FileDescriptorProto)(nil)), "Service") | |||
var methodProtoPath = protoPathIndex(reflect.TypeOf((*descriptorpb.ServiceDescriptorProto)(nil)), "Method") | |||
|
|||
func isProtoPathMatches(paths []int32, outerPaths []int32, typeName string, typeIndex int32, fieldPaths []int32) bool { | |||
func isProtoPathMatches(paths, outerPaths []int32, typeName string, typeIndex int32, fieldPaths []int32) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather we keep this as it is and make the parameters explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted this to source
@@ -2356,7 +2339,7 @@ func protoPathIndex(descriptorType reflect.Type, what string) int32 { | |||
} | |||
path, err := strconv.Atoi(strings.Split(pbtag, ",")[1]) | |||
if err != nil { | |||
panic(fmt.Errorf("protobuf descriptor id for %s cannot be converted to a number: %s", what, err.Error())) | |||
panic(fmt.Errorf("protobuf descriptor id for %s cannot be converted to a number: %v", what, err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also prefer the old style here. I avoid using %v
so that we can use the warnings go vet
produces when the wrong type is used with the wrong verb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%v for error is ok. And %s for error is ok too. But if error is nil verb %s text this %!s(), verb %s text this . But error is handling before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what you're saying, but yeah we don't need to worry about the error being nil
here so we should be able to keep using %s
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted this to source
6682c66
to
4792df0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for your contribution! |
) [](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/grpc-ecosystem/grpc-gateway/v2](https://togithub.com/grpc-ecosystem/grpc-gateway) | require | minor | `v2.13.0` -> `v2.14.0` | --- ### Release Notes <details> <summary>grpc-ecosystem/grpc-gateway</summary> ### [`v2.14.0`](https://togithub.com/grpc-ecosystem/grpc-gateway/releases/tag/v2.14.0) [Compare Source](https://togithub.com/grpc-ecosystem/grpc-gateway/compare/v2.13.0...v2.14.0) #### New features This release contains two significant new OpenAPIv2 generator features, contributed by [@​krak3n](https://togithub.com/krak3n): 1. A new option to [disable rendering of 200 OK responses](https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/customizing_openapi_output/#disable-default-responses). This is useful if you define custom responses for your endpoints and you modify the return code a forward response writer. Note that this does not change the behavior of the gateway itself. 2. A new annotation for [defining header parameters](https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/customizing_openapi_output/#custom-http-header-request-parameters). This lets to define header parameters you want to be rendered in the swagger.json output in addition to those defined in your API messages. Note that this does not change the behavior of the gateway itself and must be coupled with custom header parsing in your application. #### What's Changed - release: Update release.yml with option to workaround SLSA generator failure by [@​asraa](https://togithub.com/asraa) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/2987](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/2987) - release: add a workflow_dispatch trigger for testing by [@​asraa](https://togithub.com/asraa) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/2989](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/2989) - Use io/os instread of ioutil and use suitable verb by [@​sashamelentyev](https://togithub.com/sashamelentyev) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/2991](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/2991) - runtime pkg cleanup by [@​sashamelentyev](https://togithub.com/sashamelentyev) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/2993](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/2993) - mux: fix path components mutation by [@​jonathaningram](https://togithub.com/jonathaningram) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/3001](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/3001) - fix: set consumes definition per operation by [@​stomy13](https://togithub.com/stomy13) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/2995](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/2995) - protoc gen oas v2 cleanup by [@​sashamelentyev](https://togithub.com/sashamelentyev) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/2996](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/2996) - Use ReplaceAll instead of Replace with -1 pos by [@​sashamelentyev](https://togithub.com/sashamelentyev) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/3003](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/3003) - Errors cleanup by [@​sashamelentyev](https://togithub.com/sashamelentyev) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/3004](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/3004) - Cleanup by [@​sashamelentyev](https://togithub.com/sashamelentyev) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/3012](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/3012) - Support disabling default response rendering by [@​krak3n](https://togithub.com/krak3n) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/3006](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/3006) - Support request header parameters by [@​krak3n](https://togithub.com/krak3n) in [https://github.com/grpc-ecosystem/grpc-gateway/pull/3010](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/3010) #### New Contributors - [@​asraa](https://togithub.com/asraa) made their first contribution in [https://github.com/grpc-ecosystem/grpc-gateway/pull/2987](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/2987) - [@​sashamelentyev](https://togithub.com/sashamelentyev) made their first contribution in [https://github.com/grpc-ecosystem/grpc-gateway/pull/2991](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/2991) - [@​stomy13](https://togithub.com/stomy13) made their first contribution in [https://github.com/grpc-ecosystem/grpc-gateway/pull/2995](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/2995) - [@​krak3n](https://togithub.com/krak3n) made their first contribution in [https://github.com/grpc-ecosystem/grpc-gateway/pull/3006](https://togithub.com/grpc-ecosystem/grpc-gateway/pull/3006) **Full Changelog**: grpc-ecosystem/grpc-gateway@v2.13.0...v2.14.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 6am on monday" in timezone Australia/Sydney, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/google/osv.dev). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4zNy4wIiwidXBkYXRlZEluVmVyIjoiMzQuMzcuMCJ9-->
No description provided.