293 Commits

Author SHA1 Message Date
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
f8c030d096
Improve "no describer found" error message (#1979) 2022-04-13 19:54:31 +02:00
Baptiste Lafontaine
1302bc7568
Create an enum model describer (#1965)
* Create an enum model describer

* Bump Api-Platform

Co-authored-by: Guilhem Niot <guilhem@gniot.fr>
2022-04-04 11:42:44 +02:00
Guilhem Niot
2295f68b89
Add support of inline path parameters (#1973)
* Add support of inline path parameters

* Fix CS
2022-03-28 14:37:14 +02:00
Guilhem Niot
8111ce645b
Reproduce and fix duplicate operation id errors (#1972)
* Replicate and fix duplicate operation id errors

* Fix CS
2022-03-28 14:36:03 +02:00
Guilhem Niot
e722f642ad Fix the tests 2022-03-21 17:03:22 +01:00
Jack Cutting
9545a0ce52 Allow security policies to be removed using the Security annotation by passing it a name of null. 2022-01-26 17:33:35 +00:00
Guilhem Niot
e0b25e5580 zircote/swagger-php attributes were moved to Attributes namespace 2022-01-10 17:08:13 +01:00
Guilhem Niot
43212d9b7e Context::getRootContext() was removed 2022-01-10 16:50:45 +01:00
Guilhem Niot
ced932b8e7
Test more PHP 8.1 attributes support (#1936)
* Test `@Areas` as a php 8.1 attribute

* Test `@Security` as PHP 8.1 attribute
2021-12-21 16:39:08 +01:00
Alex Kalineskou
cc97b0ba45
Add support for php attributes (#1932)
* Add support for php attributes

* Fix tests for php 8.1

* Simplify the annotations

* Revert the changes to the tests

* CS

* Test FOSRest parsing of attributes

* CS

* typo

* CS

* Test fetchArticle php 8.1 attributes

* Fix namespaces

Co-authored-by: Guilhem Niot <guilhem@gniot.fr>
2021-12-21 16:16:14 +01:00
Guilhem Niot
ab99b4bcb9 Fix api-platform routes import 2021-12-21 13:52:16 +01:00
Guilhem Niot
0fada289f5 Fix CS 2021-12-21 13:46:02 +01:00
Guilhem Niot
b4c74ee938 Fix retrieval of container in tests 2021-12-21 13:41:49 +01:00
Fabiano Roberto
e04521ebea Fix usage of configureRoutes in tests 2021-12-21 11:54:39 +01:00
Alexey Alshenetsky
7de49bb4a8
Add missing null check to ControllerReflector::getReflectionMethod (#1918)
* add null check

https://github.com/nelmio/NelmioApiDocBundle/issues/1909

* less code is better

* add tests for ControllerReflection::getReflectionMethod()

* lint fix

* style_ci fixes

Co-authored-by: Alexey <alshenestky@icloud.com>
2021-12-12 01:32:51 +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
Guilhem Niot
a184cb8ef4
Fix deprecations (#1923) 2021-12-11 14:19:43 +01:00
Guilhem Niot
82bb3cb916
Fix usage of getCollectionValueTypes and getCollectionKeyTypes (#1910)
* Fix usage of getCollectionValueTypes and getCollectionKeyTypes

* fix cs
2021-11-30 13:06:32 +01:00
Vladislav
d59dbbd859
Issue 1848 operation id by route name (#1907)
* Fix #1885 update psr/log and psr/container

* Issue #1848 operation id by route name

Co-authored-by: Vlad Gaiduk <uahaiduk@gmail.com>
2021-11-22 20:18:16 +01:00
Guilhem Niot
e16d1fedb9 Fix CS 2021-11-04 00:09:07 +01:00
Guilhem Niot
200ec0fdcb Merge branch '3.x' 2021-11-04 00:06:42 +01:00
Samaël tomas
efa83ca54e
Fix OpenApiRenderer list could be null (#1881)
Co-authored-by: Samael tomas <samael.tomas@wizbii.com>
2021-10-19 14:29:11 +02:00
Frederik Holz
aa18c6c83b
[3.x]: Hide the default section per area with new config parameter (#1868)
* Add new config node disable_default_routes to prevent registering RouteDescriber to specific areas which allowes disabling rendering of default routes, Adjust tests accordingly

* Add documentation for new config variable

* Change disable_default_routes to filter route collection instead of disabling route describer, Add test for new handling in FilteredRouteCollectionBuilder

* Change naming of matching method for disabling default routes

* Fix codestyle issue

* Fix codestyle issue

* Change naming of dataProvider to match testing name

Co-authored-by: Frederik Holz <team-orange@auxmoney.com>
2021-10-06 19:28:59 +02:00
Guilhem Niot
9c729ab7b7
Fix support without twig (#1878)
* fix support without twig

* Support null openApiRenderer

* Register a twig extension instead of registering twig function at runtime

* fix tests
2021-09-22 23:43:32 +02:00
Zdeněk Drahoš
1a21f1855e Enable overriding server url for yaml and json export from console 2021-07-29 12:22:54 +02:00
Zdeněk Drahoš
1b9be28ad6 Enable dumping docs to yaml 2021-07-29 11:57:00 +02:00
Zdeněk Drahoš
2c890ff93b Hotfix testing private service in Symfony < 5.3
https://github.com/nelmio/NelmioApiDocBundle/runs/3031148906?check_suite_focus=true#step:7:106
Error: Call to undefined method Nelmio\ApiDocBundle\Tests\Render\Html\GetNelmioAssetTest::getContainer()

https://symfony.com/blog/new-in-symfony-4-1-simpler-service-testing
In practice, tests based on WebTestCase and KernelTestCase now access to a special container via the static::$container property that allows fetching non-removed private services:

https://github.com/symfony/symfony/blob/5.3/CHANGELOG-5.3.md#changelog-for-53x
feature #40366 [FrameworkBundle] Add KernelTestCase::getContainer() (Nyholm)
static $container @deprecated since Symfony 5.3, use static::getContainer() instead
2021-07-10 18:00:11 +02:00
Zdeněk Drahoš
9cb6006b69 Refactoring including assets 2021-06-27 10:00:43 +02:00
Zdeněk Drahoš
5124f07ece Enable dumping html docs with cdn and offline assets 2021-06-27 09:24:35 +02:00
Zdeněk Drahoš
4ebee933c4 Extract rendering docs from command and controller 2021-06-27 08:41:33 +02:00
Asmir Mustafic
985b43fb60
log name collisions (#1862) 2021-08-17 21:51:11 +02:00
Asmir Mustafic
0bcdc59b88
add missing typehint 2021-08-16 15:19:26 +02:00
Asmir Mustafic
497afa1361
improve testing by checking explicitly that collisions are not generated 2021-08-16 13:11:59 +02:00
Guilhem Niot
be014ff11b
Merge pull request #1830 from nelmio/ADDPROP
Fix additionalProperties support
2021-08-03 09:35:12 +02:00
Alexander Melihov
2df454c0c3
Compound validation rule support (#1818)
* Compound validation rule support

* Compound validation rule support

* Compound validation rule support

* Compound validation rule support

* Remove duplicated method

* error during merge

* wrong variable name

* Simplify PR

* Fix CS

* Use same indentation as before

Co-authored-by: Guilhem Niot <guilhem@gniot.fr>
Co-authored-by: Guilhem Niot <guilhem.niot@gmail.com>
2021-06-16 09:59:06 +02:00
Guilhem Niot
305668a345 Explictly enable property access in the tests (related to https://github.com/symfony/symfony/pull/40140, it is a dev dependency) 2021-06-14 13:28:11 +02:00
Guilhem Niot
ee00f02a48 Fix additionalProperties support 2021-06-07 19:23:02 +02:00
Guilhem Niot
d8a7859484 Explictly enable property access in the tests (related to https://github.com/symfony/symfony/pull/40140, it is a dev dependency) 2021-06-07 19:04:16 +02:00
Christopher Davis
5f1645db40 Check min/max On Range Constraints Before Use
Previously it was possible to set only one of the min or max values and
get a schema like:

    "property": {
      "type": "integer",
      "minimum": 1,
      "maximum": 0
    }

Also possible that `Range` would be used with {min,max}PropertyPath and
you'd get a schema with both minimum and max set to zero.

With the checks in place, that's no longer the case.
2021-05-25 06:44:16 -05:00
Christopher Davis
7fd8c0ecfe Check if min and max Are Set on Count Constraints
It's possible to set a count constraint with a min but no max, which
would generate an OpenAPI Schema like...

    "property": {
        "type": "array",
        "minItems": 1,
        "maxItems": 0
    }

With this change the schema will only set `minItems` in that example.
2021-05-25 06:44:09 -05:00
Guilhem Niot
bf77277f2f
Merge pull request #1788 from raziel057/patch-1
Fix Open API doc for DateTime requirements
2021-03-26 22:54:00 +01:00
tlallement
0e7ebe5650 Small fixes for RFC3339 and new assertion 2021-03-24 18:01:32 +01:00
Thomas Lallement
a72588861f Add support for 'c' format 2021-03-16 11:05:00 +01:00
Thomas Lallement
73ad2e3cdf Fix property naming 2021-03-16 10:42:37 +01:00
Thomas Lallement
7f9b00d620 Code improvements and add unit test 2021-03-16 10:40:12 +01:00
Javier Spagnoletti
b08bf79212 Fix calls to nonexistent method ControllerReflector::getReflectionClassAndMethod() 2021-03-14 17:19:25 +01:00
Guilhem Niot
f857061475
Merge pull request #1791 from phansys/useless_checks
Remove old useless configurations from tests
2021-03-14 17:08:49 +01:00
Alexander M. Turek
12ac91bfcd Added support for constraint attributes 2021-03-14 17:02:52 +01:00
Alexander M. Turek
16221de418 Added support for constraint attributes 2021-03-12 10:57:40 +01:00