Skip to content

Commit 53d0474

Browse files
authored
Merge pull request #222 from os2display/feature/2829-add-feedsource-post-put-delete-functionality
2829: Feed source operations and data validation
2 parents 5ee6c9c + fea6a7c commit 53d0474

18 files changed

+1645
-173
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ All notable changes to this project will be documented in this file.
99
- [#219](https://github.com/os2display/display-api-service/pull/219)
1010
- Fixed psalm, test, coding standards and updated api spec.
1111

12+
- [#222](https://github.com/os2display/display-api-service/pull/222)
13+
- Adds create, update, delete operations to feed-source endpoint.
14+
- Adds data validation for feed source.
15+
1216
## [2.1.3] - 2024-10-25
1317

1418
- [#220](https://github.com/os2display/display-api-service/pull/220)

config/api_platform/feed_source.yaml

+107-24
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ resources:
55
output: App\Dto\FeedSource
66
provider: App\State\FeedSourceProvider
77
processor: App\State\FeedSourceProcessor
8-
98
operations:
10-
ApiPlatform\Metadata\Get: &get
9+
ApiPlatform\Metadata\Get: &ref_0
1110
normalizationContext:
1211
jsonld_embed_context: true
1312
openapiContext:
@@ -20,7 +19,7 @@ resources:
2019
- schema:
2120
type: string
2221
format: ulid
23-
pattern: "^[A-Za-z0-9]{26}$"
22+
pattern: '^[A-Za-z0-9]{26}$'
2423
name: id
2524
in: path
2625
required: true
@@ -29,10 +28,8 @@ resources:
2928
description: OK
3029
content:
3130
application/ld+json:
32-
examples:
31+
examples: null
3332
headers: {}
34-
35-
# https://api-platform.com/docs/core/controllers/
3633
_api_Feed_get_source_config:
3734
class: ApiPlatform\Metadata\Get
3835
method: GET
@@ -49,13 +46,13 @@ resources:
4946
- schema:
5047
type: string
5148
format: ulid
52-
pattern: "^[A-Za-z0-9]{26}$"
49+
pattern: '^[A-Za-z0-9]{26}$'
5350
name: id
5451
in: path
5552
required: true
5653
- schema:
5754
type: string
58-
pattern: "^[A-Za-z0-9]*$"
55+
pattern: '^[A-Za-z0-9]*$'
5956
name: name
6057
in: path
6158
required: true
@@ -66,17 +63,18 @@ resources:
6663
examples:
6764
example1:
6865
value:
69-
- {key: 'key1', id: 'id1', value: 'value1'}
66+
- key: key1
67+
id: id1
68+
value: value1
7069
headers: {}
71-
7270
ApiPlatform\Metadata\GetCollection:
7371
filters:
74-
- 'entity.search_filter'
75-
- 'entity.blameable_filter'
76-
- 'entity.order_filter'
77-
- 'created.at.order_filter'
78-
- 'modified.at.order_filter'
79-
- 'feed_source.search_filter'
72+
- entity.search_filter
73+
- entity.blameable_filter
74+
- entity.order_filter
75+
- created.at.order_filter
76+
- modified.at.order_filter
77+
- feed_source.search_filter
8078
openapiContext:
8179
operationId: get-v2-feed-sources
8280
description: Retrieves a collection of FeedSource resources.
@@ -99,23 +97,108 @@ resources:
9997
description: The number of items per page
10098
- schema:
10199
type: string
102-
pattern: "^[A-Za-z0-9]*$"
100+
pattern: '^[A-Za-z0-9]*$'
103101
name: supportedFeedOutputType
104102
in: query
103+
responses:
104+
'200':
105+
description: OK
106+
content:
107+
application/ld+json:
108+
examples: null
109+
headers: {}
110+
ApiPlatform\Metadata\Put:
111+
security: is_granted("ROLE_ADMIN")
112+
openapiContext:
113+
description: Update a Feed Source resource.
114+
summary: Update a Feed Source resource.
115+
operationId: put-v2-feed-source-id
116+
tags:
117+
- FeedSources
118+
parameters:
119+
- schema:
120+
type: string
121+
format: ulid
122+
pattern: '^[A-Za-z0-9]{26}$'
123+
name: id
124+
in: path
125+
required: true
126+
ApiPlatform\Metadata\Delete:
127+
security: is_granted("ROLE_ADMIN")
128+
openapiContext:
129+
description: Delete a Feed Source resource.
130+
summary: Delete a Feed Source resource.
131+
operationId: delete-v2-feed-source-id
132+
tags:
133+
- FeedSources
134+
parameters:
135+
- schema:
136+
type: string
137+
format: ulid
138+
pattern: '^[A-Za-z0-9]{26}$'
139+
name: id
140+
in: path
105141
required: true
142+
ApiPlatform\Metadata\Post:
143+
security: is_granted("ROLE_ADMIN")
144+
openapiContext:
145+
operationId: create-v2-feed-source
146+
description: Creates a Feed Source resource.
147+
summary: Creates a Feed Source resource.
148+
tags:
149+
- FeedSources
150+
'_api_/feed_sources/{id}/slides_get': &ref_1
151+
normalizationContext:
152+
groups:
153+
- 'playlist-slide:read'
154+
class: ApiPlatform\Metadata\GetCollection
155+
method: GET
156+
provider: App\State\FeedSourceSlideProvider
157+
filters:
158+
- entity.search_filter
159+
- entity.blameable_filter
160+
- App\Filter\PublishedFilter
161+
- entity.order_filter
162+
- created.at.order_filter
163+
- modified.at.order_filter
164+
uriTemplate: '/feed-sources/{id}/slides'
165+
openapiContext:
166+
description: Retrieves collection of weighted slide resources (feedsource).
167+
summary: Retrieves collection of weighted slide resources (feedsource).
168+
operationId: get-v2-feed-source-slide-id
169+
tags:
170+
- FeedSources
171+
parameters:
172+
- schema:
173+
type: string
174+
format: ulid
175+
pattern: '^[A-Za-z0-9]{26}$'
176+
name: id
177+
in: path
178+
required: true
179+
- schema:
180+
type: integer
181+
minimum: 0
182+
format: int32
183+
default: 1
184+
in: query
185+
name: page
186+
required: true
187+
- schema:
188+
type: string
189+
default: '10'
190+
in: query
191+
name: itemsPerPage
192+
description: The number of items per page
106193
responses:
107194
'200':
108195
description: OK
109196
content:
110197
application/ld+json:
111-
examples:
198+
examples: null
112199
headers: {}
113-
114-
# Our DTO must be a resource to get a proper URL
115-
# @see https://stackoverflow.com/a/75705084
116-
# @see https://github.com/api-platform/core/issues/5451
117200
App\Dto\FeedSource:
118201
provider: App\State\FeedSourceProvider
119-
120202
operations:
121-
ApiPlatform\Metadata\Get: *get
203+
ApiPlatform\Metadata\Get: *ref_0
204+
get_slides: *ref_1

config/services.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ services:
204204
arguments:
205205
$collectionExtensions: !tagged_iterator api_platform.doctrine.orm.query_extension.collection
206206

207+
App\State\FeedSourceSlideProvider:
208+
tags: [ { name: 'api_platform.state_provider', priority: 2 } ]
209+
arguments:
210+
$collectionExtensions: !tagged_iterator api_platform.doctrine.orm.query_extension.collection
211+
207212
App\State\FeedProvider:
208213
tags: [ { name: 'api_platform.state_provider', priority: 2 } ]
209214
arguments:

psalm-baseline.xml

-11
Original file line numberDiff line numberDiff line change
@@ -386,17 +386,6 @@
386386
<code><![CDATA[find]]></code>
387387
</UndefinedInterfaceMethod>
388388
</file>
389-
<file src="src/State/FeedSourceProcessor.php">
390-
<MissingTemplateParam>
391-
<code><![CDATA[ProcessorInterface]]></code>
392-
</MissingTemplateParam>
393-
<ParamNameMismatch>
394-
<code><![CDATA[$object]]></code>
395-
</ParamNameMismatch>
396-
<UndefinedDocblockClass>
397-
<code><![CDATA[T]]></code>
398-
</UndefinedDocblockClass>
399-
</file>
400389
<file src="src/State/FeedSourceProvider.php">
401390
<PossiblyNullPropertyAssignmentValue>
402391
<code><![CDATA[$object->getId()]]></code>

0 commit comments

Comments
 (0)