114 Commits

Author SHA1 Message Date
Samuel ROZE
3e3ef87b79 Added nested JMS groups exclusion 2014-08-18 11:32:36 +02:00
Bez Hermoso
bcaaf28d61 Default to DataTypes::STRING 2014-08-04 10:02:18 -07:00
William DURAND
6c7c53e78d Fix CS & file permissions 2014-07-30 10:50:23 +02:00
ogizanagi
4939d116e0 Fix embedded collection of custom FormType Error
Fix an error when trying to use embedded form collections.

Referenced issue: #442
2014-07-21 22:27:09 +02:00
Paweł Mikołajczuk
55f26508ab Don't parse custom properties as classes.
Sometimes instead real class name we can use custom handler name. Then this class can't be initialized and we will get this exception ```ReflectionException: Class custom_handler_name does not exist```
2014-07-10 11:46:30 +02:00
Sander Marechal
b66e5c4449 Parse JSM\Inline, fixes #372 2014-07-08 13:20:13 +02:00
gnat42
48e7bd2616 If a description is not provided use form label
It would be nice if there was no description the form label was used instead. In the future I think it would be even better to have the label as an header, and the description as 'additional' instructions.
2014-07-03 13:34:07 -06:00
Giorgio Premi
e2c2d00075 FormTypeParser: FormType constructor should be called when possible 2014-06-27 10:58:53 +02:00
William DURAND
0030ce6825 Merge pull request #358 from pborreli/typos 2014-06-27 10:22:56 +02:00
Pascal Borreli
dbc3fcbb73 Fixed typos 2014-06-27 10:22:36 +02:00
Bez Hermoso
882f658599 Added 'default' parameters in {JmsMetadata,Validator}Parser, and FOSRestHandler. 2014-06-27 10:19:28 +02:00
William Durand
0d1bde9f8a Merge pull request #352 from sroze/output-post-parser
Add PostParserInterface to JmsMetadataParser to get ValidatorParser found children parsed
2014-06-27 10:14:51 +02:00
Bez Hermoso
3a31c93c94 Unified data types [actualType and subType]
Updated tests.

JMS parsing fixes; updated {Validator,FormType}Parser, FOSRestHandler, and AbstractFormatter, and updated DataTypes enum.

Modified dataType checking.

Updated tests.

Updated DataTypes enum.

Quick fix and added doc comments.

CS fixes.

Refactored FormTypeParser to produce nested parameters. Updated tests accordingly.

Logical and CS fixes.

Sub-forms and more tests.

Ignore data_class and always use form-type to avoid conflicts.

Quick fix.
2014-06-27 09:35:18 +02:00
Jonathan Chan
d4e12d66f2 Add default values support for form types
Adding displaying default value in Markdown

updating tests to work with new default value
2014-06-26 11:20:49 -04:00
Jonathan Chan
b124824a8d added file type to FormType Parser 2014-06-25 10:25:45 +02:00
Bez Hermoso
14d1021c8b Unified data types [actualType and subType]
This is the result of https://github.com/nelmio/NelmioApiDocBundle/issues/410.

This PR aims to provide a uniform way of declaring data-types of parameters for
parsers and handlers to follow. In turn, this would allow formatters to
determine data-types in a cleaner and less volatile manner. (See use-case that
can be improved with this PR:
https://github.com/nelmio/NelmioApiDocBundle/blob/master/Formatter/AbstractFormatter.php#L103)

This is possible by the addition two properties to each property item in
`response`, and `parameters` fields in each API endpoint produced by the
`ApiDocExtractor`:

* `actualType` Contains a value from one of the `DataTypes` class constants.

* `subType` Can contain either `null`, or any other `DataTypes` class constant.
This is relevant when the `actualType` is a `DataTypes::COLLECTION`, wherein
`subType` would specify the type of the collection items. It is also relevant
when `actualType` is a `DataTypes::MODEL`, wherein `subType` would contain an
identifier of the model (the FQCN or anything the parser would wish to specify)

Examples:

```php

array(
    'id' => array(
        'dataType' => 'integer',
        'actualType' => DataTypes::INTEGER,
        'subType' => null,
    ),
    'profile' => array(
        'dataType' => 'object (Profile)',
        'actualType' => DataTypes::MODEL,
        'subType' => 'Foo\Entity\Profile',
        'children' => array(
            'name' => array(
                'dataType' => 'string',
                'actualType' => DataTypes::STRING,
                'subType' => null,
             ),
            'birthDate' => array(
                'dataType' => 'date',
                'actualType' => DataTypes::DATE,
                'subType' => null,
            ),
        )
    ),
    'languages' => array(
        'dataType' => 'array of strings',
        'actualType' => DataTypes::COLLECTION,
        'subType' => DataTypes::STRING,
    ),
    'roles' => array(
        'dataType' => 'array of choices',
        'actualType' => DataTypes::COLLECTION,
        'subType' => DataTypes::ENUM,
    ),
    'groups' => array(
        'dataType' => 'array of objects (Group)',
        'actualType' => DataTypes::COLLECTION,
        'subType' => 'Foo\Entity\Group',
    ),
    'profileRevisions' => array(
         'dataType' => 'array of objects (Profile)',
         'actualType' => DataTypes::COLLECTION,
         'subType' => 'Foo\Entity\Profile',
    ),
    'address' => array(
        'dataType' => 'object (a_type_a_custom_JMS_serializer_handler_handles)',
        'actualType' => DataTypes::MODEL,
        'subType' => 'a_type_a_custom_JMS_serializer_handler_handles',
    ),
);
```

When a formatter omits the `dataType` property or leaves it blank, it is
inferred within `ApiDocExtractor` before everything is passed to formatters.
2014-06-25 09:05:48 +02:00
William DURAND
b48650a9e0 Fix CS 2014-06-25 08:52:01 +02:00
William DURAND
fa92011126 fix cs 2014-05-16 11:33:58 +02:00
William Durand
36c223ab3a Merge pull request #329 from maxromanovsky/form-type-parser-improvements
Form Parser improvements for date, datetime & choice form types (format & types)
2014-05-12 11:56:00 -04:00
Cedric LOMBARDOT
4181079d8b Fix parse of input forms with options required
When form like model type was parsed this pass the required 'class' option to enable the build of the class
2014-04-11 09:45:35 +00:00
Max Romanovsky
b4fa6013cd Form Parser improvements for date, datetime & choice form types (format & types) 2014-04-04 13:52:12 +03:00
Samuel ROZE
3f66888f00 Add PostParserInterface to JmsMetadataParser to get ValidatorParser found children parsed. 2014-03-20 16:39:36 +01:00
Paweł Mikołajczuk
32e37dbd8a Don't try to call class with custom handlers.
With JMS Serializer you can set up own type and use it later with custom handler for this property - Parser allways try to call that custom property type like a class. This fix that.
2014-02-03 16:57:46 +01:00
Julius Beckmann
0845377300 Use only JMS/GroupExclusion if groups are there
When no groups are given in the ApiDoc, there should be no GroupExclusion and the Entity should be parsed wihtout exclusions.

Otherwise only the "Default" group of the Entity would be parsed, which may not be used.

The ApiDoc should not enforce the Entity to be grouped with "Default", to generate a "full-view" of it.
2013-12-20 15:08:26 +01:00
William DURAND
c3097c7439 cs 2013-12-11 01:59:59 +01:00
Samuel ROZE
1112cca784 Add support of All constraint 2013-11-18 10:24:56 +01:00
William DURAND
e59ae1e1ef Fix tests for Symfony2 2.1 2013-11-14 14:20:51 +01:00
William DURAND
7fdcd65286 Add not blank format validation
All credits go to @spolischook

See: https://github.com/nelmio/NelmioApiDocBundle/pull/234

Closes #234
2013-11-14 11:12:58 +01:00
Martin Westergaard Lassen
83315fcc80 Set format according to Date, DateTime and Time annotations 2013-11-14 11:05:05 +01:00
William DURAND
be130a2d10 Fix incompatibility with Symfony2 2.1
All credits go to @restyler

See: https://github.com/nelmio/NelmioApiDocBundle/pull/237

Closes: #231
Replaces: #237
2013-11-14 11:00:44 +01:00
William Durand
357d1ff967 Merge pull request #262 from skler/issue-259-2
[FIX] Issue 259
2013-11-14 01:47:29 -08:00
William Durand
29965ec7bb Merge pull request #264 from driebit/embedded-forms
Add support for embedded forms
2013-11-14 01:42:43 -08:00
William DURAND
d7fd929379 Fix CS 2013-11-14 10:33:57 +01:00
Samuel ROZE
f02a6729eb Support "callback" on Choice Validator 2013-11-06 15:25:10 +01:00
David de Boer
fbe9488963 Add support for embedded forms 2013-10-23 15:45:30 +02:00
Mauro Foti
018860205c [FIX] Issue 259 2013-10-11 18:29:10 +02:00
Adrien Brault
083ae3aef1 Can now specifiy form name
If you create you forms using FormFactoryInterface::createNamed, then you should now be able to tell the ApiDocBundle the correct form prefix.
2013-10-08 12:09:46 -07:00
Vincent CHALAMON
4fb050175a fix #226 2013-08-16 17:02:18 +02:00
William Durand
96b40b8a8c Merge pull request #210 from jhallbachner/validation2
Added Support for Validation Component (refactored)
2013-08-13 03:28:09 -07:00
Josh Hall-Bachner
54a6ad566d Updated postParse logic to utilize an interface and to avoid unnecessary "supports" checks.
Expanded documentation on new classes and methods.
2013-07-02 21:57:09 -07:00
Josh Hall-Bachner
23f64b84f6 Fixed multi-level validation nesting.
Removed "class" parameters from results after processed.

Updated README.
2013-06-30 23:46:43 -07:00
Josh Hall-Bachner
5e1549a29d Built parse-merging into the ApiDocExtractor.
Wired up a "post-parse" pass to allow recursive parsing across multiple parsers.
2013-06-30 23:46:41 -07:00
Josh Hall-Bachner
0913157399 Added the initial structure for a Symfony Validation handler that is injected into the parsers. 2013-06-30 23:46:41 -07:00
Valentin Ferriere
475c92f17f Update FormTypeParser.php
This catch is missing, because it can break here https://github.com/symfony/Form/blob/master/FormRegistry.php#L89
2013-06-19 10:17:37 +02:00
William Durand
0eb7ec27ec Merge pull request #152 from adriensamson/issue-147
Fix Illegal offset warning in FormTypeParser (closes #147)
2013-06-18 06:44:06 -07:00
Pierre-Yves LEBECQ
13efea8975 Added support for the jms version annotations in formatters 2013-05-12 14:54:01 +02:00
fieg
06271f824a added support for JMS Serializer GroupsExclusionStrategy 2013-05-12 14:29:36 +02:00
Tobias Schultze
d2cd56dafc fix jms metadata parser for hashmaps: array<K, V> 2013-05-10 19:09:57 +02:00
marapper
a97c65da70 Make parameters description conform to others 2013-05-07 23:11:32 +04:00
Benjamin Laugueux
6859384983 Handle the prefix form when parseForm.
Cf. #166 and thanks to @madesst.
2013-04-30 16:19:00 +02:00