Fix no-invalid-media-type-examples in OpenAPI
What does this MR do and why?
This MR fixes 20 no-invalid-media-type-examples warnings in the OpenAPI v3 specification by updating invalid examples in lib/api/access_requests.rb and regenerating doc/api/openapi/openapi_v3.yaml.
The invalid examples were structured as a flat hash, but the schema requires a nested user object. By fixing this, 22 instances of the no-invalid-media-type-examples warnings are resolved.
| Schema | Old Value | New Value |
|---|---|---|
|
|
id: 1\\ username: raymond_smith\\ name: Raymond Smith\\ state: active\\ created_at: '2012-10-22T14:13:35Z'\\ access_level: 20 |
user:\\ id: 1\\ username: raymond_smith\\ name: Raymond Smith\\ state: active\\ requested_at: '2012-10-22T14:13:35Z' |
|
|
id: 1\\ username: raymond_smith\\ name: Raymond Smith\\ state: active\\ created_at: '2012-10-22T14:13:35Z'\\ access_level: 20 |
user:\\ id: 1\\ username: raymond_smith\\ name: Raymond Smith\\ state: active\\ access_level: '20'\\ created_at: '2012-10-22T14:13:35Z' |
How to set up and validate locally
Regenerate the OpenAPI docs:
bin/rake gitlab:openapi:v2:generate
bin/rake gitlab:openapi:v3:generateRun the Redocly CLI to confirm output resolves all 22 warnings in files:
npx @redocly/cli lint doc/api/openapi/openapi_v3.yaml --extends=recommended --max-problems 10000 --format=json | jq -r '.problems[] | select(.ruleId == "no-invalid-media-type-examples")'/cc @abignotti
Edited by Luciano Scarpaci