getDetailResponse example

public function getAdminContext(): Context
    {
        return new Context(new AdminApiSource(Uuid::randomHex()));
    }

    public function testAdminApi(): void
    {
        $id = Uuid::randomHex();
        $accept = 'application/json';
        $context = $this->getAdminContext();
        $response = $this->getDetailResponse($context$id, '/api/category/' . $id$accept, false);

        static::assertEquals($accept$response->headers->get('content-type'));
        $content = $response->getContent();
        static::assertIsString($content);
        $content = json_decode($content, true, 512, \JSON_THROW_ON_ERROR);
        static::assertEquals($id$content['data']['name']);
    }

    public function testAdminJsonApi(): void
    {
        $id = Uuid::randomHex();
        
if ($experimental = $this->isExperimental($definition)) {
            $tags[] = 'Experimental';
        }

        return new Get([
            'summary' => 'Detailed information about a ' . $this->convertToHumanReadable($definition->getEntityName()) . ' resource.' . ($experimental ? ' Experimental API, not part of our backwards compatibility promise, thus this API can introduce breaking changes at any time.' : ''),
            'description' => $definition->since() ? 'Available since: ' . $definition->since() : '',
            'operationId' => 'get' . $this->convertToOperationId($definition->getEntityName()),
            'tags' => $tags,
            'parameters' => [$this->getIdParameter($definition)],
            'responses' => [
                Response::HTTP_OK => $this->getDetailResponse($schemaName),
                Response::HTTP_NOT_FOUND => $this->getResponseRef((string) Response::HTTP_NOT_FOUND),
                Response::HTTP_UNAUTHORIZED => $this->getResponseRef((string) Response::HTTP_UNAUTHORIZED),
            ],
        ]);
    }

    private function getCreatePath(EntityDefinition $definition): Post
    {
        $schemaName = $this->snakeCaseToCamelCase($definition->getEntityName());

        $tags = [$this->convertToHumanReadable($definition->getEntityName())];

        
Home | Imprint | This part of the site doesn't use cookies.