Skip to content
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

Allow unset PathItem method #4107

Merged
merged 3 commits into from
Mar 2, 2021
Merged

Conversation

soyuka
Copy link
Member

@soyuka soyuka commented Mar 2, 2021

After disabling itemOperation GET

    itemOperations: [
        'get' => [
            'controller' => ApiPlatform\Core\Action\NotFoundAction::class,
            'read' => false,
            'output' => false,
        ],
    ]

there is not nice way to remove that path from OpenApi docs. Now to do
that you have to write:

$pathItem = $openApi->getPaths()->getPath('/resource/{id}');
$openApi->getPaths()->addPath(
    '/resource/{id}',
    new Model\PathItem(
        $pathItem->getRef(),
        $pathItem->getSummary(),
        $pathItem->getDescription(),
        null,
        $pathItem->getPut(),
        $pathItem->getPost(),
        $pathItem->getDelete(),
        $pathItem->getOptions(),
        $pathItem->getHead(),
        $pathItem->getPatch(),
        $pathItem->getTrace(),
        $pathItem->getServers(),
        $pathItem->getParameters(),
    )
);

After change it will be:

$pathItem = $openApi->getPaths()->getPath('/resource/{id}');
$openApi->getPaths()->addPath(
    '/resource/{id}',
    $pathItem->withGet(null)
);
Q A
Branch? main for features / current stable version branch for bug fixes
Bug fix? yes/no
New feature? yes/no
Deprecations? yes/no
Tickets Fix #...
License MIT
Doc PR api-platform/docs#...

d0niek and others added 2 commits March 2, 2021 09:09
After disabling itemOperation `GET`

```
    itemOperations: [
        'get' => [
            'controller' => ApiPlatform\Core\Action\NotFoundAction::class,
            'read' => false,
            'output' => false,
        ],
    ]
```

there is not nice way to remove that path from OpenApi docs. Now to do
that you have to write:

```
$pathItem = $openApi->getPaths()->getPath('/resource/{id}');
$openApi->getPaths()->addPath(
    '/resource/{id}',
    new Model\PathItem(
        $pathItem->getRef(),
        $pathItem->getSummary(),
        $pathItem->getDescription(),
        null,
        $pathItem->getPut(),
        $pathItem->getPost(),
        $pathItem->getDelete(),
        $pathItem->getOptions(),
        $pathItem->getHead(),
        $pathItem->getPatch(),
        $pathItem->getTrace(),
        $pathItem->getServers(),
        $pathItem->getParameters(),
    )
);
```

After change it will be:

```
$pathItem = $openApi->getPaths()->getPath('/resource/{id}');
$openApi->getPaths()->addPath(
    '/resource/{id}',
    $pathItem->withGet(null)
);
```
@soyuka soyuka merged commit ce6ff3f into api-platform:2.6 Mar 2, 2021
@soyuka soyuka deleted the fix/openapi-pathitem branch March 2, 2021 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants