-
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
Fix #201: Exclude path params from body schemas. #1145
Fix #201: Exclude path params from body schemas. #1145
Conversation
When body is "*" and some request fields are captured by path parameters, exclude those fields from the request body Swagger schema. Define an inline request body schema with all the request fields NOT captured by path parameters. Also filter path parameters out of the required fields list for the body schema.
"$ref": "#/definitions/examplepbABitOfEverything" | ||
"type": "object", | ||
"example": { | ||
"uuid": "0cf361e1-4b44-483d-a159-54dabdf7e814" |
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.
This is a bit unfortunate - the example here is from the proto message definition, and that example has uuid in it. Arguably, the example should be updated since it's not really applicable to everywhere the message is used.
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.
That sounds right - could you update the example to include both the required values int64_value
and double_value
?
@@ -2201,7 +2380,7 @@ | |||
"in": "body", | |||
"required": true, | |||
"schema": { | |||
"$ref": "#/definitions/examplepbBody" | |||
"type": "object" |
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.
the only field in the request object is captured by a path parameter.
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.
Is there some way we could remove this "in": "body"
entry altogether?
@johanbrandhorst this is a first pass at fixing #201 , with the fix confirmed in the existing a_bit_of_everything example and in our application's generated documentation. |
// If we are excluding some fields, define a schema inline. | ||
schema = renderMessageAsSchema(meth.RequestType, reg, customRefs, bodyExcludedFields) |
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.
If we have no fields left here, we could skip this part?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hey Josh, sorry there hasn't been any activity on here, are you waiting on me? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hey, @johanbrandhorst what is currently blocking the accept of this pull request? |
We were happy to merge this but it seems the author disappeared. Would you be willing to contribute a fix for this? If so, could I ask that it be against the v2 branch only? |
@jgiles are you still planning on working on this or are you fine with me using your work as a starting point and finish it? |
When body is "*" and some request fields are captured by path
parameters, exclude those fields from the request body Swagger schema.
Define an inline request body schema with all the request fields NOT
captured by path parameters. Also filter path parameters out of the
required fields list for the body schema.