NelmioApiDocBundle/ModelDescriber/Annotations
Christopher Davis 883d7b6c89
Apply enum from Choice Constraints to Items When Choice is Multiple (#1784)
* Apply `enum` from Choice Constraints to Items When Choice is Multiple

Otherwise JSON schema like this is generated:

```
"property": {
  "type": "array",
  "enum": ["one", "two", "three"],
  "items": {
    "type": "string"
  }
}
```

With this change, however, this schema is generated:

```
"property": {
  "type": "array",
  "items": {
    "type": "string",
    "enum": ["one", "two", "three"]
  }
}
```

A possible downside here is that the symfony constraint stuff happens
before types are figured out from PHPDoc. So it's _possible_ to end up
with something that won't validated. Take something like this:

```
/**
 * @Assert\Choice(multiple=true, choices={"..."})
 * @var string
 */
```

This would generate:

```
"property": {
  "type": "string",
  "items": {
    "enum": ["..."]
  }
}
```

* Fix CS

* cs

* more cs

* fix tests

Co-authored-by: Guilhem Niot <guilhem@gniot.fr>
2021-02-19 09:41:32 +01:00
..
AnnotationsReader.php Merge remote-tracking branch 'origin/3.x' into HEAD 2020-07-12 15:07:56 +02:00
OpenApiAnnotationsReader.php Merge remote-tracking branch 'origin/3.x' into HEAD 2020-07-12 15:07:56 +02:00
PropertyPhpDocReader.php Merge remote-tracking branch 'origin/3.x' into HEAD 2020-07-12 15:07:56 +02:00
SymfonyConstraintAnnotationReader.php Apply enum from Choice Constraints to Items When Choice is Multiple (#1784) 2021-02-19 09:41:32 +01:00