Page MenuHomePhabricator

Create example implementation for OpenAPI specs referencing response bodies inline
Open, In Progress, HighPublic

Description

Description

We are establishing a new pattern for defining response bodies as JSON schemas so they can be referenced directly as part of the OpenAPI spec generation. However, this is an untested pattern and needs a proof of concept for implementation.

Problem statement

The OpenAPI specifications are generated on demand, but currently do not contain complete responses in the spec. We took an initial approach of hardcoding responses as PHP arrays, but decided that will be too manual and arduous to maintain. Instead, we aligned on defining reusable JSON schema definitions that can be referenced then injected directly into the OpenAPI spec. However, we have not yet tested this approach and therefore need a proof of concept that can be referenced for repeating the pattern across MediaWiki endpoints.

    1. Conditions of acceptance
  • Create proof of concept for pulling and injecting response bodies into the generated spec. Proposal to start with GET: w/rest.php/v1/page/{title}
    • Schedule a knowledge sharing session with other members of the team to demonstrate the new pattern.
  • Document instructions for how to follow a similar pattern across other endpoints.
    • Update related phab ticket with link to instructions, and/or additional details:

Out of scope

This work will only include an example that can be referenced. Replicating this pattern across endpoints will be covered in a separate ticket.

Event Timeline

The task description says "Instead, we aligned on defining reusable JSON schema definitions that can be referenced then injected directly into the OpenAPI spec". That is true, but not strictly necessary for moving the response body definitions out of PHP arrays into .json files.

We also have T375777: REST: add support for re-usable json schema files, which focuses on the "reusable" part.

My current thinking is to focus the implementation of this task, T376290, on moving the response body definitions into .json files, and to implement reusable schemas as a second step under T375777. That should keep code reviews simpler and more focused than if we tried to do this all at once.

If anyone has objections, let me know. Otherwise, I'll proceed along those lines.

Change #1077834 had a related patch set uploaded (by BPirkle; author: BPirkle):

[mediawiki/core@master] REST: Allow specifying response body schemas in json files

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

HCoplin-WMF renamed this task from Create example implementation for OpenAPI specs referencing response bodies inline to wCreate example implementation for OpenAPI specs referencing response bodies inline .Oct 7 2024, 10:26 AM
HCoplin-WMF renamed this task from wCreate example implementation for OpenAPI specs referencing response bodies inline to Create example implementation for OpenAPI specs referencing response bodies inline .
HCoplin-WMF triaged this task as High priority.
BPirkle changed the task status from Open to In Progress.Oct 10 2024, 3:15 PM
BPirkle moved this task from Incoming (Needs Triage) to In Progress on the MW-Interfaces-Team board.

Change #1077834 merged by jenkins-bot:

[mediawiki/core@master] REST: Allow specifying response body schemas in json files

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