Page MenuHomePhabricator

Use openapi compliant examples in swagger spec
Closed, ResolvedPublic8 Estimated Story PointsBUG REPORT

Assigned To
Authored By
santhosh
Dec 17 2024, 4:26 AM
Referenced Files
F58916004: image.png
Mar 25 2025, 12:37 PM
F58915994: image.png
Mar 25 2025, 12:37 PM
F58915989: image.png
Mar 25 2025, 12:37 PM
F58118801: image.png
Jan 4 2025, 5:40 AM
F58118807: image.png
Jan 4 2025, 5:40 AM
F58118767: image.png
Jan 4 2025, 5:40 AM
F58118782: image.png
Jan 4 2025, 5:40 AM

Description

cxserver uses a non-standard scheme for the openapi spec to defined API input, output example. we use x-amples key which was introduced in service-runner templates many years ago.

Currently, OpenAPI 3.0 allows defining examples in the spec. Documentation: https://swagger.io/docs/specification/v3_0/adding-examples/

Migrating from nonstandard examples to new format allows us to use standard tooling around the examples to create mock tests and present the examples in betterway in swagger UI.

Event Timeline

Wangombe changed the task status from Open to In Progress.Jan 4 2025, 3:54 AM
Wangombe claimed this task.

Change #1108144 had a related patch set uploaded (by Wangombe; author: Wangombe):

[mediawiki/services/cxserver@master] cxserver spec.yaml: Update endpoint to use openapi compliant examples

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

Focus areaBefore (production)After
Schema
image.png (830×915 px, 67 KB)
image.png (794×916 px, 70 KB)
Examples
image.png (867×1 px, 66 KB)
image.png (761×1 px, 72 KB)

Change #1109751 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/services/cxserver@master] Error handling: Skip passing the error to Express

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

Change #1109751 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/services/cxserver@master] Error handling: Skip passing the error to Express

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

Change #1109751 merged by jenkins-bot:

[mediawiki/services/cxserver@master] Error handling: Skip passing the error to Express

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

Change #1111373 had a related patch set uploaded (by KartikMistry; author: KartikMistry):

[operations/deployment-charts@master] Update cxserver to 2025-01-13-044601-production

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

Change #1111373 merged by jenkins-bot:

[operations/deployment-charts@master] Update cxserver to 2025-01-13-044601-production

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

Mentioned in SAL (#wikimedia-operations) [2025-01-15T05:23:23Z] <kart_> Updated cxserver to 2025-01-13-044601-production (T382294)

Mentioned in SAL (#wikimedia-operations) [2025-01-15T05:23:23Z] <kart_> Updated cxserver to 2025-01-13-044601-production (T382294)

Note that this patch is related to T377966: Make cxserver Logstash logs readable and reliable

I need to make some updates to spec.js file to update the logic responsible for validating examples for the spec.yaml file as described in this patch .. Keeping the testing of endpoints dynamic is crucial for the new spec.yaml file and seeing that it's structure has changed, we should now have logic to match it.

service-checker doesn't have support yet for the swagger example stanzas. Given it is the underlying library that does all the monitoring based on openapi specs SRE should add support for this to it. That being said, and to ensure a smooth migration, I suggest to not drop the x-amples stanzas from specs until we 've added support. Definitely do deploy the new stanzas though, they 'll definitely help in ensuring support in the service checker's side.

Nikerabbit changed the point value for this task from 4 to 8.Feb 17 2025, 8:59 AM

Change #1122072 had a related patch set uploaded (by Wangombe; author: Wangombe):

[mediawiki/services/cxserver@master] cxserver spec.yaml: Update endpoints to use openapi compliant examples

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

Change #1122072 merged by jenkins-bot:

[mediawiki/services/cxserver@master] cxserver spec.yaml: Update endpoints to use openapi compliant examples

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

https://gerrit.wikimedia.org/r/1122072 has been merged. We can do a sanity check on it. After, we are not planning on continuing work on this so it should ideally be moved back to Ready for Dev column.

Please create a new task for the remaining work so that this can be resolved.

Change #1128066 had a related patch set uploaded (by KartikMistry; author: KartikMistry):

[operations/deployment-charts@master] Update cxserver to 2025-03-14-045617-production

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

Change #1128066 merged by jenkins-bot:

[operations/deployment-charts@master] Update cxserver to 2025-03-14-045617-production

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

Mentioned in SAL (#wikimedia-operations) [2025-03-19T05:16:51Z] <kart_> Updated cxserver to 2025-03-14-045617-production (T382294)

These changes have been deployed.

Some improvements:

  1. The endpoints include a visible description on first glance without having to expand any of the items.
    image.png (1×1 px, 153 KB)
  2. Examples and schema are well defined against each endpoint
    image.png (922×1 px, 86 KB)
    image.png (1×1 px, 95 KB)