Skip to content

Allow unset PathItem method#4099

Closed
d0niek wants to merge 16 commits into
api-platform:2.6from
d0niek:main
Closed

Allow unset PathItem method#4099
d0niek wants to merge 16 commits into
api-platform:2.6from
d0niek:main

Conversation

@d0niek

@d0niek d0niek commented Feb 25, 2021

Copy link
Copy Markdown
Contributor

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#...

dunglas and others added 16 commits January 24, 2021 18:18
* 2.6:
  docs: update changelog
  fix: defaults when using attributes (api-platform#3978)
* fix: load swagger even when conf is false

* fix: change aliases and definitions for swagger disabled in tests

* fix: manage necessary services loading

* fix typo
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)
);
```

@alanpoulain alanpoulain left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soyuka could you check it too?

@soyuka

soyuka commented Mar 1, 2021

Copy link
Copy Markdown
Member

can you target 2.6?

@soyuka soyuka mentioned this pull request Mar 1, 2021
@d0niek

d0niek commented Mar 1, 2021

Copy link
Copy Markdown
Contributor Author

can you target 2.6?

Do you mean merge to branche 2.6 instead of main?

@soyuka

soyuka commented Mar 1, 2021

Copy link
Copy Markdown
Member

yes please, and you will have to rebase then :)

@soyuka soyuka changed the base branch from main to 2.6 March 2, 2021 08:14
@soyuka

soyuka commented Mar 2, 2021

Copy link
Copy Markdown
Member

I don't want to mess your `main branch, I picked your commit at #4107

Thanks!

@soyuka soyuka closed this Mar 2, 2021
@d0niek

d0niek commented Mar 2, 2021

Copy link
Copy Markdown
Contributor Author

@soyuka so I don't have to do new PR?

I hope I helped you :-)

@soyuka

soyuka commented Mar 2, 2021

Copy link
Copy Markdown
Member

Yes thanks for your patches I've added them :)

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.

9 participants