Skip to content

Commit

Permalink
Trial and error for nelmio
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Apr 2, 2024
1 parent 3c3359e commit 8505145
Show file tree
Hide file tree
Showing 29 changed files with 226 additions and 243 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"pimcore/static-resolver-bundle": "^1.3",
"pimcore/generic-data-index-bundle": "1.x-dev",
"pimcore/pimcore": "^11.0",
"api-platform/core": "^3.2"
"api-platform/core": "^3.2",
"nelmio/api-doc-bundle": "^4.2"
},
"require-dev": {
"pimcore/admin-ui-classic-bundle": "^v1.3",
Expand Down
36 changes: 36 additions & 0 deletions config/api/V1/translation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/api/v1/translations:
post:
tags: [Translation]
summary: Get all translations
requestBody:
description: Locale and array of keys
content:
application/json:
schema:
ref: '#/components/schemas/Translation'
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
locale:
type: string
example: en
keys:
type: array
items:
type: string
example: 'key1'
'403':
description: Unauthorized
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: 'Unauthorized'
31 changes: 0 additions & 31 deletions config/api_platform/resources/asset.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions config/api_platform/resources/asset/document.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions config/api_platform/resources/asset/image.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions config/api_platform/resources/asset/video.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions config/api_platform/resources/schedule/task.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions config/api_platform/resources/token/create.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions config/api_platform/resources/token/refresh.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions config/api_platform/resources/translation.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions config/api_platform/resources/user.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions config/api_platform/resources/version.yaml

This file was deleted.

43 changes: 23 additions & 20 deletions config/pimcore/config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
api_platform:
title: 'Pimcore Studio API'
description: 'API for Pimcore Studio UI'
version: 0.0.1
graphql:
graphql_playground: false
graphiql:
enabled: false
event_listeners_backward_compatibility_layer: false
keep_legacy_inflector: false
enable_docs: true
enable_entrypoint: false
enable_swagger_ui: false
enable_re_doc: false
show_webby: false
swagger:
api_keys:
access_token:
name: 'Authorization'
type: 'header'
imports:
- { resource: 'packages/nelmio_api_doc.yaml' }

#api_platform:
# title: 'Pimcore Studio API'
# description: 'API for Pimcore Studio UI'
# version: 0.0.1
# graphql:
# graphql_playground: false
# graphiql:
# enabled: false
# event_listeners_backward_compatibility_layer: false
# keep_legacy_inflector: false
# enable_docs: true
# enable_entrypoint: false
# enable_swagger_ui: false
# enable_re_doc: false
# show_webby: false
# swagger:
# api_keys:
# access_token:
# name: 'Authorization'
# type: 'header'

pimcore:
translations:
Expand Down
14 changes: 14 additions & 0 deletions config/pimcore/packages/nelmio_api_doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
nelmio_api_doc:
models:
names:
- { alias: Translation, type: Pimcore\Bundle\StudioApiBundle\Dto\Translation }
areas:
path_patterns: # an array of regexps (document only routes under /api, except /api/doc)
- ^/api(?!/doc$)
host_patterns: # document only routes with a host of the form api.*
- ^api\.
documentation:
info:
title: My API
description: My API Description
version: 1.0.0
16 changes: 15 additions & 1 deletion config/pimcore/routing.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
api_platform:
resource: .
type: api_platform
prefix: /api
prefix: /testtesttest


api_platform_swagger_ui:
path: /api/doc/swagger
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }


studio_api:
resource: "../../src/Controller/Api"
type: annotation
prefix: /api
options:
expose: true
9 changes: 7 additions & 2 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ services:
- { name: security.voter }

#Decorators
Pimcore\Bundle\StudioApiBundle\ApiPlatform\OpenApiFactoryDecorator:
decorates: 'api_platform.openapi.factory'
#Pimcore\Bundle\StudioApiBundle\ApiPlatform\OpenApiFactoryDecorator:
#decorates: 'api_platform.openapi.factory'

#Service Locator
generic_data_index.asset_hydrator.service_locator:
Expand All @@ -126,3 +126,8 @@ services:
Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Asset\SearchResult\SearchResultItem\Text: '@Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\Asset\TextHydratorInterface'
Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Asset\SearchResult\SearchResultItem\Unknown: '@Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\Asset\UnknownHydratorInterface'
Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Asset\SearchResult\SearchResultItem\Video: '@Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\Asset\VideoHydratorInterface'


Pimcore\Bundle\StudioApiBundle\EventSubscriber\ApiExceptionListener:
tags:
- { name: kernel.event_subscriber }
44 changes: 0 additions & 44 deletions src/ApiPlatform/OpenApiFactoryDecorator.php

This file was deleted.

12 changes: 12 additions & 0 deletions src/Controller/Api/AbstractApiController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Pimcore\Bundle\StudioApiBundle\Controller\Api;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Route;

#[Route('/api')]

Check failure on line 8 in src/Controller/Api/AbstractApiController.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.2, highest, false)

Class Symfony\Component\Routing\Route is not an Attribute class.
abstract class AbstractApiController extends AbstractController
{

}
Loading

0 comments on commit 8505145

Please sign in to comment.