Skip to content

openapi.parameters in yaml extractor not work #5484

@jorissae

Description

@jorissae

API Platform version(s) affected: 3.1.*

Description

The new key openApi which replace the openApiContext use a Parameter Object but the openapi.parameter array is not converted in Parameter[] when I use yaml

How to reproduce

use openapi.parameter on any yaml resource:

        openapi:
          parameters:
            username:
              name: username
              in: path
              example: "foo"
            customerAlias:
              name: customerAlias
              in: path
              example: 111112

image

Suggestion

add array to parameter converter in YamlResourceExtractor (like XmlResourceExtractor)

<?php
$parameters = [];
if(\array_key_exists('parameters', $resource['openapi'])) {
    foreach ($resource['openapi']['parameters'] as $parameter) {
        $parameters[] = new Parameter($parameter['name'], $parameter['in'], $parameter['description'] ?? '', $parameter['required'] ?? false, $parameter['deprecated'] ?? false, $parameter['allowEmptyValue'] ?? false, $parameter['schema'] ?? [], $parameter['style'] ?? null, $parameter['explode'] ?? false, $parameter['allowReserved '] ?? false, $parameter['example'] ?? null, isset($parameter['examples']) ? new \ArrayObject($parameter['examples']) : null, isset($parameter['content']) ? new \ArrayObject($parameter['content']) : null);
    }
    $resource['openapi']['parameters'] = $parameters;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions