58 Commits

Author SHA1 Message Date
Asmir Mustafic
883049a9e0 use the configured context factory to create the serialization context 2022-08-22 20:45:23 +02:00
Christopher Davis
235963df41
Merge pull request #1902 from chrisguitarguy/constraint_groups
Respect Constraint Validation Groups When Describing Models
2022-06-10 16:15:42 -05:00
Guilhem Niot
be8499ffdc
Merge pull request #1988 from nelmio/ROOTCONTEXT
Use the same root context everywhere
2022-06-10 20:52:06 +02:00
Christopher Davis
6b2ef45b24 Merge remote-tracking branch 'origin/master' into constraint_groups 2022-05-11 08:18:52 -05:00
Christopher Davis
da02f3ad33
Stop Model Property Description When a Schema Type or Ref is Already Defined (#1978)
* Return a Result Object from AnnotationsReader::updateDefinition

This is so we can make a decision on whether or not a schema's type or
ref has been manually defined by a user via an `@OA\Schema` annotation
as something other than an object.

If it has been defined, this bundle should not read model properties any
further as it causes errors.

I put this in AnnotationReader as it seemed the most flexible in the
long run. It could have gone in `OpenApiAnnotationsReader`, but then any
additional things added to `updateDefinition` could be left out of the
decision down the road. This is also a convenient place to decide this
once for `ObjectModelDescriber` and `JMSModelDescriber`.

* Stop Model Describer if a Schema Type or Ref Has Been Defined

Via the result object added in the previous commit.

This lets user "short circuit" the model describers by manually defining
the schema type or ref on a plain PHP object or form. For example,
a collection class could be defined like this:

    /**
     * @OA\Schema(type="array", @OA\Items(ref=@Model(type=SomeEntity::class)))
     */
     class SomeCollection implements \IteratorAggregate { }

Previously the model describer would error as it tries to merge the
`array` schema with the already defiend `object` schema. Now it will
prefer the array schema and skip reading all the properties of the
object.

* Add a Documentation Bit on Stopping Property Description

* Mark UpdateClassDefinitionResult as Internal
2022-04-30 20:28:05 +02:00
Guilhem Niot
52e7fc4de1 Use the same root context everywhere 2022-04-30 20:07:44 +02:00
Guilhem Niot
ade4b6c17c
Merge branch 'master' into constraint_groups 2021-12-19 11:38:47 +01:00
Alexey Alshenetsky
14383f4ee5
Add support for zircore/swagger-php 4.0 (#1916)
* add zircore/swagger-php v4 to composer.json

* fix incompatibilities

* add compatibility with 3.2

* Apply fixes from StyleCI

* mark SetsContextTrait as internal

* Bump php version

Co-authored-by: Alexey <alshenestky@icloud.com>
Co-authored-by: Alexey Alshenetsky <alshenetsky@users.noreply.github.com>
Co-authored-by: Guilhem Niot <guilhem@gniot.fr>
2021-12-11 14:39:04 +01:00
Christopher Davis
7357de9c16 Add a Configuration Option to Enable Validation Groups
If this was turned on by default, that seems like a _large_ BC break as
folks entire OpenAPI doc could change underneath them.

The config option defaults to false and users can enable it if they
desire.
2021-11-06 07:13:56 -05:00
Guilhem Niot
4436c468f1 Fix the tests broken by zircote/swagger-php 2020-09-27 22:20:04 +02:00
Guilhem Niot
5b6983e179 Fix the JMSModelDescriber 2020-09-09 08:35:01 +02:00
Paul Dugas
fcb52246b2
Ignore ReflectionException for "magic" JMS\Accessor methods (#1715)
* Update JMSModelDescriber.php

Ignore ReflectionException thrown when getter or setter from JMS\ Accessor are "magic" methods.

* Add tests to avoid future regressions

* CS

Co-authored-by: Guilhem Niot <guilhem.niot@gmail.com>
2020-09-09 08:27:47 +02:00
Guilhem Niot
23fdbf0412 Merge branch '3.x' 2020-08-06 10:29:17 +02:00
Guilhem Niot
edf6b70175 Apply StyleCI fixes 2020-08-06 10:26:59 +02:00
Guilhem Niot
523d28e955
Add annotations support at methods level when using the JMS serializer (#1682) 2020-07-18 13:31:41 +02:00
Guilhem Niot
545432f7ec Support annotations for virtual properties 2020-07-18 10:10:37 +02:00
Filip Benčo
78664ef9ec
OpenApi 3 Support (#1623)
* Initial pass for OA3 upgrade

* Fix Util Tests

* Fix first batch of Unit Tests. Up to Model

* Another batch of fixed tests

* Update annotations

* Convert Model & Property Describers

* Update tests, Fix RouteDescribers, FIx additional bugs

* Another batch of updates

* Another batch of fixed Functional Tests

* Fix FunctionalTest tests

* Fix Bazinga Tests

* FIx FOS Rest

* Fix JMS TEsts & describers

* Fix all Tests

* Fix few stuff from own CR

* CS Fixes

* CS Fixes 2

* CS Fixes 3

* CS Fixes 4

* Remove collection bug

* Updates after first CRs

* CS

* Drop support for SF3

* Update the docs

* Add an upgrade guide

* misc doc fixes

* Configurable media types

* Code Style Fixes

* Don't use ::$ref for @Response and @RequestBody

* Fix upgrading guide

* Fix OA case

Co-authored-by: Filip Benčo <filip.benco@websupport.sk>
Co-authored-by: Guilhem Niot <guilhem.niot@gmail.com>
Co-authored-by: Mantis Development <mantis@users.noreply.github.com>
2020-05-28 13:19:11 +02:00
Asmir Mustafic
2fd95e2242
add support for jms serializer inline property feature 2020-05-07 20:02:10 +02:00
Guilhem Niot
d58b4a4d66 Apply fixes from StyleCI 2020-02-23 16:50:24 +00:00
Nadrshin
99f5d37601 Support JMS "bool" type (alias for "boolean") (#1547) 2019-11-14 21:06:26 +01:00
Asmir Mustafic
eb255010a0 Support typed embedded relation with willdurand/hateoas 3.0 (#1510)
* allow typed embedded relation with hateoas 3.0

* symfony/framework-bundle 4.2.7 is broken

https://github.com/symfony/symfony/pull/31156

* internal public methods
2019-05-02 10:02:16 +02:00
Asmir Mustafic
65e940f7f8
use jms serialization groups detection 2019-04-17 22:05:30 +02:00
Asmir Mustafic
d6ea99420e Allow model describers on jms custom types (#1495)
* allow model describers on jms custom types

* add fallback describer

* test custom type def

* remove object_fallback describer from the container when jms is not active
2019-04-16 12:13:33 +02:00
Guilhem N
73f07aac50
Tipo 2019-02-13 21:18:18 +01:00
Guilhem N
0414277d0a
Minor fix 2019-02-13 21:13:17 +01:00
Asmir Mustafic
fd7b5e1679
fix missing previous recursive call 2019-01-26 21:03:21 +01:00
Asmir Mustafic
0fb5d7afa2
jms 2.0 groups tested 2019-01-26 21:03:21 +01:00
Asmir Mustafic
d15b4123c1
add hateoas v3 compat 2019-01-26 20:55:52 +01:00
Asmir Mustafic
66bcf02903
when the naming strategy is not available, we are using jms/serializer 2.0 2019-01-26 20:55:29 +01:00
Asmir Mustafic
9bae1115d6 jms serializer group names are based on the internal property name, not on the serialized name (#1421) 2018-10-17 17:19:37 +02:00
Asmir Mustafic
7f78ef9ba6 Restore jms nested groups feature (#1402)
* fix missing variable definition

* fix caching typo

* do not pre allocate reserved names

* use model hash instead of spl hash

* register later the model
2018-10-10 17:24:13 +02:00
Asmir Mustafic
bd26696f8f respect jms serializer nested group exclusion 2018-08-26 22:58:35 +02:00
Javier Spagnoletti
df9893428e [JMSModelDescriber] Allow to use free form objects from JMS serialization (#1368)
* [JMSModelDescriber] Allow to use free form objects from JMS serialization

* Remove unused variable

* Refactor `describeItem()`

* Add more tests

* early detect of free form objects

* Add test for array property without type

* Merge `findPropertyType()` and `registerPropertyType()` methods

* Update `registerPropertyType()` in order to set "object" as type for arrays with undefined item types

* Set "additionalProperties" definition for arrays without defined items

* Simplified `registerPropertyType()`

* Merged `registerPropertyType()` into `describeItem()`

* Fix comment

* Fix comment
2018-08-21 17:41:32 +02:00
Asmir Mustafic
09e6f30572 Jms serializer default groups should not generate new definitions when possible (#1367)
* if the group does not define per property exclusion, then remove possible obsolete property exclusions

* if the group is using only the default group, then is as not defining a group

* test that the user does not get a new alias just because another property pf the same object has some groups

* use strict comparison
2018-07-26 14:14:26 +02:00
Javier Spagnoletti
1063972c27 [JMSModelDescriber] Update JMSModelDescriber in order to iterate over nested array definitions (#1365) 2018-07-23 18:35:05 +02:00
Javier Spagnoletti
dbd2076921 Normalize description for classes implementing \DateTimeInterface 2018-05-04 15:22:18 -03:00
Asmir Mustafic
c5b1d538f8 Improve support for JMS dictionaries (associative arrays) (#1301)
* improve support for JMS dictionaries (associative arrays)

Doc: https://swagger.io/docs/specification/data-models/dictionaries/

* use schema merge instead of reflection
2018-04-21 16:57:37 +02:00
Guilhem Niot
8026ff46eb Support `@Model` in in-object annotations 2018-03-22 19:14:01 +01:00
Guilhem Niot
7d99a96cf4 Allow to change a property name 2018-02-19 21:42:56 +01:00
Guilhem N
f193fdb1f1
Inject the AnnotationsReader in Model describers instead of internal classes (#1203) 2018-01-24 19:58:38 +01:00
Robert Gruber
fe9d12772b Add some missing property attributes for JMS model describer (#1196)
* Add some missing property attributes for JMS model describer

* Introduce own Swagger definition annotation reader

* Shorten annotation mapping by using merge
2018-01-24 15:20:20 +01:00
Guilhem N
73a5f104d6
Use @SWG\Parameter type when set instead of throwing (#1174)
* Add an exception

* Just use the manually defined type when set

* Update the jms model describer
2018-01-11 12:26:59 +01:00
Guilhem Niot
eb77f3708c Cleanup 2018-01-04 11:34:23 +01:00
Guilhem N
8a53891ee9
Merge pull request #1132 from 7thcubic/complex_groups
Fix complex groups context for jms models
2018-01-03 12:01:06 +01:00
David Buchmann
f4a9ad7ef7 do not fail if phpdocumentor is not available 2017-12-28 10:46:05 +01:00
David Buchmann
75cf1201ed Apply fixes from StyleCI 2017-12-22 17:42:18 +00:00
Guilhem N
48107de67d
Merge branch 'master' into complex_groups 2017-12-21 17:17:36 +01:00
David Buchmann
3fa948aee8 set up DI and add type support 2017-12-19 08:56:35 +01:00
David Buchmann
fe3629cdeb WIP parse phpdoc annotations in jms models 2017-12-19 08:56:35 +01:00
Yi Ping
3b81fa4f2f changes 2017-12-18 08:06:19 +08:00