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

apidom-reference: regression in AsyncAPI 2.x dereferencing #3974

Closed
4 tasks done
char0n opened this issue Mar 28, 2024 · 4 comments
Closed
4 tasks done

apidom-reference: regression in AsyncAPI 2.x dereferencing #3974

char0n opened this issue Mar 28, 2024 · 4 comments

Comments

@char0n
Copy link
Member

char0n commented Mar 28, 2024

TODO:


Steps To Reproduce

Given the following AsyncAPI definition:

asyncapi: '2.4.0'
info:
  title: Base API
  version: '1.0.0'
  description: ""
channels:
  c:
    publish:
      message:
        $ref: 'https://test-fake-url.com/apis/test/1#/components/messages/someMessage'

With https://test-fake-url.com/apis/test/1 linking to this file:

asyncapi: '2.4.0'
info:
  title: Components
  version: '1.0.0'
  description: ""

components:
  messages:
    someMessage:
      contentType: application/json
      payload:
        $ref: "#/components/schemas/somePayload"
  schemas:
    somePayload:
      type: object
      properties:
        sentAt:
          $ref: "#/components/schemas/sentAt"
    sentAt:
      type: string
      format: date-time
      description: Date and time when the message was sent.

When calling dereference, up to now we would have gotten back the following (no $refs, everything fully inlined)

"asyncapi": "2.4.0"
"info":
  "title": "Base API"
  "version": "1.0.0"
  "description": ""
"channels":
  "c":
    "publish":
      "message":
        "contentType": "application/json"
        "payload":
          "type": "object"
          "properties":
            "sentAt":
              "type": "string"
              "format": "date-time"
              "description": "Date and time when the message was sent."

However, now we get we get the following ($ref to sentAt) which causes additional problems as the local definition for sentAt is not present

"asyncapi": "2.4.0"
"info":
  "title": "Base API"
  "version": "1.0.0"
  "description": ""
"channels":
  "c":
    "publish":
      "message":
        "contentType": "application/json"
        "payload":
          "type": "object"
          "properties":
            "sentAt":
              "$ref": "#/components/schemas/sentAt"
@char0n
Copy link
Member Author

char0n commented Mar 28, 2024

I could successfully reproduce.

@char0n
Copy link
Member Author

char0n commented Mar 28, 2024

The issue is related to refractor cache.

The workaround for now is to perform dereference in replace or error mode:

const actual = await dereference(<PATH>, {
  parse: { mediaType: mediaTypes.latest('json') },
  dereference: { circular: '<error | replace>' },
});

@char0n
Copy link
Member Author

char0n commented Mar 28, 2024

Bug fix needs to applied to all dereferencing strategies.

@char0n
Copy link
Member Author

char0n commented Mar 28, 2024

All dereference strategies has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant