diff --git a/datasette/views/special.py b/datasette/views/special.py index dbe5eab1..1df74f07 100644 --- a/datasette/views/special.py +++ b/datasette/views/special.py @@ -813,9 +813,15 @@ class ApiExplorerView(BaseView): "json": { "rows": [ { - column: None + column: "<{}{}>".format( + column, + ( + " (primary key)" + if column in pks + else "" + ), + ) for column in await db.table_columns(table) - if column not in pks } ] }, diff --git a/tests/test_api_write.py b/tests/test_api_write.py index 91a88606..f600d4f5 100644 --- a/tests/test_api_write.py +++ b/tests/test_api_write.py @@ -44,6 +44,22 @@ def _headers(token): } +@pytest.mark.asyncio +async def test_api_explorer_upsert_example_json(ds_write): + response = await ds_write.client.get("/-/api", actor={"id": "root"}) + print("STATUS", response.status_code) + assert response.status_code == 200 + import urllib.parse + + text = urllib.parse.unquote_plus(response.text) + upsert_idx = text.index("/data/docs/-/upsert") + upsert_chunk = text[upsert_idx : upsert_idx + 500] + assert '"id": ""' in upsert_chunk + assert '"title": ""' in upsert_chunk + assert '"score": "<score>"' in upsert_chunk + assert '"age": "<age>"' in upsert_chunk + + @pytest.mark.asyncio @pytest.mark.parametrize( "content_type",