-
Notifications
You must be signed in to change notification settings - Fork 69
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
Improve description of field masks in API documentation #475
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.
I'm afraid this "field mask only" label will make things even more confusing than they already are. As an example of this, your first screenshot shows the Applications
message (for list responses) and indicates the applications
field as needing to be in the field mask, which isn't the case.
Also, do we emphasize enough that empty fields (zero values) are omitted from the JSON, regardless of field mask? This is of course something we'd want to fix in a future version of The Things Stack but that's going to take some time.
Can we somehow get a better list of which fields are field mask only, then? @johanstokking shared this but I don't understand how it's used https://github.com/TheThingsNetwork/lorawan-stack/blob/v3.14/pkg/ttnpb/field_mask_validation.go |
Not really, because it also depends on the context.
I think the best way to document this, is to do it in the request messages, so in the |
2d6e5b8
to
b8d3a39
Compare
b8d3a39
to
6eb4bc6
Compare
Created a new issue for this -> #493 Will merge this as is, with improved description of how field masks work |
{{% tts %}} APIs use field masks to specify a subset of fields that should be returned by a reading request, or to specify fields that should be updated in a writing request. See Google's [Protocol Buffers reference](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask) for more information about field masks. | ||
{{% tts %}} APIs use field masks to specify a subset of fields that should be returned by a reading request, or to specify fields that should be updated in a writing request. By default, API requests will not return or update most fields, unless they are specified in a field mask. | ||
|
||
The following fields are always returned and always updated: |
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.
These fields are always returned for messages that have them.
Only updated_at
is automatically updated.
@@ -6,17 +6,185 @@ weight: -1 | |||
|
|||
## Field Masks | |||
|
|||
{{% tts %}} APIs use field masks to specify a subset of fields that should be returned by a reading request, or to specify fields that should be updated in a writing request. See Google's [Protocol Buffers reference](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask) for more information about field masks. | |||
{{% tts %}} APIs use field masks to specify a subset of fields that should be returned by a reading request, or to specify fields that should be updated in a writing request. By default, API requests will not return or update most fields, unless they are specified in a field mask. |
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.
It depends on the request. Not all requests take field masks.
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.
Updated, it looks like all requests which operate this way list a field_mask
parameter, i.e https://www.thethingsindustries.com/docs/reference/api/application/#message:UpdateApplicationRequest or http://localhost:1313/reference/api/end_device/#message:GetEndDeviceRequest
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 still think we can do better, but let's not block this any longer.
{{< warning >}} If you are not getting the fields you expect in API responses, see the [Field Masks]({{< relref "field-mask" >}}) reference. | ||
{{</ warning >}} | ||
|
||
{{< note >}} If you're having trouble with the HTTP API, you can always inspect requests in the Console using your browser's inspector. All of the data displayed in the Console is pulled using HTTP API requests, and this should give you some insight in to how they are formed. |
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.
{{< note >}} If you're having trouble with the HTTP API, you can always inspect requests in the Console using your browser's inspector. All of the data displayed in the Console is pulled using HTTP API requests, and this should give you some insight in to how they are formed. | |
{{< note >}} If you are having trouble with the HTTP API, you can always inspect requests in the Console using your browser's inspector. All of the data displayed in the Console is pulled using HTTP API requests, and this should give you some insight in to how they are formed. |
Summary
Closes https://github.com/TheThingsIndustries/lorawan-stack-support/issues/373
Closes https://github.com/TheThingsIndustries/lorawan-stack-support/issues/527
Screenshots
Changes
Checklist
make server
, posted screenshots, verified external links. Test withHUGO_PARAMS_SEARCH_ENABLED=true
if style changes will affect the search bar.new-in-version
shortcode, according to the guidelines in CONTRIBUTING.