Page MenuHomePhabricator

Improve examples in OpenAPI Schema
Open, Needs TriagePublic

Description

There are a few things that could be done to improve the examples in our OpenAPI Schema:

  • Use less ambiguous example values. E.g. For the GET item response, "id": "Q11" rather than "id": "string". "string" is ambiguous as it could mean 'replace "string" with any type string' or it could mean 'the actual string "string"' like is possible for property.data-type.
  • Add an example to the lowest level fields where it makes sense. E.g. site, title, and badges of sitelinks. Labels, descriptions, and aliases are probably okay how they are.
  • Ensure all requests and responses have good examples. Auto-generated ones are fine as long as they are clear.
  • Add/improve statement examples with property data-types other than string
  • Remove long examples from top level schemas (e.g. Statements in global/schema-parts.json). These top level examples are better in the request and response objects where there is proper formatting and syntax highlighting in the Swagger UI. Labels, descriptions, and aliases are probably okay how they are.
  • establish a rule for when to use actual example values in request/response examples and when to use a {placeholder}

Event Timeline

Change 855994 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/extensions/Wikibase@master] REST: Remove Statement example in OpenAPI Schema

https://gerrit.wikimedia.org/r/855994

Change 855994 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Remove Statement example in OpenAPI Schema

https://gerrit.wikimedia.org/r/855994

Suggesting to do soon as low-hanging fruit improvements:

  • provide actual real-life-like values instead autogenerated ones, e.g. "id": "Q123" over ""id": "string"
  • Add an example to the lowest level fields where it makes sense

- Add/improve statement examples with property data-types other than string. Ideally using all "core" Wikibase data types. Could start with: wikibase item, geographical coordinate, time, URL, external identifier
- add examples for making POST and PUT requests including a reference, and a qualifier

Hello @WMDE-leszek

By the time this task was created, labels, descriptions, and aliases in the schemas section had the same examples of labels, descriptions, and aliases of the item.
However, after adding the property endpoint, those examples were changed to be more generic and overridden in the item or property schema.
Do the new examples for the terms in schemas are accepted? Or should they be changed? And if so, should we add the item or property examples?

Screenshot from 2023-06-30 11-50-16.png (624×629 px, 34 KB)

I think if this should be changed somehow, it should be added to the current task.

Thanks.

Hi, before I start asking more questions, I need a clarification - is this only referring to the Schemas sub-section in our OpenAPI documentation? (points 1,2,4 and 5 seem to?)

But, "Ensure all requests and responses have good examples. Auto-generated ones are fine as long as they are clear." tells me it's also to do with the endpoint information that is displayed when you expand it

Hi @Ifrahkhanyaree_WMDE, this is referring to all examples in the OpenAPI document (request examples, response examples, and examples in the schema subsection). By default, the examples in the request and response sections will use the same examples as the ones in the Schema subsection, unless it is overwritten with something different.