khellang/Nancy.Swagger — pull request #52 by TimSchlechter (2014-10-22 20:30:39+00:00)
Title: Added hooks to to enrich the raw swagger data

I pushed PR #47 a while ago, but wasn't sure about the solution. After thinking about it again, I came to the conclusion it wasn't a very nice solution.

This PR introduces the concept of enriching the swagger data. You could implement a class which implements ISwaggerDataEnricher. This interface exposes four methods, which are called by the SwaggerAnnotationsConverter just after an instance containing data was created.

I implemented the JsonNetEnricher as an example, which uses reflection to find JsonObjectAttribute and JsonPropertyAttribute by name (so no dependency to Newtonsoft.Json is needed). It uses the data from this properties to enrich the SwaggerModelData and SwaggerModelPropertyData.

An approval test was added which demonstrates the resulting output.

I added this post-processing only in the Nancy.Swagger.Annotation project, because I'm not sure if this approach is suitable/needed when working with the DefaultSwaggerMetadataConverter.