nelmio/NelmioApiDocBundle — pull request #210 by jhallbachner (2013-07-01 06:54:22+00:00)
Title: Added Support for Validation Component (refactored)

As per conversation on the original PR, this is a refactored version of the Validation function, built as an additional parser rather than adding an extra injected handler level to the parsing process. This PR supersedes #199.

----

Especially with the addition of automatic deserialization (and possibly soon automatic validation) of request objects to the FOSRestBundle, using a single PHP object with serialization and validation metadata is a pretty straightforward method for defining an API request format in Symfony. ApiDocBundle currently supports the parameter part of this via the JmsSerializerParser but doesn't capture details that are set via the validation component; thus, this pull request.

This PR adds an additional Parser, which extracts certain details (primarily required status, type, and format) from Symfony validation metadata on request objects. It also adds an additional column ("format") in the output for parameters which reflects constraints drawn from validation. Finally, it adds additional logic to the parsing process, adding a process to merge metadata extracted from multiple parsers and a second parse pass to allow parsing of subordinate classes.

I also added a set of tests to verify that the metadata was being read and processed correctly.

The format used in the "format" column can be considered WIP and I'll update it as preferred.