Skip to content

Fix rendering of responses with empty bodies #3674

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

Merged
merged 1 commit into from
Jan 26, 2022

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Jan 25, 2022

This PR fixes the rendering of API responses, so that responses which are objects with no properties are still rendered.

Preview: https://pr3674--matrix-org-previews.netlify.app

See, for example, PUT /_matrix/client/v3/pushrules/{scope}/{kind}/{ruleId}/enabled.

They are shown only as an example, which isn't super-clear, but is better than nothing:

image

For reference, the following endpoints now show an example response with an empty body:

PUT /_matrix/client/v3/room_keys/version/{version}
DELETE /_matrix/client/v3/room_keys/version/{version}
POST /_matrix/client/v3/pushers/set
PUT /_matrix/client/v3/pushrules/{scope}/{kind}/{ruleId}
DELETE /_matrix/client/v3/pushrules/{scope}/{kind}/{ruleId}
PUT /_matrix/client/v3/pushrules/{scope}/{kind}/{ruleId}/actions
PUT /_matrix/client/v3/pushrules/{scope}/{kind}/{ruleId}/enabled
POST /_matrix/client/v3/rooms/{roomId}/invite   (with a threepid)
PUT /_matrix/client/v3/user/{userId}/rooms/{roomId}/tags/{tag}
DELETE /_matrix/client/v3/user/{userId}/rooms/{roomId}/tags/{tag}
POST /_matrix/client/v3/rooms/{roomId}/report/{eventId}

PUT /_matrix/federation/v2/send_leave/{roomId}/{eventId}
PUT /_matrix/federation/v1/3pid/onbind
PUT /_matrix/federation/v1/exchange_third_party_invite/{roomId}

PUT /_matrix/app/v1/transactions/{txnId}
GET /_matrix/app/v1/users/{userId}
GET /_matrix/app/v1/rooms/{roomAlias}
PUT /_matrix/client/v3/directory/list/appservice/{networkId}/{roomId}

POST /_matrix/identity/v2/account/logout
POST /_matrix/identity/v2/terms
GET /_matrix/identity/v2
POST /_matrix/identity/v2/3pid/unbind

These endpoints are now shown with a non-empty example response:

GET /_matrix/client/v3/rooms/{roomId}/state/{eventType}/{stateKey}
GET /_matrix/client/v3/user/{userId}/account_data/{type}
GET /_matrix/client/v3/user/{userId}/rooms/{roomId}/account_data/{type}

Finally, GET /_matrix/client/v3/thirdparty/protocols now has an entire hierarchy of objects. It's special, because its response is an object using only additionalProperties (ie, it is a map from arbitrary strings to objects). The rendering isn't super-clear, but it's not much different from the same before the site redesign.

@richvdh richvdh force-pushed the rav/empty_response_body_fixes branch from 77286a5 to 160fadb Compare January 25, 2022 17:35
@richvdh richvdh requested a review from a team January 25, 2022 17:44
@richvdh
Copy link
Member Author

richvdh commented Jan 25, 2022

question: how, if at all, should this be represented in the changelogs?

@afranke afranke mentioned this pull request Jan 25, 2022
@turt2live
Copy link
Member

question: how, if at all, should this be represented in the changelogs?

copy/paste one of the existing "fix various typos throughout the specification"-worded entries. It's minor enough where I don't think it needs its own changelog, but should be represented as something happening.

Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall seems fine. If you're still willing to fight the rendering system, the old spec platform had a sentence to say that it's the successful response, just so it doesn't look like a possible bug in the example rendering. A similar "An empty object" line would be great, but not a blocker.

@richvdh
Copy link
Member Author

richvdh commented Jan 26, 2022

A similar "An empty object" line would be great, but not a blocker.

That doesn't seem like quite the right wording here, since it's within spec to return an object with unspecced keys - which is to say, the object isn't necessarily empty.

It could certainly be improved, but I'm not really sure what would be best and I don't want to hold up this PR.

@richvdh richvdh merged commit 783624d into main Jan 26, 2022
@richvdh
Copy link
Member Author

richvdh commented Jan 26, 2022

bother, I forgot the changelog. Will add it on main directly.

richvdh added a commit that referenced this pull request Jan 26, 2022
@richvdh
Copy link
Member Author

richvdh commented Jan 26, 2022

done in 4a9c236

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

Successfully merging this pull request may close these issues.

2 participants