yahehe / Nancy.Swagger

Nancy plugin for generated API documentation in Swagger format.
MIT License
133 stars 60 forks source link

Dictionaries not supported #161

Open poloBBQ opened 6 years ago

poloBBQ commented 6 years ago

Expected Behavior

Dictionary properties with string keys should generate a swagger document using object-typed additionalProperties as explained in the Swagger specification.

public Dictionary<string, int> Dictionary { get; set; }

Should output something equivalent to:

"dictionary": {"type": "object","additionalProperties": {"type": "integer","format": "int32"}}

Actual Behavior

An array is generated, which is an incorrect interpretation of a dictionary. As an example:

public Dictionary<string, int> Dictionary { get; set; }

Outputs:

"dictionary": {"type": "array","items": {"type": "string"}}

Other Information:

I forked the repo and commited a change to support dictionaries, please let me know if I should create a pull request with it or do any corrections https://github.com/evicertia/Nancy.Swagger/tree/dictionary-support

Thanks.

yahehe commented 6 years ago

Your changes look good to me @poloBBQ ! The only thing I would ask is if you could write some tests to valid the correct functionality. Feel free to open a PR!