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

[AsyncAPI] Referencing schemas or messages from a local file leads to an error #344

Closed
arthureberledev opened this issue Jun 4, 2024 · 1 comment · Fixed by #352
Closed
Assignees

Comments

@arthureberledev
Copy link

We have multiple asyncapi files in our project that share the same components. If i try to seperate them into multiple yaml files to reuse them, I either get an error that findValue(String) is null or that "properties" is null.

This is an example asyncapi spec file:

# asyncapi.yaml
asyncapi: 2.6.0
info:
  title: Account Service
  version: "1.0.0"
channels:
  user/signedup:
    subscribe:
      operationId: userSignedUp
      message:
        $ref: "#/components/messages/UserSignedUp"
components:
  messages:
    UserSignedUp:
      payload:
        # this works:
        $ref: "#/components/schemas/user"
        # this leads to the error
        # `Cannot invoke "com.fasterxml.jackson.databind.JsonNode.get(String)" because the return value of "com.fasterxml.jackson.databind.JsonNode.findValue(String)" is null`:
        $ref: "./user-message.yaml"
  schemas:
    user:
      # this works:
      type: object
      properties:
        firstName:
          type: string
          description: "foo"
        lastName:
          type: string
          description: "bar"
      # this leads to the error
      # `Cannot invoke "com.fasterxml.jackson.databind.JsonNode.has(String)" because "properties" is null`:
      $ref: "./user.yaml"

# user-message.yaml
payload:
  type: object
  properties:
    firstName:
      type: string
      description: "foo"
    lastName:
      type: string
      description: "bar"

# user.yaml
type: object
properties:
  firstName:
    type: string
    description: "foo"
  lastName:
    type: string
    description: "bar"

It works with referencing parameters from a local file though, e. g.:

...
components:
  parameters:
    stage:
     $ref: "./stage.yaml"

Is this just not supported currently or is this perhaps a bug?

@jemacineiras jemacineiras self-assigned this Oct 22, 2024
@jemacineiras
Copy link
Contributor

Hi @arthureberledev,

I'm sorry for not getting back to you sooner.
I will take a look at it. I guess part of this problem is solved with the refactoring I recently made. But I think we force to keep the component structure inside the files, at least for now.

I will back to you as soon as I can.

@jemacineiras jemacineiras linked a pull request Nov 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants