Skip to content
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

Incorrect field resolution in output openapi object #19

Open
80220 opened this issue Sep 9, 2022 · 2 comments
Open

Incorrect field resolution in output openapi object #19

80220 opened this issue Sep 9, 2022 · 2 comments

Comments

@80220
Copy link

80220 commented Sep 9, 2022

Hi Jenny,
I added this testcase in mine forked branch, that shows incorrect resolution of StaticRoute field:
master...80220:protobuf2swagger:patch/bad_resolution
Looking at Json Descriptor object (root) I can't find a way to resolve this import properly. Wonder if that is a problem in dependant lib (protobufjs) maybe it creates invalid tree out of proto files?

Adding logging to display the field, its type is StaticRoute and the root tree contains 2 definitions of it under different namespaces and the wrong one is resolved (not the one indicated by import in request.proto file)

image

My assumption is, that the type attribute of the field should be set to:
type: 'a.b.c.d.StaticRoute', (as per import statement)
instead of
type: 'StaticRoute',
that would assure proper resolution.
But if so then the problem is in protobuf.js that builds this json tree out of proto files.
Gimme your thoughts on this/thanks!

@80220
Copy link
Author

80220 commented Sep 12, 2022

@JennieJi
Copy link
Owner

Hi @80220 , I missed this message, sorry for the late reply.
From the test case you created,

It seems to me that when backend defines the protos, a/b/c/d/request.proto is for one set of APIs and a/b/common.proto is for another set, which means they are better not to be generated in one single Swagger JSON as they are probably running on two different servers and you have no idea what kind of conflicts they have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants