OpenAPI viewer cannot reference schema file in another GitLab project

Summary

I want to add openapi documentation to my projects that have APIs. We use a centralized repository of request/response protobuf definitions and in that repository we generate openapi schemas for each message, enum, etc. We tried to reference these yaml files from another project when writing the openapi for the APIs but the referenced schema files cannot load.

Steps to reproduce

Create new repository openapi-schemas and put in an openapi schema definition file:

ExampleMessage.yaml:

type: object
properties:
  test:
    type: integer

Create new repository example-project and put in an openapi documentation file for the service:

openapi.yaml:

openapi: 3.0.3
info:
  title: Example service
  description: Example service for reproducing GitLab CORS error importing schema from another repo
  version: v1

servers:
  - url: 'https://{env}.apis.example.com'
    description: external traffic
    variables:
      env:
        enum:
          - dev
          - test
          - staging
          - prod
        default: test

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

paths:
  /example/v1/healthcheck:
    get:
      responses:
        200:
          description: Successful healthcheck response
          content:
            application/json:
              schema:
                # Example URL, but get the actual URL to this file from the other repo when recreating the issue
                $ref: "https://gitlab.com/openapi-schemas/-/raw/master/ExampleMessage.yaml"

Example Project

Schemas project: https://gitlab.com/johriley/openapi-schemas

OpenAPI project: https://gitlab.com/johriley/example-project/-/blob/main/openapi.yaml

What is the current bug behavior?

The schemas do not load, and when I click to open an endpoint to view it, I see an error at the top of the page that it could not reference the file. And there is no real definition inside of the endpoint for the schema.

What is the expected correct behavior?

The endpoint shows the schema that is being referenced for the request/response body.

Relevant logs and/or screenshots

Error shown at the top of the OpenAPI page when expanding the endpoint: image

Logs in the browser console showing the error loading the file: image

The example response just says "string" instead of the actual example response structure: image

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

I'm not sure how to run any of these. I'm not sure how our GitLab is set up. We access it from gitlab.com/ftdr/... which is being our company's SSO login.

I can say that when I go to the help page I see this:

GitLab Enterprise Edition 16.1.0-pre 579d7b5d

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited by Jacques Erasmus