Page MenuHomePhabricator

REST API vNext: Create dedicated REST shared-schema repository
Closed, ResolvedPublic3 Estimated Story Points

Description

Problem statement: There is value in having some object models shared across APIs to improve consistency and interoperability. While we can’t assume universally reusable concepts when our APIs span such a broad set of use cases, common core definitions for things like error messages, date formats, pagination, and even core data elements for commonly used objects (eg: page, revision, user) should be able to be pulled into subsequent API definitions, with room to expand or extend as needed.

Deliverables

  • Create a new repository for API shared schemas, separate from the existing event-schemas repo and separate from the OpenAPI spec archive (T432800).
  • Update the schema.wikimedia.org directory structure to add the new section (exact layout, e.g. /schemas/ vs /specs/ split, this task includes proposing/closing it, not just applying an already-agreed layout).
  • Decide the schema ID/URI convention (rootless relative path vs. domain-inclusive URI; whether a custom resolver is required).
  • Decide naming convention for shared fields (snake_case vs. camelCase) -- applies to vNext APIs only, not classic/legacy APIs.
  • Adopt per-schema versioning to start (not schema "suites" yet) -- not a formal DECISION like the repo split; flag as such if questioned later.
  • Coordinate with Andrew/DPE on puppet deployment for the new repo (file a ticket; Andrew offered to help with the puppet side).
  • Cross-reference T376841 (human-readable schema viewer on schema.wikimedia.org) as related/existing work -- do not duplicate.

Out of scope for this task: defining the actual shared/reusable fragment schemas (e.g. a common Page definition with id/title/namespace/href)

Related Objects

Event Timeline

Notes from vNext sync:

  • We might want to separate literal repo creation from the deployment steps to schema.wikimedia.org. There would be benefit to having a repo to put things in.
    • Alternative: Start by keeping the schemas somewhere local to MediaWiki REST folders, then move them to schema later, after the repo is available. <-- We are assuming this route in this ticket.

Quick question @Ottomata what's the right GitLab repo that we can use to expose our stuff on https://schema.wikimedia.org/?
Thank you

Hm! Good q! The existing event schema repos are at data-engineering/schemas-event-(primary|secondary) I don't think MW (WMF?) API schemas should be under data-engineering.

So I'm not sure of the correct repo group to use. Maybe just mediawiki? There is an old and basically unused api-platform group. Anyway, up to you all to figure out the repo group, but the only recommendation I'd give is to avoid team names! :)

As for the actual repo name, we could use a similar naming pattern. How might you describe these schemas? They are specifically for use by (mediawiki? WMF?) HTTP APIs, yes? schemas-http-api? schemas-web-api ?

Estimation question:

  • Will this information be accessible to MediaWiki, if it's stored outside? We will need the data within MediaWiki as part of spec generation; do we need to have the base definitions within MediaWiki instead of as a separate repo?
    • Does this need to be a dedicated/separate repo, or would it be better to have a repo within MediaWiki that is referenced by schema?
HCoplin-WMF updated the task description. (Show Details)
HCoplin-WMF updated the task description. (Show Details)

Notes from estimation:

  • Where the repo lives doesn't matter much in terms of referencing the schema. Finding all the schemas should happen on schema.wikimedia, with assumed static URLs.
  • Suggestion: We should have our own schema for our own definitions.
  • If we want to validate the schemas, it's nice to have them locally so we don't have to make web requests to validate. For that purpose, there is precedent for making copies of specific objects (basically a local cache) for testing or other purposes.
    • Most frameworks for validation also allow custom resolvers for external mapping

We also need to decide if this repo will have releases or if any schema file that is committed is assumed to be stable (or at least has a convention to mark the stability of the file). For example, if title-object-1.1.json was committed, can it immediately be assumed to be unchanging? Currently, with schemas inside the mediawiki core repo, we can amend schema files within a single release as we actually get experience using it or get more time to notice deficiencies in the schema. This avoids a proliferation of schema files created within a few days due to corrections of oversights.

AGhirelli-WMF set the point value for this task to 3.

Note that this would include things similar to what is under includes/Rest/Handler/Schema/. Once something is stable and ready for broader reuse, it would be migrated this new schema repo, with local copies of the schema being kept only in the test/ directory to avoid http access for CI and local testing.

For example, if title-object-1.1.json was committed, can it immediately be assumed to be unchanging?

FWIW, this is how event schema works. If we have some need to change a released schema, it has to be done manually and is brittle.

This avoids a proliferation of schema files created within a few days due to corrections of oversights.

Event schemas suffer from this problem too.

We have a convention that solves this problem, but only for new-in-development schemas: namespace them in under development/ while they are at dev or rc status. When promote to production, we reset back to v 1.0.0 to start.

For already released schemas, I'm not sure. Perhaps, SemVer prelease convention may help?

title-object-1.1.0.json
title-object-1.2.0-rc0.json
title-object-1.2.0-rc1.json

Then, when 1.2.0 is released, all the rc* versions could be be deleted, so only 1.2 remains

title-object-1.1.0.json
title-object-1.2.0.json

For example, if title-object-1.1.json was committed, can it immediately be assumed to be unchanging?

FWIW, this is how event schema works. If we have some need to change a released schema, it has to be done manually and is brittle.

For experimental schemas, we should use something like title-object-1.1-rc1.json or title-object-1.1-beta.json.