Skip to content

Fix unresolved OpenAPI references

Jacques Erasmus requested to merge 381047-fix-unresolved-references into master

What does this MR do and why?

Currently, any external references will not resolve correctly because the OpenAPI (Swagger) viewer is rendered in an iFrame, so external requests are blocked due to CORS.

This MR aims to resolve this issue by bundling the spec with its external references into one spec file before passing it to the iFrame.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
Screenshot_2023-12-06_at_11.56.05 Screenshot_2023-12-06_at_11.56.35

How to set up and validate locally

  1. Create an openapi.yml file containing an external reference:
openapi: 3.0.0

info:
  title: Simple API
  version: 1.0.0

paths:
  /greeting:
    $ref: './greeting.yaml'
  1. Create the external reference (e.g. ./greeting.yaml):
get:
  summary: Get a friendly greeting
  responses:
    '200':
      description: A successful response
      content:
        text/plain:
          example: Hello, World!
  1. Open the openapi.yml file created in Step 1
  2. The contents from ./greeting.yaml should be rendered

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #381047 (closed)

Edited by Jacques Erasmus

Merge request reports