Skip to content

Commit

Permalink
Merge pull request #222 from os2display/feature/2829-add-feedsource-p…
Browse files Browse the repository at this point in the history
…ost-put-delete-functionality

2829: Feed source operations and data validation
  • Loading branch information
tuj authored Nov 20, 2024
2 parents 5ee6c9c + fea6a7c commit 53d0474
Show file tree
Hide file tree
Showing 18 changed files with 1,645 additions and 173 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ All notable changes to this project will be documented in this file.
- [#219](https://github.com/os2display/display-api-service/pull/219)
- Fixed psalm, test, coding standards and updated api spec.

- [#222](https://github.com/os2display/display-api-service/pull/222)
- Adds create, update, delete operations to feed-source endpoint.
- Adds data validation for feed source.

## [2.1.3] - 2024-10-25

- [#220](https://github.com/os2display/display-api-service/pull/220)
Expand Down
131 changes: 107 additions & 24 deletions config/api_platform/feed_source.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ resources:
output: App\Dto\FeedSource
provider: App\State\FeedSourceProvider
processor: App\State\FeedSourceProcessor

operations:
ApiPlatform\Metadata\Get: &get
ApiPlatform\Metadata\Get: &ref_0
normalizationContext:
jsonld_embed_context: true
openapiContext:
Expand All @@ -20,7 +19,7 @@ resources:
- schema:
type: string
format: ulid
pattern: "^[A-Za-z0-9]{26}$"
pattern: '^[A-Za-z0-9]{26}$'
name: id
in: path
required: true
Expand All @@ -29,10 +28,8 @@ resources:
description: OK
content:
application/ld+json:
examples:
examples: null
headers: {}

# https://api-platform.com/docs/core/controllers/
_api_Feed_get_source_config:
class: ApiPlatform\Metadata\Get
method: GET
Expand All @@ -49,13 +46,13 @@ resources:
- schema:
type: string
format: ulid
pattern: "^[A-Za-z0-9]{26}$"
pattern: '^[A-Za-z0-9]{26}$'
name: id
in: path
required: true
- schema:
type: string
pattern: "^[A-Za-z0-9]*$"
pattern: '^[A-Za-z0-9]*$'
name: name
in: path
required: true
Expand All @@ -66,17 +63,18 @@ resources:
examples:
example1:
value:
- {key: 'key1', id: 'id1', value: 'value1'}
- key: key1
id: id1
value: value1
headers: {}

ApiPlatform\Metadata\GetCollection:
filters:
- 'entity.search_filter'
- 'entity.blameable_filter'
- 'entity.order_filter'
- 'created.at.order_filter'
- 'modified.at.order_filter'
- 'feed_source.search_filter'
- entity.search_filter
- entity.blameable_filter
- entity.order_filter
- created.at.order_filter
- modified.at.order_filter
- feed_source.search_filter
openapiContext:
operationId: get-v2-feed-sources
description: Retrieves a collection of FeedSource resources.
Expand All @@ -99,23 +97,108 @@ resources:
description: The number of items per page
- schema:
type: string
pattern: "^[A-Za-z0-9]*$"
pattern: '^[A-Za-z0-9]*$'
name: supportedFeedOutputType
in: query
responses:
'200':
description: OK
content:
application/ld+json:
examples: null
headers: {}
ApiPlatform\Metadata\Put:
security: is_granted("ROLE_ADMIN")
openapiContext:
description: Update a Feed Source resource.
summary: Update a Feed Source resource.
operationId: put-v2-feed-source-id
tags:
- FeedSources
parameters:
- schema:
type: string
format: ulid
pattern: '^[A-Za-z0-9]{26}$'
name: id
in: path
required: true
ApiPlatform\Metadata\Delete:
security: is_granted("ROLE_ADMIN")
openapiContext:
description: Delete a Feed Source resource.
summary: Delete a Feed Source resource.
operationId: delete-v2-feed-source-id
tags:
- FeedSources
parameters:
- schema:
type: string
format: ulid
pattern: '^[A-Za-z0-9]{26}$'
name: id
in: path
required: true
ApiPlatform\Metadata\Post:
security: is_granted("ROLE_ADMIN")
openapiContext:
operationId: create-v2-feed-source
description: Creates a Feed Source resource.
summary: Creates a Feed Source resource.
tags:
- FeedSources
'_api_/feed_sources/{id}/slides_get': &ref_1
normalizationContext:
groups:
- 'playlist-slide:read'
class: ApiPlatform\Metadata\GetCollection
method: GET
provider: App\State\FeedSourceSlideProvider
filters:
- entity.search_filter
- entity.blameable_filter
- App\Filter\PublishedFilter
- entity.order_filter
- created.at.order_filter
- modified.at.order_filter
uriTemplate: '/feed-sources/{id}/slides'
openapiContext:
description: Retrieves collection of weighted slide resources (feedsource).
summary: Retrieves collection of weighted slide resources (feedsource).
operationId: get-v2-feed-source-slide-id
tags:
- FeedSources
parameters:
- schema:
type: string
format: ulid
pattern: '^[A-Za-z0-9]{26}$'
name: id
in: path
required: true
- schema:
type: integer
minimum: 0
format: int32
default: 1
in: query
name: page
required: true
- schema:
type: string
default: '10'
in: query
name: itemsPerPage
description: The number of items per page
responses:
'200':
description: OK
content:
application/ld+json:
examples:
examples: null
headers: {}

# Our DTO must be a resource to get a proper URL
# @see https://stackoverflow.com/a/75705084
# @see https://github.com/api-platform/core/issues/5451
App\Dto\FeedSource:
provider: App\State\FeedSourceProvider

operations:
ApiPlatform\Metadata\Get: *get
ApiPlatform\Metadata\Get: *ref_0
get_slides: *ref_1
5 changes: 5 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ services:
arguments:
$collectionExtensions: !tagged_iterator api_platform.doctrine.orm.query_extension.collection

App\State\FeedSourceSlideProvider:
tags: [ { name: 'api_platform.state_provider', priority: 2 } ]
arguments:
$collectionExtensions: !tagged_iterator api_platform.doctrine.orm.query_extension.collection

App\State\FeedProvider:
tags: [ { name: 'api_platform.state_provider', priority: 2 } ]
arguments:
Expand Down
11 changes: 0 additions & 11 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,6 @@
<code><![CDATA[find]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="src/State/FeedSourceProcessor.php">
<MissingTemplateParam>
<code><![CDATA[ProcessorInterface]]></code>
</MissingTemplateParam>
<ParamNameMismatch>
<code><![CDATA[$object]]></code>
</ParamNameMismatch>
<UndefinedDocblockClass>
<code><![CDATA[T]]></code>
</UndefinedDocblockClass>
</file>
<file src="src/State/FeedSourceProvider.php">
<PossiblyNullPropertyAssignmentValue>
<code><![CDATA[$object->getId()]]></code>
Expand Down
Loading

0 comments on commit 53d0474

Please sign in to comment.