Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-document references in remote documents not resolving correctly #298

Open
chase-crumbaugh opened this issue May 30, 2024 · 3 comments
Open
Labels
bug Something isn't working

Comments

@chase-crumbaugh
Copy link

I am encountering an issue in which the local (as in, within the document itself, e.g. $ref: #/components/schemas/...) references in a remotely referenced spec are not being resolved correctly.

Below is a minimal reproducible. If you download the openai spec contents and replace the $ref with a local reference to the same document, you will not get an error.

Input spec:

openapi: 3.0.3
info:
  title: Test
  version: 1.0.0
paths:
  /api/v1/completions:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml#/components/schemas/CreateChatCompletionRequest"
      responses:
        "200":
          description: A successful response
          content:
            application/json:
              schema:
                type: object

Error:
schema properties build failed: cannot find reference #/components/schemas/ChatCompletionStreamOptions, line 7920, col 27

Doc config:

config := &datamodel.DocumentConfiguration{
	AllowRemoteReferences:               true,
	AllowFileReferences:                 true,
	IgnorePolymorphicCircularReferences: true,
	IgnoreArrayCircularReferences:       true,
	ExtractRefsSequentially:             true,
}

doc, err := libopenapi.NewDocumentWithConfiguration(docInfo.Schema, config)
@daveshanley
Copy link
Member

Hmm... looks like a bug.

@daveshanley daveshanley added the bug Something isn't working label May 31, 2024
@chase-crumbaugh
Copy link
Author

Bump :)

@daveshanley
Copy link
Member

I won't be doing a bug bash for a while, I am building something on top of these tools at the moment and I need all my brain power. Please feel free to submit a PR however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants