-
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
Read only support #882
Read only support #882
Conversation
Looks like you need to rebase on master to start with. |
Note: these are normally simply documented as |
c1de7cc
to
5a7c48f
Compare
@johanbrandhorst PR updated with support for "Output only." comment on field. Added missing tests on updateSwaggerWithComment. |
The generate job is failing; did you run the generate job as described in CONTRIBUTING.md to regenerate the files? |
@@ -1223,6 +1224,12 @@ func updateSwaggerDataFromComments(swaggerObject interface{}, comment string, is | |||
// Figure out which properties to update. | |||
summaryValue := infoObjectValue.FieldByName("Summary") | |||
descriptionValue := infoObjectValue.FieldByName("Description") | |||
readOnlyValue := infoObjectValue.FieldByName("ReadOnly") | |||
|
|||
if readOnlyValue.Kind() == reflect.Bool && readOnlyValue.CanSet() && strings.Contains(comment, "Output only.") { |
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.
Nice 😎
* explicit swagger option on the field * Implicit comment "Output only." on the field
Codecov Report
@@ Coverage Diff @@
## master #882 +/- ##
==========================================
+ Coverage 52.99% 53.69% +0.69%
==========================================
Files 39 39
Lines 3921 3926 +5
==========================================
+ Hits 2078 2108 +30
+ Misses 1647 1621 -26
- Partials 196 197 +1
Continue to review full report at Codecov.
|
Do you think it's possible to release grpc-gateway at some point with the generated artifacts ? |
We automatically build binaries for all releases. We're planning on making another release soon! |
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!
Can be set via: * explicit swagger option on the field * Implicit comment "Output only." on the field
Add read only support.
This helps simplifying asymmetry in request/response using the same proto message definition
For instance, a proto can define some HATEOAS links that are read-only that should not be present in the request body of PUT or POST but present in the response body of GET for instance.
What do you think ?
Thanks