lerenn / asyncapi-codegen

An AsyncAPI Golang Code generator that generates all Go code from the broker to the application/user. Just plug your application to your favorite message broker!
Apache License 2.0
91 stars 23 forks source link

Additional properties (aka map) don't work and, moreover, is not parsed correctly #164

Closed nuttert closed 6 months ago

nuttert commented 6 months ago

I wanted to create one of the fundamental types map[string]string, but it does not work:

Parameters:
      type: map
      additionalProperties:
          type: string

First of all, I guess it's not correct to define it like this:

AdditionalProperties  map[string]*Schema            `json:"additionalProperties"`

it should be:

AdditionalProperties *Schema            `json:"additionalProperties"`

And also you need to define the map in the scheme.tmpl

lerenn commented 6 months ago

Hello @nuttert !

Good catch ! Must be a miss-reading on my side for not implementing it.

I'm currently in a conference, so I may not have the time to fix it right away, but I'll do it as soon as possible.

Thanks for taking the time to read the cause and fill in an issue. It's really appreciated ! If you have any other issues/comments, please do not hesitate.

lerenn commented 6 months ago

@nuttert, I'm working on a fix. However, it seems that the "map" type doesn't exists: https://json-schema.org/understanding-json-schema/reference/type

If you try a Json schema validator with the example you provided, it complains about the type. However, if you change it to type: object, it does work : https://www.jsonschemavalidator.net/s/XS58CpjF

So it should be changed to :

Parameters:
      type: object
      additionalProperties:
          type: string

I'll work on a fix based on that :)

lerenn commented 6 months ago

@nuttert, should be good now ! feel free to reopen if there is any problem :)