Skip to content

fix(openapi): nullable default values in operation openapi definition #7318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* [c41a0bca4](https://github.com/api-platform/core/commit/c41a0bca49778663743a52e9da9ddb3b1439c2f8) fix(jsonld): child class @type shortName (#7312)
* [d26088ba1](https://github.com/api-platform/core/commit/d26088ba1080f9fb8d94db5b476b0322d2a14ab2) chore: allow doctrine-persistence:^4.0 (#7309)
* [e0754a2f](https://github.com/api-platform/core/commit/e0754a2f606e6279269722ef81b4b11fc927d836) fix(openapi): nullable default values in operation openapi definition

## v4.1.19

Expand Down
10 changes: 5 additions & 5 deletions src/Metadata/Extractor/XmlResourceExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ private function buildOpenapi(\SimpleXMLElement $resource): bool|OpenApiOperatio
in: $this->phpize($parameter, 'in', 'string'),
description: $this->phpize($parameter, 'description', 'string'),
required: $this->phpize($parameter, 'required', 'bool'),
deprecated: $this->phpize($parameter, 'deprecated', 'bool'),
allowEmptyValue: $this->phpize($parameter, 'allowEmptyValue', 'bool'),
schema: isset($parameter->schema->values) ? $this->buildValues($parameter->schema->values) : null,
deprecated: $this->phpize($parameter, 'deprecated', 'bool', false),
allowEmptyValue: $this->phpize($parameter, 'allowEmptyValue', 'bool', false),
schema: isset($parameter->schema->values) ? $this->buildValues($parameter->schema->values) : [],
style: $this->phpize($parameter, 'style', 'string'),
explode: $this->phpize($parameter, 'explode', 'bool'),
allowReserved: $this->phpize($parameter, 'allowReserved', 'bool'),
explode: $this->phpize($parameter, 'explode', 'bool', false),
allowReserved: $this->phpize($parameter, 'allowReserved', 'bool', false),
example: $this->phpize($parameter, 'example', 'string'),
examples: isset($parameter->examples->values) ? new \ArrayObject($this->buildValues($parameter->examples->values)) : null,
content: isset($parameter->content->values) ? new \ArrayObject($this->buildValues($parameter->content->values)) : null,
Expand Down
17 changes: 15 additions & 2 deletions src/OpenApi/Model/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@ final class Parameter
{
use ExtensionTrait;

public function __construct(private string $name, private string $in, private string $description = '', private bool $required = false, private bool $deprecated = false, private bool $allowEmptyValue = false, private array $schema = [], private ?string $style = null, private bool $explode = false, private bool $allowReserved = false, private $example = null, private ?\ArrayObject $examples = null, private ?\ArrayObject $content = null)
{
public function __construct(
private string $name,
private string $in,
private string $description = '',
private bool $required = false,
private bool $deprecated = false,
private bool $allowEmptyValue = false,
private array $schema = [],
private ?string $style = null,
private bool $explode = false,
private bool $allowReserved = false,
private $example = null,
private ?\ArrayObject $examples = null,
private ?\ArrayObject $content = null,
) {
if (null === $style) {
if ('query' === $in || 'cookie' === $in) {
$this->style = 'form';
Expand Down
Loading