-
Notifications
You must be signed in to change notification settings - Fork 251
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
Supporting duplicate models (different packages) in protoc-gen-openapi #309
Comments
I don't know if this is an option for you, but I also have a versioned API and I just generate seperately for v1 and v2. |
Thank you for the suggestion. We follow the same naming (package and directory) but in this case, the aim would be to have a monorepo for all service contracts creating a single library (per language) used in other services. As individual services can be versioned separately, there wouldn't be a clean way to generate a v2 of the whole thing. |
I ran into that issue as well and decided to rethink my architecture, based on what tools I had available. I know that is the not necessarily the most desirable way of doing thing. E.g. Envoy Proxy makes heavy use of component usage between versions, but they mostly need documentation for proto usage. I'm pretty sure it would be possible to get gnostic's protoc-gen-openapi to do something along the lines of what grpc-gateway does. |
@morphar We have also encountered this problem recently. It is normal to use the same message name in different packages, but Gnostic does not seem to support different packages using the same message name. Should we splice the package name before the message name, such as |
@shenqidebaozi I don't think I understand the problem. |
I have a setup where the same model name is used in different packages (or different versions of the same package). In my protos, these are in separate directories (/foo/v1/bar.proto and /foo/v2/bar.proto, both declaring Bar).
The openapi (v2) generator from grpc-gateway handles this by including the version or if needed full package name in the generated model types, whereas with gnostic, I get duplicate types and errors in later tooling using the openapi spec.
What I would ideally want is to get the same style output in JavaScript based on the openapi spec as I do with other tooling directly using the grpc/proto definitions, with models keeping their names but packaged up in directories matching the proto package / directory structure, though I'm not sure if there's a way of representing this in openapi.
Is there a way of either getting the gnostic protoc-gen-openapi tool to work with this sort of setup, or alternatively, best practices for grpc/proto that means that this would not be a problem?
The text was updated successfully, but these errors were encountered: