asyncapi / parser-go

It parses AsyncAPI documents.
Apache License 2.0
55 stars 17 forks source link

Can't refer to a key that has "." in it #40

Closed hexdigest closed 5 years ago

hexdigest commented 5 years ago

Hi!

I have a document with the following structure:

channels:
  hello.world:
    publish:
      message:
        payload:
          type: object
          required:
            - address
          properties:
            name:
              type: string
            address:
              $ref: "#/channels/hello.world/publish/message/payload/definitions/address"
            status:
              $ref: "#/channels/hello.world/publish/message/payload/definitions/status"

"." in the topic is very common for many message brockers but unfortunately references can't be resolved because of this piece of code:

filedereferencer.go:

path := strings.Split(strings.Trim(ref, "#"), "/")
element := m.Get(trimFirstRune(strings.Join(path, ".")))

which generates incorrect path to look up for the substituion: "channels.hello.world.publish.message.payload.definitions.address"

fmvilas commented 5 years ago

Thanks for reporting, @hexdigest!

@xino12 can you have a look at this? Thanks!

fmvilas commented 5 years ago

This is already fixed. Thanks!