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
API docs and the live API disagree #820
Comments
Use standard string instead of sql.NullString for `style_sheet`, `script`, and `signature`. Addresses #820
Another thing I discovered today: the I think both responses & inputs should use the same format (probably RFC3339, which is what the documentation says). |
Another one, a minor inconsistency: the same thing that appears as |
As a followup to this, I discovered another inconsistency with dates, this one is considerably trickier to workaround: when I create a new post (either via Reproduction:
Notice that the date I set is different from the one returned after post creation. Changing the date format results in the correct created date:
However, trying to update a post with RFC3339 format date fails:
In the logs, I see:
I can work this around in my client library by sending an update request immediately after a create, if the request had a |
While writing some tests for my library, stumbled upon another minor inconsistency: trying to retrieve a non-existent post will always return a response in Reproduction:
Update: same thing happens when I try to post an update, or delete a non-existing post: the response is in text/plain. Looks like the entire |
One more: contrary to the documentation: creating a collection requires the
If I change the payload to |
Thanks for reporting all of this! I've fixed one issue here as noted below, and that will go out in the next release. Otherwise, I'll address other issues here, and would appreciate if you could open separate issues where indicated just to help us make sure each one gets tackled.
|
Yep, I can open separate issues! Will do so later today. |
Thank you! Awesome to see a Rust library come together, by the way. Will be happy to promote it on our developer site. Once those issues are created, we can consider this issue closed by #854. |
Overview
I'm writing an API client in Rust, and have been following the API docs for the most part. Unfortunately, I ran into a couple of cases where the docs are inaccurate, and other cases where the API is just... strange or inconsistent.
I hope you don't mind that I'm reporting multiple problems in one issue: they are all somewhat related, anyway.
Application configuration
Version or last commit: 0.14.0
API issues
Updating a Collection's visibility
The docs say that if I want to update a Collection's visibility - to, say, public - I need to send
{"visibility": 1}
to the/api/collections/{alias}
endpoint in aPOST
request.However, that doesn't work.
Steps to reproduce
Workaround
Digging around in the source, I discovered that I need to use the
public
property for this. That works.Expected behaviour
However, when retrieving a collection's info,
public
is serialized as a bool, so I have no way of knowing whether the blog is unlisted, private, or password protected. The only state I can be sure of is ifpublic: true
, then the collection is public. If it is false, it can be either of the three.It would be nice if the API matched the documentation, and that if
visibility
would be included in the collection properties in response to aGET
request to/api/collections/{alias}
. Keepingpublic
there too, for compatibility is fine too. I just wish I could both retrieve the full range of visibility settings, and set them consistently: with the same key, and same type as they are retrieved.Some optional string properties (of a Collection) are inconsistently de/serialized
I first noticed the problem when trying to set a custom style sheet for a collection via the
/api/collections/{alias}
update API, and the API telling me that it expects valid JSON.Steps to reproduce
I would have expected this to work, because if I set the style via the web UI, retrieving the collection info has it serialized as a string:
Workaround
A bit of searching around, I found that Go's
sql.NullString
is picky, and in order for Go to correctly deserialize the JSON string value tosql.NullString
, I need to use a different format:Using that as the payload for the collection update request does the right thing.
Expected behaviour
I'd expect that the format I receive when retrieving the collection info, can be fed back to the update directly. That it'd use the same format. I don't mind either the string format, or the more verbose NullString thing, but it would be fantastic if the API was consistent.
Or if the docs documented both formats.
Also applies to
This also applies to
script
andsignature
too.Some optional properties (of a Collection) are less optional than others
Some optional properties of a Collection, such as
verification_link
,description
, andstyle_sheet
seem to be included in the/api/collections/{alias}
GET response, even if they're empty: they appear as""
:...while others, such as
script
, andsignature
do not appear in this, unless they're set. This makes it a tiny bit harder to implement serialization and deserialization for the Collection type, because I have to treat some of the optional properties more specially than the others.Closing thoughts
While I found workarounds for all of the issues above, it would make it much easier to use the API, if the problems listed above were fixed. There may be other issues and inconsistencies too, that I have not discovered yet - I barely started exploring the API. If I find further issues, I will report them. Either as a followup to this issue here, or a separate one, whichever you find more convenient.
The text was updated successfully, but these errors were encountered: