Conversation
| return new JsonResponse(['status' => 'success'], 200); | ||
| } | ||
|
|
||
| #[Route(path: '/api/packages/{package}/delete-version/{version}', name: 'api_delete_package_version', requirements: ['package' => '[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+?'], defaults: ['_format' => 'json'], methods: ['POST'])] |
There was a problem hiding this comment.
I think should should be a path /api/packages/{package}/versions/{version} instead, using the DELETE method
|
|
||
| <pre> | ||
| POST https://{{ packagist_host }}/api/update-package?username=[username]&apiToken=[apiToken] {"repository":"[url]"} | ||
| PUT https://{{ packagist_host }}/api/update-package?username=[username]&apiToken=[apiToken] {"repository":"[url]"} |
There was a problem hiding this comment.
This is wrong. This endpoints receiving a webhook to trigger an update of the method of this package expects the POST method, not PUT
| <h3 id="delete-package-version">Delete a package version</h3> | ||
|
|
||
| <p>This endpoint deletes a package version by package name and version. Parameters <code>username</code> and <code>apiToken</code> are required. Only the <code>POST</code> method is allowed. The <code>content-type: application/json</code> header is required.</p> | ||
| <p>This endpoint is considered SAFE and allows either your main or safe <a href="{{ path('my_profile') }}">API token</a> to be used.</p> |
There was a problem hiding this comment.
should this be considered safe ?
| } | ||
|
|
||
| $repo = $this->getEM()->getRepository(Version::class); | ||
| $repo->remove($packageVersion); |
There was a problem hiding this comment.
this should be wrapped in $em->transactional() (which calls flush() automatically at the end) or $em->getConnection()->transactional() (keeping an explicit flush of the entity manager inside the closure) to ensure that the removal is done in a transactional way.
|
|
||
| #[Route(path: '/api/packages/{package}', name: 'api_edit_package', requirements: ['package' => '[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+?'], defaults: ['_format' => 'json'], methods: ['PUT'])] | ||
| public function editPackageAction(Request $request, Package $package, ValidatorInterface $validator, StatsDClient $statsd): JsonResponse | ||
| public function editPackageAction(Request $request, #[MapEntity(mapping: ['package' => 'name'])] Package $package, ValidatorInterface $validator, StatsDClient $statsd): JsonResponse |
There was a problem hiding this comment.
this looks like a different change than adding a new API endpoint.
Fixed Edit Package API
and Docs with the correct HTTP method
New Delete Package Version API
Similar to whats right now possible to be able to delete a package version